Exemple #1
0
def test_netcdf_multi_indexed_values():
    nc = mv.read(file_in_testdir('xs_date_mv5.nc'))
    mv.setcurrent(nc, 't')
    assert (mv.attributes(nc)['long_name'] == "Temperature")
    assert (np.isclose(mv.values(nc, [0, 0, 0]), 234.7144))
    assert (np.isclose(mv.values(nc, [0, 0, 4]), 237.4377))
    assert (np.isclose(mv.values(nc, [0, 1, 0]), 248.7220))
    assert (np.isclose(mv.values(nc, [0, 1, 1]), 249.3030))
Exemple #2
0
def test_netcdf_multi_indexed_values_with_all():
    nc = mv.read(file_in_testdir('xs_date_mv5.nc'))
    mv.setcurrent(nc, 't')
    assert (mv.attributes(nc)['long_name'] == "Temperature")
    v = mv.values(nc, [0, 0, 'all'])
    assert (len(v) == 64)
    assert (np.isclose(v[0], 234.714))
    assert (np.isclose(v[63], 258.979))
    v = mv.values(nc, [0, 'all', 0])
    assert (len(v) == 5)
    assert (np.isclose(v[0], 234.714))
    assert (np.isclose(v[4], 260.484))
Exemple #3
0
def test_cross_section_data():
    grib = mv.read(os.path.join(PATH, 't_for_xs.grib'))
    xs_data = mv.mcross_sect(
        line=[59.9, -180, -13.5, 158.08],
        data=grib,
    )
    # the result of this should be a netCDF variable
    assert mv.type(xs_data) == 'netcdf'
    mv.setcurrent(xs_data, 't')
    assert mv.dimension_names(xs_data) == ['time', 'nlev', 'lon']
    assert np.isclose(mv.value(xs_data, 0), 230.39156)
    xs_data_x2 = xs_data * 2
    assert np.isclose(mv.value(xs_data_x2, 0), 460.7831)
Exemple #4
0
def test_netcdf_var_indexing():
    nc = mv.read(file_in_testdir('xs_date_mv5.nc'))
    mv.setcurrent(nc, 0)
    assert (mv.attributes(nc)['long_name'] == "time")
    mv.setcurrent(nc, 1)
    assert (mv.attributes(nc)['long_name'] == "latitude")
    mv.setcurrent(nc, 4)
    assert (mv.attributes(nc)['long_name'] == "Temperature")
Exemple #5
0
def test_netcdf_single_value():
    nc = mv.read(file_in_testdir('xs_date_mv5.nc'))
    mv.setcurrent(nc, 't')
    assert (mv.attributes(nc)['long_name'] == "Temperature")
    assert (np.isclose(mv.value(nc, 0), 234.7144))
    assert (np.isclose(mv.value(nc, 4), 237.4377))