コード例 #1
0
    def process(self):
        """
        Create a saturated vapour pressure lookup table by calling the
        Utilities.saturation_vapour_pressure_goff_gratch function in
        psychrometric_calculations.Utilities.

        Returns:
            svp : iris.cube.Cube
               A cube of saturated vapour pressure values at temperature
               points defined by t_min, t_max, and t_increment (defined above).
        """
        temperatures = np.arange(self.t_min, self.t_max + 0.5*self.t_increment,
                                 self.t_increment)
        temperature = iris.cube.Cube(temperatures, 'air_temperature',
                                     units='K')

        svp = Utilities.saturation_vapour_pressure_goff_gratch(temperature)

        temperature_coord = iris.coords.DimCoord(
            temperature.data, 'air_temperature', units='K')

        svp.add_dim_coord(temperature_coord, 0)
        svp.attributes['minimum_temperature'] = self.t_min
        svp.attributes['maximum_temperature'] = self.t_max
        svp.attributes['temperature_increment'] = self.t_increment

        return svp
コード例 #2
0
    def test_basic(self):
        """Basic calculation of some saturated vapour pressures."""
        result = Utilities.saturation_vapour_pressure_goff_gratch(
            self.temperature)
        expected = [195.64190713, 469.67078994, 990.94206073]

        np.testing.assert_allclose(result.data, expected, rtol=1.e-5)
        self.assertEqual(result.units, Unit('Pa'))
コード例 #3
0
ファイル: test_Utilities.py プロジェクト: arh89/improver
    def test_basic(self):
        """Basic calculation of some enthalpy gradients."""
        specific_heat = np.array([1089.5, 1174., 1258.5])
        latent_heat = np.array([2531771., 2508371., 2484971.])

        expected = [[21631.198581, 38569.575046, 52448.138051]]
        result = Utilities.calculate_d_enthalpy_dt(
            self.mixing_ratio.data, specific_heat,
            latent_heat, self.temperature.data)

        self.assertArrayAlmostEqual(result.data, expected)
コード例 #4
0
ファイル: test_Utilities.py プロジェクト: arh89/improver
    def test_basic(self):
        """Basic calculation of some enthalpies."""
        specific_heat = np.array([1089.5, 1174., 1258.5])
        latent_heat = np.array([2531771., 2508371., 2484971.])

        expected = [[536447.103773,  818654.207476, 1097871.329623]]
        result = Utilities.calculate_enthalpy(
            self.mixing_ratio.data, specific_heat,
            latent_heat, self.temperature.data)

        self.assertArrayAlmostEqual(result, expected)
コード例 #5
0
    def test_basic(self):
        """Basic calculation of some enthalpies."""
        specific_heat = self.pressure.copy(data=[1089.5, 1174., 1258.5])
        specific_heat.units = 'J kg-1 K-1'
        latent_heat = self.pressure.copy(data=[2531771., 2508371., 2484971.])
        latent_heat.units = 'J kg-1'

        expected = [536447.1, 818654.2, 1097871.3]
        result = Utilities.calculate_enthalpy(self.mixing_ratio, specific_heat,
                                              latent_heat, self.temperature)

        self.assertArrayAlmostEqual(result.data, expected)
        self.assertEqual(result.units, Unit('J kg-1'))
コード例 #6
0
    def test_basic(self):
        """Basic calculation of some enthalpy gradients."""
        specific_heat = self.pressure.copy(data=[1089.5, 1174., 1258.5])
        specific_heat.units = 'J kg-1 K-1'
        latent_heat = self.pressure.copy(data=[2531771., 2508371., 2484971.])
        latent_heat.units = 'J kg-1'

        expected = [21631.19827498, 38569.57448917, 52448.13601681]
        result = Utilities.calculate_d_enthalpy_dt(self.mixing_ratio,
                                                   specific_heat, latent_heat,
                                                   self.temperature)

        self.assertArrayAlmostEqual(result.data, expected)
        self.assertEqual(result.units, Unit('J kg-1 K-1'))
コード例 #7
0
 def test_basic(self):
     """Basic calculation of some latent heats of condensation."""
     expected = [2531771., 2508371., 2484971.]
     result = Utilities.latent_heat_of_condensation(self.temperature)
     self.assertArrayEqual(result.data, expected)
     self.assertEqual(result.units, Unit('J kg-1'))
コード例 #8
0
 def test_basic(self):
     """Basic calculation of some moist air specific heat capacities."""
     expected = [1089.5, 1174., 1258.5]
     result = Utilities.specific_heat_of_moist_air(self.mixing_ratio)
     self.assertArrayEqual(result.data, expected)
     self.assertEqual(result.units, Unit('J kg-1 K-1'))
コード例 #9
0
 def test_basic(self):
     """Test that the __repr__ returns the expected string."""
     result = str(Utilities())
     msg = '<Utilities>'
     self.assertEqual(result, msg)
コード例 #10
0
ファイル: test_Utilities.py プロジェクト: arh89/improver
 def test_basic(self):
     """Basic calculation of some latent heats of condensation."""
     expected = [[2531771, 2508371, 2484971]]
     result = Utilities.latent_heat_of_condensation(self.temperature)
     self.assertArrayAlmostEqual(result.data, expected)
コード例 #11
0
ファイル: test_Utilities.py プロジェクト: arh89/improver
 def test_basic(self):
     """Basic calculation of some moist air specific heat capacities."""
     expected = np.array([[1089.5, 1174., 1258.5]], dtype=np.float32)
     result = Utilities.specific_heat_of_moist_air(self.mixing_ratio.data)
     self.assertArrayAlmostEqual(result, expected)