Skip to content

Commit 206bf5c

Browse files
committed
fix time_downsampling in create_test_set
1 parent 3a6a871 commit 206bf5c

File tree

1 file changed

+4
-43
lines changed

1 file changed

+4
-43
lines changed

adbo/create_test_set.py

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,7 @@
44
import doctest
55
from pathlib import Path
66
from typing import Optional, List
7-
8-
# --- Mock Function for Demonstration ---
9-
# In your real environment, this import should find the actual
10-
# adforce.mesh module.
11-
try:
12-
from adforce.mesh import swegnn_dg_from_mesh_ds_from_path
13-
14-
print(
15-
"Successfully imported 'swegnn_dg_from_mesh_ds_from_path' from 'adforce.mesh'."
16-
)
17-
except ImportError:
18-
print("Warning: Could not import 'adforce.mesh'.")
19-
print("Using a MOCK function for demonstration purposes.")
20-
21-
def swegnn_dg_from_mesh_ds_from_path(path=None, **kwargs):
22-
"""Mock function for demonstration."""
23-
print(f" (Mock) Calling swegnn_dg_from_mesh_ds_from_path(path='{path}')")
24-
25-
# In a real run, this returns an xarray.Dataset.
26-
# We return a mock object with a .to_netcdf() method.
27-
class MockDataset:
28-
def to_netcdf(self, output_path):
29-
print(f" (Mock) Saving xarray.Dataset to {output_path}")
30-
# Create a dummy file to show it worked
31-
with open(output_path, "w") as f:
32-
f.write(f"Mock SWE-GNN data from {path}")
33-
34-
def close(self):
35-
# Add a close method to mimic xarray.Dataset
36-
pass
37-
38-
# Check if the mock path exists, as the real function would
39-
if path is None or not os.path.exists(path):
40-
raise FileNotFoundError(f"Mock or real: Path not found at {path}")
41-
42-
return MockDataset()
43-
44-
45-
# --- Helper Function ---
7+
from adforce.mesh import swegnn_dg_from_mesh_ds_from_path
468

479

4810
def find_best_run_from_json(json_path: str) -> Optional[str]:
@@ -127,9 +89,6 @@ def find_best_run_from_json(json_path: str) -> Optional[str]:
12789
return best_run_path
12890

12991

130-
# --- Core Worker Function ---
131-
132-
13392
def convert_best_bo_run_to_swegnn(
13493
bayesopt_run_folder: str, output_nc_path: str
13594
) -> None:
@@ -164,7 +123,9 @@ def convert_best_bo_run_to_swegnn(
164123
swegnn_ds = None
165124
try:
166125
print(f" Converting {best_run_path} to SWE-GNN format...")
167-
swegnn_ds = swegnn_dg_from_mesh_ds_from_path(path=best_run_path)
126+
swegnn_ds = swegnn_dg_from_mesh_ds_from_path(
127+
path=best_run_path, time_downsampling=7
128+
)
168129

169130
print(f" Saving to {output_nc_path}...")
170131
swegnn_ds.to_netcdf(output_nc_path)

0 commit comments

Comments
 (0)