Skip to content

Commit

Permalink
fix theta and add to l2 routine
Browse files Browse the repository at this point in the history
  • Loading branch information
hgloeckner committed Aug 17, 2024
1 parent 650b8ed commit dfedd2a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
13 changes: 9 additions & 4 deletions src/halodrops/helper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def calc_q_from_rh(ds):
return ds


def calc_theta_from_T(dataset):
def calc_theta_from_T(ds):
"""
Input :
Expand All @@ -248,8 +248,13 @@ def calc_theta_from_T(dataset):
Function to estimate potential temperature from the temperature and pressure in the given dataset.
"""
theta = mpcalc.potential_temperature(
dataset.p.values * units.Pa, dataset.ta.values * units.kelvin
).magnitude
ds["theta"] = (ds.ta.dims, theta)
ds.p.values * units.Pa, ds.ta.values * units.kelvin
)
ds["theta"] = (ds.ta.dims, theta.magnitude)
ds["theta"].attrs = dict(
standard_name="potential temperature",
long_name="potential temperature",
units=str(theta.units),
)

return ds
1 change: 1 addition & 0 deletions src/halodrops/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ def run_pipeline(pipeline: dict, config: configparser.ConfigParser):
"get_l2_filename",
"add_l2_ds",
"create_prep_l3",
"add_q_and_theta_to_l2_ds",
"remove_non_mono_incr_alt",
"interpolate_alt",
"prepare_l2_for_gridded",
Expand Down
5 changes: 1 addition & 4 deletions src/halodrops/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,10 +1073,7 @@ def add_q_and_theta_to_l2_ds(self):
self : object
Returns the sonde object with potential temperature and specific humidity added to the L2 dataset.
"""
if hasattr(self, "_interim_l3_ds"):
ds = self._interim_l3_ds
else:
ds = self.l2_ds
ds = self._prep_l3_ds

ds = hh.calc_q_from_rh(ds)
ds = hh.calc_theta_from_T(ds)
Expand Down

0 comments on commit dfedd2a

Please sign in to comment.