Skip to content

Commit

Permalink
add flight id
Browse files Browse the repository at this point in the history
  • Loading branch information
hgloeckner committed Nov 14, 2024
1 parent 6d48fee commit 6762ecb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions pydropsonde/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ def run_pipeline(pipeline: dict, config: configparser.ConfigParser):
"add_global_attributes_to_interim_l2_ds",
"add_sonde_id_variable",
"add_platform_id_variable",
"add_flight_id_variable",
"get_l2_filename",
"write_l2",
],
Expand Down
27 changes: 27 additions & 0 deletions pydropsonde/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,33 @@ def add_platform_id_variable(self, variable_name="platform_id"):
object.__setattr__(self, "_interim_l2_ds", ds)
return self

def add_flight_id_variable(self, variable_name="flight_id"):
"""
Adds a variable and related attributes to the sonde object with the Sonde object (self)'s flight_id attribute.
Parameters
----------
variable_name : str, optional
The name of the variable to be added. Default is 'flight_id'.
Returns
-------
self : object
Returns the sonde object with a variable containing flight_id. Name of the variable provided by 'variable_name'.
"""
if hasattr(self, "_interim_l2_ds"):
ds = self._interim_l2_ds
else:
ds = self.aspen_ds

attrs = dict(
description="unique flight ID",
long_name="flight identifier",
)

ds = ds.assign_coords({variable_name: self.flight_id})
ds[variable_name] = ds[variable_name].assign_attrs(attrs)
object.__setattr__(self, "_interim_l2_ds", ds)
return self

def get_flight_attributes(
Expand Down

0 comments on commit 6762ecb

Please sign in to comment.