Skip to content

Commit

Permalink
add sonde_id variable to l2
Browse files Browse the repository at this point in the history
  • Loading branch information
Geet-George committed Dec 11, 2023
1 parent d24783d commit 1141721
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/halodrops/sonde.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,3 +527,33 @@ def get_l2_variables(self, l2_variables: dict = hh.l2_variables):
object.__setattr__(self, "_interim_l2_ds", ds)

return self

def add_sonde_id_variable(self, variable_name="sonde_id"):
"""
Adds a variable and related attributes to the sonde object with the Sonde object (self)'s serial_id attribute.
Parameters
----------
variable_name : str, optional
The name of the variable to be added. Default is 'sonde_id'.
Returns
-------
self : object
Returns the sonde object with a variable containing serial_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

ds = ds.assign({variable_name: self.serial_id})
ds[variable_name].attrs = {
"descripion": "unique sonde ID",
"long_name": "sonde identifier",
"cf_role": "trajectory_id",
}

object.__setattr__(self, "_interim_l2_ds", ds)

return self

0 comments on commit 1141721

Please sign in to comment.