Skip to content

Commit

Permalink
add wvel
Browse files Browse the repository at this point in the history
  • Loading branch information
hgloeckner committed Jan 6, 2025
1 parent 6f02bbe commit be1b30f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
33 changes: 30 additions & 3 deletions pydropsonde/circles.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,34 @@ def add_omega(self):
"long_name": "Area-averaged atmospheric pressure velocity (omega)",
"units": "hPa hr-1",
}
self.circle_ds = ds.assign(
dict(omega_p=(ds.div.dims, omega.values, omega_attrs))
)
self.circle_ds = ds.assign(dict(omega=(ds.div.dims, omega.values, omega_attrs)))
return self

def add_wvel(self):
"""
Calculate vertical velocity as
- int diff dz
This calculates the vertical velocity from omega
Returns:
self: circle object with updated circle_ds
"""
ds = self.circle_ds
alt_dim = self.alt_dim
div = ds.div.where(~np.isnan(ds.div), drop=True).sortby(alt_dim)
zero_vel = xr.DataArray(data=[0], dims=alt_dim, coords={alt_dim: [0]})

height = xr.concat([zero_vel, div[alt_dim]], dim=alt_dim)
height_diff = height.diff(dim=alt_dim)

del_w = -div * height_diff.values

w_vel = del_w.cumsum(dim=alt_dim)
wvel_attrs = {
"standard_name": "upward_air_velocity",
"long_name": "Area-averaged atmospheric vertical velocity",
"units": "m s-1",
}
self.circle_ds = ds.assign(dict(wvel=(ds.omega.dims, w_vel, wvel_attrs)))
return self
1 change: 1 addition & 0 deletions pydropsonde/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ def run_pipeline(pipeline: dict, config: configparser.ConfigParser):
"add_divergence",
"add_vorticity",
"add_omega",
"add_wvel",
],
"output": "circles",
"comment": "calculate circle products",
Expand Down

0 comments on commit be1b30f

Please sign in to comment.