@@ -43,59 +43,19 @@ def _validate_coordinates_headers_trace_mask(dataset: Dataset, headers: Structur
4343 )
4444
4545 # Verify dimension coordinate variables
46- shot_line = validate_variable (
47- dataset ,
48- name = "shot_line" ,
49- dims = [("shot_line" , 1 )],
50- coords = ["shot_line" ],
51- dtype = ScalarType .INT32 ,
52- )
53- assert shot_line .metadata is None
54-
55- gun = validate_variable (
56- dataset ,
57- name = "gun" ,
58- dims = [("gun" , 3 )],
59- coords = ["gun" ],
60- dtype = ScalarType .INT32 ,
61- )
62- assert gun .metadata is None
63-
64- shot_point = validate_variable (
65- dataset ,
66- name = "shot_point" ,
67- dims = [("shot_point" , 256 )],
68- coords = ["shot_point" ],
69- dtype = ScalarType .INT32 ,
70- )
71- assert shot_point .metadata is None
72-
73- cable = validate_variable (
74- dataset ,
75- name = "cable" ,
76- dims = [("cable" , 512 )],
77- coords = ["cable" ],
78- dtype = ScalarType .INT32 ,
79- )
80- assert cable .metadata is None
81-
82- channel = validate_variable (
83- dataset ,
84- name = "channel" ,
85- dims = [("channel" , 24 )],
86- coords = ["channel" ],
87- dtype = ScalarType .INT32 ,
88- )
89- assert channel .metadata is None
90-
91- domain_var = validate_variable (
92- dataset ,
93- name = domain ,
94- dims = [(domain , 2048 )],
95- coords = [domain ],
96- dtype = ScalarType .INT32 ,
97- )
98- assert domain_var .metadata is None
46+ for dim_name in ["shot_line" , "gun" , "shot_point" , "cable" , "channel" , domain ]:
47+ validate_variable (
48+ dataset ,
49+ name = dim_name ,
50+ dims = [
51+ (
52+ dim_name ,
53+ {"shot_line" : 1 , "gun" : 3 , "shot_point" : 256 , "cable" : 512 , "channel" : 24 , domain : 2048 }[dim_name ],
54+ )
55+ ],
56+ coords = [dim_name ],
57+ dtype = ScalarType .INT32 ,
58+ )
9959
10060 # Verify non-dimension coordinate variables
10161 validate_variable (
@@ -106,98 +66,62 @@ def _validate_coordinates_headers_trace_mask(dataset: Dataset, headers: Structur
10666 dtype = ScalarType .INT32 ,
10767 )
10868
109- source_coord_x = validate_variable (
110- dataset ,
111- name = "source_coord_x" ,
112- dims = [("shot_line" , 1 ), ("gun" , 3 ), ("shot_point" , 256 )],
113- coords = ["source_coord_x" ],
114- dtype = ScalarType .FLOAT64 ,
115- )
116- assert source_coord_x .metadata .units_v1 .length == LengthUnitEnum .METER
117-
118- source_coord_y = validate_variable (
119- dataset ,
120- name = "source_coord_y" ,
121- dims = [("shot_line" , 1 ), ("gun" , 3 ), ("shot_point" , 256 )],
122- coords = ["source_coord_y" ],
123- dtype = ScalarType .FLOAT64 ,
124- )
125- assert source_coord_y .metadata .units_v1 .length == LengthUnitEnum .METER
126-
127- group_coord_x = validate_variable (
128- dataset ,
129- name = "group_coord_x" ,
130- dims = [("shot_line" , 1 ), ("gun" , 3 ), ("shot_point" , 256 ), ("cable" , 512 ), ("channel" , 24 )],
131- coords = ["group_coord_x" ],
132- dtype = ScalarType .FLOAT64 ,
133- )
134- assert group_coord_x .metadata .units_v1 .length == LengthUnitEnum .METER
135-
136- group_coord_y = validate_variable (
137- dataset ,
138- name = "group_coord_y" ,
139- dims = [("shot_line" , 1 ), ("gun" , 3 ), ("shot_point" , 256 ), ("cable" , 512 ), ("channel" , 24 )],
140- coords = ["group_coord_y" ],
141- dtype = ScalarType .FLOAT64 ,
142- )
143- assert group_coord_y .metadata .units_v1 .length == LengthUnitEnum .METER
69+ # Verify coordinate variables with units
70+ for coord_name in ["source_coord_x" , "source_coord_y" , "group_coord_x" , "group_coord_y" ]:
71+ coord = validate_variable (
72+ dataset ,
73+ name = coord_name ,
74+ dims = [("shot_line" , 1 ), ("gun" , 3 ), ("shot_point" , 256 )]
75+ + ([("cable" , 512 ), ("channel" , 24 )] if "group" in coord_name else []),
76+ coords = [coord_name ],
77+ dtype = ScalarType .FLOAT64 ,
78+ )
79+ assert coord .metadata .units_v1 .length == LengthUnitEnum .METER
14480
14581
14682class TestSeismic3DPreStackFieldRecordsTemplate :
147- """Unit tests for SeismicPreStackTemplate ."""
83+ """Unit tests for Seismic3DPreStackFieldRecordsTemplate ."""
14884
14985 def test_configuration (self ) -> None :
150- """Unit tests for SeismicPreStackTemplate in time domain ."""
86+ """Unit tests for Seismic3DPreStackFieldRecordsTemplate ."""
15187 t = Seismic3DPreStackFieldRecordsTemplate (data_domain = "time" )
15288
153- # Template attributes for prestack shot
89+ # Template attributes
15490 assert t .name == "PreStackFieldRecords3DTime"
155- assert t .default_variable_name == "amplitude"
156- assert t .trace_domain == "time"
157- assert t .spatial_dimension_names == ("shot_line" , "gun" , "shot_point" , "cable" , "channel" )
158- assert t .dimension_names == ("shot_line" , "gun" , "shot_point" , "cable" , "channel" , "time" )
159- assert t .physical_coordinate_names == ("source_coord_x" , "source_coord_y" , "group_coord_x" , "group_coord_y" )
160- assert t .logical_coordinate_names == ("orig_field_record_num" ,)
161- assert t .coordinate_names == (
162- "source_coord_x" ,
163- "source_coord_y" ,
164- "group_coord_x" ,
165- "group_coord_y" ,
166- "orig_field_record_num" ,
167- )
91+ assert t ._dim_names == ("shot_line" , "gun" , "shot_point" , "cable" , "channel" , "time" )
92+ assert t ._physical_coord_names == ("source_coord_x" , "source_coord_y" , "group_coord_x" , "group_coord_y" )
93+ # TODO(Anyone): Disable chunking in time domain when support is merged.
94+ # https://github.com/TGSAI/mdio-python/pull/723
16895 assert t .full_chunk_shape == (1 , 1 , 16 , 1 , 32 , 1024 )
16996
17097 # Variables instantiated when build_dataset() is called
17198 assert t ._builder is None
17299 assert t ._dim_sizes == ()
173- assert t ._units == {}
174100
175- # Verify prestack shot attributes
101+ # Verify dataset attributes
176102 attrs = t ._load_dataset_attributes ()
177103 assert attrs == {"surveyDimensionality" : "3D" , "ensembleType" : "shot_point" , "processingStage" : "pre-stack" }
178104 assert t .default_variable_name == "amplitude"
179105
180- assert t .name == "PreStackFieldRecords3DTime"
181-
182106 def test_build_dataset (self , structured_headers : StructuredType ) -> None :
183- """Unit tests for SeismicPreStackTemplate build in time domain ."""
107+ """Unit tests for Seismic3DPreStackFieldRecordsTemplate build."""
184108 t = Seismic3DPreStackFieldRecordsTemplate (data_domain = "time" )
185109 t .add_units ({"source_coord_x" : UNITS_METER , "source_coord_y" : UNITS_METER }) # spatial domain units
186110 t .add_units ({"group_coord_x" : UNITS_METER , "group_coord_y" : UNITS_METER }) # spatial domain units
187111 t .add_units ({"time" : UNITS_SECOND }) # data domain units
188112
189113 dataset = t .build_dataset (
190- "North Sea 3D Shot Time " , sizes = (1 , 3 , 256 , 512 , 24 , 2048 ), header_dtype = structured_headers
114+ "North Sea 3D Field Records " , sizes = (1 , 3 , 256 , 512 , 24 , 2048 ), header_dtype = structured_headers
191115 )
192116
193- assert dataset .metadata .name == "North Sea 3D Shot Time "
117+ assert dataset .metadata .name == "North Sea 3D Field Records "
194118 assert dataset .metadata .attributes ["surveyDimensionality" ] == "3D"
195119 assert dataset .metadata .attributes ["ensembleType" ] == "shot_point"
196120 assert dataset .metadata .attributes ["processingStage" ] == "pre-stack"
197121
198122 _validate_coordinates_headers_trace_mask (dataset , structured_headers , "time" )
199123
200- # Verify seismic variable (prestack shot time data)
124+ # Verify seismic variable
201125 seismic = validate_variable (
202126 dataset ,
203127 name = "amplitude" ,
0 commit comments