Esempio n. 1
0
def test_array():
    nc_file = 'test/Atmd2008051603.nc4'
    try:
        assert os.path.exists(nc_file)
    except:
        raise("Test data not loaded, too big for github: {}".format(nc_file))
    gm.Ambient(nc_file)
    assert True
Esempio n. 2
0
def test_time_series():
    _data_collection = {
        'ambient': gm.Ambient('./test/Atmd2008012101.nc4', load_on_init=True),
        'shortwave': gm.ShortWave( './test/SW2008012101.nc4', load_on_init=True),
        'wind': gm.Wind('./test/Wind2008012101.nc4', load_on_init=True),
        'precipitation': gm.Precipitation('./test/Rain2008012101.nc4', load_on_init=True)
    }
    merge1 = gm.Merge(_data_collection)
    _data_collection = {
        'ambient': gm.Ambient('./test/Atmd2008012102.nc4', load_on_init=True),
        'shortwave': gm.ShortWave( './test/SW2008012102.nc4', load_on_init=True),
        'wind': gm.Wind('./test/Wind2008012102.nc4', load_on_init=True),
        'precipitation': gm.Precipitation('./test/Rain2008012102.nc4', load_on_init=True)
    }
    merge2 = gm.Merge(_data_collection)
    time_series = gm.TimeSeries([merge1, merge2])
    time_series.write_daily('./test/ts_summary.nc4')
    pass
Esempio n. 3
0
def test_dataset_subset():
    nc_file = 'test/Atmd2008051603.nc4'
    try:
        assert os.path.exists(nc_file)
    except:
        raise("Test data not loaded, too big for github: {}".format(nc_file))
    array = gm.Ambient(nc_file)

    gmuds_grid_trishuli = gm.GmudGridTrishuli()
    x0, x1, y0, y1 = gmuds_grid_trishuli.bounds
    subset = array.subset(x0, x1, y0, y1, coords_grid=gmuds_grid_trishuli)
    assert True
Esempio n. 4
0
def test_write_geotiff():
    nc_file = 'test/Atmd2008051603.nc4'
    d_var = 'Tad'
    try:
        assert os.path.exists(nc_file)
    except:
        raise("Test data not loaded, too big for github: {}".format(nc_file))
    array = gm.Ambient(nc_file)

    utm_grid_trishuli = gm.GmudGridTrishuli()
    x0, x1, y0, y1 = array.get_max_bounds(utm_grid_trishuli)
    subset = array.subset(x0, x1, y0, y1)
    #subset_ = array.subset_bygrid(utm_grid_trishuli)
    #assert (subset_['Tad'].values == subset['Tad'].values).all()
    data_array = subset[d_var][:,:,0]
    array.write_geotiff(data_array, 'test/test_{}.tif'.format(d_var))

    assert True
Esempio n. 5
0
def test_merge():
    nc_file = './test/SW2008012101.nc4'
    sw = gm.ShortWave(nc_file, load_on_init=True)
    nc_file = './test/Wind2008012101.nc4'
    wn = gm.Wind(nc_file, load_on_init=True)
    nc_file = './test/Atmd2008012101.nc4'
    am = gm.Ambient(nc_file, load_on_init=True)
    nc_file = './test/Rain2008012101.nc4'
    pcp = gm.Precipitation(nc_file, load_on_init=True)


    _data_collection = {
        'ambient': am,
        'shortwave': sw,
        'wind': wn,
        'precipitation': pcp
    }

    full = gm.Merge(_data_collection)