Skip to content

Commit b5c03a7

Browse files
committed
fixup! Support parquet in sim2seis mock
1 parent be2e18c commit b5c03a7

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

test-data/ert/seismic_example/mock_sim2seis.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ class MonitorDate(StrEnum):
5454
JAN2030 = "20300101"
5555

5656

57+
class OutputFormat(StrEnum):
58+
CSV = "csv"
59+
PARQUET = "parquet"
60+
61+
5762
# Coordinate/region table: (X_UTME, Y_UTMN, REGION)
5863
COORDINATE_TABLE: list[tuple[float, float, float]] = [
5964
(463401.665023891, 6929758.90312445, 1.0),
@@ -177,9 +182,9 @@ def _build_stem(
177182

178183

179184
def generate_file(
180-
output_format: str,
181185
parameters: dict[str, dict[str, float]],
182186
output_dir: Path,
187+
output_format: OutputFormat,
183188
horizon: HorizonName,
184189
attribute: Attribute,
185190
stacking_offset: StackingOffset,
@@ -218,7 +223,7 @@ def generate_file(
218223
)
219224

220225
df = pd.DataFrame(rows)
221-
if output_format == "parquet":
226+
if output_format is OutputFormat.PARQUET:
222227
df.to_parquet(filepath, index=False)
223228
else:
224229
df.to_csv(filepath, index=False)
@@ -229,7 +234,7 @@ def generate_file(
229234
def generate_many(
230235
parameters: dict[str, dict[str, float]],
231236
output_dir: Path,
232-
output_format: str,
237+
output_format: OutputFormat,
233238
horizons: list[HorizonName] | None = None,
234239
attributes: list[Attribute] | None = None,
235240
stacking_offsets: list[StackingOffset] | None = None,
@@ -259,9 +264,9 @@ def generate_many(
259264
monitors,
260265
):
261266
generate_file(
262-
output_format,
263267
parameters,
264268
output_dir,
269+
output_format,
265270
*combo,
266271
)
267272

@@ -280,8 +285,9 @@ def generate_many(
280285
)
281286
parser.add_argument(
282287
"--format",
283-
choices=["csv", "parquet"],
284-
default="csv",
288+
type=OutputFormat,
289+
choices=list(OutputFormat),
290+
default=OutputFormat.CSV,
285291
help="Output file format.",
286292
)
287293
args = parser.parse_args()

0 commit comments

Comments
 (0)