Skip to content

Commit

Permalink
remove measurements above aircraft
Browse files Browse the repository at this point in the history
  • Loading branch information
hgloeckner committed Jan 29, 2025
1 parent d68be7a commit 5b376d3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 23 deletions.
5 changes: 3 additions & 2 deletions pydropsonde/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,11 @@ def run_pipeline(pipeline: dict, config: configparser.ConfigParser):
"detect_floater",
"crop_aspen_ds_to_landing_time",
"create_interim_l2_ds",
"get_flight_attributes",
"set_alt_dim",
"remove_above_aircraft",
"get_l2_variables",
"convert_to_si",
"set_alt_dim",
"replace_alt_dim",
"set_qc_vars",
"get_qc",
Expand All @@ -517,7 +519,6 @@ def run_pipeline(pipeline: dict, config: configparser.ConfigParser):
"intake": "sondes",
"apply": iterate_Sonde_method_over_dict_of_Sondes_objects,
"functions": [
"get_flight_attributes",
"get_sonde_attributes",
"add_l2_attributes_to_interim_l2_ds",
"add_sonde_id_variable",
Expand Down
59 changes: 38 additions & 21 deletions pydropsonde/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,44 @@ def crop_aspen_ds_to_landing_time(self):
)
return self

def create_interim_l2_ds(self):
"""
Creates an interim L2 dataset from the aspen_ds or cropped_aspen_ds attribute.
Parameters
----------
None
Returns
-------
self : object
Returns the sonde object with the interim L2 dataset added as an attribute.
"""
if self.qc.is_floater:
ds = self.cropped_aspen_ds
else:
ds = self.aspen_ds
self.interim_l2_ds = ds

return self

def remove_above_aircraft(self, max_alt=15000):
"""
Remove measurements that are above the aircraft altitude or some threshold value if aircraft altitude is not given.
Parameters
----------
max_alt :
maximum realistic meassured altitude
"""
ds = self.interim_l2_ds
aircraft_alt = self.flight_attrs.get(
"aircraft_msl_altitude_(m)", float(max_alt)
)
self.interim_l2_ds = ds.where(ds[self.alt_dim] < aircraft_alt, drop=True)
return self

def set_qc_vars(self, qc_vars=None):
"""
set the variables for which to run the quality control.
Expand Down Expand Up @@ -505,27 +543,6 @@ def remove_non_qc_sondes(self, used_flags=None, remove_ugly=True):
)
return None

def create_interim_l2_ds(self):
"""
Creates an interim L2 dataset from the aspen_ds or cropped_aspen_ds attribute.
Parameters
----------
None
Returns
-------
self : object
Returns the sonde object with the interim L2 dataset added as an attribute.
"""
if self.qc.is_floater:
ds = self.cropped_aspen_ds
else:
ds = self.aspen_ds
self.interim_l2_ds = ds

return self

def convert_to_si(self, variables=["rh", "p", "ta"], skip=False):
"""
Converts variables to SI units.
Expand Down

0 comments on commit 5b376d3

Please sign in to comment.