def __init__(self, air_temperature, rel_humidity, rad_temperature=None, wind_speed=None, comfort_parameter=None): """Initialize a UTCI comfort object from DataCollections of UTCI inputs. Args: air_temperature: Data Collection of air temperature values in Celcius. rel_humidity: Data Collection of relative humidity values in % or a single relative humdity value to be used for the whole analysis. rad_temperature: Data Collection of mean radiant temperature (MRT) values in degrees Celcius or a single MRT value to be used for the whole analysis. If None, this will be the same as the air_temperature. wind_speed: Data Collection of meteorological wind speed values in m/s (measured 10 m above the ground) or a single wind speed value to be used for the whole analysis. If None, this will default to a very low wind speed of 0.1 m/s. comfort_parameter: Optional UTCIParameter object to specify parameters under which conditions are considered acceptable. If None, default will assume comfort thresholds consistent with those used by meterologists to categorize outdoor conditions. """ # set up the object using air temperature as a base self._check_datacoll(air_temperature, Temperature, 'C', 'air_temperature') self._input_collections = [air_temperature] self._calc_length = len(air_temperature.values) self._base_collection = air_temperature # check required inputs self._air_temperature = air_temperature.values self._rel_humidity = self._check_input( rel_humidity, RelativeHumidity, '%', 'rel_humidity') # check inputs with defaults if rad_temperature is not None: self._rad_temperature = self._check_input( rad_temperature, Temperature, 'C', 'rad_temperature') else: self._rad_temperature = self._air_temperature if wind_speed is not None: self._wind_speed = self._check_input( wind_speed, Speed, 'm/s', 'air_speed') else: self._wind_speed = [0.1] * self.calc_length # check that all input data collections are aligned. BaseCollection.are_collections_aligned(self._input_collections) # check comfort parameters if comfort_parameter is None: self._comfort_par = UTCIParameter() else: assert isinstance(comfort_parameter, UTCIParameter), 'comfort_parameter '\ 'must be a UTCIParameter object. Got {}'.format(type(comfort_parameter)) self._comfort_par = comfort_parameter # compute UTCI self._calculate_utci()
def __init__(self, air_temperature, rel_humidity, rad_temperature=None, wind_speed=None, comfort_parameter=None): """Initialize a UTCI comfort object from DataCollections of UTCI inputs. """ # set up the object using air temperature as a base self._check_datacoll(air_temperature, Temperature, 'C', 'air_temperature') self._input_collections = [air_temperature] self._calc_length = len(air_temperature.values) self._base_collection = air_temperature # check required inputs self._air_temperature = air_temperature.values self._rel_humidity = self._check_input(rel_humidity, RelativeHumidity, '%', 'rel_humidity') # check inputs with defaults if rad_temperature is not None: self._rad_temperature = self._check_input(rad_temperature, Temperature, 'C', 'rad_temperature') else: self._rad_temperature = self._air_temperature if wind_speed is not None: self._wind_speed = self._check_input(wind_speed, Speed, 'm/s', 'air_speed') else: self._wind_speed = [0.1] * self.calc_length # check that all input data collections are aligned. BaseCollection.are_collections_aligned(self._input_collections) # check comfort parameters if comfort_parameter is None: self._comfort_par = UTCIParameter() else: assert isinstance(comfort_parameter, UTCIParameter), 'comfort_parameter '\ 'must be a UTCIParameter object. Got {}'.format(type(comfort_parameter)) self._comfort_par = comfort_parameter # compute UTCI self._calculate_utci()
def from_air_and_rad_temp(cls, outdoor_temperature, air_temperature, rad_temperature=None, air_speed=None, comfort_parameter=None): """Initalize an Adaptive Comfort object from air and radiant temperature.""" if rad_temperature is None: to = air_temperature else: to = BaseCollection.compute_function_aligned( t_operative, [air_temperature, rad_temperature], OperativeTemperature(), 'C') return cls(outdoor_temperature, to, air_speed, comfort_parameter)
def test_init_incorrect(): """Test the init methods for base collections with incorrect inputs.""" a_per = AnalysisPeriod(6, 21, 12, 6, 21, 13) dt1, dt2 = DateTime(6, 21, 12), DateTime(6, 21, 13) v1, v2 = 20, 25 avg = (v1 + v2) / 2 dc1 = BaseCollection(Header(Temperature(), 'C', a_per), [v1, v2], [dt1, dt2]) dc1 = BaseCollection(Header(Temperature(), 'C', a_per), [v1, v2], (dt1, dt2)) dc1 = BaseCollection(Header(Temperature(), 'C', a_per), [v1, v2], xrange(2)) assert dc1.average == avg with pytest.raises(Exception): dc1 = BaseCollection(Header(Temperature(), 'C', a_per), [v1, v2], 'te') with pytest.raises(Exception): dc1 = BaseCollection(Header(Temperature(), 'C', a_per), [v1, v2], { '1': 1, '2': 2 })
def test_init(): """Test the init methods for base collections.""" a_per = AnalysisPeriod(6, 21, 12, 6, 21, 13) dt1, dt2 = DateTime(6, 21, 12), DateTime(6, 21, 13) v1, v2 = 20, 25 avg = (v1 + v2) / 2 # Setup data collection dc1 = BaseCollection(Header(Temperature(), 'C', a_per), [v1, v2], [dt1, dt2]) assert dc1.datetimes == (dt1, dt2) assert dc1.values == (v1, v2) assert dc1.average == avg str(dc1) # Test the string representation of the collection str(dc1.header) # Test the string representation of the header
def __init__(self, air_temperature, rel_humidity, rad_temperature=None, air_speed=None, met_rate=None, clo_value=None, external_work=None, comfort_parameter=None): """Initialize a PMV comfort object from DataCollections of PMV inputs. Args: air_temperature: Data Collection of air temperature values in Celcius. rel_humidity: Data Collection of relative humidity values in % or a single relative humdity value to be used for the whole analysis. rad_temperature: Data Collection of mean radiant temperature (MRT) values in degrees Celcius or a single MRT value to be used for the whole analysis. If None, this will be the same as the air_temperature. air_speed: Data Collection of air speed values in m/s or a single air_speed value to be used for the whole analysis. If None, this will default to 0.1 m/s. met_rate: Data Collection of metabolic rate in met or a single metabolic rate value to be used for the whole analysis. If None, default is set to 1.1 met (for seated, typing). clo_value: Data Collection of clothing values rate in clo or a single clothing value to be used for the whole analysis. If None, default is set to 0.7 clo (for long sleeve shirt and pants). external_work: Data Collection of external work in met or a single external work value to be used for the whole analysis. If None, default is set to 0 met. comfort_parameter: Optional PMVParameter object to specify parameters under which conditions are considered acceptable. If None, default will assume a PPD threshold of 10%, no absolute humidity constraints and a still air threshold of 0.1 m/s. """ # set up the object using air temperature as a base self._check_datacoll(air_temperature, Temperature, 'C', 'air_temperature') self._input_collections = [air_temperature] self._calc_length = len(air_temperature.values) self._base_collection = air_temperature # check and set required inputs self._air_temperature = air_temperature.values self._rel_humidity = self._check_input(rel_humidity, RelativeHumidity, '%', 'rel_humidity') # check parameters with defaults if rad_temperature is not None: self._rad_temperature = self._check_input(rad_temperature, Temperature, 'C', 'rad_temperature') else: self._rad_temperature = self._air_temperature if air_speed is not None: self._air_speed = self._check_input(air_speed, Speed, 'm/s', 'air_speed') else: self._air_speed = [0.1] * self.calc_length if met_rate is not None: self._met_rate = self._check_input(met_rate, MetabolicRate, 'met', 'met_rate') else: self._met_rate = [1.1] * self.calc_length if clo_value is not None: self._clo_value = self._check_input(clo_value, ClothingInsulation, 'clo', 'clo_value') else: self._clo_value = [0.7] * self.calc_length if external_work is not None: self._external_work = self._check_input(external_work, MetabolicRate, 'met', 'external_work') else: self._external_work = [0.] * self.calc_length # check that all input data collections are aligned. BaseCollection.are_collections_aligned(self._input_collections) # check comfort parameters if comfort_parameter is None: self._comfort_par = PMVParameter() else: assert isinstance(comfort_parameter, PMVParameter), 'comfort_parameter '\ 'must be a PMVParameter object. Got {}'.format(type(comfort_parameter)) self._comfort_par = comfort_parameter # value to track whether humidity ratio has been computed self._hr_calculated = False self._hr_comfort_required = True if self.comfort_parameter.humid_ratio_lower == 0 and \ self.comfort_parameter.humid_ratio_upper == 1: self._hr_comfort_required = False # calculate PMV self._calculate_pmv()
def __init__(self, air_temperature, rel_humidity, rad_temperature=None, air_speed=None, met_rate=None, clo_value=None, external_work=None, comfort_parameter=None): """Initialize a PMV comfort object from DataCollections of PMV inputs. """ # set up the object using air temperature as a base self._check_datacoll(air_temperature, Temperature, 'C', 'air_temperature') self._input_collections = [air_temperature] self._calc_length = len(air_temperature.values) self._base_collection = air_temperature # check and set required inputs self._air_temperature = air_temperature.values self._rel_humidity = self._check_input(rel_humidity, RelativeHumidity, '%', 'rel_humidity') # check parameters with defaults if rad_temperature is not None: self._rad_temperature = self._check_input(rad_temperature, Temperature, 'C', 'rad_temperature') else: self._rad_temperature = self._air_temperature if air_speed is not None: self._air_speed = self._check_input(air_speed, Speed, 'm/s', 'air_speed') else: self._air_speed = [0.1] * self.calc_length if met_rate is not None: self._met_rate = self._check_input(met_rate, MetabolicRate, 'met', 'met_rate') else: self._met_rate = [1.1] * self.calc_length if clo_value is not None: self._clo_value = self._check_input(clo_value, ClothingInsulation, 'clo', 'clo_value') else: self._clo_value = [0.7] * self.calc_length if external_work is not None: self._external_work = self._check_input(external_work, MetabolicRate, 'met', 'external_work') else: self._external_work = [0.] * self.calc_length # check that all input data collections are aligned. BaseCollection.are_collections_aligned(self._input_collections) # check comfort parameters if comfort_parameter is None: self._comfort_par = PMVParameter() else: assert isinstance(comfort_parameter, PMVParameter), 'comfort_parameter '\ 'must be a PMVParameter object. Got {}'.format(type(comfort_parameter)) self._comfort_par = comfort_parameter # value to track whether humidity ratio has been computed self._hr_calculated = False self._hr_comfort_required = True if self.comfort_parameter.humid_ratio_lower == 0 and \ self.comfort_parameter.humid_ratio_upper == 1: self._hr_comfort_required = False # calculate PMV self._calculate_pmv()