|
4 | 4 |
|
5 | 5 | import logging |
6 | 6 | import os |
7 | | -from copy import deepcopy |
8 | 7 | from typing import TYPE_CHECKING |
9 | 8 |
|
10 | 9 | import numpy as np |
11 | 10 | import zarr |
12 | 11 | from segy import SegyFile |
13 | 12 | from segy.config import SegySettings |
14 | | -from segy.schema import HeaderField |
15 | | -from segy.schema import ScalarType as ScalarType2 |
16 | 13 | from segy.standards.codes import MeasurementSystem as segy_MeasurementSystem |
17 | 14 | from segy.standards.fields.trace import Rev0 as TraceHeaderFieldsRev0 |
18 | 15 |
|
@@ -344,33 +341,6 @@ def _add_grid_override_to_metadata(dataset: Dataset, grid_overrides: dict[str, A |
344 | 341 | dataset.metadata.attributes["gridOverrides"] = grid_overrides |
345 | 342 |
|
346 | 343 |
|
347 | | -def _scalar_to_size(scalar: ScalarType2) -> int: |
348 | | - # TODO(BrianMichell): #0000 Lazy way to support conversion. |
349 | | - if scalar == ScalarType2.STRING8: |
350 | | - return 8 |
351 | | - try: |
352 | | - return int(str(scalar)[-2:]) // 8 |
353 | | - except ValueError: |
354 | | - return 1 |
355 | | - |
356 | | - |
357 | | -def _customize_segy_spec(segy_spec: SegySpec) -> SegySpec: |
358 | | - assigned_bytes = [] |
359 | | - |
360 | | - ret = deepcopy(segy_spec) |
361 | | - |
362 | | - for field in segy_spec.trace.header.fields: |
363 | | - byte = field.byte - 1 |
364 | | - for i in range(byte, byte + _scalar_to_size(field.format)): |
365 | | - assigned_bytes.append(i) # noqa: PERF402 |
366 | | - unassigned_bytes = [i for i in range(240) if i not in assigned_bytes] |
367 | | - field_to_customize = [ |
368 | | - HeaderField(name=f"__MDIO_RAW_UNSPECIFIED_Field_{i}", format=ScalarType.UINT8, byte=i + 1) |
369 | | - for i in unassigned_bytes |
370 | | - ] |
371 | | - return ret.customize(trace_header_fields=field_to_customize) |
372 | | - |
373 | | - |
374 | 344 | def _add_raw_headers_to_template(mdio_template: AbstractDatasetTemplate) -> AbstractDatasetTemplate: |
375 | 345 | """Add raw headers capability to the MDIO template by monkey-patching its _add_variables method. |
376 | 346 |
|
@@ -451,9 +421,6 @@ def segy_to_mdio( # noqa PLR0913 |
451 | 421 | input_path = _normalize_path(input_path) |
452 | 422 | output_path = _normalize_path(output_path) |
453 | 423 |
|
454 | | - if os.getenv("MDIO__DO_RAW_HEADERS") == "1": |
455 | | - segy_spec = _customize_segy_spec(segy_spec) |
456 | | - |
457 | 424 | if not overwrite and output_path.exists(): |
458 | 425 | err = f"Output location '{output_path.as_posix()}' exists. Set `overwrite=True` if intended." |
459 | 426 | raise FileExistsError(err) |
|
0 commit comments