Ejemplo n.º 1
0
def test_domain_compat():
    d0_data = {
        "id": "d0",
        "latitude": {
            "start": 0.0,
            "end": 45.0,
            "step": 1.5,
            "crs": "values",
        },
        "longitude": {
            "start": 10,
            "end": 20,
            "crs": "indices",
        },
        "time": {
            "start": 1981,
            "end": 2016,
            "crs": "values",
        },
    }
    # from json
    d0 = Domain.from_json(d0_data)
    assert d0.id == 'd0'
    assert len(d0.dimensions) == 3
    # json
    assert d0.json['id'] == 'd0'
    assert 'time' in d0.json
    assert 'latitude' in d0.json
    assert 'longitude' in d0.json
Ejemplo n.º 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)
Ejemplo n.º 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')"
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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()
Ejemplo n.º 7
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
Ejemplo n.º 8
0
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)