Esempio n. 1
0
def test_sig0():
    acc = ds.xroms.sig0
    assert np.allclose(acc, xroms.potential_density(ds.temp, ds.salt, 0))
    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())
Esempio n. 2
0
def test_mld():
    acc = ds.xroms.mld(thresh=0.03)
    sig0 = xroms.potential_density(ds.temp, ds.salt, 0)
    assert np.allclose(acc, xroms.mld(sig0, ds.h, ds.mask_rho), equal_nan=True)
    acc.name == acc.attrs["name"]
    acc.attrs["grid"] == ds.xroms.grid
    items = ["T", "X", "Y", "longitude", "latitude", "time"]
    assert set(items).issubset(acc.cf.get_valid_keys())
Esempio n. 3
0
def test_ertel():
    acc = ds.xroms.ertel
    xsig0 = xroms.potential_density(ds.temp, ds.salt)
    xbuoy = xroms.buoyancy(xsig0)
    assert np.allclose(acc, xroms.ertel(xbuoy, ds.u, ds.v, ds.f, grid))
    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())
Esempio n. 4
0
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)
Esempio n. 5
0
    def sig0(self):
        """Calculate potential density referenced to z=0, on rho/rho grids.

        Notes
        -----
        See `xroms.potential_density` for full docstring.

        Example usage
        -------------
        >>> ds.xroms.sig0
        """

        if "sig0" not in self.ds:
            var = xroms.potential_density(self.ds.temp, self.ds.salt, 0)
            self.ds["sig0"] = var
        return self.ds.sig0
Esempio n. 6
0
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)
Esempio n. 7
0
def test_potential_density():
    sig0 = xroms.density(temp, salt, 0)
    xsig0 = xroms.potential_density(ds.temp, ds.salt)
    assert np.allclose(xsig0[0, :, 0, 0], sig0)