1414
1515from mdio .api .io import _normalize_path
1616from mdio .api .io import to_mdio
17+ from mdio .builder .schemas .chunk_grid import RegularChunkGrid
18+ from mdio .builder .schemas .chunk_grid import RegularChunkShape
19+ from mdio .builder .schemas .compressors import Blosc
20+ from mdio .builder .schemas .compressors import BloscCname
21+ from mdio .builder .schemas .dtype import ScalarType
1722from mdio .builder .schemas .v1 .units import LengthUnitEnum
1823from mdio .builder .schemas .v1 .units import LengthUnitModel
24+ from mdio .builder .schemas .v1 .variable import VariableMetadata
1925from mdio .builder .xarray_builder import to_xarray_dataset
2026from mdio .converters .exceptions import EnvironmentFormatError
2127from mdio .converters .exceptions import GridTraceCountError
2228from mdio .converters .exceptions import GridTraceSparsityError
2329from mdio .converters .type_converter import to_structured_type
2430from mdio .core .grid import Grid
25- from mdio .builder .schemas .chunk_grid import RegularChunkGrid
26- from mdio .builder .schemas .chunk_grid import RegularChunkShape
27- from mdio .builder .schemas .compressors import Blosc
28- from mdio .builder .schemas .compressors import BloscCname
29- from mdio .builder .schemas .dtype import ScalarType
3031from mdio .segy import blocked_io
3132from mdio .segy .utilities import get_grid_plan
3233
@@ -337,6 +338,7 @@ def _add_segy_ingest_attributes(dataset: Dataset, segy_file: SegyFile, grid_over
337338
338339def _add_raw_headers_to_template (mdio_template : AbstractDatasetTemplate ) -> AbstractDatasetTemplate :
339340 """Add raw headers capability to the MDIO template by monkey-patching its _add_variables method.
341+
340342 This function modifies the template's _add_variables method to also add a raw headers variable
341343 with the following characteristics:
342344 - Same rank as the Headers variable (all dimensions except vertical)
@@ -348,9 +350,11 @@ def _add_raw_headers_to_template(mdio_template: AbstractDatasetTemplate) -> Abst
348350 - Chunked the same as the Headers variable
349351 Args:
350352 mdio_template: The MDIO template to mutate
353+ Returns:
354+ The mutated MDIO template
351355 """
352356 # Check if raw headers enhancement has already been applied to avoid duplicate additions
353- if hasattr (mdio_template , ' _mdio_raw_headers_enhanced' ):
357+ if hasattr (mdio_template , " _mdio_raw_headers_enhanced" ):
354358 return mdio_template
355359
356360 # Store the original _add_variables method
@@ -365,7 +369,6 @@ def enhanced_add_variables() -> None:
365369
366370 # Create chunk grid metadata
367371 chunk_metadata = RegularChunkGrid (configuration = RegularChunkShape (chunk_shape = chunk_shape ))
368- from mdio .builder .schemas .v1 .variable import VariableMetadata
369372
370373 # Add the raw headers variable using the builder's add_variable method
371374 mdio_template ._builder .add_variable (
0 commit comments