Skip to content

Commit 320ecf0

Browse files
authored
Update coops.py
Fixed u and v calcualtion from speed and dir
1 parent a190712 commit 320ecf0

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

intake_coops/coops.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,13 @@ def process_adcp(self, metadata, ds, process_adcp):
148148
process_adcp = "process_subtidal"
149149

150150
if process_adcp in ["process_uv", "process_along", "process_subtidal"]:
151+
# dir is "dir (True)" and looks like it is compass oriented
152+
# e.g. https://tidesandcurrents.noaa.gov/cdata/DataPlot?id=COI0501&bin=9&bdate=20050529&edate=20050530&unit=1&timeZone=UTC&view=data
151153
ds["u"] = (
152-
np.cos(np.deg2rad(ds.cf["dir"])) * ds.cf["speed"] / 100
154+
np.sin(np.deg2rad(ds.cf["dir"])) * ds.cf["speed"] / 100
153155
)
154156
ds["v"] = (
155-
np.sin(np.deg2rad(ds.cf["dir"])) * ds.cf["speed"] / 100
157+
np.cos(np.deg2rad(ds.cf["dir"])) * ds.cf["speed"] / 100
156158
)
157159
ds["s"] /= 100
158160
ds["s"].attrs = {"standard_name": "sea_water_speed", "units": "m s-1"}

0 commit comments

Comments
 (0)