Skip to content

feat: implement scale-offset and data type casting via codecs#154

Open
d-v-b wants to merge 5 commits intoEOPF-Explorer:mainfrom
d-v-b:feat/scale-offset-codecs
Open

feat: implement scale-offset and data type casting via codecs#154
d-v-b wants to merge 5 commits intoEOPF-Explorer:mainfrom
d-v-b:feat/scale-offset-codecs

Conversation

@d-v-b
Copy link
Copy Markdown
Contributor

@d-v-b d-v-b commented Apr 2, 2026

this PR defines the scale-offset transformation as a pair of codecs: a ScaleOffset codec, which implements the Zarr V3 scale-offset codec , and the CastValueRustV1 codec from cast-value.py, which implements the Zarr V3 cast_value codec. This means float data can be decoded as float, but stored as ints, in a cf- and xarray-independent manner.

Right now it's exposed via a boolean parameter to convert_s2_optimized, and command-line flag --experimental-scale-offset-codec.

caveat: downstream consumers will need the ScaleOffset and CastValue codecs available in order to decode the data. We should work on ways to make this straightforward.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 2, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 90.62500% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/eopf_geozarr/codecs/scale_offset.py 87.23% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@d-v-b d-v-b requested a review from emmanuelmathot April 2, 2026 19:30


@dataclass(frozen=True)
class ScaleOffset(ArrayArrayCodec):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did not make a stand-alone library for this codec, because it is so simple.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok but will it live in zarr-python or will users have to import eopf-geozarr to use the scale_offset?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in the current state users have to import eopf-geozarr, but I don't like that outcome. I will see if we can get this into zarr-python

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.

3 participants