def test_get_universal_thermal_climate_index():
    """Test the get_universal_thermal_climate_index method."""
    calc_length = 8760
    relative_path = './tests/epw/chicago.epw'
    epw = EPW(relative_path)
    utci_obj = epw.get_universal_thermal_climate_index(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 test_get_standard_effective_temperature():
    """Test the get_standard_effective_temperature method."""
    calc_length = 8760
    relative_path = './tests/epw/chicago.epw'
    epw = EPW(relative_path)
    set_obj = epw.get_standard_effective_temperature(False, False,
                                                     met_rate=2.4, clo_value=1.0)

    assert isinstance(set_obj, PMV)
    assert isinstance(set_obj.air_temperature, HourlyContinuousCollection)
    assert len(set_obj.air_temperature.values) == calc_length
    assert set_obj.air_temperature[0] == -6.1
    assert isinstance(set_obj.rel_humidity, HourlyContinuousCollection)
    assert len(set_obj.rel_humidity.values) == calc_length
    assert set_obj.rel_humidity[0] == 81

    assert isinstance(set_obj.standard_effective_temperature, HourlyContinuousCollection)
    assert len(set_obj.standard_effective_temperature.values) == calc_length
    assert set_obj.standard_effective_temperature[0] == pytest.approx(12.76, rel=1e-2)
    assert isinstance(set_obj.thermal_condition, HourlyContinuousCollection)
    assert len(set_obj.thermal_condition.values) == calc_length
    assert set_obj.thermal_condition[0] == -1

    assert set_obj.percent_neutral == pytest.approx(18.961187, rel=1e-3)
    assert set_obj.percent_hot == pytest.approx(38.6415525, rel=1e-3)
    assert set_obj.percent_cold == pytest.approx(42.39726, rel=1e-3)
Esempio n. 3
0
    def test_json_methods(self):
        """Test JSON serialization methods"""
        relative_path = './tests/epw/chicago.epw'
        epw = EPW(relative_path)

        epw_json = epw.to_json()
        rebuilt_epw = EPW.from_json(epw_json)
        assert epw_json == rebuilt_epw.to_json()
Esempio n. 4
0
def test_dict_methods():
    """Test JSON serialization methods"""
    relative_path = './tests/assets/epw/chicago.epw'
    epw = EPW(relative_path)

    epw_dict = epw.to_dict()
    rebuilt_epw = EPW.from_dict(epw_dict)
    assert epw_dict == rebuilt_epw.to_dict()
Esempio n. 5
0
 def ddy_from_epw(epw_file, sim_par):
     """Produce a DDY from an EPW file."""
     epw_obj = EPW(epw_file)
     des_days = [
         epw_obj.approximate_design_day('WinterDesignDay'),
         epw_obj.approximate_design_day('SummerDesignDay')
     ]
     sim_par.sizing_parameter.design_days = des_days
def test_get_universal_thermal_climate_index_with_sun_and_wind():
    """Test the get_universal_thermal_climate_index method with wind and sun."""
    relative_path = './tests/epw/chicago.epw'
    epw = EPW(relative_path)
    utci_obj = epw.get_universal_thermal_climate_index(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_sun():
    """Test the get_universal_thermal_climate_index method with sun."""
    relative_path = './tests/epw/chicago.epw'
    epw = EPW(relative_path)
    utci_obj = epw.get_universal_thermal_climate_index(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_with_wind():
    """Test the get_universal_thermal_climate_index method with wind."""
    relative_path = './tests/epw/chicago.epw'
    epw = EPW(relative_path)
    utci_obj = epw.get_universal_thermal_climate_index(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)
Esempio n. 9
0
def test_file_string_methods():
    """Test serialization to/from EPW file strings"""
    relative_path = './tests/assets/epw/chicago.epw'
    epw = EPW(relative_path)

    epw_contents = epw.to_file_string()
    rebuilt_epw = EPW.from_file_string(epw_contents)
    assert epw.location == rebuilt_epw.location
    assert epw.dry_bulb_temperature == rebuilt_epw.dry_bulb_temperature
Esempio n. 10
0
    def test_ladybug_epw(self):
        CURR_DIRECTORY = os.path.abspath(os.path.dirname(__file__))
        test_file_path = os.path.join(CURR_DIRECTORY, "room//epws//USA_AK_Anchorage.Intl.AP.702730_TMY3.epw")
        test_epw = EPW(test_file_path)
        test_epw.import_data()

        assert test_epw.location.city == "Anchorage Intl Ap"
        assert test_epw.location.country == "USA"
        assert test_epw.location.latitude == 61.18
Esempio n. 11
0
def test_get_standard_effective_temperature_with_wind():
    """Test the get_standard_effective_temperature method with wind."""
    relative_path = './tests/epw/chicago.epw'
    epw = EPW(relative_path)
    set_obj = epw.get_standard_effective_temperature(True, False,
                                                     met_rate=2.4, clo_value=1.0)

    assert set_obj.percent_neutral == pytest.approx(19.82, rel=1e-2)
    assert set_obj.percent_hot == pytest.approx(15.56, rel=1e-2)
    assert set_obj.percent_cold == pytest.approx(64.61, rel=1e-2)
Esempio n. 12
0
def test_get_standard_effective_temperature_with_sun():
    """Test the get_standard_effective_temperature method with sun."""
    relative_path = './tests/epw/chicago.epw'
    epw = EPW(relative_path)
    set_obj = epw.get_standard_effective_temperature(False, True,
                                                     met_rate=2.4, clo_value=1.0)

    assert set_obj.percent_neutral == pytest.approx(17.043378, rel=1e-3)
    assert set_obj.percent_hot == pytest.approx(44.56621, rel=1e-3)
    assert set_obj.percent_cold == pytest.approx(38.39041, rel=1e-3)
Esempio n. 13
0
def test_write_epw():
    """Test save epw_rel."""
    path = './tests/assets/epw/tokyo.epw'
    epw = EPW(path)

    modified_path = './tests/assets/epw/tokyo_modified.epw'
    epw.write(modified_path)
    assert os.path.isfile(modified_path)
    assert os.stat(modified_path).st_size > 1
    os.remove(modified_path)
Esempio n. 14
0
def test_invalid_epw():
    """Test the import of incorrect file type and a non-existent epw file."""
    path = './tests/assets/epw/non-existent.epw'
    with pytest.raises(Exception):
        epw = EPW(path)
        epw.location

    path = './tests/assets/stat/chicago.stat'
    with pytest.raises(Exception):
        epw = EPW(path)
        epw.location
Esempio n. 15
0
    def test_ladybug_epw(self):
        CURR_DIRECTORY = os.path.abspath(os.path.dirname(__file__))
        test_file_path = os.path.join(
            CURR_DIRECTORY,
            "room//epws//USA_AK_Anchorage.Intl.AP.702730_TMY3.epw")
        test_epw = EPW(test_file_path)
        test_epw.import_data()

        assert test_epw.location.city == "Anchorage Intl Ap"
        assert test_epw.location.country == "USA"
        assert test_epw.location.latitude == 61.18
Esempio n. 16
0
def test_set_data():
    """Test the ability to set the data of any of the epw hourly data."""
    relative_path = './tests/assets/epw/chicago.epw'
    epw = EPW(relative_path)
    epw.dry_bulb_temperature[12] = 20
    assert epw.dry_bulb_temperature[12] == 20
    epw.dry_bulb_temperature.values = list(range(8760))
    assert epw.dry_bulb_temperature.values == tuple(range(8760))

    # Test if the set data is not annual
    with pytest.raises(Exception):
        epw.dry_bulb_temperature = list(range(365))
Esempio n. 17
0
def test_set_ground_temperatures():
    """Test the functions that set ground temperature."""
    relative_path = './tests/assets/epw/chicago.epw'
    epw = EPW(relative_path)
    grnd_dict = dict(epw.monthly_ground_temperature)
    grnd_dict[0.5].values = list(range(12))
    epw.monthly_ground_temperature = grnd_dict
    assert epw.monthly_ground_temperature[0.5].values == tuple(range(12))

    # test when the type is not a monthly collection.
    grnd_dict = dict(epw.monthly_ground_temperature)
    grnd_dict[0.5] = list(range(12))
    with pytest.raises(Exception):
        epw.monthly_ground_temperature = grnd_dict
Esempio n. 18
0
def test_zhang_huang_accuracy():
    """Test zhang huang solar model to ensure that average error is within
    25% of actual solar."""
    path = './tests/assets/epw/chicago.epw'
    epw = EPW(path)

    wea = Wea.from_zhang_huang_solar(
        epw.location, epw.total_sky_cover, epw.relative_humidity,
        epw.dry_bulb_temperature, epw.wind_speed, epw.atmospheric_station_pressure)

    # test global horizontal radiation
    glob_horiz_error = [abs(i - j) for i, j in zip(
        epw.global_horizontal_radiation,
        wea.global_horizontal_irradiance)]
    avg_glob_horiz_error = sum(glob_horiz_error) / sum(
        epw.global_horizontal_radiation)
    assert (sum(glob_horiz_error) / 8760) < 50
    assert avg_glob_horiz_error < 0.5

    # test direct normal radiation
    dir_normal_error = [abs(i - j) for i, j in zip(
        epw.direct_normal_radiation, wea.direct_normal_irradiance)]
    avg_dir_normal_error = sum(dir_normal_error) / sum(
        epw.direct_normal_radiation)
    assert sum(dir_normal_error) / 8760 < 100
    assert avg_dir_normal_error < 0.5

    # test diffuse horizontal radiation
    dif_horiz_error = [abs(i - j) for i, j in zip(
        epw.diffuse_horizontal_radiation,
        wea.diffuse_horizontal_irradiance)]
    avg_dif_horiz_error = sum(dif_horiz_error) / sum(
        epw.diffuse_horizontal_radiation)
    assert sum(dif_horiz_error) / 8760 < 50
    assert avg_dif_horiz_error < 0.5
Esempio n. 19
0
def test_windrose_frequency_lines():
    """Test frequency Polygon2Ds"""

    epw_path = os.path.join(os.getcwd(), 'tests/fixtures/epw/tokyo.epw')
    epw = EPW(epw_path)

    w = WindRose(epw.wind_direction, epw.wind_speed, 5)

    # Without calmrose
    w.show_zeros = False
    w.show_freq = True
    _ = w.colored_mesh

    freqs = w.frequency_lines

    assert isinstance(freqs[0], Polygon2D)
    assert not freqs[0].vertices[0].is_equivalent(freqs[0].vertices[-1], 1e-10)

    # With calmrose
    w.show_zeros = True
    w.show_freq = True
    _ = w.colored_mesh

    freqs = w.frequency_lines

    assert isinstance(freqs[0], Polygon2D)
    assert not freqs[0].vertices[0].is_equivalent(freqs[0].vertices[-1], 1e-10)
Esempio n. 20
0
def test_windrose_mesh_number_of_directions():
    # Test if mesh number of directions

    epw_path = os.path.join(os.getcwd(), 'tests/fixtures/epw/tokyo.epw')
    epw = EPW(epw_path)

    # Test 16 directions
    w = WindRose(epw.wind_direction, epw.wind_speed, 16)
    w.legend_parameters.segment_count = 3
    w.show_zeros = True
    w.show_freq = True

    assert len(w.histogram_data) == 16

    # Test error if number of directions < 0
    with pytest.raises(AssertionError):
        WindRose(epw.wind_direction, epw.wind_speed, 0)

    # Test error if number of directions < 3
    w = WindRose(epw.wind_direction, epw.wind_speed, 2)
    with pytest.raises(AssertionError):
        w.colored_mesh

    w = WindRose(epw.wind_direction, epw.wind_speed, 3)
    assert isinstance(w.colored_mesh, Mesh2D)
Esempio n. 21
0
def test_frequency_intervals():
    """Test the distance of frequency_intervals"""

    # Plot windrose
    epw_path = os.path.join(os.getcwd(), 'tests/fixtures/epw/tokyo.epw')
    epw = EPW(epw_path)

    w = WindRose(epw.wind_direction, epw.wind_speed, 3)
    w.show_zeros = False
    w.show_freq = False
    w.frequency_hours = 200.0

    test_freq_int = int(math.ceil(w.real_freq_max / 200.0))
    assert w.frequency_intervals_compass == pytest.approx(test_freq_int, abs=1e-10)
    assert w.frequency_intervals_mesh == pytest.approx(test_freq_int, abs=1e-10)

    # Test changing interals from 18
    # Reduce
    w.frequency_intervals_compass = 10.0
    test_freq_int = 10.0
    assert w.frequency_maximum == pytest.approx(10 * 200.0, abs=1e-10)
    assert w.frequency_intervals_compass == pytest.approx(test_freq_int, abs=1e-10)
    assert w.frequency_intervals_mesh == pytest.approx(test_freq_int, abs=1e-10)

    # Check that resetting frequency_max works
    w._frequency_intervals_compass = None
    # w.real_freq_max: 4406
    chk_max = int(math.ceil(4406 / 200)) * 200

    assert w.frequency_maximum == pytest.approx(chk_max, abs=1e-10)
    assert w.frequency_intervals_compass == pytest.approx(23, abs=1e-10)
    assert w.frequency_intervals_mesh == pytest.approx(23, abs=1e-10)
Esempio n. 22
0
def test_windrose_mesh():
    # Plot windrose
    epw_path = os.path.join(os.getcwd(), 'tests/fixtures/epw/tokyo.epw')
    epw = EPW(epw_path)

    w = WindRose(epw.wind_direction, epw.wind_speed, 16)
    w.legend_parameters.segment_count = 3

    # Test the plot grid
    assert isinstance(w.frequency_lines[0], Polygon2D)
    assert isinstance(w.orientation_lines[0], LineSegment2D)

    # Test False, False
    w.show_zeros = False
    w.show_freq = False
    assert isinstance(w.colored_mesh, Mesh2D)

    # Test True, False
    w.show_zeros = True
    w.show_freq = False
    assert isinstance(w.colored_mesh, Mesh2D)

    # Test False, True
    w.show_zeros = False
    w.show_freq = True
    assert isinstance(w.colored_mesh, Mesh2D)

    # Test True, True
    w.show_zeros = True
    w.show_freq = True
    assert isinstance(w.colored_mesh, Mesh2D)
Esempio n. 23
0
def test_init_prevailing_temperature_hourly():
    """Test the PrevailingTemperature object with hourly inputs."""
    relative_path = './tests/epw/chicago.epw'
    epw = EPW(relative_path)

    prevail_obj = PrevailingTemperature(epw.dry_bulb_temperature, True)
    assert isinstance(prevail_obj.hourly_prevailing_temperature,
                      HourlyContinuousCollection)
    assert len(prevail_obj.hourly_prevailing_temperature.values) == 8760
    assert isinstance(prevail_obj.daily_prevailing_temperature,
                      DailyCollection)
    assert len(prevail_obj.daily_prevailing_temperature.values) == 365
    assert isinstance(prevail_obj.monthly_prevailing_temperature,
                      MonthlyCollection)
    assert len(prevail_obj.monthly_prevailing_temperature.values) == 12
    assert isinstance(prevail_obj.monthly_per_hour_prevailing_temperature,
                      MonthlyPerHourCollection)
    assert len(
        prevail_obj.monthly_per_hour_prevailing_temperature.values) == 288

    prevail_obj = PrevailingTemperature(epw.dry_bulb_temperature, False)
    assert isinstance(prevail_obj.hourly_prevailing_temperature,
                      HourlyContinuousCollection)
    assert len(prevail_obj.hourly_prevailing_temperature.values) == 8760
    assert isinstance(prevail_obj.daily_prevailing_temperature,
                      DailyCollection)
    assert len(prevail_obj.daily_prevailing_temperature.values) == 365
    assert isinstance(prevail_obj.monthly_prevailing_temperature,
                      MonthlyCollection)
    assert len(prevail_obj.monthly_prevailing_temperature.values) == 12
    assert isinstance(prevail_obj.monthly_per_hour_prevailing_temperature,
                      MonthlyPerHourCollection)
    assert len(
        prevail_obj.monthly_per_hour_prevailing_temperature.values) == 288
Esempio n. 24
0
def test_init_indoor_solarcal_collection_epw():
    """Test the initialization of the IndoorSolarCal collection with EPW input."""
    calc_length = 8760
    relative_path = './tests/epw/chicago.epw'
    epw = EPW(relative_path)
    solarcal_obj = IndoorSolarCal(epw.location, epw.direct_normal_radiation,
                                  epw.diffuse_horizontal_radiation, 24)

    assert isinstance(solarcal_obj.direct_normal_solar,
                      HourlyContinuousCollection)
    assert len(solarcal_obj.direct_normal_solar.values) == calc_length
    assert solarcal_obj.direct_normal_solar[12] == pytest.approx(151, rel=1e-3)
    assert isinstance(solarcal_obj.diffuse_horizontal_solar,
                      HourlyContinuousCollection)
    assert len(solarcal_obj.diffuse_horizontal_solar.values) == calc_length
    assert solarcal_obj.diffuse_horizontal_solar[12] == pytest.approx(168,
                                                                      rel=1e-3)

    assert isinstance(solarcal_obj.effective_radiant_field,
                      HourlyContinuousCollection)
    assert len(solarcal_obj.effective_radiant_field.values) == calc_length
    assert solarcal_obj.effective_radiant_field[12] == pytest.approx(33.31652,
                                                                     rel=1e-3)
    assert isinstance(solarcal_obj.mrt_delta, HourlyContinuousCollection)
    assert len(solarcal_obj.mrt_delta.values) == calc_length
    assert solarcal_obj.mrt_delta[12] == pytest.approx(7.6436828, rel=1e-3)
    assert isinstance(solarcal_obj.mean_radiant_temperature,
                      HourlyContinuousCollection)
    assert len(solarcal_obj.mean_radiant_temperature.values) == calc_length
    assert solarcal_obj.mean_radiant_temperature[12] == pytest.approx(
        31.6436828, rel=1e-3)
Esempio n. 25
0
def test_from_zhang_huang():
    """Test from zhang huang solar model"""
    path = './tests/assets/epw/chicago.epw'
    epw = EPW(path)

    # test it first without pressure values
    wea_from_zh = Wea.from_zhang_huang_solar(
        epw.location, epw.total_sky_cover, epw.relative_humidity,
        epw.dry_bulb_temperature, epw.wind_speed)

    # include EPW pressure values
    wea_from_zh = Wea.from_zhang_huang_solar(
        epw.location, epw.total_sky_cover, epw.relative_humidity,
        epw.dry_bulb_temperature, epw.wind_speed, epw.atmospheric_station_pressure)

    assert wea_from_zh.location.city == 'Chicago Ohare Intl Ap'
    assert wea_from_zh.timestep == 1
    assert wea_from_zh.global_horizontal_irradiance[0] == \
        pytest.approx(0, rel=1e-1)
    assert wea_from_zh.global_horizontal_irradiance[12] == \
        pytest.approx(417.312, rel=1e-1)
    assert wea_from_zh.direct_normal_irradiance[12] == \
        pytest.approx(654.52, rel=1e-1)
    assert wea_from_zh.diffuse_horizontal_irradiance[12] == \
        pytest.approx(144.51, rel=1e-1)
Esempio n. 26
0
def test_utci_collection_comfort_percent_outputs():
    """Test the is_comfortable and percent outputs of the UTCI collection."""
    relative_path = './tests/epw/chicago.epw'
    epw = EPW(relative_path)
    utci_obj = UTCI(epw.dry_bulb_temperature,
                    epw.relative_humidity,
                    wind_speed=epw.wind_speed)

    assert utci_obj.percent_comfortable == pytest.approx(35.6849315, rel=1e-3)
    assert utci_obj.percent_uncomfortable == pytest.approx(64.31506849,
                                                           rel=1e-3)
    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)

    assert utci_obj.percent_extreme_cold_stress == pytest.approx(0.35388127,
                                                                 rel=1e-3)
    assert utci_obj.percent_very_strong_cold_stress == pytest.approx(
        4.37214611, rel=1e-3)
    assert utci_obj.percent_strong_cold_stress == pytest.approx(16.541095,
                                                                rel=1e-3)
    assert utci_obj.percent_moderate_cold_stress == pytest.approx(23.8356164,
                                                                  rel=1e-3)
    assert utci_obj.percent_slight_cold_stress == pytest.approx(15.8675799,
                                                                rel=1e-3)

    assert utci_obj.percent_slight_heat_stress == pytest.approx(1.826484,
                                                                rel=1e-3)
    assert utci_obj.percent_moderate_heat_stress == pytest.approx(1.312785,
                                                                  rel=1e-3)
    assert utci_obj.percent_strong_heat_stress == pytest.approx(0.2054794,
                                                                rel=1e-3)
    assert utci_obj.percent_very_strong_heat_stress == 0.0
    assert utci_obj.percent_extreme_heat_stress == 0.0
    def test_cls_method_hoy(self):
        """Make sure default values are set correctly."""
        location = EPW(self.epwfile).location

        hoys = range(1, 24)

        slh = SolarAccessGridBased.from_location_and_hoys(
            location, hoys, [self.test_pts], [self.test_vec])

        bat = slh.write(self.base_folder, project_name="test")

        sh = bat_to_sh(bat)

        # start to run the subprocess
        if os.name == 'nt':
            success = slh.run(bat)
        else:
            success = slh.run(sh)

        if success:
            ag = slh.results()[0]
            for sensor in ag:
                value = sum(v[0]
                            for v in sensor.combined_values_by_id(sensor.hoys))
                assert value == 10
Esempio n. 28
0
def test_epw_from_missing_values():
    """Test import custom epw with wrong types."""
    epw = EPW.from_missing_values()
    assert epw.is_header_loaded
    assert epw.is_data_loaded
    assert len(epw.dry_bulb_temperature) == 8760
    assert list(epw.dry_bulb_temperature.values) == [99.9] * 8760
Esempio n. 29
0
def test_epw_from_missing_values():
    """Test initialization of EPW from missing values."""
    epw = EPW.from_missing_values()
    assert epw.is_header_loaded
    assert epw.is_data_loaded
    assert len(epw.dry_bulb_temperature) == 8760
    assert list(epw.dry_bulb_temperature.values) == [99.9] * 8760
Esempio n. 30
0
def epw_to_daylight_hours(epw, folder, name):
    """Convert EPW to EN 17037 schedule as a CSV file.

    This command generates a valid schedule for EN 17037, also known as daylight hours.
    Rather than a typical occupancy schedule, the daylight hours is half the year with
    the largest quantity of daylight. This is generated by sorting the EPW file by
    diffuse horizontal illuminance.

    \b
    Args:
        epw: Path to epw file.
    """
    try:
        epw_data = EPW(epw)
        diffuse_horizontal_illuminance = epw_data.diffuse_horizontal_illuminance
        _illuminance, indices = diffuse_horizontal_illuminance.highest_values(
            4380)
        values = ['1' if i in indices else '0' for i in range(8760)]

        if not os.path.isdir(folder):
            os.makedirs(folder)

        # write csv
        file_path = os.path.join(folder, '%s.csv' % name)
        with open(file_path, 'w') as fp:
            fp.write('\n'.join(values))

    except Exception:
        _logger.exception('Failed to generate daylight hours schedule.')
        sys.exit(1)
    else:
        sys.exit(0)
Esempio n. 31
0
def test_import_data():
    """Test the imported data properties."""
    relative_path = './tests/fixtures/epw/chicago.epw'
    epw = EPW(relative_path)
    assert isinstance(epw.years, HourlyContinuousCollection)
    assert isinstance(epw.dry_bulb_temperature, HourlyContinuousCollection)
    assert isinstance(epw.dew_point_temperature, HourlyContinuousCollection)
    assert isinstance(epw.relative_humidity, HourlyContinuousCollection)
    assert isinstance(epw.atmospheric_station_pressure, HourlyContinuousCollection)
    assert isinstance(epw.extraterrestrial_horizontal_radiation, HourlyContinuousCollection)
    assert isinstance(epw.extraterrestrial_direct_normal_radiation, HourlyContinuousCollection)
    assert isinstance(epw.horizontal_infrared_radiation_intensity, HourlyContinuousCollection)
    assert isinstance(epw.global_horizontal_radiation, HourlyContinuousCollection)
    assert isinstance(epw.direct_normal_radiation, HourlyContinuousCollection)
    assert isinstance(epw.diffuse_horizontal_radiation, HourlyContinuousCollection)
    assert isinstance(epw.global_horizontal_illuminance, HourlyContinuousCollection)
    assert isinstance(epw.direct_normal_illuminance, HourlyContinuousCollection)
    assert isinstance(epw.diffuse_horizontal_illuminance, HourlyContinuousCollection)
    assert isinstance(epw.zenith_luminance, HourlyContinuousCollection)
    assert isinstance(epw.wind_direction, HourlyContinuousCollection)
    assert isinstance(epw.wind_speed, HourlyContinuousCollection)
    assert isinstance(epw.total_sky_cover, HourlyContinuousCollection)
    assert isinstance(epw.opaque_sky_cover, HourlyContinuousCollection)
    assert isinstance(epw.visibility, HourlyContinuousCollection)
    assert isinstance(epw.ceiling_height, HourlyContinuousCollection)
    assert isinstance(epw.present_weather_observation, HourlyContinuousCollection)
    assert isinstance(epw.present_weather_codes, HourlyContinuousCollection)
    assert isinstance(epw.precipitable_water, HourlyContinuousCollection)
    assert isinstance(epw.aerosol_optical_depth, HourlyContinuousCollection)
    assert isinstance(epw.snow_depth, HourlyContinuousCollection)
    assert isinstance(epw.days_since_last_snowfall, HourlyContinuousCollection)
    assert isinstance(epw.albedo, HourlyContinuousCollection)
    assert isinstance(epw.liquid_precipitation_depth, HourlyContinuousCollection)
    assert isinstance(epw.liquid_precipitation_quantity, HourlyContinuousCollection)
    assert isinstance(epw.sky_temperature, HourlyContinuousCollection)