Skip to content

Commit

Permalink
More diwasp
Browse files Browse the repository at this point in the history
  • Loading branch information
dnowacki-usgs committed Jun 11, 2024
1 parent dcc8c76 commit 77ffb16
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 1 addition & 2 deletions stglib/core/waves.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def make_diwasp_pres(ds):
DTp = np.full(len(ds.time), np.nan)
Dp = np.full(len(ds.time), np.nan)

for burst in tqdm(np.arange(0, 10)): # 150):
for burst in tqdm(np.arange(0, 100)): # 150):
SM = {
"freqs": np.arange(freqspace / 2, fs / 2, freqspace),
"dirs": np.arange(dirspace / 2, 360, dirspace),
Expand Down Expand Up @@ -83,7 +83,6 @@ def make_diwasp_pres(ds):


def make_waves_ds(ds):
print(dir(pyDIWASP))
print("Computing wave statistics")
if "P_1ac" in ds:
presvar = "P_1ac"
Expand Down
13 changes: 11 additions & 2 deletions stglib/rsk/nc2waves.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ def nc_to_waves(nc_filename):
for k in ["wp_peak", "wh_4061", "wp_4060", "pspec"]:
ds[k] = spec[k]

diwasp = waves.make_diwasp_pres(ds)
print(diwasp)
dodiwasp = False
if "diwasp" in ds.attrs and ds.attrs["diwasp"].lower() == "true":
dodiwasp = True
diwasp = waves.make_diwasp_pres(ds)
print(diwasp)

# ds = utils.create_water_depth(ds)

Expand Down Expand Up @@ -52,6 +55,12 @@ def nc_to_waves(nc_filename):

ds.to_netcdf(nc_filename, unlimited_dims=["time"])
utils.check_compliance(nc_filename, conventions=ds.attrs["Conventions"])

if dodiwasp:
diwasp_filename = ds.attrs["filename"] + "_diwasp-cal.nc.nc"
diwasp.to_netcdf(diwasp_filename)
utils.check_compliance(diwasp_filename, conventions=ds.attrs["Conventions"])

print("Done writing netCDF file", nc_filename)

return ds
Expand Down

0 comments on commit 77ffb16

Please sign in to comment.