Esempio n. 1
0
def test_pr_units_input_error(path_uas_cmcccm):
    with pytest.raises(TypeError):
        NCdata.pr_rate_from_flux(path_uas_cmcccm)
Esempio n. 2
0
def test_pr_unit_conversion(path_pr_access10, direct_pr_access10):
    with nc.Dataset(path_pr_access10) as dataset_reader:
        pr = NCdata.pr_rate_from_flux(dataset_reader)
    assert pr.var_units == 'mm hr-1'
    assert_almost_equal(pr.variable, np.asarray(direct_pr_access10.variables['pr'])*86400, decimal=2)
Esempio n. 3
0
def precip_rate_ncdata_cnrmcm5(path_pr_cnrmcm5):
    with nc.Dataset(path_pr_cnrmcm5, 'r') as pflux_src:
        return NCdata.pr_rate_from_flux(pflux_src)
Esempio n. 4
0
def precip_rate_ncdata_access13(path_pr_access13):
    with nc.Dataset(path_pr_access13, 'r') as pflux_src:
        return NCdata.pr_rate_from_flux(pflux_src)
Esempio n. 5
0
# ESTABLISHING DATA LOCATION
# folder = r"C:\repos\wnpmonsoon\tests\data"
folder = r"/home/rwegener/repos/wnpmonsoon/tests/data/"
# precip_test_file = folder + r"\ACCESS1-0\pr_day_ACCESS1-0_rcp85_r1i1p1_1year_spatial_clip.nc"
precip_test_file_lin = os.path.join(
    folder, r"ACCESS1-3/pr_day_ACCESS1-3_rcp85_r1i1p1_1year_spatial_clip.nc")
uas_test_file_lin = os.path.join(
    folder, r"ACCESS1-3/uas_day_ACCESS1-3_rcp85_r1i1p1_1year_spatial_clip.nc")
vas_test_file_lin = os.path.join(
    folder, r"ACCESS1-3/vas_day_ACCESS1-3_rcp85_r1i1p1_1year_spatial_clip.nc")

# Generate precipitation rate
with nc.Dataset(precip_test_file_lin, 'r') as p_flux_reader:
    print(p_flux_reader.__class__)
    p_rate = NCdata.pr_rate_from_flux(p_flux_reader)
p_rate_path = os.path.join(folder, r"created/pr_from_flux_ACCESS1-3.nc")
# p_rate.write(p_rate_path)

# Generate wind direction
with nc.Dataset(uas_test_file_lin, 'r') as uas_reader, \
     nc.Dataset(vas_test_file_lin, 'r') as vas_reader:
    wdir = NCdata.wind_dir_from_components(uas_reader, vas_reader)
wdir_path = os.path.join(folder, r"created/wdir_ACCESS1-3.nc")
# wdir.write(wdir_path)

# Compute monsoon
criteria = criteria_generator(pr_min=5, wd_min=180, wd_max=270)

with nc.Dataset(p_rate_path, 'r') as pr_reader, \
     nc.Dataset(wdir_path, 'r') as wd_reader: