Skip to content

Commit

Permalink
fix ancillary vars (rh, q, ta, theta)
Browse files Browse the repository at this point in the history
  • Loading branch information
hgloeckner committed Feb 3, 2025
1 parent 4c86dd4 commit 0ee2899
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
1 change: 0 additions & 1 deletion pydropsonde/helper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ def calc_rh_from_q(ds):
w_s = mtf.partial_pressure_to_mixing_ratio(e_s, ds.p.values)
w = physics.q2mr(ds.q.values)
rh = w / w_s

try:
rh_attrs = ds.rh.attrs
rh_attrs.update(
Expand Down
35 changes: 24 additions & 11 deletions pydropsonde/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1531,20 +1531,33 @@ def add_qc_to_interim_l3(self, keep=None):
self: The instance with updated `interim_l3_ds` including quality control flags.
"""
ds = self.interim_l3_ds

for var in ds.variables:
if var != "sonde_id":
ds[var].attrs.pop("ancillary_variables", None)
if keep is None:
keep = []
elif keep == "all":
keep = (
[f"{var}_qc" for var in list(self.qc.qc_by_var.keys())]
+ list(self.qc.qc_details.keys())
+ ["alt_near_gpsalt"]
)
else:
for var in ds.variables:
if var != "sonde_id":
ds[var].attrs.pop("ancillary_variables", None)
if keep is None:
keep = []
if keep == "all":
keep = (
[f"{var}_qc" for var in list(self.qc.qc_by_var.keys())]
+ list(self.qc.qc_details.keys())
+ ["alt_near_gpsalt"]
)
for variable in self.qc.qc_vars:
ds = self.qc.add_variable_flags_to_ds(ds, variable, details=True)
if (not np.isin("q", self.qc.qc_vars)) and np.isin(
"rh", self.qc.qc_vars
):
ds = self.qc.add_variable_flags_to_ds(
ds, "rh", add_to="q", details=True
)
if (not np.isin("theta", self.qc.qc_vars)) and np.isin(
"ta", self.qc.qc_vars
):
ds = self.qc.add_variable_flags_to_ds(
ds, "ta", add_to="theta", details=True
)
elif keep == "var_flags":
keep = [f"{var}_qc" for var in list(self.qc.qc_by_var.keys())] + [
"sonde_qc"
Expand Down

0 comments on commit 0ee2899

Please sign in to comment.