Exemple #1
0
def test_dimension():
    dim = Dimension(0, 1, crs='indices')
    assert dim.start == 0
    assert dim.end == 1
    assert dim.crs == 'indices'
    assert Dimension.from_json(dim.json).start == 0
    assert str(dim) == "Dimension(start='0',end='1',step='1',crs='indices')"
Exemple #2
0
def test_domain():
    d0 = Domain(
        dict(
            time=Dimension(0, 1, crs='indices'),
            lat=Dimension(40, 60, crs='values'),
            lon=Dimension(0, 20, crs='values'),
        ))
    assert len(d0.dimensions) == 3
    assert d0.dimensions['time'].start == 0
    assert d0.dimensions['time'].end == 1
    assert d0.dimensions['time'].crs == 'indices'
    assert 'id' in d0.json
    assert 'time' in d0.json
    assert 'lat' in d0.json
    assert 'lon' in d0.json
    assert len(Domain.from_json(d0.json).dimensions) == 3
    assert d0.id in str(d0)
Exemple #3
0
def test_operation():
    d0 = Domain(dict(time=Dimension(0, 1, crs='indices')))
    tas = Variable(uri='http://data.test.org/tas.nc', var_name='tas')
    operation = Operation('subset', domain=d0, input=[tas])
    assert operation.name == 'subset'
    assert operation.domain == d0.id
    assert operation.input[0] == tas.name
    assert 'domain' in operation.json
    assert Operation.from_json(operation.json).name == 'subset'
    assert str(operation) == "Operation(name='subset')"
Exemple #4
0
def test_esgfapi(wps):  # noqa: D103
    from owslib_esgfwps import Dimension, Domain, Variable

    uri = resource_file("test.nc")

    variable = Variable(var_name="meantemp", uri=uri, name="test")
    domain = Domain([Dimension("time", 0, 10, crs="indices")])

    resp = wps.emu_subset(variable=variable, domain=domain)
    out = resp.get(asobj=True)
    assert "netcdf" in out.ncdump
Exemple #5
0
def test_esgfapi(wps):
    from owslib_esgfwps import Domain, Dimension, Variable

    uri = data_path("test.nc")

    variable = Variable(var_name='meantemp', uri=uri, name='test')
    domain = Domain([Dimension('time', 0, 10, crs='indices')])

    resp = wps.emu_subset(variable=variable, domain=domain)
    out = resp.get(asobj=True)
    assert 'netcdf' in out.ncdump
Exemple #6
0
def test_wps_pelican_subset():
    headers = {'COMPUTE-TOKEN': 'TOKEN'}
    wps = WebProcessingService(url='http://localhost:5000/wps',
                               headers=headers,
                               verify=True)
    d0 = Domain(dict(time=Dimension(0, 1, crs='indices')))
    v0 = Variable(uri=TEST_SU_OPENDAP, var_name='su')
    exec = wps.execute('pelican_subset',
                       inputs=[('domain', Domains([d0])),
                               ('variable', Variables([v0]))],
                       mode=SYNC)
    assert exec.isSucceded()
Exemple #7
0
def test_dimension_compat():
    dim_data = {"start": 0.0, "end": 90.0, "step": 1, "crs": "indices"}
    # from json
    dim = Dimension.from_json(dim_data)
    assert dim.start == 0.0
    assert dim.end == 90.0
    assert dim.step == 1
    assert dim.crs == 'indices'
    # json
    assert dim.json['start'] == 0.0
    assert dim.json['end'] == 90.0
    assert dim.json['step'] == 1
    assert dim.json['crs'] == 'indices'
Exemple #8
0
def test_domains():
    d0 = Domain(dict(time=Dimension(0, 1, crs='indices')))
    domains = Domains([d0])
    assert Domains.from_json(domains.json).domains[0].id == d0.id
    assert d0.id in str(domains)
    assert 'time' in domains.value
from .common import client_for, resource_file, get_output
from pelican.processes.wps_esgf_subset import PelicanSubset
import owslib.wps
from owslib_esgfwps import (
    Domain,
    Domains,
    Variable,
    Variables,
    Dimension
)

NC_FILE_URL = resource_file('test.nc')

variable = Variable(var_name='meantemp', uri=NC_FILE_URL)
domain = Domain(dict(
    time=Dimension(0, 10, crs='indices'),
))


def test_wps_esgf_subset():
    client = client_for(Service(processes=[PelicanSubset()]))
    datainputs = "variable={variable};" \
                 "domain={domain}".format(
                     variable=Variables([variable]).value,
                     domain=Domains([domain]).value)
    resp = client.get(
        service='wps', request='execute', version='1.0.0',
        identifier='pelican_subset',
        datainputs=datainputs)
    assert_response_success(resp)
    out = get_output(resp.xml)