Skip to content

Commit

Permalink
allow dewpoint in input, update, warn if diff too high
Browse files Browse the repository at this point in the history
  • Loading branch information
observingClouds committed Sep 16, 2024
1 parent 385ba16 commit 4d68821
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/level0_cor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ input_units: # data units in radiosonde files (cor)
"wind_speed" : "m/s"
"v" : "m/s"
"u" : "m/s"
"dew_point" : "degree_Celsius"
filename_fmt:
file: "??%Y%m%d%H_?"
datetime_fmt: "%Y%m%d%H"
16 changes: 15 additions & 1 deletion pysonde/sounding.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,21 @@ def calculate_additional_variables(self, config):
dewpoint = td.convert_rh_to_dewpoint(
self.profile.temperature.values, self.profile.humidity.values
)
self.profile.insert(10, "dew_point", dewpoint)
if "dew_point" in self.profile:
logging.warning(
"Values for dew point already exist in input file. To ensure consistency, they will be recalculated."
)
diff = np.mean(self.profile.dew_point - dewpoint)
assert (
np.abs(diff).magnitude < 50
), "The difference seems to be large. Are the input units in the config correct?"
logging.info(
f"Mean difference between calculated and existing dew point: {diff:.2f}"
)
self.profile.dew_point = dewpoint
else:
self.profile.insert(10, "dew_point", dewpoint)

# Mixing ratio
e_s = td.calc_saturation_pressure(self.profile.temperature.values)
if "pint" in e_s.dtype.__str__():
Expand Down

0 comments on commit 4d68821

Please sign in to comment.