コード例 #1
0
def get_GSWP3_data(met_vars, year):

    file_tpl = "{d}/gridded/GSWP3/{v}/GSWP3.BC.{v}.3hrMap.{y}.nc"

    data = {}
    for v in met_vars:
        with xr.open_dataset(file_tpl.format(d=pud.get_data_dir(), v=v, y=year)) as ds:
            data[v] = ds[v].copy()
    data = xr.Dataset(data)

    return data
コード例 #2
0
def get_GLEAM3a_data(met_vars, year):
    assert met_vars == ['Qle'], 'GLEAM loading is incomplete'

    file_tpl = '{d}/gridded/GLEAM_v3a_BETA/{v}_{y}_GLEAM_v3a_BETA.nc'

    data = {}
    for v in met_vars:
        with xr.open_dataset(file_tpl.format(d=pud.get_data_dir(), v='Et', y=year), decode_times=False) as ds:
            data['Qle'] = ds['Et'].copy()
    data = xr.Dataset(data)

    return data
コード例 #3
0
def get_MPI_data(met_vars, year):
    assert met_vars == ['Qle'], 'MPI loading is incomplete'

    file_tpl = '{d}/gridded/MPI/Ensemble{v}cor_May12.{y}.nc'

    data = {}
    for v in met_vars:
        with xr.open_dataset(file_tpl.format(d=pud.get_data_dir(), v='LE', y=year), decode_times=False) as ds:
            data['Qle'] = ds['EnsembleLEcor_May12'].copy()
    data = xr.Dataset(data)

    return data
コード例 #4
0
def get_MODIS_data(met_vars, year):
    assert met_vars == ['Qle'], 'MODIS loading is incomplete'

    file_tpl = '{d}/gridded/MODIS/MOD16_{v}_GSWP3_{y}.nc'

    data = {}
    for v in met_vars:
        with xr.open_dataset(file_tpl.format(d=pud.get_data_dir(), v='ET', y=year)) as ds:
            data['Qle'] = ds['et'].copy()
    data = xr.Dataset(data)

    return data
コード例 #5
0
def get_PRINCETON_data(met_vars, year):

    file_tpl = "{d}/gridded/PRINCETON/0_5_3hourly/{v}_3hourly_{y}-{y}.nc"

    dataset_vars = get_dataset_vars('PRINCETON', met_vars)

    data = {}
    for v, fv in dataset_vars.items():
        with xr.open_dataset(file_tpl.format(d=pud.get_data_dir(), v=fv, y=year)) as ds:
            data[v] = ds[fv].copy()
    data = xr.Dataset(data)

    return data
コード例 #6
0
def get_WATCH_WFDEI_data(met_vars, year):

    file_tpl = "{d}/gridded/WATCH_WFDEI/{v}_WFDEI/{v}_WFDEI_{y}*.nc"

    data = {}
    for v in met_vars:
        files = sorted(glob.glob(file_tpl.format(d=pud.get_data_dir(), v=v, y=year)))
        datasets = [xr.open_dataset(f, decode_times=False) for f in files]
        # TODO: WATCH_FDEI uses a fill-value mask, so replace with NANs?
        data[v] = xr.concat(
            [correct_WATCH_WFDEI_coords(ds, v, year) for ds in datasets],
            dim='time')
        [ds.close() for ds in datasets]
    data = xr.Dataset(data)

    return data
コード例 #7
0
def get_CRUNCEP_data(met_vars, year):

    file_tpl = "{d}/gridded/CRUNCEP/cruncep2015_1_{v}_{y}.nc"

    dataset_vars = get_dataset_vars('CRUNCEP', met_vars)
    infile_vars = get_dataset_vars('CRUNCEP', met_vars, in_file=True)

    data = {}
    for v, fv in dataset_vars.items():
        # TODO: CRUNCEP uses a mask variable, so replace with NANs?
        with xr.open_dataset(file_tpl.format(d=pud.get_data_dir(), v=fv, y=year)) as ds:
            data[v] = correct_CRUNCEP_coords(ds, infile_vars[v], year)
    data = xr.Dataset(data)

    # CRUNCEP uses stupid units: ftp://nacp.ornl.gov/synthesis/2009/frescati/model_driver/cru_ncep/analysis/readme.htm
    data['SWdown'] = data.SWdown / 21600

    return data