Skip to content

Commit

Permalink
Migrate from deprecated seawater toolbox to gsw
Browse files Browse the repository at this point in the history
  • Loading branch information
dnowacki-usgs committed Nov 8, 2024
1 parent b5ff620 commit 79e654f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ python
compliance-checker
dask
git-lfs
gsw
joblib
matplotlib-base
netcdf4
Expand All @@ -12,7 +13,6 @@ pyarrow
pytest
pyyaml
scipy
seawater
sqlite
tqdm
xarray
Expand Down
2 changes: 1 addition & 1 deletion requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies:
- compliance-checker
- dask
- git-lfs
- gsw
- joblib
- matplotlib-base
- netcdf4
Expand All @@ -16,7 +17,6 @@ dependencies:
- pytest
- pyyaml
- scipy
- seawater
- sqlite
- tqdm
- xarray
Expand Down
10 changes: 5 additions & 5 deletions stglib/eofe.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import gsw
import numpy as np
import pandas as pd
import seawater as sw
import xarray as xr

from .aqd import aqdutils
Expand Down Expand Up @@ -553,10 +553,10 @@ def calc_cor_brange(ds):
)
math_sign = "+"

soundspd = sw.svel(ds.attrs["average_salinity"], ds.Temperature_C, p)
soundspd = gsw.sound_speed(ds.attrs["average_salinity"], ds.Temperature_C, p)
ds["brange"] = xr.DataArray(time_sec * soundspd).round(3) # round brange to mm

histtext = f"Adjusted sound velocity calculated using svel(s,t,p) from seawater toolbox (https://pythonhosted.org/seawater/eos80.html#seawater.eos80.svel). Svel inputs: Salinity (s) from average salinity of {ds.attrs['average_salinity']} PSU, temperature (t) from ea400 internal temperature measurements, pressure (p) from instrument depth {math_sign} median(altitude)/2. "
histtext = f"Adjusted sound velocity calculated using sound_speed(s,t,p) from gsw toolbox (https://teos-10.github.io/GSW-Python/). Inputs: Salinity (s) from average salinity of {ds.attrs['average_salinity']} PSU, temperature (t) from ea400 internal temperature measurements, pressure (p) from instrument depth {math_sign} median(altitude)/2. "

ds = utils.insert_history(ds, histtext)

Expand Down Expand Up @@ -692,11 +692,11 @@ def calc_cor_bin_height(ds):

# spd = sw.svel(ds.attrs["average_salinity"], ds.Temperature_C, p)
# speed up finding sound speed by taking mean across sample dim then expand dims after
spd2 = sw.svel(
spd2 = gsw.sound_speed(
ds.attrs["average_salinity"],
ds["Temperature_C"].mean(dim="sample"),
p.mean(dim="sample"),
)
).T
soundspd = (
xr.DataArray(spd2, dims=["bins", "time"])
.expand_dims({"sample": ds.sample})
Expand Down

0 comments on commit 79e654f

Please sign in to comment.