Skip to content
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

Update unscaling to use the per-band scale/offset values #707

Closed
wants to merge 2 commits into from

Conversation

jddeal
Copy link

@jddeal jddeal commented May 15, 2024

Hey there!

This is a small change to extend unscale=True to lean on the per-band values instead of assuming the first scale/offset applies to all bands.

(Sponsored by Vaisala Xweather)

@vincentsarago

This comment was marked as resolved.

@jddeal
Copy link
Author

jddeal commented May 15, 2024

I suspect we might have a rather uncommon use case, but we haven't run into any limitations through gdal or rasterio that would imply only one scale/offset should be set per file.

Some example docs:

@four43
Copy link

four43 commented May 15, 2024

@jddeal I'm not quite sure why we need this. In GDAL/Rasterio I thought the metadata model was to have only one scale/offset value 🤷‍♂️

I will be forever sad that the nodata value is applied per file, not per band anymore. That's such a shame for heterogeneous data :(

@vincentsarago
Copy link
Member

@jddeal I don't seems to have push right on the fork so I cannot edit this PR

Comment on lines +266 to +267
scales = numpy.array(dataset.scales).reshape((-1,) + (1,) * (len(data.shape[1:])))
offsets = numpy.array(dataset.offsets).reshape((-1,) + (1,) * (len(data.shape[1:])))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
scales = numpy.array(dataset.scales).reshape((-1,) + (1,) * (len(data.shape[1:])))
offsets = numpy.array(dataset.offsets).reshape((-1,) + (1,) * (len(data.shape[1:])))
scales = numpy.array(dataset.scales).reshape(-1, 1, 1)
offsets = numpy.array(dataset.offsets).reshape(-1, 1, 1)

should be enough, I don't see rasterio handling non 2D data

@vincentsarago vincentsarago mentioned this pull request May 16, 2024
@vincentsarago
Copy link
Member

edited in #708

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants