Пример #1
0
    def _create_profile(self):
        """ Create a vertical profile that we can interpolate into later. 
        Integrating with the hydrostatic assumption.
        """
        from pyclouds import parameterisations

        parameterisation = parameterisations.SaturationVapourPressure()

        dz = 100.
        R_d = self.R_d

        R_v = self.R_v
        R_d = self.R_d
        cp_d = self.c_p
        cp_v = self.cp_v

        z = 0.0
        p = self.ps

        # Cathy suggested using the liquid water potential temperature as the
        # temperature in the first model level
        T = self.theta_l(0.0)

        profile = []

        n = 0
        while z < self.z_max:
            qt = self.q_t(z)

            # assume no liquid water
            ql = 0.0
            qv = qt

            qd = 1.0 - qt

            theta_l = self.theta_l(z)

            R_l = R_d * qd + R_v * qv
            c_l = cp_d * qd + cp_v * qv

            T = theta_l / ((self.p0 / p)**(R_l / c_l))
            # T = self.iteratively_find_temp(theta_l=theta_l, p=p, q_t=qt, q_l=ql, T_initial=T)

            rho = 1.0 / (
                (qd * R_d + qv * R_v) * T / p)  # + 1.0/(ql/rho_l), ql = 0.0

            profile.append((z, rho, p, T))

            # integrate pressure
            z += dz
            p += -rho * self.g * dz

            n += 1

        self._profile = np.array(profile)
Пример #2
0
    def rel_humidity(self, z):
        q_v = self.q_t(z)
        p = self.p(z)
        T = self.temp(z)

        from pyclouds import parameterisations
        parameterisation = parameterisations.SaturationVapourPressure()

        qv_sat = parameterisation.qv_sat(T=T, p=p)

        return q_v / qv_sat
Пример #3
0
    def _create_profile(self):
        """ Create a vertical profile that we can interpolate into later. 
        Integrating with the hydrostatic assumption.
        """
        try:
            from pyclouds import parameterisations
        except ImportError:
            warnings.warn("pyclouds module couldn't be found, can't create"
                          "profile for interpolation of rho, T, RH and p")
            return

        parameterisation = parameterisations.SaturationVapourPressure()

        # XXX: R_v and cp_v are not given in the RICO test definition on the
        # the KNMI site I will use what I believe are standard values here
        self.R_v = parameterisations.common.default_constants.get('R_v')
        self.cp_v = parameterisations.common.default_constants.get('cp_v')

        dz = 100.
        R_d = self.R_d

        R_v = self.R_v
        R_d = self.R_d
        cp_d = self.c_p
        cp_v = self.cp_v

        z = 0.0
        p = self.ps

        # Cathy suggested using the liquid water potential temperature as the
        # temperature in the first model level
        T = self.theta_l(0.0)

        profile = []

        n = 0
        while z < self.z_max:
            qt = self.q_t(z)

            # assume no liquid water
            ql = 0.0
            qv = qt

            qd = 1.0 - qt

            theta_l = self.theta_l(z)

            R_l = R_d * qd + R_v * qv
            c_l = cp_d * qd + cp_v * qv

            T = theta_l / ((self.p0 / p)**(R_l / c_l))
            # T = self.iteratively_find_temp(theta_l=theta_l, p=p, q_t=qt, q_l=ql, T_initial=T)

            rho = 1.0 / (
                (qd * R_d + qv * R_v) * T / p)  # + 1.0/(ql/rho_l), ql = 0.0

            profile.append((z, rho, p, T))

            # integrate pressure
            z += dz
            p += -rho * self.g * dz

            n += 1

        self._profile = np.array(profile)