diff --git a/src/halodrops/helper/__init__.py b/src/halodrops/helper/__init__.py index 7e2b1d8..68adbab 100644 --- a/src/halodrops/helper/__init__.py +++ b/src/halodrops/helper/__init__.py @@ -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 : @@ -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 diff --git a/src/halodrops/pipeline.py b/src/halodrops/pipeline.py index 885f80f..034229b 100644 --- a/src/halodrops/pipeline.py +++ b/src/halodrops/pipeline.py @@ -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", diff --git a/src/halodrops/processor.py b/src/halodrops/processor.py index ef79bbd..ea641b4 100644 --- a/src/halodrops/processor.py +++ b/src/halodrops/processor.py @@ -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)