Ejemplo n.º 1
0
def test_outdoor_solarcal_collection_defaults():
    """Test the default inputs assigned to the OutdoorSolarCal collection."""
    calc_length = 24
    irr_header = Header(Irradiance(), 'W/m2',
                        AnalysisPeriod(end_month=1, end_day=1))
    dir_norm = HourlyContinuousCollection(irr_header, [500] * calc_length)
    diff_horiz = HourlyContinuousCollection(irr_header, [200] * calc_length)
    solarcal_obj = OutdoorSolarCal(Location(), dir_norm, diff_horiz, 350, 24)

    assert isinstance(solarcal_obj.fraction_body_exposed,
                      HourlyContinuousCollection)
    assert len(solarcal_obj.fraction_body_exposed.values) == calc_length
    assert solarcal_obj.fraction_body_exposed[12] == 1

    assert isinstance(solarcal_obj.sky_exposure, HourlyContinuousCollection)
    assert len(solarcal_obj.sky_exposure.values) == calc_length
    assert solarcal_obj.sky_exposure[12] == 1

    assert isinstance(solarcal_obj.floor_reflectance,
                      HourlyContinuousCollection)
    assert len(solarcal_obj.floor_reflectance.values) == calc_length
    assert solarcal_obj.floor_reflectance[12] == 0.25

    assert isinstance(solarcal_obj.solarcal_body_parameter, SolarCalParameter)
    default_par = SolarCalParameter()
    assert solarcal_obj.solarcal_body_parameter.posture == default_par.posture
    assert solarcal_obj.solarcal_body_parameter.sharp == default_par.sharp
    assert solarcal_obj.solarcal_body_parameter.body_azimuth == default_par.body_azimuth
    assert solarcal_obj.solarcal_body_parameter.body_absorptivity == default_par.body_absorptivity
    assert solarcal_obj.solarcal_body_parameter.body_emissivity == default_par.body_emissivity
