Example #1
0
def test_mrt_direct_exposed():
    # TODO: test output
    mean_radiant_temperature(
        {"rlds": 150, "rlus": 350, "rsdsdiff": 400, "rsus": 100, "rsds": 700},
        cos_zenith=0.5,
        direct_exposed=0.7,
    )
Example #2
0
def test_mrt_raises():
    with pytest.raises(ValueError):
        mean_radiant_temperature({})
    with pytest.raises(ValueError):
        mean_radiant_temperature(
            {
                "rlds": 150,
                "rlus": np.array([350, 150]),
                "rsdsdiff": np.array([400, 200]),
                "rsus": np.array([100, 50]),
                "rsds": np.array([700, 400]),
            }
        )
Example #3
0
def test_mrt_array():
    EXPECTED_RESULT = np.array([313.33875095746555, 291.2519186818613])
    TEST_RESULT = mean_radiant_temperature(
        {
            "rlds": np.array([150, 50]),
            "rlus": np.array([350, 150]),
            "rsdsdiff": np.array([400, 200]),
            "rsus": np.array([100, 50]),
            "rsds": np.array([700, 400]),
        },
        cos_zenith=np.array([0.5, 0.2]),
    )
    assert np.allclose(TEST_RESULT, EXPECTED_RESULT)
Example #4
0
def test_integration_array():
    EXPECTED_RESULT = 273.15 + np.array([22.32159032, 18.02267449])
    mrt = mean_radiant_temperature(
        {
            "rlds": np.array([150, 50]),
            "rlus": np.array([350, 150]),
            "rsdsdiff": np.array([400, 200]),
            "rsus": np.array([100, 50]),
            "rsds": np.array([700, 400]),
        },
        cos_zenith=np.array([0.5, 0.2]),
        lit=np.array([1, 1]),
    )
    TEST_RESULT = universal_thermal_climate_index(
        {
            "tas": np.array([295, 296]),
            "sfcWind": np.array([6.0, 6.0]),
            "hurs": np.array([100, 100]),
        },
        mrt,
    )
    assert np.allclose(TEST_RESULT, EXPECTED_RESULT)
Example #5
0
# calculate 3hr-mean solar zenith
mean_cosz = np.ones((ntime, nlat, nlon)) * np.nan
lit = np.ones((ntime, nlat, nlon)) * np.nan
for i in range(ntime):
    mean_cosz[i, ...], lit[i, ...] = cos_mean_solar_zenith_angle(mjd[i], 3, lat, lon)

# calculate mean radiant temperature
mrt = mean_radiant_temperature(
    {
        "rlds": rlds_cube.data,
        "rlus": rlus_cube.data,
        "rsdsdiff": rsdsdiff_cube.data,
        "rsus": rsus_cube.data,
        "rsds": rsds_cube.data,
    },
    angle_factor_down=0.5,
    angle_factor_up=0.5,
    absorption=0.7,
    emissivity=0.97,
    cos_zenith=mean_cosz,
    lit=lit
)

# regrid wind to temperature grid
# don't think area-weighting makes sense, use bi-linear
uas_cube_regrid = uas_cube.regrid(tas_cube, iris.analysis.Linear())
vas_cube_regrid = vas_cube.regrid(tas_cube, iris.analysis.Linear())
wind = np.sqrt(uas_cube_regrid.data**2 + vas_cube_regrid.data**2)

# calculate UTCI