def test_get_universal_thermal_climate_index_with_sun_and_wind(): """Test the get_universal_thermal_climate_index method with wind and sun.""" utci_obj = UTCI.from_epw(epw, True, True) assert utci_obj.percent_neutral == pytest.approx(31.4269406, rel=1e-3) assert utci_obj.percent_hot == pytest.approx(11.4611872, rel=1e-3) assert utci_obj.percent_cold == pytest.approx(57.111872, rel=1e-3)
def test_get_universal_thermal_climate_index_with_wind(): """Test the get_universal_thermal_climate_index method with wind.""" utci_obj = UTCI.from_epw(epw, True, False) assert utci_obj.percent_neutral == pytest.approx(35.6849315, rel=1e-3) assert utci_obj.percent_hot == pytest.approx(3.3447488, rel=1e-3) assert utci_obj.percent_cold == pytest.approx(60.970319, rel=1e-3)
def test_get_universal_thermal_climate_index_with_sun(): """Test the get_universal_thermal_climate_index method with sun.""" utci_obj = UTCI.from_epw(epw, False, True) assert utci_obj.percent_neutral == pytest.approx(40.730593, rel=1e-3) assert utci_obj.percent_hot == pytest.approx(20.4223744, rel=1e-3) assert utci_obj.percent_cold == pytest.approx(38.8470319, rel=1e-3)
def test_get_universal_thermal_climate_index(): """Test the get_universal_thermal_climate_index method.""" calc_length = 8760 utci_obj = UTCI.from_epw(epw, False, False) assert isinstance(utci_obj, UTCI) assert isinstance(utci_obj.air_temperature, HourlyContinuousCollection) assert len(utci_obj.air_temperature.values) == calc_length assert utci_obj.air_temperature[0] == -6.1 assert isinstance(utci_obj.rel_humidity, HourlyContinuousCollection) assert len(utci_obj.rel_humidity.values) == calc_length assert utci_obj.rel_humidity[0] == 81 assert isinstance(utci_obj.universal_thermal_climate_index, HourlyContinuousCollection) assert len(utci_obj.universal_thermal_climate_index.values) == calc_length assert utci_obj.universal_thermal_climate_index[0] == pytest.approx( -5.367017, rel=1e-3) assert isinstance(utci_obj.thermal_condition_eleven_point, HourlyContinuousCollection) assert len(utci_obj.thermal_condition_eleven_point.values) == calc_length assert utci_obj.thermal_condition_eleven_point[0] == -2 assert utci_obj.percent_neutral == pytest.approx(47.488584, rel=1e-3) assert utci_obj.percent_hot == pytest.approx(9.38356164, rel=1e-3) assert utci_obj.percent_cold == pytest.approx(43.1278538, rel=1e-3)
def utci(epw_file, include_wind, include_sun, csv, output_file): """Get a data collection for UTCI from an EPW weather file. \b Args: epw_file: Path to an .epw file. """ try: epw_obj = EPW(epw_file) utci_obj = UTCI.from_epw(epw_obj, include_wind, include_sun) utci_data = utci_obj.universal_thermal_climate_index if csv: output_file.write('\n'.join([str(v) for v in utci_data.values])) else: output_file.write(json.dumps(utci_data.to_dict())) except Exception as e: _logger.exception('Failed to get UTCI from EPW file.\n{}'.format(e)) sys.exit(1) else: sys.exit(0)