def test_horizontal_solarcal_collection_defaults(): """Test the default inputs assigned to the HorizontalSolarCal 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 = HorizontalSolarCal(Location(), dir_norm, diff_horiz, 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.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
def test_solarcal_parameter_incorrect(): """Test incorrect SolarCalParameter properties.""" with pytest.raises(Exception): SolarCalParameter( posture='seated', sharp=180, body_azimuth=135, # both sharp and azimuth body_absorptivity=0.8, body_emissivity=0.97) with pytest.raises(Exception): SolarCalParameter(posture='disco pose') # incorrect posture with pytest.raises(Exception): SolarCalParameter(sharp=270) # incorrect sharp with pytest.raises(Exception): SolarCalParameter(body_absorptivity=60) # incorrect body_absorptivity with pytest.raises(Exception): SolarCalParameter(body_emissivity=97) # incorrect body_emissivity
def test_solarcal_parameter_to_from_str(): """Test the to/from string methods of the SolarCalParameter object.""" posture = 'seated' sharp = 180 absorptivity = 0.8 emissivity = 0.97 solarcal_par = SolarCalParameter(posture=posture, sharp=sharp, body_absorptivity=absorptivity, body_emissivity=emissivity) new_solarcal_par = SolarCalParameter.from_string(str(solarcal_par)) assert new_solarcal_par.posture == posture assert new_solarcal_par.sharp == sharp assert new_solarcal_par.body_azimuth is None assert new_solarcal_par.body_absorptivity == absorptivity assert new_solarcal_par.body_emissivity == emissivity
def _load_solarcal_par_str(solarcal_par_str): """Load a SolarCalParameter from a string. Args: solarcal_par_str: A string of a SolarCalParameter to be loaded. """ if solarcal_par_str is not None and solarcal_par_str != '' \ and solarcal_par_str != 'None': return SolarCalParameter.from_string(solarcal_par_str)
def test_solarcal_parameter_default(): """Test the default SolarCalParameter properties.""" solarcal_par = SolarCalParameter() str(solarcal_par) # test casting the parameters to a string assert solarcal_par.posture == 'standing' assert solarcal_par.sharp == 135 assert solarcal_par.body_azimuth is None assert solarcal_par.body_absorptivity == 0.7 assert solarcal_par.body_emissivity == 0.95 solarcal_par.POSTURES # test that the acceptable postures are there
def test_solarcal_parameter_init(): """Test the initialization of the SolarCalParameter object.""" posture = 'seated' sharp = 180 absorptivity = 0.8 emissivity = 0.97 solarcal_par = SolarCalParameter(posture=posture, sharp=sharp, body_absorptivity=absorptivity, body_emissivity=emissivity) assert solarcal_par.posture == posture assert solarcal_par.sharp == sharp assert solarcal_par.body_azimuth is None assert solarcal_par.body_absorptivity == absorptivity assert solarcal_par.body_emissivity == emissivity
def test_horizontal_solarcal_collection_full_input(): """Test the initialization of the HorizontalSolarCal 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 = HorizontalSolarCal(Location(), dir_norm, diff_horiz, 24, 0.6, 0.35, custom_par) assert solarcal_obj.fraction_body_exposed[12] == 0.6 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
degrees the human is facing from the sun. _absorptivity_: A number between 0 and 1 representing the average shortwave absorptivity of the body (including clothing and skin color). Typical clothing values - white: 0.2, khaki: 0.57, black: 0.88 Typical skin values - white: 0.57, brown: 0.65, black: 0.84 Default is 0.7 for average (brown) skin and medium clothing. _emissivity_: A number between 0 and 1 representing the average longwave emissivity of the body. Default is 0.95, which is almost always the case except in rare situations of wearing metalic clothing. Returns: sol_body_par: A solar body parameter object that can be plugged into any of the components that estimate mean radiant temperature (MRT) deltas as a result of being in the sun. """ ghenv.Component.Name = 'LB Solar Body Parameters' ghenv.Component.NickName = 'SolarBodyPar' ghenv.Component.Message = '1.2.0' ghenv.Component.Category = 'Ladybug' ghenv.Component.SubCategory = '4 :: Extra' ghenv.Component.AdditionalHelpFromDocStrings = '4' try: from ladybug_comfort.parameter.solarcal import SolarCalParameter except ImportError as e: raise ImportError('\nFailed to import ladybug_comfort:\n\t{}'.format(e)) sol_body_par = SolarCalParameter(_posture_, _sharp_, _body_az_, _absorptivity_, _emissivity_)