Skip to content

Commit

Permalink
separate divergence and vorticity calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ninarobbins committed Nov 26, 2024
1 parent 537d29d commit 43eb4a4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
22 changes: 15 additions & 7 deletions pydropsonde/circles.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,23 +217,31 @@ def apply_fit2d(self, alt_var="alt"):
self.circle_ds = ds
return self

def get_div_and_vor(self):
def get_divergence(self):
D = self.circle_ds.dudx + self.circle_ds.dvdy
D_attrs = {
"standard_name": "divergence_of_wind",
"long_name": "Area-averaged horizontal mass divergence",
"units": "m-1",
}
self.circle_ds = self.circle_ds.assign(
D=(["alt"], D.values, D_attrs)
)
print(self.circle_ds)
return self

def get_vorticity(self):
vor = self.circle_ds.dvdx - self.circle_ds.dudy

vor_attrs = {
"standard_name": "atmosphere_relative_vorticity",
"long_name": "Area-averaged horizontal relative vorticity",
"units": "s-1",
}
D_attrs = {
"standard_name": "divergence_of_wind",
"long_name": "Area-averaged horizontal mass divergence",
"units": "m-1",
}
self.circle_ds = self.circle_ds.assign(
dict(D=(["alt"], D.values, D_attrs), vor=(["alt"], vor.values, vor_attrs))
vor=(["alt"], vor.values, vor_attrs)
)
print(self.circle_ds)
return self

def get_density(self, sonde_dim="sonde_id"):
Expand Down
3 changes: 2 additions & 1 deletion pydropsonde/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,8 @@ def run_pipeline(pipeline: dict, config: configparser.ConfigParser):
"calculate_circle_data": {
"intake": "circles",
"apply": iterate_Circle_method_over_dict_of_Circle_objects,
"functions": ["drop_m_N_vars", "get_xy_coords_for_circles", "apply_fit2d"],
"functions": ["drop_m_N_vars", "get_xy_coords_for_circles", "apply_fit2d", "get_divergence",
"get_vorticity"],
"output": "circles",
"comment": "calculate circle products",
},
Expand Down

0 comments on commit 43eb4a4

Please sign in to comment.