From 176b50128d96db059b7bfcb845d4b3c20a8aa082 Mon Sep 17 00:00:00 2001 From: Dan Nowacki Date: Tue, 23 Apr 2024 16:53:30 -0700 Subject: [PATCH] Incorporate comment into atmospheric pressure correction (#222) --- doc/atmos.rst | 3 +++ stglib/core/utils.py | 4 ++++ stglib/rsk/cdf2nc.py | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/doc/atmos.rst b/doc/atmos.rst index 17c07aec..7577b41c 100644 --- a/doc/atmos.rst +++ b/doc/atmos.rst @@ -20,10 +20,13 @@ which sets the zero offset for the pressure sensor. In the example below, the of float64 atmpres(time) _FillValue: nan offset: -10.25 + comment: Atmospherically corrected using NOAA station 9414523 Redwood City, CA unlimited dimensions: current shape = (8874,) filling on +A second optional but highly recommended attribute for the ``atmpres`` variable is ``comment``. This can be used to store information about the station used for atmospheric compensation. For example, ``atmpres:comment = "Atmospherically corrected using NOAA station 9414523 Redwood City, CA"``. + The time base of the atmospheric pressure file must be the same as that of the instrument pressure record. This file will be used by the run scripts to atmospherically compensate the pressure record. Steps to generate an atmospheric pressure file diff --git a/stglib/core/utils.py b/stglib/core/utils.py index bc1dce5c..83e59f41 100644 --- a/stglib/core/utils.py +++ b/stglib/core/utils.py @@ -1166,6 +1166,10 @@ def atmos_correct(ds, atmpres): ds.attrs["atmospheric_pressure_correction_offset_applied"] = met["atmpres"].attrs[ "offset" ] + if "comment" in met["atmpres"].attrs: + ds.attrs["atmospheric_pressure_correction_comment"] = met["atmpres"].attrs[ + "comment" + ] # Is reindexing with a tolerance still necessary? Keeping old code around to check # ds["P_1ac"] = ( diff --git a/stglib/rsk/cdf2nc.py b/stglib/rsk/cdf2nc.py index 2e3bab38..7666cc64 100755 --- a/stglib/rsk/cdf2nc.py +++ b/stglib/rsk/cdf2nc.py @@ -165,6 +165,10 @@ def atmos_correct_profile(ds, atmpres): ds.attrs["atmospheric_pressure_correction_offset_applied"] = met["atmpres"].attrs[ "offset" ] + if "comment" in met["atmpres"].attrs: + ds.attrs["atmospheric_pressure_correction_comment"] = met["atmpres"].attrs[ + "comment" + ] return ds