Skip to content

Commit

Permalink
Merge pull request #40 from efvik/main
Browse files Browse the repository at this point in the history
Wave spectra indexing fix
  • Loading branch information
KonstantinChri authored Oct 23, 2024
2 parents 09bfa2d + aaaf737 commit e56b711
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions metocean_api/ts/aux_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,13 @@ def get_near_coord(infile, lon, lat, product):
station = __distance_2points(ds.latitude.values,ds.longitude.values,lat,lon).argmin()
lon_near = ds.longitude.values[0,station]
lat_near = ds.latitude.values[0,station]
station += 1 # station labels are 1-indexed
return {'x':station}, lon_near, lat_near
elif product == "NORAC_wave_spec":
station = __distance_2points(ds.latitude.values,ds.longitude.values,lat,lon).argmin()
lon_near = ds.longitude.values[0,station]
lat_near = ds.latitude.values[0,station]
station += 1 # station labels are 1-indexed
return {'station':station}, lon_near, lat_near
else:
raise ValueError(f'Product not found {product}')
Expand Down
8 changes: 4 additions & 4 deletions metocean_api/ts/read_metno.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ def nora3_wave_spec(ts: TimeSeries, save_csv=False, save_nc=False, use_cache=Fal
# merge temp files and create combined result
with xr.open_mfdataset(tempfiles) as ds:
da = ds["SPEC"]
da.attrs["longitude"] = float(ds["longitude"][0].values)
da.attrs["latitude"] = float(ds["latitude"][0].values)
da.attrs["longitude"] = lon_near
da.attrs["latitude"] = lat_near

if save_csv:
s = da.shape
Expand Down Expand Up @@ -407,8 +407,8 @@ def norac_wave_spec(ts: TimeSeries, save_csv=False, save_nc=False, use_cache=Fal
# merge temp files and create combined result
with xr.open_mfdataset(tempfiles) as ds:
da = ds["efth"]
da.attrs["longitude"] = float(ds["longitude"][0].values)
da.attrs["latitude"] = float(ds["latitude"][0].values)
da.attrs["longitude"] = lon_near
da.attrs["latitude"] = lat_near

if save_csv:
s = da.shape
Expand Down

0 comments on commit e56b711

Please sign in to comment.