Skip to content

Commit

Permalink
Merge branch 'master' into vecwaves
Browse files Browse the repository at this point in the history
  • Loading branch information
dnowacki-usgs committed Feb 15, 2024
2 parents 519e741 + 181b5fe commit bb3195c
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 260 deletions.
3 changes: 1 addition & 2 deletions doc/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ EXO
EXO-specific options include:

- ``skiprows``: number of lines to skip in the CSV before the real data begins
- ``trim_by_salinity``: if ``'true'``, use salinity (``S_41``) as a master variable. Wherever salinity is ``_FillValue``, all other variables will be filled as well. Useful for when the instrument comes out of the water.

Note that negative numeric values in the YAML config file must be treated with care so as not to be interpreted as strings. If you want the minimum value to be, say, -0.2 units for a particular parameter, you must write this as ``-0.2`` and not ``-.2`` in the config file. The latter format will be interpreted as a string and will cause an error.

Expand Down Expand Up @@ -198,4 +197,4 @@ Lowell TCM Hobo
- All the _min, _max, _bad_ens, etc. options available to the EXO.
- ``skipfooter``: number of lines to skip in the CSV file at the end of the file
- ``ncols``: number of columns of data to read, starting at first
- ``names``: option for user specified column names (only recommended when code will not read names using automated/default method)
- ``names``: option for user specified column names (only recommended when code will not read names using automated/default method)
4 changes: 0 additions & 4 deletions stglib/aqd/aqdutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,6 @@ def coord_transform(vel1, vel2, vel3, heading, pitch, roll, T, T_orig, cs, out="
return u, v, w


def swap_bindist_to_depth(ds):
return ds.swap_dims({"bindist": "depth"})


def set_orientation(VEL, T):
"""
Create Z variable depending on instrument orientation
Expand Down
2 changes: 0 additions & 2 deletions stglib/aqd/wvscdf2nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def cdf_to_nc(cdf_filename, atmpres=False, writefile=True):
# Make bin_depth variable
ds = aqdutils.make_bin_depth(ds, waves=True)

# Swap dimensions from bindist to depth
# ds = aqdutils.swap_bindist_to_depth(ds)
ds = cdf2nc.ds_swap_dims(ds)
# Rename DataArrays within Dataset for EPIC compliance
# and append depth coord to velocities and amplitudes
Expand Down
29 changes: 2 additions & 27 deletions stglib/core/qaqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,29 +186,6 @@ def trim_bad_ens_indiv(ds, var):
return ds


def trim_by_salinity(ds, var):
if (
"trim_by_salinity" in ds.attrs
and ds.attrs["trim_by_salinity"].lower() == "true"
and var in ds
): # xarray doesn't support writing attributes as booleans
if (
"trim_by_salinity_exclude" in ds.attrs
and var in ds.attrs["trim_by_salinity_exclude"]
):
pass
else:
print("%s: Trimming using valid salinity threshold" % var)
ds[var][ds["S_41"].isnull()] = np.nan

if var != "S_41":
notetxt = "Values filled using valid salinity threshold. "

ds = utils.insert_note(ds, var, notetxt)

return ds


def trim_by_any(ds, var):
attrlist = []
for a in ds.attrs:
Expand Down Expand Up @@ -406,8 +383,8 @@ def trim_std_ratio(ds, var):
ds = utils.insert_note(ds, var, notetxt)

else:
print(
f"{var}_std does not exist was NOT able to trim using standard deviation ratio method"
raise ValueError(
f"User specified {ds.attrs[var + '_std_ratio']=} but {var}_std does not exist. Was not able to trim using standard deviation ratio method"
)

return ds
Expand All @@ -416,9 +393,7 @@ def trim_std_ratio(ds, var):
def trim_warmup(ds, var):
if var + "_warmup_samples" in ds.attrs:
if "sample" in ds[var].coords:
print(ds[var])
ds[var] = ds[var].where(ds["sample"] > ds.attrs[var + "_warmup_samples"])
print(ds[var])
notetxt = f"Removed {ds.attrs[var + '_warmup_samples']} samples at the beginning of each burst. "

ds = utils.insert_note(ds, var, notetxt)
Expand Down
15 changes: 9 additions & 6 deletions stglib/core/runcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ def get_metadata(args):
with open(args.config) as f:
config = yaml.safe_load(f)

for k in config:
if k in metadata:
warnings.warn(
f"attrs collision. Replacing '{k}={metadata[k]}' from global attributes file with '{k}={config[k]}' from YAML config file."
)
metadata[k] = config[k]
try:
for k in config:
if k in metadata:
warnings.warn(
f"attrs collision. Replacing '{k}={metadata[k]}' from global attributes file with '{k}={config[k]}' from YAML config file."
)
metadata[k] = config[k]
except TypeError:
raise TypeError(f"Could not load metadata from {args.config}")

return metadata

Expand Down
Loading

0 comments on commit bb3195c

Please sign in to comment.