Skip to content

Commit 17ecbd1

Browse files
committed
pre-commit
1 parent c810849 commit 17ecbd1

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/mdio/converters/segy.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@
1818
from mdio.converters.exceptions import GridTraceSparsityError
1919
from mdio.converters.type_converter import to_structured_type
2020
from mdio.core.grid import Grid
21+
from mdio.schemas.chunk_grid import RegularChunkGrid
22+
from mdio.schemas.chunk_grid import RegularChunkShape
23+
from mdio.schemas.compressors import Blosc
24+
from mdio.schemas.compressors import BloscCname
25+
from mdio.schemas.dtype import ScalarType
26+
from mdio.schemas.metadata import ChunkGridMetadata
2127
from mdio.schemas.v1.dataset_serializer import to_xarray_dataset
2228
from mdio.schemas.v1.units import AllUnits
2329
from mdio.schemas.v1.units import LengthUnitEnum
2430
from mdio.schemas.v1.units import LengthUnitModel
25-
from mdio.schemas.dtype import ScalarType
26-
from mdio.schemas.v1.variable import Variable
27-
from mdio.schemas.compressors import Blosc, BloscCname
28-
from mdio.schemas.metadata import ChunkGridMetadata
29-
from mdio.schemas.chunk_grid import RegularChunkGrid, RegularChunkShape
3031
from mdio.segy import blocked_io
3132
from mdio.segy.utilities import get_grid_plan
3233

@@ -319,7 +320,7 @@ def _add_text_binary_headers(dataset: Dataset, segy_file: SegyFile) -> None:
319320

320321
def _add_raw_headers_to_template(mdio_template: AbstractDatasetTemplate) -> None:
321322
"""Add raw headers capability to the MDIO template by monkey-patching its _add_variables method.
322-
323+
323324
This function modifies the template's _add_variables method to also add a raw headers variable
324325
with the following characteristics:
325326
- Same rank as the Headers variable (all dimensions except vertical)
@@ -329,27 +330,25 @@ def _add_raw_headers_to_template(mdio_template: AbstractDatasetTemplate) -> None
329330
- zstd compressor
330331
- No additional metadata
331332
- Chunked the same as the Headers variable
332-
333+
333334
Args:
334335
mdio_template: The MDIO template to mutate
335336
"""
336337
# Store the original _add_variables method
337338
original_add_variables = mdio_template._add_variables
338-
339-
def enhanced_add_variables():
339+
340+
def enhanced_add_variables() -> None:
340341
# Call the original method first
341342
original_add_variables()
342-
343+
343344
# Now add the raw headers variable
344345
chunk_shape = mdio_template._var_chunk_shape[:-1]
345-
346+
346347
# Create chunk grid metadata
347348
chunk_metadata = ChunkGridMetadata(
348-
chunk_grid=RegularChunkGrid(
349-
configuration=RegularChunkShape(chunk_shape=chunk_shape)
350-
)
349+
chunk_grid=RegularChunkGrid(configuration=RegularChunkShape(chunk_shape=chunk_shape))
351350
)
352-
351+
353352
# Add the raw headers variable using the builder's add_variable method
354353
mdio_template._builder.add_variable(
355354
name="raw_headers",
@@ -360,7 +359,7 @@ def enhanced_add_variables():
360359
coordinates=None, # No coordinates as specified
361360
metadata_info=[chunk_metadata],
362361
)
363-
362+
364363
# Replace the template's _add_variables method
365364
mdio_template._add_variables = enhanced_add_variables
366365

0 commit comments

Comments
 (0)