예제 #1
0
    def test_vmr_rh_conversion(self):
        """Check the consistency of VMR and relative humidity conversion.

        Converting VMR into relative humidity and back to ensure that both
        functions yield consistent results.
        """
        rh = atmosphere.vmr2relative_humidity(0.025, 1013e2, 300)
        vmr = atmosphere.relative_humidity2vmr(rh, 1013e2, 300)

        assert np.allclose(vmr, 0.025)
예제 #2
0
    def get_relative_humidity(self, i_p, *args):
        def p_eq(t):
            p = np.zeros(t.shape)

            inds = t >= 273.15
            tt = np.exp( 54.842763 - 6763.22 / t - 4.21 * np.log(t) + 0.000367 * t + \
                         np.tanh(0.0415 * (t - 218.8)) * ( 53.878 - 1331.22/t - \
                                                           9.44523 * np.log(t) + 0.014025 * t) )
            p[inds] = tt[inds]

            inds = t < 273.15
            tt = np.exp(9.550426 - 5723.265 / t + 3.53068 * np.log(t) -
                        0.00728332 * t)
            p[inds] = tt[inds]
            return p

        from typhon.physics.atmosphere import vmr2relative_humidity
        t = self.get_temperature(i_p).ravel()
        p = self.get_pressure(i_p).ravel()
        vmr = self.get_H2O(i_p).ravel()
        q = vmr2relative_humidity(vmr, p, t)  #, e_eq = p_eq)
        return q
예제 #3
0
era_5_t_full = era_5.variables["t"][:]
era_5_rh_full = era_5.variables["r"][:]

f = RegularGridInterpolator(
    (era_5_lon, era_5_lat[::-1]), era_5_t_full[0, ::-1, ::-1, :].T
)
era_5_t = f((hamp.lon + 360.0, hamp.lat))

f = RegularGridInterpolator(
    (era_5_lon, era_5_lat[::-1]), era_5_rh_full[0, ::-1, ::-1, :].T
)
era_5_rh = f((hamp.lon + 360.0, hamp.lat))

# Convert to WV saturation pressure assumptions
era_5_h2o = relative_humidity2vmr(era_5_rh, era_5_p.reshape(1, -1), era_5_t)
era_5_rh = vmr2relative_humidity(era_5_h2o, era_5_p.reshape(1, -1), era_5_t, e_eq=p_eq)

f = RegularGridInterpolator(
    (era_5_lon, era_5_lat[::-1]), era_5_phy_full[0, ::-1, ::-1, :].T
)
era_5_z = f((hamp.lon + 360.0, hamp.lat)) / 9.80665

z = np.linspace(0, 12e3, 61)
p = np.zeros((hamp.lon.size, z.size))
t = np.zeros((hamp.lon.size, z.size))
rh = np.zeros((hamp.lon.size, z.size))
h2o = np.zeros((hamp.lon.size, z.size))

for i in range(hamp.lon.size):
    f = interp1d(era_5_z[i, :], era_5_p[::-1], fill_value="extrapolate")
    p[i, :] = f(z) * 100.0
예제 #4
0
    def test_vmr2relative_humidity(self):
        """Test conversion from VMR into relative humidity."""
        rh = atmosphere.vmr2relative_humidity(0.025, 1013e2, 300)

        assert np.allclose(rh, 0.7160499)