You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Attribute hygiene in S2 output: flag_meanings, short_name, dtype, valid_min/valid_max #351
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/*.
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).
dtype attribute. It repeats the Zarr data type. sanitize_array_attrs removes it only for decoded floats (conversion/utils.py:1158-1160). 108 arrays.
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.
Activity
[-]#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[/+]