Skip to content

Commit

Permalink
Added water level utility
Browse files Browse the repository at this point in the history
  • Loading branch information
De Meo committed Oct 10, 2024
1 parent b099de0 commit 0780085
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
25 changes: 22 additions & 3 deletions doc/sgtid.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
SBE 26plus Seagauge (tides)
***************************
Instrument data to raw .cdf
===========================

Starting from exported .tid or .wb file, use :doc:`runots </runots>` to process using the two :doc:`configuration files </config>`.
Convert from exported .tid file to a raw netCDF file with .cdf extension using ``runsgtid2cdf.py``.

runsgtid2cdf.py
----------------

.. argparse::
:ref: stglib.core.cmd.sgtid2cdf_parser
:prog: runsgtid2cdf.py

Raw .cdf to CF-compliant .nc
============================

Convert the raw .cdf data into a CF-compliant netCDF file with .nc extension using ``runsgcdf2nc.py``.

runsgcdf2nc.py
---------------

.. argparse::
:ref: stglib.core.cmd.sgcdf2nc_parser
:prog: runsgcdf2nc.py
10 changes: 9 additions & 1 deletion stglib/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1404,10 +1404,18 @@ def create_water_level_var(ds):
"""
Create water level variable from NAVD88 sensor height
"""
ds["water_level"] = xr.DataArray(ds["P_1ac"] + ds["z"].values)

if "sample" in ds.dims:
ds["water_level"] = xr.DataArray(
ds["P_1ac"].squeeze().mean(dim="sample") + ds["z"].values
)
else:
ds["water_level"] = ds["P_1ac"] + ds["z"].values

ds["water_level"].attrs["long_name"] = "Water level NAVD88"
ds["water_level"].attrs["units"] = "m"
ds["water_level"].attrs[
"standard_name"
] = "sea_surface_height_above_geopotential_datum"
ds["water_level"].attrs["geopotential_datum_name"] = "NAVD88"
return ds
2 changes: 0 additions & 2 deletions stglib/sg/wvscdf2nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ def cdf_to_nc(cdf_filename, atmpres=None):
ds = utils.clip_ds(ds)
ds = utils.create_nominal_instrument_depth(ds)
ds = utils.create_z(ds)
ds = utils.create_water_level_var(ds)
ds = utils.create_water_depth_var(ds)
ds = utils.ds_add_lat_lon(ds)
ds = utils.add_start_stop_time(ds)
ds = utils.add_min_max(ds)
Expand Down
1 change: 1 addition & 0 deletions stglib/sg/wvsnc2waves.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def nc_to_waves(nc_filename):
for k in ["wp_peak", "wh_4061", "wp_4060", "pspec"]:
ds[k] = spec[k]

ds = utils.create_water_level_var(ds)
ds = utils.create_water_depth_var(ds)

# Drop unneeded variables/attributes
Expand Down

0 comments on commit 0780085

Please sign in to comment.