Beispiel #1
0
 def _calculate_humidity_ratio(self):
     """Compute the humidity ratio at each step of the Data Collection."""
     self._humidity_ratio = [
         humid_ratio_from_db_rh(db, rh)
         for db, rh in zip(self._air_temperature, self._rel_humidity)
     ]
     self._hr_calculated = True
Beispiel #2
0
def test_humid_ratio_from_db_rh():
    """Test the accuracy of the humid_ratio_from_db_rh function."""
    assert humid_ratio_from_db_rh(30, 0) == pytest.approx(0, rel=1e-3)
    assert humid_ratio_from_db_rh(30, 50) == pytest.approx(0.013314, rel=1e-3)
    assert humid_ratio_from_db_rh(30, 100) == pytest.approx(0.02721, rel=1e-3)
    assert humid_ratio_from_db_rh(20, 0) == pytest.approx(0, rel=1e-3)
    assert humid_ratio_from_db_rh(20, 50) == pytest.approx(0.00726, rel=1e-3)
    assert humid_ratio_from_db_rh(20, 100) == pytest.approx(0.014698, rel=1e-3)
    assert humid_ratio_from_db_rh(-20, 0) == pytest.approx(0, rel=1e-3)
    assert humid_ratio_from_db_rh(-20, 50) == pytest.approx(0.0003173,
                                                            rel=1e-3)
    assert humid_ratio_from_db_rh(-20, 100) == pytest.approx(0.00063508,
                                                             rel=1e-3)
Beispiel #3
0
def test_compute_function_aligned():
    """Test the method for computing funtions with aligned collections."""
    epw_file_path = './tests/fixtures/epw/chicago.epw'
    chicago_epw = EPW(epw_file_path)
    pressure_at_chicago = 95000
    hr_inputs = [
        chicago_epw.dry_bulb_temperature, chicago_epw.relative_humidity,
        pressure_at_chicago
    ]
    humid_ratio = HourlyContinuousCollection.compute_function_aligned(
        humid_ratio_from_db_rh, hr_inputs, HumidityRatio(), 'fraction')
    assert isinstance(humid_ratio, HourlyContinuousCollection)
    assert len(humid_ratio.values) == 8760
    for i, val in enumerate(humid_ratio.values):
        assert val == humid_ratio_from_db_rh(
            chicago_epw.dry_bulb_temperature[i],
            chicago_epw.relative_humidity[i], pressure_at_chicago)

    hr_inputs = [20, 70, pressure_at_chicago]
    humid_ratio = HourlyContinuousCollection.compute_function_aligned(
        humid_ratio_from_db_rh, hr_inputs, HumidityRatio(), 'fraction')
    assert isinstance(humid_ratio, float)
    assert humid_ratio == humid_ratio_from_db_rh(20, 70, pressure_at_chicago)
Beispiel #4
0
    # Process inputs and assign defaults.
    input_list = [
        _air_temp, _mrt_, _air_speed_, _rel_humid, _met_rate_, _clothing_
    ]
    input, data_colls = extract_collections(input_list)
    pmv_par = pmv_par_ or PMVParameter()

    if data_colls == []:
        # The inputs are all individual values.
        pmv_result = predicted_mean_vote(input[0], float(input[1]), input[2],
                                         input[3], input[4], input[5], 0,
                                         pmv_par.still_air_threshold)
        pmv = pmv_result['pmv']
        ppd = pmv_result['ppd']
        set = pmv_result['set']
        hr = humid_ratio_from_db_rh(input[0], input[3])
        comfort = pmv_par.is_comfortable(pmv_result['ppd'], hr)
        condition = pmv_par.discomfort_reason(pmv_result['pmv'],
                                              pmv_result['ppd'])
        heat_loss = [
            pmv_result['heat_loss']['cond'], pmv_result['heat_loss']['sweat'],
            pmv_result['heat_loss']['res_l'], pmv_result['heat_loss']['res_s'],
            pmv_result['heat_loss']['rad'], pmv_result['heat_loss']['conv']
        ]
    else:
        # The inputs include Data Collections.
        if not isinstance(_air_temp, BaseCollection):
            _air_temp = data_colls[0].get_aligned_collection(
                float(_air_temp), Temperature(), 'C')

        comf_obj = PMV(_air_temp, _rel_humid, _mrt_, _air_speed_, _met_rate_,
 def test_humid_ratio_from_db_rh(self):
     """Test humid_ratio_from_db_rh"""
     assert psy.humid_ratio_from_db_rh(17, 50) == approx(0.005949, rel=1e-3)
     assert psy.humid_ratio_from_db_rh(30, 100) == approx(0.02696, rel=1e-3)