Fix xrimage alpha creation in finalize #35
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is to fix the huge bug in trollimage 1.6.1. Right now it is producing seemingly completely transparent images. The solution that works here is not the prettiest but it should work for the supported cases. There is another possibility but I'm not sure it is any better. Here are the two cases that are in conflict and the preferred series of operations to complete these tasks:
Add alpha band
a. Create alpha band from "null" values
b. Scale data to output data type including scale the alpha band from 0-1 to dtype_min to dtype_max
c. Cast to data type
Fill NA values with
fill_value
a. Scale data to output data type
b. Fill "null" values with fill_value (after casting it to output data type)
c. Cast to data type
If you change these operations around to support only one of these cases it results in either an all
1
alpha band or afill_value
that does not represent the original user provided one.Best long term solution would be to modify
fill_or_alpha
to accept a dtype kwarg and absorb some of this functionality (maybe scaling to the dtype). Thefill_or_alpha
is currently used by theconvert
method and I'm not sure if any users have started using it (I doubt it), but it is a public method.@mraspaud Thoughts?
git diff origin/master **/*py | flake8 --diff
(remove if you did not edit any Python files)