Beispiel #1
0
def parameterise(
    collection=None, area=None, level=None, time=None, time_components=None
):
    """
    Parameterises inputs to instances of parameter classes which allows
    them to be used throughout roocs.
    For supported formats for each input please see their individual classes.

    :param collection: Collection input in any supported format.
    :param area: Area input in any supported format.
    :param level: Level input in any supported format.
    :param time: Time input in any supported format.
    :param time_components: Time Components input in any supported format.
    :return: Parameters as instances of their respective classes.
    """

    # if collection is a dataset/dataarray it doesn't need to be parameterised
    if type(collection) not in (xr.core.dataarray.DataArray, xr.core.dataset.Dataset):
        collection = collection_parameter.CollectionParameter(collection)

    area = area_parameter.AreaParameter(area)
    level = level_parameter.LevelParameter(level)
    time = time_parameter.TimeParameter(time)
    time_components = time_components_parameter.TimeComponentsParameter(time_components)

    return locals()
Beispiel #2
0
def parameterise(collection=None, area=None, level=None, time=None):

    # if collection is a dataset/dataarray it doesn't need to be parameterised
    if type(collection) not in (xr.core.dataarray.DataArray, xr.core.dataset.Dataset):
        collection = collection_parameter.CollectionParameter(collection)

    area = area_parameter.AreaParameter(area)
    time = time_parameter.TimeParameter(time)
    level = level_parameter.LevelParameter(level)

    return locals()
Beispiel #3
0
def test_parameter_classes_as_args(tmpdir, load_esgf_test_data):
    collection = collection_parameter.CollectionParameter(CMIP5_IDS[1])
    time = time_parameter.TimeParameter(("2085-01-16", "2120-12-16"))
    area = area_parameter.AreaParameter((0, -10, 120, 40))

    result = subset(
        collection, time=time, area=area, output_dir=tmpdir, file_namer="simple"
    )
    _check_output_nc(result)

    ds_subset = xr.open_dataset(result.file_uris[0], use_cftime=True)
    assert ds_subset.tas.shape == (433, 1, 1)
Beispiel #4
0
def test_subset_args_as_parameter_classes(tmpdir):
    """Tests clisops subset function with a time subset
    with the arguments as parameter classes from roocs-utils."""

    time = time_parameter.TimeParameter(
        ("2000-01-01T00:00:00", "2020-12-30T00:00:00"))
    area = area_parameter.AreaParameter((0, -90.0, 360.0, 90.0))

    result = subset(
        ds=CMIP5_TAS_FILE,
        time=time,
        area=area,
        output_dir=tmpdir,
        output_type="nc",
        file_namer="simple",
    )
    _check_output_nc(result)