Open gerritholl opened 1 year ago
I'll mention it here for the record, but I think any workflow that depends on fill_value
being passed to Scene.resample
is either a workaround for a larger issue (ex. _FillValue
missing from an integer product) or the user knows exactly what they want for some very specific reason (ex. "I want all fill values to be 'grey' in the final image").
Maybe CategoricalDataCompositor
and MaskingCompositor
need to behave differently with regard to fill values. I'm not sure how that could be done without breaking compatibility, though. In the case I described here, fill_value=255
is actually redundant, because the _FillValue
in the input data is also 255. The CategoricalDataCompositor
then replaces the fill value with other values, but only if it is called after resampling.
How can we support users of the MaskingCompositor
defining whether fill values should be masked or not, without ensuring that the MaskingCompositor
is called after resampling (thus generate=False
)? I'm trying to get something binary, 1/0, but the fill value is 255.
Describe the bug
With the CategoricalDataCompositor and the MaskingCompositor, the values for a resampled scene may be different depending on whether the composite is calculated before or after resampling. This might affect other compositors as well.
I'm not sure if it classifies as a bug, but I think it's an unexpected and undesired consequence of how Satpy works.
To Reproduce
Expected behavior
I expect identical results between
generate=True
andgenerate=False
.Actual results
With 'generate=True
, the result is 255. With
generate=False`, the result is 0.Environment Info:
Additional context
This happens because the values received by the compositor differ between the
generate=True
andgenerate=False
cases. Ifgenerate=True
, the compositor datasets from the unresampled scene, which does not contain fill values added by the resampler. Ifgenerate=False
, or if the compositor relies on datasets with different incompatible areas, it will receive datasets from the resampled scene, including fill values added by the resampler. In the first case, the resampled scene contains fill values added by the resampler. In the second case, those fill values have been replaced by theCategoricalDataResampler
. A similar phenomenon happens with theMaskingCompositor
.I think it should affect other compositors as well, but it may be less clear there because most compositors do not generate entirely new values.
I have no idea how this could be resolved, in particular not without breaking stuff or significant redesign of Satpy.