11"""
2- Pydantic-zarr integrated models for Sentinel-1 GRD γ0T RTC GeoZarr stores.
2+ Pydantic-zarr integrated models for Sentinel-1 GRD gamma0T RTC GeoZarr stores.
33
44Uses the pyz.v3 GroupSpec/ArraySpec with TypedDict members to enforce strict
55structure validation — same pattern as s2.py (which uses pyz.v2 for Zarr V2).
3535
3636from pydantic import BaseModel , Field , model_validator
3737from typing_extensions import TypedDict
38- from zarr_cm import geo_proj , multiscales as multiscales_cm , spatial as spatial_cm
38+ from zarr_cm import geo_proj
39+ from zarr_cm import multiscales as multiscales_cm
40+ from zarr_cm import spatial as spatial_cm
3941
4042from eopf_geozarr .data_api .geozarr .common import DatasetAttrs
4143from eopf_geozarr .pyz .v3 import ArraySpec , GroupSpec
5961# ============================================================================
6062
6163
62- class S1RtcOrbitGroupAttrs (BaseModel , extra = "allow" ):
64+ class S1RtcOrbitGroupAttrs (BaseModel ):
6365 """Attributes for an orbit-direction group (ascending or descending).
6466
6567 Carries the three GeoZarr conventions plus proj:/spatial:/multiscales metadata.
@@ -71,7 +73,7 @@ class S1RtcOrbitGroupAttrs(BaseModel, extra="allow"):
7173 spatial_dimensions : list [str ] = Field (alias = "spatial:dimensions" )
7274 spatial_bbox : list [float ] = Field (alias = "spatial:bbox" )
7375
74- model_config = {"populate_by_name" : True , "serialize_by_alias" : True }
76+ model_config = {"extra" : "allow" , " populate_by_name" : True , "serialize_by_alias" : True }
7577
7678 @model_validator (mode = "after" )
7779 def validate_zarr_conventions (self ) -> Self :
@@ -108,13 +110,13 @@ def validate_spatial_bbox(self) -> Self:
108110 return self
109111
110112
111- class S1RtcResolutionAttrs (BaseModel , extra = "allow" ):
112- """Attributes for a resolution-level group (r10m, r20m, … )."""
113+ class S1RtcResolutionAttrs (BaseModel ):
114+ """Attributes for a resolution-level group (r10m, r20m, ... )."""
113115
114116 spatial_shape : list [int ] = Field (alias = "spatial:shape" )
115117 spatial_transform : list [float ] = Field (alias = "spatial:transform" )
116118
117- model_config = {"populate_by_name" : True , "serialize_by_alias" : True }
119+ model_config = {"extra" : "allow" , " populate_by_name" : True , "serialize_by_alias" : True }
118120
119121 @model_validator (mode = "after" )
120122 def validate_shape (self ) -> Self :
@@ -131,14 +133,14 @@ def validate_transform(self) -> Self:
131133 return self
132134
133135
134- class S1RtcConditionsAttrs (BaseModel , extra = "allow" ):
136+ class S1RtcConditionsAttrs (BaseModel ):
135137 """Attributes for the conditions group."""
136138
137139 proj_code : str = Field (alias = "proj:code" )
138140 spatial_dimensions : list [str ] = Field (alias = "spatial:dimensions" )
139141 spatial_transform : list [float ] = Field (alias = "spatial:transform" )
140142
141- model_config = {"populate_by_name" : True , "serialize_by_alias" : True }
143+ model_config = {"extra" : "allow" , " populate_by_name" : True , "serialize_by_alias" : True }
142144
143145
144146# ============================================================================
@@ -207,21 +209,17 @@ def border_mask(self) -> ArraySpec[Any]:
207209class S1RtcOverviewResolutionDataset (
208210 GroupSpec [S1RtcResolutionAttrs , S1RtcOverviewResolutionMembers ] # type: ignore[type-var]
209211):
210- """An overview resolution dataset (r20m– r720m): data variables only."""
212+ """An overview resolution dataset (r20m- r720m): data variables only."""
211213
212214
213- class S1RtcConditionsGroup (
214- GroupSpec [S1RtcConditionsAttrs , dict [str , ArraySpec [Any ]]] # type: ignore[type-var]
215- ):
215+ class S1RtcConditionsGroup (GroupSpec [S1RtcConditionsAttrs , dict [str , ArraySpec [Any ]]]):
216216 """Time-invariant condition arrays, keyed by name (e.g. gamma_area_008)."""
217217
218218 @model_validator (mode = "after" )
219219 def validate_has_gamma_area (self ) -> Self :
220220 """At least one gamma_area_* array should be present."""
221221 if not any (k .startswith ("gamma_area_" ) for k in self .members ):
222- raise ValueError (
223- "Conditions group must contain at least one 'gamma_area_*' array"
224- )
222+ raise ValueError ("Conditions group must contain at least one 'gamma_area_*' array" )
225223 return self
226224
227225
0 commit comments