Ejemplo n.º 2
0
def test_init_outdoor_solarcal_collection():
    """Test the initialization of the OutdoorSolarCal collection."""
    calc_length = 24
    irr_header = Header(Irradiance(), 'W/m2',
                        AnalysisPeriod(end_month=1, end_day=1))
    dir_norm = HourlyContinuousCollection(irr_header, [500] * calc_length)
    diff_horiz = HourlyContinuousCollection(irr_header, [200] * calc_length)
    solarcal_obj = OutdoorSolarCal(Location(), dir_norm, diff_horiz, 350, 24)

    assert solarcal_obj.comfort_model == 'Outdoor SolarCal'
    assert solarcal_obj.calc_length == calc_length
    str(solarcal_obj)  # test that the string representaiton is ok

    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] == 500
    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] == 200

    assert isinstance(solarcal_obj.shortwave_effective_radiant_field,
                      HourlyContinuousCollection)
    assert len(
        solarcal_obj.shortwave_effective_radiant_field.values) == calc_length
    assert solarcal_obj.shortwave_effective_radiant_field[12] == pytest.approx(
        137.30710, rel=1e-3)
    assert isinstance(solarcal_obj.longwave_effective_radiant_field,
                      HourlyContinuousCollection)
    assert len(
        solarcal_obj.longwave_effective_radiant_field.values) == calc_length
    assert solarcal_obj.longwave_effective_radiant_field[12] == pytest.approx(
        -28.8326, rel=1e-3)
    assert isinstance(solarcal_obj.shortwave_mrt_delta,
                      HourlyContinuousCollection)
    assert len(solarcal_obj.shortwave_mrt_delta.values) == calc_length
    assert solarcal_obj.shortwave_mrt_delta[12] == pytest.approx(31.50184,
                                                                 rel=1e-3)
    assert isinstance(solarcal_obj.longwave_mrt_delta,
                      HourlyContinuousCollection)
    assert len(solarcal_obj.longwave_mrt_delta.values) == calc_length
    assert solarcal_obj.longwave_mrt_delta[12] == pytest.approx(-6.614966,
                                                                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(24.886886, 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(48.88688,
                                                                      rel=1e-3)
Ejemplo n.º 3
0
def test_init_outdoor_solarcal_collection_epw():
    """Test the initialization of the OutdoorSolarCal collection with EPW input."""
    calc_length = 8760
    relative_path = './tests/epw/chicago.epw'
    epw = EPW(relative_path)
    solarcal_obj = OutdoorSolarCal(epw.location, epw.direct_normal_radiation,
                                   epw.diffuse_horizontal_radiation,
                                   epw.horizontal_infrared_radiation_intensity,
                                   epw.dry_bulb_temperature)

    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.shortwave_effective_radiant_field,
                      HourlyContinuousCollection)
    assert len(
        solarcal_obj.shortwave_effective_radiant_field.values) == calc_length
    assert solarcal_obj.shortwave_effective_radiant_field[12] == pytest.approx(
        83.29130, rel=1e-3)
    assert isinstance(solarcal_obj.longwave_effective_radiant_field,
                      HourlyContinuousCollection)
    assert len(
        solarcal_obj.longwave_effective_radiant_field.values) == calc_length
    assert solarcal_obj.longwave_effective_radiant_field[12] == pytest.approx(
        -27.39307, rel=1e-3)
    assert isinstance(solarcal_obj.shortwave_mrt_delta,
                      HourlyContinuousCollection)
    assert len(solarcal_obj.shortwave_mrt_delta.values) == calc_length
    assert solarcal_obj.shortwave_mrt_delta[12] == pytest.approx(19.109207,
                                                                 rel=1e-3)
    assert isinstance(solarcal_obj.longwave_mrt_delta,
                      HourlyContinuousCollection)
    assert len(solarcal_obj.longwave_mrt_delta.values) == calc_length
    assert solarcal_obj.longwave_mrt_delta[12] == pytest.approx(-6.284688,
                                                                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(12.8245189, 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(9.524518,
                                                                      rel=1e-3)
Ejemplo n.º 4
0
def test_outdoor_solarcal_collection_full_input():
    """Test the initialization of the OutdoorSolarCal collection will all inputs."""
    calc_length = 24
    irr_header = Header(Irradiance(), 'W/m2',
                        AnalysisPeriod(end_month=1, end_day=1))
    dir_norm = HourlyContinuousCollection(irr_header, [500] * calc_length)
    diff_horiz = HourlyContinuousCollection(irr_header, [200] * calc_length)
    custom_par = SolarCalParameter('seated', None, 45, 0.65, 0.97)
    solarcal_obj = OutdoorSolarCal(Location(), dir_norm, diff_horiz, 350, 24,
                                   0.6, 0.4, 0.35, custom_par)

    assert solarcal_obj.fraction_body_exposed[12] == 0.6
    assert solarcal_obj.sky_exposure[12] == 0.4
    assert solarcal_obj.floor_reflectance[0] == 0.35
    assert solarcal_obj.solarcal_body_parameter.posture == 'seated'
    assert solarcal_obj.solarcal_body_parameter.sharp is None
    assert solarcal_obj.solarcal_body_parameter.body_azimuth == 45
    assert solarcal_obj.solarcal_body_parameter.body_absorptivity == 0.65
    assert solarcal_obj.solarcal_body_parameter.body_emissivity == 0.97
            longwave radiant exchange with the sky.
"""

ghenv.Component.Name = 'LB Outdoor Solar MRT'
ghenv.Component.NickName = 'OutdoorSolarMRT'
ghenv.Component.Message = '0.1.1'
ghenv.Component.Category = 'Ladybug'
ghenv.Component.SubCategory = '1 :: Analyze Data'
ghenv.Component.AdditionalHelpFromDocStrings = '5'

try:
    from ladybug_comfort.collection.solarcal import OutdoorSolarCal
except ImportError as e:
    raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e))

try:
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


if all_required_inputs(ghenv.Component) and _run is True:
    solar_mrt_obj = OutdoorSolarCal(_location, _dir_norm_rad, _diff_horiz_rad,
                                    _horiz_infrared, _surface_temp, fract_body_exp_,
                                    sky_exposure_, _ground_ref_, _solar_body_par_)
    
    short_erf = solar_mrt_obj.shortwave_effective_radiant_field
    long_erf = solar_mrt_obj.longwave_effective_radiant_field
    short_dmrt = solar_mrt_obj.shortwave_mrt_delta
    long_dmrt = solar_mrt_obj.longwave_mrt_delta
    mrt = solar_mrt_obj.mean_radiant_temperature