-
Notifications
You must be signed in to change notification settings - Fork 20
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 simple lon/lat based MODIS interpolation #31
Conversation
Codecov Report
@@ Coverage Diff @@
## main #31 +/- ##
==========================================
+ Coverage 78.02% 79.54% +1.51%
==========================================
Files 16 19 +3
Lines 1156 1305 +149
==========================================
+ Hits 902 1038 +136
- Misses 254 267 +13
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Do I need to make this an interpolator class? |
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.
Nice works I just have a bunch of questions!
Interestingly if I set the chunk size of the input to Dask Profile - Angle - 800 Chunk SizeDask Profile - Simple - 800 Chunk SizeSo the angle-based interpolation takes longer but uses a little less memory, but the simple interp (which uses map_blocks) takes less time and uses less memory. However, I have to acknowledge that 800 for a chunk size is not usually what we use and may be unrealistic. 800 rows * 1354 cols * 4 bytes (float32) -> ~4.3MB...pretty small chunk size. |
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.
Some final styling comments...
|
||
if res_factor == 4: | ||
# Use linear extrapolation for the first two 250 meter pixels along track | ||
m = (result_array[k0 + 5, :] - result_array[k0 + 2, :]) / (y[5, 0] - y[2, 0]) |
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.
These for lines are duplicated, could they be factorized?
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.
They aren't exactly repeated. They have different indexes. Given that there isn't a difference in number of lines (unless I'm reading it wrong) I think I'd prefer to keep it this way since it is more clear, at least to me, what the logic is trying to do. I'd be worried that putting things in a separate function would make it harder to parse this out.
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 computation of m and b (slope and offset) is identical with an offset of 32, right? I think they should be factorized. Maybe even with the 500m, just passing the indices.
else: | ||
# 500m | ||
# Use linear extrapolation for the first two 250 meter pixels along track | ||
m = (result_array[k0 + 2, :] - result_array[k0 + 1, :]) / (y[2, 0] - y[1, 0]) |
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.
These three lines are duplicated too.
return new_lons.astype(lon_array.dtype), new_lats.astype(lon_array.dtype) | ||
|
||
|
||
# def interpolate_geolocation(nav_array): |
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.
Is this commented function necessary?
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.
No. I could have sworn I deleted this already. Removed it now anyway.
This ports the CSPP Polar2Grid MODIS lon/lat interpolation which only depends on longitude and latitude and is still fast.
git diff origin/main **/*py | flake8 --diff