-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add to_latlon method #3
base: develop
Are you sure you want to change the base?
Conversation
sandorkertesz
commented
Mar 25, 2024
•
edited
Loading
edited
earthkit/geo/latlon.py
Outdated
constants.south, | ||
int((constants.north - constants.south) / dy) + 1, | ||
) | ||
lon_v = np.linspace(0, constants.full_circle - dx, int(constants.full_circle / dx)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This "constants.full_circle - dx" doesn't cover the cases not integer-divisible to 360 (like 0.7, 0.13, 0.14, ...). You're looking for np.arange I believe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to have control over endpoint (that linspace allows direct control, but arange doesn't unfortunately)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This "constants.full_circle - dx" doesn't cover the cases not integer-divisible to 360 (like 0.7, 0.13, 0.14, ...). You're looking for np.arange I believe
I think we should use the same algorithm here that MIR uses. E.g. when generating a 0.7x0.7 global grid this is how the resulting grid looks like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes indeed -- and I believe that np.arange can get you there faster :-) You will however "need to count" the resulting number of points (also, as mir has to do when understanding the increments + bounding box
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I managed to reproduce the same lat/lons that mir generates, will push the code soon.
earthkit/geo/latlon.py
Outdated
from . import constants | ||
|
||
|
||
def generate_latlon(dx, dy): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename these (dx,dy) to (dlon,dlat)
earthkit/geo/latlon.py
Outdated
from . import constants | ||
|
||
|
||
def generate_latlon(dx, dy): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the name should be a bit more explicit that it will generate complete matrices of lats/lons rather than a 1d array of each. Something like generate_latlon_grids or generate_latlon_matrices (still trying to think of the better name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The primary goal of this method is to return the latitudes/longitudes of the global grid generated with MIR interpolation when only dlon/dlat is specified in the target grid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It must give correct results to the target lat-lon grids earthkit-regrid offers. This is the current scope. When the geo library will be available this method will simply delegate the call to it and will offer a more generic solution.
Refactored method and added more tests. The new name is |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #3 +/- ##
===========================================
+ Coverage 96.17% 97.11% +0.93%
===========================================
Files 5 6 +1
Lines 157 208 +51
Branches 9 14 +5
===========================================
+ Hits 151 202 +51
Misses 3 3
Partials 3 3 ☔ View full report in Codecov by Sentry. |
What's the current state of this branch? |
My new preferred name for this is |
Maybe it should be |
just to say I agree with everything here (to|make)_latlon(|s). I personally like make_latlons, for consistency as has been pointed out, but got used to to_latlon (so the exact opposite). |
Well, the |