コード例 #1
0
 def test_units_validation_equal_units(self):
     ## heat index coefficients require the data be in specific units
     field = self.get_field(name='tasmax',units='fahrenheit',with_value=True)
     field_rhs = self.get_field(name='rhsmax',units='percent',with_value=True)
     field.variables.add_variable(field_rhs.variables['rhsmax'], assign_new_uid=True)
     self.assertEqual(set(field.variables.keys()),set(['tasmax','rhsmax']))
     hi = HeatIndex(field=field,parms={'tas':'tasmax','rhs':'rhsmax'})
     vc = hi.execute()
     self.assertIsInstance(vc,VariableCollection)
コード例 #2
0
 def test_units_validation_wrong_units(self):
     ## heat index coefficients require the data be in specific units
     field = self.get_field(name='tasmax',units='kelvin',with_value=True)
     field_rhs = self.get_field(name='rhsmax',units='percent',with_value=True)
     field.variables.add_variable(field_rhs.variables['rhsmax'], assign_new_uid=True)
     self.assertEqual(set(field.variables.keys()),set(['tasmax','rhsmax']))
     hi = HeatIndex(field=field,parms={'tas':'tasmax','rhs':'rhsmax'})
     with self.assertRaises(UnitsValidationError):
         hi.execute()
コード例 #3
0
ファイル: test_heat_index.py プロジェクト: NCPP/ocgis
 def test_system_units_validation_equal_units(self):
     # Heat index coefficients require the data be in specific units.
     field = self.get_field(name='tasmax', units='fahrenheit', with_value=True)
     field_rhs = self.get_field(name='rhsmax', units='percent', with_value=True)
     with orphaned(field_rhs['rhsmax']):
         field.add_variable(field_rhs['rhsmax'], is_data=True)
     self.assertEqual(set(get_variable_names(field.get_by_tag(TagName.DATA_VARIABLES))),
                      set(['tasmax', 'rhsmax']))
     hi = HeatIndex(field=field, parms={'tas': 'tasmax', 'rhs': 'rhsmax'})
     vc = hi.execute()
     self.assertIsInstance(vc, VariableCollection)
コード例 #4
0
ファイル: test_heat_index.py プロジェクト: NCPP/ocgis
    def test_system_units_validation_wrong_units(self):
        # Heat index coefficients require the data be in specific units.
        field = self.get_field(name='tasmax', units='kelvin', with_value=True)
        field_rhs = self.get_field(name='rhsmax', units='percent', with_value=True)

        with orphaned(field_rhs['rhsmax']):
            field.add_variable(field_rhs['rhsmax'], is_data=True)

        self.assertEqual(set(get_variable_names(field.get_by_tag(TagName.DATA_VARIABLES))),
                         {'tasmax', 'rhsmax'})
        hi = HeatIndex(field=field, parms={'tas': 'tasmax', 'rhs': 'rhsmax'})
        with self.assertRaises(UnitsValidationError):
            hi.execute()
コード例 #5
0
ファイル: test_heat_index.py プロジェクト: wk1984/ocgis
 def test_system_units_validation_equal_units(self):
     # Heat index coefficients require the data be in specific units.
     field = self.get_field(name='tasmax',
                            units='fahrenheit',
                            with_value=True)
     field_rhs = self.get_field(name='rhsmax',
                                units='percent',
                                with_value=True)
     with orphaned(field_rhs['rhsmax']):
         field.add_variable(field_rhs['rhsmax'], is_data=True)
     self.assertEqual(
         set(get_variable_names(field.get_by_tag(TagName.DATA_VARIABLES))),
         set(['tasmax', 'rhsmax']))
     hi = HeatIndex(field=field, parms={'tas': 'tasmax', 'rhs': 'rhsmax'})
     vc = hi.execute()
     self.assertIsInstance(vc, VariableCollection)
コード例 #6
0
ファイル: test_heat_index.py プロジェクト: wk1984/ocgis
    def test_system_units_validation_wrong_units(self):
        # Heat index coefficients require the data be in specific units.
        field = self.get_field(name='tasmax', units='kelvin', with_value=True)
        field_rhs = self.get_field(name='rhsmax',
                                   units='percent',
                                   with_value=True)

        with orphaned(field_rhs['rhsmax']):
            field.add_variable(field_rhs['rhsmax'], is_data=True)

        self.assertEqual(
            set(get_variable_names(field.get_by_tag(TagName.DATA_VARIABLES))),
            {'tasmax', 'rhsmax'})
        hi = HeatIndex(field=field, parms={'tas': 'tasmax', 'rhs': 'rhsmax'})
        with self.assertRaises(UnitsValidationError):
            hi.execute()