Exemplo n.º 1
0
def test_variable():
    tas = Variable(uri='http://data.test.org/tas.nc', var_name='tas')
    assert tas.var_name == 'tas'
    assert tas.uri == 'http://data.test.org/tas.nc'
    assert 'uri' in tas.json
    assert 'id' in tas.json
    assert Variable.from_json(tas.json).var_name == 'tas'
    assert tas.id in str(tas)
Exemplo n.º 2
0
def test_variables():
    tas = Variable(uri='http://data.test.org/tas.nc', var_name='tas')
    vars = Variables([tas])
    assert Variables.from_json(vars.json).variables[0].var_name == 'tas'
    assert 'tas' in str(vars)
    assert 'tas' in vars.value
    new_value = Variables()
    new_value.value = vars.value
Exemplo 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')"
Exemplo 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
Exemplo 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
Exemplo 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()
Exemplo n.º 7
0
def test_variable_compat():
    tas_data = {
        "id": "tas|v0",
        "uri": "http://somewhere/test.nc",
        "domain": "d0"
    }
    # from json
    tas = Variable.from_json(tas_data)
    assert tas.id == 'tas|v0'
    assert tas.var_name == 'tas'
    assert tas.uri == 'http://somewhere/test.nc'
    assert tas.domain == 'd0'
    # json
    assert tas.json['id'] == 'tas|v0'
    assert tas.json['uri'] == 'http://somewhere/test.nc'
    assert tas.json['domain'] == 'd0'
Exemplo n.º 8
0
from pywps.tests import assert_response_success

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)