def test_buoyancy(): acc = ds.xroms.buoyancy xsig0 = xroms.potential_density(ds.temp, ds.salt) assert np.allclose(acc, xroms.buoyancy(xsig0)) acc.name == acc.attrs["name"] acc.attrs["grid"] == ds.xroms.grid items = ["T", "X", "Y", "Z", "longitude", "latitude", "vertical", "time"] assert set(items).issubset(acc.cf.get_valid_keys())
def test_ertel(): v_z = 0 u_z = 0 # test one corner of domain f = ds.f[0, 0].values vort = 0 sig0 = xroms.density(temp, salt, 0) buoy = -g * sig0 / rho0 phi_z = (buoy[2] - buoy[0]) / (z_rho[2] - z_rho[0]) ertel = -v_z + u_z + (f + vort) * phi_z xsig0 = xroms.potential_density(ds.temp, ds.salt) xbuoy = xroms.buoyancy(xsig0) assert np.allclose(xroms.ertel(xbuoy, ds.u, ds.v, ds.f, grid)[0, 1, 0, 0], ertel)
def buoyancy(self): """Calculate buoyancy on rho/rho grids. Notes ----- See `xroms.buoyancy` for full docstring. Example usage ------------- >>> ds.xroms.buoyancy """ if "buoyancy" not in self.ds: var = xroms.buoyancy(self.sig0, self.ds.rho0) self.ds["buoyancy"] = var return self.ds.buoyancy
def test_buoyancy(): xsig0 = xroms.potential_density(ds.temp, ds.salt) xbuoy = xroms.buoyancy(xsig0) sig0 = xroms.density(temp, salt, 0) buoy = -g * sig0 / rho0 assert np.allclose(xbuoy[0, :, 0, 0], buoy)