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)
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()
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)
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()
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)
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()