-
Notifications
You must be signed in to change notification settings - Fork 19
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
optionally clip data in crude_stretch #90
Comments
So on one hand I like this. I know I've done things like this Polar2Grid in the past and even gone as far as making it possible to only clip the minimum and not the maximum or vice versa. If this was implemented it might be nice to allow for that option. That said, I don't think this clipping is actually necessary. The crude stretch is scaling the data to a 0 to 1 range. I believe the trollimage/trollimage/xrimage.py Lines 807 to 829 in ea87a27
Based on this code this is true for anything doing a stretch (which would mean floating point numbers between 0 and 1), but would not effect integers which may or may not be desired. Another consideration if I'm wrong: A separate clip method? Still duplicating limits in two enhancement operations but at least they are right next to each other. |
There is one edge case that may mean you're wrong, or that at least would still need special treatment: the fill value. For example: if BTs range from 180 to 320, then |
I think the |
Ah yes, it would seem you are right. |
Sounds good. The fill value handling in trollimage is relatively new (in the last year maybe). |
Feature Request
Is your feature request related to a problem? Please describe.
Users generating NinJoTIFF files with Satpy who wish to use the pyninjotiff clipping functionality currently have to define the boundaries of their data values in two places:
enhancements/generic.yaml
) in the units to which the data are calibrated; for example, for solar infrared channels, this is in brightness temperature in units of Kelvin, such as:ch_min_measurement_unit
andch_max_measurement_unit
, now in units such as interpreted by NinJo, which may be in °C. From atrollflow2.yaml
example:This happens because
stretch
(implemented introllimage.xrimage.XRImage.crude_stretch
) stretches the data between the two values such that 0 maps to the indicated minimum and 1 maps to the indicated maximum; and then pyninjotiff clips the data (inpyninjotiff.ninjotiff._finalize
) and rescales it making place for a fill value.It is the responsibility of the user to make sure those two match, or values as interpreted by the client software (in this case NinJo) will be incorrect.
This is problematic, because:
There is ongoing work to replace the ninjotiff writer by a ninjogeotiff writer (see pytroll/satpy#1839). This new writer provides an opportunity for a cleanup. As part of that cleanup, the two problems with the current approach can be resolved. This feature request is triggered by a need fo rthe ninjogeotiff writer.
Describe the solution you'd like
I would like that
trollimage.xrimage.XRImage.crude_stretch
optionally clips the data to the indicated range. This can be implemented by an additional boolean keyword argumentclip
, which would default to False (the current behaviour). This would allow the user to configure their limits only in one place and the satpy writer to focus on actual writing.Describe any changes to existing user workflow
The status quo would remain the default, so this change should be fully backwards compatible.
Additional context
Perhaps the satpy writer could still take care of the clipping, but look up the clip limits in the enhancement history, which may contain the parameters to crude stretch. This feels wrong.
Perhaps the stretch-that-can-clip would be a different enhancement than the current crude-stretch, rather than the current enhancement with a new keyword argument. I think a keyword argument fits better.
Perhaps clipping should be a separate step from enhancing, and there should be two enhancements applied if users want clipping. I don't know how to apply two enhancements.
Perhaps there are other approaches that I'm not thinking of.
The text was updated successfully, but these errors were encountered: