Skip to content

Commit

Permalink
correct assignments and complete attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
ninarobbins committed Sep 25, 2024
1 parent 32e234a commit dae4ed4
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions pydropsonde/circles.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,18 @@ def get_div_and_vor(self):
D = self.circle_ds.dudx + self.circle_ds.dvdy
vor = self.circle_ds.dvdx - self.circle_ds.dudy

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

Expand All @@ -43,21 +53,24 @@ def get_density(self, sonde_dim="sonde_id"):
self.circle_ds.ta.values * units.kelvin,
mr,
)
density_attrs = {"standard_name": "air_density", "units": str(density.units)}
self.circle_ds = self.circle_ds.assign(
dict(density=(self.circle_ds.ta.dims, density.magnitude, density_attrs))
)
density_attrs = {
"standard_name": "air_density",
"long_name": "Air density",
"units": str(density.units),
}
mean_density_attrs = {
"standard_name": "mean_air_density",
"long_name": "Mean air density in circle",
"units": str(density.units),
}
self.circle_ds = self.circle_ds.assign(
dict(
density=(self.circle_ds.ta.dims, density.magnitude, density_attrs),
mean_density=(
["alt"],
self.circle_ds.density.mean(sonde_dim),
mean_density_attrs,
)
),
)
)

Expand All @@ -77,6 +90,7 @@ def get_vertical_velocity(self):
w_vel = del_w.cumsum(dim="alt")
w_vel_attrs = {
"standard_name": "upward_air_velocity",
"long_name": "Area-averaged vertical air velocity",
"units": str(units.meter / units.second),
}
self.circle_ds = self.circle_ds.assign(
Expand All @@ -101,6 +115,7 @@ def get_omega(self):
# Assign omega to the dataset with correct attributes
omega_attrs = {
"standard_name": "atmosphere_vertical_velocity",
"long_name": "Area-averaged atmospheric pressure velocity",
"units": str(p_vel.units),
}
self.circle_ds = self.circle_ds.assign(
Expand Down

0 comments on commit dae4ed4

Please sign in to comment.