Skip to content

Attribute hygiene in S2 output: flag_meanings, short_name, dtype, valid_min/valid_max #351

Open

Description

@emmanuelmathot

Problems

  1. flag_meanings is a JSON list. CF defines it as one string of words separated by blanks. 36 arrays in one product.
    • We write the SCL list in SCL_ATTRS (s2_optimization/s2_multiscale.py:51-54).
    • We pass through the source lists on quality/mask/*, conditions/mask/l1c_classification/*/b00 and conditions/mask/detector_footprint/*.
  2. short_name is wrong on other levels. Example: /measurements/reflectance/r60m/b08 has b08_r10m, and scl at r120m/r360m/r720m has scl_r60m.
    • inject_missing_bands copies the source attributes (s2_multiscale.py:280).
    • _coarsen_variable copies them again for each level (s2_multiscale.py:208).
    • The style is also mixed (b05_60m and b08_r60m).
  3. dtype attribute. It repeats the Zarr data type. sanitize_array_attrs removes it only for decoded floats (conversion/utils.py:1158-1160). 108 arrays.
  4. valid_min/valid_max. The docstring of sanitize_array_attrs (utils.py:1142-1145) says that they are removed for decoded floats, but the code does not remove them. The source values pass through: for example, scl is uint8 with valid_max: 65535.

Proposal

  • In sanitize_array_attrs, join a list flag_meanings with blanks. Write SCL_ATTRS as a string.
  • Write short_name again for each level, as <variable>_r<resolution>m. If no reader needs it, remove it.
  • Always remove the dtype attribute.
  • Remove valid_min/valid_max when the value is outside the range of the data type. Do what the docstring says for decoded floats.
  • Do not change _FillValue (see #TBD-01).

Tests

  • Regenerate tests/_test_data/optimized_geozarr_examples/*.json (REGENERATE_SNAPSHOTS=1).
  • Add checks in tests/test_array_attrs.py:
    • flag_meanings is a string;
    • there is no dtype attribute;
    • valid_* is inside the dtype range;
    • short_name matches the level.

Impact

No reader found for these attributes. titiler /info shows a different minmax for SCL.

Activity

  1. changed the title [-]#TBD-01a Attribute hygiene: `flag_meanings`, `short_name`, `dtype`, `valid_min`/`valid_max`[/-] [+]Attribute hygiene in S2 output: flag_meanings, short_name, dtype, valid_min/valid_max[/+] on Nov 12, 2026
  2. added
    sentinel-2Sentinel-2 MSI products (L1C, L2A)
    cpm-driverGeoZarr driver for EOPF CPM (eopf convert-geozarr, engine geozarr)
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cpm-driverGeoZarr driver for EOPF CPM (eopf convert-geozarr, engine geozarr)sentinel-2Sentinel-2 MSI products (L1C, L2A)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions