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
MTG: get projection and extent information from file #845
Conversation
I'm not sure how to write a test for "coastlines look correct in image". It could be done with some fancy image processing but it may be more effort than it's worth? |
try setting the radius_of_influence parameter to 10000 when you resample |
As for the test, you could create some fake data with special pixel values at some landmarks, and then make sure the landmarks (with special pixel values) are in the right place in the resampled image. |
Regarding the zonal artefacts, are you sure the area extent is correct, ie that is extends to the corner of the corner point ? |
Thanks for the advice. I will look into those and then I need to look into the zonal artefacts, I seem to recall something about defining locations as pixel centres vs. pixel corners. |
yes, I see in your code that you use pixel centers... |
Are there examples for that in other reading routine testers? |
No, it's never been done :) but maybe you don't need to got to these length to test the navigation of this reader. I would suggest that you just check the area extent computed from the parameters given in the file against what you have determined is correct experimentally. |
After 0a7d0e2: it now appears to be correct as far as I can see. I find actually unit testing this difficult as I'm not sure how to verify that a pixel in my mock data ends up where I expect it to end up, since I don't have an independent easy way of calculating the test reference. |
Isn't the data shifted a bit to the right ? looks like the coastlines don't really match on the tip of Sweden. |
Hmm, looking at Bornholm it looks shifted indeed, I thought that the Dutch coast looked fine. That's puzzling. |
Codecov Report
@@ Coverage Diff @@
## master #845 +/- ##
=======================================
Coverage 89.54% 89.54%
=======================================
Files 200 200
Lines 29392 29392
=======================================
Hits 26319 26319
Misses 3073 3073 Continue to review full report at Codecov.
|
It looks like it's farther off the farther east. |
The coverage decreased because I shortened some methods that were covered, but did not shorten any methods that weren't. I produced a negative number of LOC, so to say... |
The offset is location-dependent. Socotra (12°N, 54°E), too far south: La Gomera and Tenerife (28°N, 17°W), too far west: Bornholm (55°N, 15°E) too far east: Île Europa (22°S, 40°E) too far north: São Tomé (0°N, 7°E), almost correct: There's still something wrong with either:
|
Maybe time to ask the data provider ? |
Can this be due to different datums / projections / ellipsoids? |
After discussion with EUMETSAT, we think the remaining projection issues are probably in the data and that the reader is fine. Therefore, I propose this PR is ready to merge. Is anyone available to review it? |
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.
LGTM
Sorry for reviewing this so late, it passed under my radar. |
NB: EUMETSAT reports that with the same test data, they consider the geolocation to be accurate. So there is still something either with the reader, or with the coastline database. |
Ok, interesting. Maybe something to look at during the next PCW ? |
The scale factors and add offsets for the MTG FCI test data as published in 2019-09 are factually incorrect. This probably causes the differences between the pytroll and FCI geolocations. Until this is fixed from EUMETSATs side, hardcode corrected add_offset and scale_factor values. Also correct for an off-by-one error in the scale factors.
The scale factors and add offsets for the MTG FCI test data as published in 2019-09 are factually incorrect. This probably causes the differences between the pytroll and FCI geolocations. Until this is fixed from EUMETSATs side, hardcode corrected add_offset and scale_factor values. Similarly, there was a small error in the semi minor axis. Also correct for an off-by-one error in the scale factors.
The FCI semi-minor axis correction does not improve anything, remove this hardcoding correction.
Those parameters will be corrected in the next version of the testdata, so the hardcoding won't be necessary. The median difference is down to 8.56 metre. That doesn't explain the coastline problem but I'm probably doing something wrong there independently of the reader. |
Are those differences consistent with what one would expect due to this being test data? |
Related? SEVIRI georeferencing offset correction. |
This is very likely caused by the SEVIRI georeferencing offset correction. Since SEVIRI data from before 2017-12 needs a correction, so does FCI test data based on SEVIRI data from before 2017-12. Thanks to @ameraner for finding this. It looks like each of the SEVIRI readers repeat this correction: satpy/satpy/readers/seviri_l1b_hrit.py Lines 586 to 589 in db1cc01
satpy/satpy/readers/seviri_l1b_native.py Lines 317 to 325 in db1cc01
satpy/satpy/readers/seviri_l1b_nc.py Lines 189 to 194 in db1cc01
|
Expand the mocking of variable attributes for the routine testing the FCI reader. One attribute was missing, and none were created in the "/attr/..." caching in which they are accessed by the reader.
We can (finally) confirm that the root of the "big" shift is the geolocation offset present in SEVIRI images recorded prior to 2017, that went uncorrected into the creation of the FCI test data. When feeding the EUM processor with a SEVIRI image from 2019 as a proxy for the FCI data, and reading that FCI image with the FCI reader, the shift is gone: |
@gerritholl @ameraner thanks for sorting this out and making the FCI reader perfectly geolocated. |
Remove the hardcoded scale factor, add offset, and sweep. Those had been added to correct for errors in the 2019-09 release of FCI testdata, but should be fixed in the upcoming release, so should be no longer needed.
From the FCI reader, remove an unused hardcoded dictionary containing extent information. This information was only used for debugging, but is redundant relative to what is available in the file, assuming a full disk image is square.
In the FCI reader, make minor fixes to comments and docstring, and replace a RuntimeError by a more specific ValueError if an invalid calibration key is passed.
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 looks good to me. I just have a couple minor comments. Thanks for the comprehensive work on the FCI reader!
# Channel dependent swath resoultion | ||
area_extent = self.calc_area_extent(key) | ||
|
||
# assumption: channels with same resolution should have same area |
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.
@ameraner can you confirm this ?
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.
@mraspaud Yes it's correct, for this L1c FDHSI product we define two rectification grids (with 1 km and 2 km nadir resolution), and channels with the same resolution share the same grid (and therefore also same area definition).
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.
perfect, thanks for then confirmation.
Apparently, PEP 257 insists that the closing quotes for a single-line docstring must be on the same line as the rest of the docstring. I will abide by what is apparently the community standard, although I will hereby note my (minority?) preference for the "closing quotes on next line" alternative. Co-Authored-By: Martin Raspaud <martin.raspaud@smhi.se>
Remove an empty line immediately after a method docstring, in order to satisfy the flake8-docstrings plugin.
Congratulations 🎉. DeepCode analyzed your code in 1.109 seconds and we found no issues. Enjoy a moment of no bugs ☀️. 👉 View analysis in DeepCode’s Dashboard |
In the MTG FCI FDHSI L1C reader, get the projection coordinates and
extent information from file. For the projection coordinates, get those
from /data/mtg_geos_projection rather than from /state/processor, as
is consistent with the documentation. The extent information was
previously hardcoded but now obtained from data/channel/measured/x and
data/channel/measured/y, which contain this information in radians.
This commit fixes #840 although there are still some issues with the
resulting image that need to be resolved.
flake8 satpy
AUTHORS.md
if not there already