-
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
Fix MODIS cviirs-based interpolation #41
Conversation
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.
Looks good so far, the test data is bigger though, is this planned?
""" | ||
g = Geod(ellps="WGS84") | ||
_, _, dist = g.inv(lons_actual, lats_actual, lons_desired, lats_desired) | ||
print(dist.min(), dist.max()) |
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.
Should this be here?
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.
Nope. Left over for sanity checking. Thanks.
The test file difference is very confusing. Both are compressed and therefore chunked (automatically done when compressing). Here is the old 250m latitude:
And new:
I'll have to do some research why the filtering is being added. |
There. Added the shuffle filter and now it is less than 10kb bigger. |
Well we have at least one case where running on my system the simple interpolation is <26m max distance, but on CI it is larger (1 pixel). |
CI seems to compute things differently
CI seems to compute things differently
Codecov Report
@@ Coverage Diff @@
## main #41 +/- ##
==========================================
- Coverage 80.15% 79.81% -0.34%
==========================================
Files 19 18 -1
Lines 1300 1214 -86
==========================================
- Hits 1042 969 -73
+ Misses 258 245 -13
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Kind of hard to know how the coverage is changing when the coverage reporting was broken. I had it fixed in one of my other non-merged PRs but I've copied the changes here. @mraspaud I ran the tests locally with coverage reporting and The 94% in the simple interpolation is for ImportError workarounds, a non-2D input error check, and the short circuit if the dask chunks are already scan-based. Some of this could be implemented, but I'm not concerned about it right now. I'd rather add these tests in some of my later PRs rather than worry about coverage in this PR. |
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.
Just a couple of minor comments, otherwise looks good to me.
""" | ||
g = Geod(ellps="WGS84") | ||
_, _, dist = g.inv(lons_actual, lats_actual, lons_desired, lats_desired) | ||
np.testing.assert_array_less(dist, max_distance_diff) # meters |
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.
For clarity, I think we should provide a custom error message to assert_array_less
.
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.
err_msg=f"Coordinates are greater than {max_distance_diff} geodetic "
"meters from the expected coordinates.")
Done.
def test_cviirs_interp(input_func, exp_func, interp_func, dist_max): | ||
lon1, lat1, satz1 = input_func() | ||
lons_exp, lats_exp = exp_func() | ||
|
||
# when working with dask arrays, we shouldn't compute anything | ||
with dask.config.set(scheduler=CustomScheduler(0)): | ||
lons, lats = interp_func(lon1, lat1, satz1) | ||
|
||
if hasattr(lons, "compute"): | ||
lons, lats = da.compute(lons, lats) | ||
assert_geodetic_distance(lons, lats, lons_exp, lats_exp, dist_max) | ||
assert not np.any(np.isnan(lons)) | ||
assert not np.any(np.isnan(lats)) | ||
|
||
|
||
def test_cviirs_nan_handling(): | ||
# See GH #19 | ||
lon1, lat1, satz1 = load_1km_lonlat_satz_as_xarray_dask() | ||
satz1 = _to_da(abs(np.linspace(-65.4, 65.4, 1354)).repeat(20).reshape(-1, 20).T) | ||
lons, lats = modis_1km_to_500m(lon1, lat1, satz1) | ||
assert not np.any(np.isnan(lons.compute())) | ||
assert not np.any(np.isnan(lats.compute())) |
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 don't think we should use cviirs
here, it might be cryptic for the unknowledgeable reader.
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.
Changed it in these test names. Is that what you wanted?
I think since I have commits here with multiple HDF5 test data versions we should squash this PR. |
Got slack approval. Merging. |
Closes #39. Includes #40. Fixes a swath width issue in the cviirs-based interpolation. This PR also recreates the modis interpolation test data to use a less terrain-y dataset. This allows for tighter tolerances in the tests. The tests were also rewritten to use geodetic distance between actual and expected results which is an overall better test than pure value differences.
TODO: Going to rewrite the cviirs and simple tests to use the same utilities.
git diff origin/main **/*py | flake8 --diff