Skip to content

Commit 5ad5a6e

Browse files
committed
conversion to netcdf works for stationary mat files
1 parent 2e0e599 commit 5ad5a6e

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

dnora/executer/post_processors.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from geo_skeletons import GriddedSkeleton
99
from dnora import msg
1010
import pathlib
11-
11+
from datetime import datetime
1212

1313
SWAN_VARS = {
1414
"Hsig": gp.wave.Hs,
@@ -53,12 +53,18 @@ def read_swan_mat_to_ds(filename: str, lon: np.ndarray, lat=np.ndarray) -> xr.Da
5353
keys.sort()
5454
start_time = "T".join(keys[0].split("_")[1:])
5555
end_time = "T".join(keys[-1].split("_")[1:])
56+
if not start_time and not end_time: # Stationary run
57+
start_time = f"{datetime.today():%Y-%m-%d %H:00}"
58+
end_time = f"{datetime.today():%Y-%m-%d %H:00}"
5659

5760
obj = wave_grid(lon=lon, lat=lat, time=(start_time, end_time))
5861

5962
for swan_var, param in SWAN_VARS.items():
6063

61-
keys = [a for a in mat.keys() if swan_var == "_".join(a.split("_")[0:-2])]
64+
if swan_var in mat.keys(): # Stationary run
65+
keys = [swan_var]
66+
else:
67+
keys = [a for a in mat.keys() if swan_var == "_".join(a.split("_")[0:-2])]
6268

6369
keys.sort()
6470
if keys:

0 commit comments

Comments
 (0)