Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add omega #125

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions pydropsonde/circles.py
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @hgloeckner for including this, it looks good to me ! And sorry for not having written this myself. Assuming hydrostaticity it is also possible to deduce from the pressure velocity $\omega$ the vertical velocity $w = - \omega / (\rho g)$, some people may find it convenient

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all good :) You wrote a pretty good explanation what should be done.

I will add the vertical velocity as well - just wanted to be sure that everything is alright like this

Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,32 @@ def add_vorticity(self):
}
self.circle_ds = ds.assign(vor=(ds.dudx.dims, vor.values, vor_attrs))
return self

def add_omega(self):
"""
Calculate vertical pressure velocity as
\int div dp

This calculates the vertical pressure velocity as described in
Bony and Stevens 2019

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)
p = ds.mean_p.where(~np.isnan(ds.div), drop=True).sortby(alt_dim)
zero_vel = xr.DataArray(data=[0], dims=alt_dim, coords={alt_dim: [0]})
pres_diff = xr.concat([zero_vel, p.diff(dim=alt_dim)], dim=alt_dim)
del_omega = -div * pres_diff.values
omega = del_omega.cumsum(dim=alt_dim) * 0.01 * 60**2
omega_attrs = {
"standard_name": "atmosphere_vertical_velocity",
"long_name": "Area-averaged atmospheric pressure velocity",
"units": "hPa hr-1",
}
self.circle_ds = ds.assign(
dict(omega_p=(ds.div.dims, omega.values, omega_attrs))
)
return self
8 changes: 7 additions & 1 deletion pydropsonde/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,13 @@ def run_pipeline(pipeline: dict, config: configparser.ConfigParser):
"calculate_circle_data": {
"intake": "circles",
"apply": iterate_Circle_method_over_dict_of_Circle_objects,
"functions": ["add_density", "apply_fit2d", "add_divergence", "add_vorticity"],
"functions": [
"add_density",
"apply_fit2d",
"add_divergence",
"add_vorticity",
"add_omega",
],
"output": "circles",
"comment": "calculate circle products",
},
Expand Down
Loading