-
Notifications
You must be signed in to change notification settings - Fork 295
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
FCI HRFI true_color unavailable even after native resampling if upper_right_corner is used #2668
Comments
the same happens with the |
Really? It works for me with the
|
Does |
hmm, it works if you specify |
then it works, indeed. So the question is how could dc3ee7d have broken this 😵 |
So assuming this failure is consistent, then my best guess is this block of code in the base resampler class in pyresample: This is used as a shortcut to say "are we resampling to essentially the same area, then just return the result". If the |
The issue originates from an satpy/satpy/composites/__init__.py Lines 1118 to 1122 in 9925d5f
... reason being that datasets[1].shape (which is ndvi_hybrid_green ) somehow has shape (0, 22272) instead of the expected (22272, 22272) .
The issue is indeed related to the However, it looks like This is where I'm now, I'll try to look further. |
Adding a note here to say that this also happens with Himawari data:
Gives:
The If I switch from |
We tracked down the issue to slight differences (10^-10) in |
Interesting, thanks for the update. Happy to help test this, might also fix the weird output images issue I mentioned on slack! |
Ok, I think I have an explanation: In theory, those differences shouldn't exist, since we calculate the coords in Line 240 in c5c18cf
the twice on the same area the same way (once when the BUT, when we use In fact, these are the parameters used inside
note the different ending digits --> so, no wonder that the resulting coordinates are not matching anymore, and xarray decides to kill the dimension. Edit: it's actually not the differing digits, the issue is rather floating point precision arithmetics, see this calculation of the coordinate of the same corner pixel with and without flipping, ending up with a difference in the last digit:
|
I didn't check, but my bet would be that the |
That being said, I'm not sure what the best fix is, if we want to keep the nice In fact, the issue exists outside of composites as well, it can be simplified to: scn = Scene(filenames=filenames, reader='fci_l1c_nc')
scn.load(['vis_06', 'vis_08'], upper_right_corner='NE')
res_scn = scn.resample(resampler='native')
diff = res_scn['vis_06'] - res_scn['vis_08']
(note the 0-size dimension) |
I'm not sure this explains the AHI and ABI failures some have reported but I'll try to take a look. Good finds so far. Let me see if I understand the segmented flipping: We have this chunk of code: satpy/satpy/readers/yaml_reader.py Lines 1036 to 1044 in c5c18cf
which says "Ok we need to flip the data in one or more ways, flip the array and the extents as needed". Then it says "Create a new copy of the area with the flipped extents". If my understanding is correct then I suggest
With a comment to maybe say "floating point precision may produce different coordinate results depending on which extents are used". |
Oh! I figured out the problem with So the code: scn = Scene(...)
scn.load([A, B, C])
cropped_scn = scn.crop(xy_bbox=[1, 2, 3, 4])
resampled_scn = cropped_scn.resample(resampler="native")
resampled_scn["C"].coords["y"].values - resampled_scn["A"].coords["y"].values will rarely return equal values with the new BaseResampler always skipping
|
I'll think about this after my next meeting. We can always work around the new base resampler, but I'm a little annoyed that we have to. |
Ok I've been trying to think about this the last couple hours and I think we can re-implement the equivalent behavior of the base resampler (pyresample PR required), but I see this as more of a band-aid than really solving the problem. At the heart of our issue is something we can't really change or at least not reasonably: xarray is using coordinates to determine how to combine DataArrays (arithmetic, etc). I think the cheating way would be to set "arithmetic_join" to "override" in xarray's Next thought is how to look at this problem from Satpy's point of view and what Satpy/we can do to handle things: The subset (a.k.a. slice) of x/y coordinate arrays is not equal to x/y coordinates generated from an area that is a subset/slice of the original area. So some initial options I thought of were that we could force the update of spatial coordinates (x/y) after any operation affecting the Other things to consider:
|
I also encountered some problems under another topic which may be related to this one. |
Thanks @djhoese for your thoughts!
I'm not sure this would fix the issue reliably, as in the case of FCI for example we're already using explicitly float64 in the extents calculation, but we're still ending up with floating point differences (see my edit in the previous comment, by just flipping the area, not even cropping :/
Rounding/chopping could maybe be more successful, even though there's still the risk that the floating point difference tips the rounding/chopping one or the other side, likely causing the same failures.. |
Describe the bug
When loading FCI FDHSI and HRFI data and loading the
true_color
composite, this composite is unavailable even after native resampling.To Reproduce
Expected behavior
I expect to get the true color composite.
Actual results
Output without debug messages:
The complete debug output is too long for a GitHub issue.
Environment Info:
The text was updated successfully, but these errors were encountered: