@@ -269,6 +269,26 @@ def get_unit_by_key(self, key: str) -> AllUnitModel | None:
269269 """Get units by variable/dimension/coordinate name. Returns None if not found."""
270270 return self ._units .get (key , None )
271271
272+ def _dim_coord_metadata (self , name : str ) -> VariableMetadata | None :
273+ """Build metadata for a dimension coordinate.
274+
275+ Dimension coordinates such as ``inline`` or ``crossline`` are integer survey
276+ indices and are inherently unitless. Returning ``None`` here keeps the
277+ ``metadata`` field unset on those coordinates rather than wrapping a
278+ ``units_v1=None`` placeholder.
279+
280+ Args:
281+ name: Coordinate name to look up units for.
282+
283+ Returns:
284+ A ``VariableMetadata`` carrying the registered unit, or ``None`` if no
285+ unit is registered for ``name``.
286+ """
287+ unit = self .get_unit_by_key (name )
288+ if unit is None :
289+ return None
290+ return VariableMetadata (units_v1 = unit )
291+
272292 def _add_dimensions (self ) -> None :
273293 """Add custom dimensions.
274294
@@ -290,20 +310,14 @@ def _add_coordinates(self) -> None:
290310 name ,
291311 dimensions = (name ,),
292312 data_type = ScalarType .INT32 ,
293- metadata = VariableMetadata ( units_v1 = self .get_unit_by_key (name ) ),
313+ metadata = self ._dim_coord_metadata (name ),
294314 )
295315
296- # Add non-dimension coordinates with computed chunk sizes
297- for name in self .coordinate_names :
298- # Compute optimal chunk size for coordinates (spatial dimensions only)
299- spatial_shape = self ._dim_sizes [:- 1 ] # Exclude vertical dimension
300- coord_chunk_shape = get_constrained_chunksize (
301- spatial_shape ,
302- ScalarType .FLOAT64 ,
303- MAX_COORDINATES_BYTES ,
304- )
305- chunk_grid = RegularChunkGrid (configuration = RegularChunkShape (chunk_shape = coord_chunk_shape ))
316+ spatial_shape = self ._dim_sizes [:- 1 ]
317+ coord_chunk_shape = get_constrained_chunksize (spatial_shape , ScalarType .FLOAT64 , MAX_COORDINATES_BYTES )
318+ chunk_grid = RegularChunkGrid (configuration = RegularChunkShape (chunk_shape = coord_chunk_shape ))
306319
320+ for name in self .coordinate_names :
307321 self ._builder .add_coordinate (
308322 name = name ,
309323 dimensions = self .spatial_dimension_names ,
@@ -313,14 +327,9 @@ def _add_coordinates(self) -> None:
313327 )
314328
315329 def _add_trace_mask (self ) -> None :
316- """Add trace mask variables with computed chunk sizes."""
317- # Compute optimal chunk size for trace mask (spatial dimensions only)
318- spatial_shape = self ._dim_sizes [:- 1 ] # Exclude vertical dimension
319- mask_chunk_shape = get_constrained_chunksize (
320- spatial_shape ,
321- ScalarType .BOOL ,
322- MAX_SIZE_LIVE_MASK ,
323- )
330+ """Add trace mask variable."""
331+ spatial_shape = self ._dim_sizes [:- 1 ]
332+ mask_chunk_shape = get_constrained_chunksize (spatial_shape , ScalarType .BOOL , MAX_SIZE_LIVE_MASK )
324333 chunk_grid = RegularChunkGrid (configuration = RegularChunkShape (chunk_shape = mask_chunk_shape ))
325334
326335 self ._builder .add_variable (
@@ -345,15 +354,7 @@ def _add_trace_headers(self, header_dtype: StructuredType) -> None:
345354 )
346355
347356 def _add_raw_headers (self ) -> None :
348- """Add raw binary headers variable.
349-
350- This variable stores the raw binary header bytes for each trace, which can be useful
351- for preserving original SEG-Y header information. Only supported in Zarr v3 format.
352-
353- The raw headers variable has:
354- - Same spatial dimensions as trace headers (all dimensions except vertical)
355- - No coordinates
356- """
357+ """Add raw 240-byte trace header variable. Zarr v3 only."""
357358 chunk_grid = RegularChunkGrid (configuration = RegularChunkShape (chunk_shape = self .full_chunk_shape [:- 1 ]))
358359 self ._builder .add_variable (
359360 name = "raw_headers" ,
0 commit comments