Skip to content

Commit

Permalink
add low physics p test
Browse files Browse the repository at this point in the history
  • Loading branch information
hgloeckner committed Feb 6, 2025
1 parent 1788f5b commit 6f6e551
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pydropsonde/helper/quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,15 @@ def alt_near_gpsalt(self, ds, diff_threshold=150):
self.qc_flags["alt_near_gpsalt"] = False
self.qc_details["alt_near_gpsalt_max_diff"] = max_diff.values

def low_physics(self, ds, rh_min=0.3, ta_min=293.15, alt_dim="gpsalt"):
def low_physics(
self,
ds,
rh_min=0.3,
ta_min=293.15,
p_min=100500,
p_max=102000,
alt_dim="gpsalt",
):
"""
Checks that the temperature and relative humidity in the lowest 100m in a dataset
are above a certain value
Expand All @@ -287,13 +295,20 @@ def low_physics(self, ds, rh_min=0.3, ta_min=293.15, alt_dim="gpsalt"):
if ds_check.sizes["time"] == 0:
self.qc_flags["rh_low_physics"] = False
self.qc_flags["ta_low_physics"] = False
self.qc_flags["p_low_physics"] = False
self.qc_details["rh_low_physics_min"] = np.nan
self.qc_details["ta_low_physics_min"] = np.nan
self.qc_details["p_low_physics_sfc"] = np.nan
else:
sfc_p = ds.p.sortby("time", ascending=False).dropna(dim="time").values[0]
self.qc_flags["ta_low_physics"] = ds_check.ta.min() > float(ta_min)
self.qc_flags["rh_low_physics"] = ds_check.rh.min() > float(rh_min)
self.qc_flags["p_low_physics"] = (sfc_p > float(p_min)) and (
sfc_p < float(p_max)
)
self.qc_details["rh_low_physics_min"] = ds_check.rh.min().values
self.qc_details["ta_low_physics_min"] = ds_check.ta.min().values
self.qc_details["p_low_physics_sfc"] = sfc_p

def check_qc(self, used_flags=None, check_ugly=True):
"""
Expand Down Expand Up @@ -422,6 +437,7 @@ def get_unit_for_qc(self, qc_name, var_name=None):
(qc_name.endswith("diff"))
or (qc_name.endswith("min"))
or (qc_name.endswith("max"))
or (qc_name.endswith("sfc"))
):
return var_unit
elif (
Expand Down

0 comments on commit 6f6e551

Please sign in to comment.