Skip to content

Commit

Permalink
Old code and update error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dnowacki-usgs committed Feb 15, 2024
1 parent 4b86204 commit 3bee670
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 2 additions & 4 deletions stglib/core/qaqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,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 +416,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
2 changes: 1 addition & 1 deletion stglib/rsk/cdf2nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def ds_add_attrs(ds):
if utils.check_time_fits_in_int32(ds, "time"):
ds["time"].encoding["dtype"] = "i4"
else:
print("Casting time to double")
print("time variable will not fit in int32; casting to double")
ds["time"].encoding["dtype"] = "double"
else:
if utils.check_time_fits_in_int32(ds, "time"):
Expand Down

0 comments on commit 3bee670

Please sign in to comment.