Skip to content

Commit 671ffa4

Browse files
committed
Merge branch 'waterdepth' into 'master'
Do not attempt to create water_depth if no pressure variable exists See merge request cmgp/stglib!13
2 parents eb0ee96 + 153d100 commit 671ffa4

File tree

7 files changed

+67
-14
lines changed

7 files changed

+67
-14
lines changed

stglib/core/utils.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,21 +1003,22 @@ def create_water_depth_var(ds):
10031003
elif "P_1" in ds:
10041004
press = "P_1"
10051005

1006-
if "sample" in ds.dims:
1007-
ds["water_depth"] = xr.DataArray(
1008-
ds[press].squeeze().mean(dim="sample")
1009-
+ ds.attrs["initial_instrument_height"]
1010-
)
1006+
if press is not None:
1007+
if "sample" in ds.dims:
1008+
ds["water_depth"] = xr.DataArray(
1009+
ds[press].squeeze().mean(dim="sample")
1010+
+ ds.attrs["initial_instrument_height"]
1011+
)
10111012

1012-
else:
1013-
ds["water_depth"] = xr.DataArray(
1014-
ds[press].squeeze() + ds.attrs["initial_instrument_height"]
1015-
)
1013+
else:
1014+
ds["water_depth"] = xr.DataArray(
1015+
ds[press].squeeze() + ds.attrs["initial_instrument_height"]
1016+
)
10161017

1017-
ds["water_depth"].attrs["long_name"] = "Total water depth"
1018-
ds["water_depth"].attrs["units"] = "m"
1019-
ds["water_depth"].attrs["standard_name"] = "sea_floor_depth_below_sea_surface"
1020-
ds["water_depth"].attrs["epic_code"] = 3
1018+
ds["water_depth"].attrs["long_name"] = "Total water depth"
1019+
ds["water_depth"].attrs["units"] = "m"
1020+
ds["water_depth"].attrs["standard_name"] = "sea_floor_depth_below_sea_surface"
1021+
ds["water_depth"].attrs["epic_code"] = 3
10211022

10221023
return ds
10231024

stglib/tests/data/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,4 @@ mc3575.asc filter=lfs diff=lfs merge=lfs -text
117117
11264sg-atmpres.cdf filter=lfs diff=lfs merge=lfs -text
118118
example_TruBlue.csv filter=lfs diff=lfs merge=lfs -text
119119
abs_test_data/** filter=lfs diff=lfs merge=lfs -text
120+
054215_DMP23X3E01tu.zip filter=lfs diff=lfs merge=lfs -text

stglib/tests/data/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
!atmpres_BEL19B3C03exo.cdf
99
!atmpres_205598_20220104_1336_wtw21.cdf
1010
!atmpres-BEL5Cwvs.cdf
11+
054215_DMP23X3E01tu/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:3e1ec5c1d2a6141922ea9d9bd84418278eda5e481570fd8e234f215bb7d822bd
3+
size 142929
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
title: 'DMP23X3E01tu'
2+
basefile: '054215_DMP23X3E01tu/054215_DMP23X3E01tu'
3+
filename: 'DMP23X3E01tu'
4+
initial_instrument_height: 0.30
5+
Turb_min: 0.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
MOORING; DMP23X3E
2+
PROGRAM; Sediment transport in coastal environments
3+
PROJECT; Strategic Placement 2023
4+
EXPERIMENT; DMP23
5+
Region; South San Francisco Bay
6+
CruiseID; 2023-655-FA
7+
SciPi; Jessica Lacy, Andrew Stevens
8+
Year; 2024
9+
Site; X3E
10+
platform_type; Tripod
11+
latitude; 37.59047
12+
longitude; -122.16087
13+
WATER_DEPTH; 1.8
14+
WATER_DEPTH_source; Water depth calculated from first in-water measurement of pressure from RBR 41324
15+
WATER_DEPTH_note; water depth at time of deployment
16+
geopotential_datum_name; NAVD88
17+
geopotential_datum_elevation_source; High-resolution (1 m) digital elevation model (DEM) of San Francisco Bay, California, created using bathymetry data collected between 1999 and 2020 (ver. 2.0, July 2021): U.S. Geological Survey data release, https://doi.org/10.5066/P9TJTS8M
18+
height_above_geopotential_datum; -0.59
19+
height_above_geopotential_datum_note; elevation in meters of the seabed with respect to the geopotential datum
20+
Deployment_date; 18-JUN-2024 16:48
21+
Recovery_date; 13-AUG-2024 15:20
22+
OFAFunding; US Army Corps of Engineers
23+
CollaboratingAgency; USGS WERC
24+
DESCRIPTION; Weightstand
25+
magnetic_variation; 13.0
26+
DATA_TYPE; TIME
27+
DATA_SUBTYPE; MOORED
28+
DATA_ORIGIN; USGS/PCMSC
29+
COORD_SYSTEM; GEOGRAPHIC
30+
Conventions; CF-1.8
31+
history; ''
32+
DATA_CMNT; ''

stglib/tests/test_scripts.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,22 @@ def rbr_diwasp(nc_file):
348348
assert "Done writing netCDF file" in result.stdout.decode("utf8")
349349

350350

351-
def test_rbr():
351+
def test_rbr_tu():
352+
with zipfile.ZipFile("stglib/tests/data/054215_DMP23X3E01tu.zip", "r") as zip_ref:
353+
zip_ref.extractall("stglib/tests/data/")
354+
rbr_raw("gatts_DMP23X3E.txt", "DMP23X3E01tu_config.yaml")
355+
rbr_nc("DMP23X3E01tu-raw.cdf")
356+
357+
358+
def test_rbr_wvs():
352359
with zipfile.ZipFile("stglib/tests/data/051001_CSF20SC201.zip", "r") as zip_ref:
353360
zip_ref.extractall("stglib/tests/data/")
354361
rbr_raw("gatts_CSF20SC2.txt", "csf20sc201_config.yaml")
355362
rbr_nc("CSF20SC201pt-raw.cdf")
356363
rbr_wvs("CSF20SC201ptb-cal.nc")
364+
365+
366+
def test_rbr():
357367
with zipfile.ZipFile("stglib/tests/data/055109_20220808_1605.zip", "r") as zip_ref:
358368
zip_ref.extractall("stglib/tests/data/")
359369
rbr_raw("gatts_055109_20220808_1605.txt", "055109_20220808_1605_config.yaml")

0 commit comments

Comments
 (0)