<jupyter_start><jupyter_text>ESGF CWT subset exampletaken from esgf-api example:https://github.com/ESGF/esgf-compute-api/blob/master/examples/getting_started.ipynb<jupyter_code>from owslib.wps import WebProcessingService<jupyter_output><empty_output><jupyter_text>Get a new token from: https://aims2.llnl.gov/Login with your ESGF OpendID (LLNL works).<jupyter_code># token
access_token = 'TOKEN'

# api_key should be in the HTTP headers
client = WebProcessingService('https://aims2.llnl.gov/wps/', verify=True, headers={'COMPUTE-TOKEN': access_token})<jupyter_output><empty_output><jupyter_text>GetCapabilitieshttps://aims2.llnl.gov/wps/?service=WPS&version=1.0.0&request=GetCapabilities<jupyter_code>for p in client.processes:
    print(p.identifier)<jupyter_output><empty_output><jupyter_text>DescribeProcesshttps://aims2.llnl.gov/wps/?service=WPS&version=1.0.0&request=DescribeProcess&identifier=CDAT.subset<jupyter_code>proc = client.describeprocess(
    'CDAT.subset'
)
proc.identifier
for inpt in proc.dataInputs:
    print(inpt.identifier, inpt.dataType)<jupyter_output><empty_output><jupyter_text>Domain<jupyter_code>from owslib_esgfwps import Domain, Dimension
d0 = Domain(dict(
        time=Dimension(0, 2000, crs='values'),
        lat=Dimension(-90, 0, crs='values'),
))
print(d0.json)<jupyter_output><empty_output><jupyter_text>Variable<jupyter_code>from owslib_esgfwps import Variable
# (122, 240, 480)
data_url = 'http://aims3.llnl.gov/thredds/dodsC/css03_data/CMIP6/CMIP/NASA-GISS/GISS-E2-1-G/historical/r10i1p1f1/Amon/tas/gn/v20180830/tas_Amon_GISS-E2-1-G_historical_r10i1p1f1_gn_185001-190012.nc'
v0 = Variable(uri=data_url, var_name='tas')
print(v0.json)<jupyter_output><empty_output><jupyter_text>Operation<jupyter_code>from owslib_esgfwps import Operation
op = Operation(name=proc.identifier, domain=d0, input=[v0])
op.json
from owslib_esgfwps import Variables, Domains, Operations
inputs = []
inputs.append(('domain', Domains([d0])))
inputs.append(('variable', Variables([v0])))
inputs.append(('operation', Operations([op])))
for inp in inputs:
    print(inp[1])<jupyter_output><empty_output><jupyter_text>Executehttps://aims2.llnl.gov/wps/?service=WPS&version=1.0.0&request=Execute&identifier=CDAT.subset&api_key=TOKEN&DataInputs=domain={};variable={};operation={}<jupyter_code>from owslib.wps import SYNC, ASYNC
exec = client.execute(proc.identifier, inputs=inputs, mode=ASYNC)
print(exec.statusLocation)

# TODO sync option is not working

from owslib.wps import monitorExecution
monitorExecution(exec)
print("status: {}, progress: {}/100, message: {}".format(exec.status, exec.percentCompleted, exec.statusMessage))
for output in exec.processOutputs:
    print(output.identifier, output.reference or output.data)<jupyter_output><empty_output><jupyter_text>Plot output from json document<jupyter_code># TODO: fix outputs
import json
output = json.loads(exec.processOutputs[0].data[0])
output['uri']
import xarray as xr
ds = xr.open_dataset(output['uri'])
%matplotlib inline
ds.tas.isel(time=0).plot()<jupyter_output><empty_output><jupyter_text>Show Output<jupyter_code>from owslib_esgfwps import Outputs
# *TODO*: returns a list of str instead of dict
# https://github.com/ESGF/esgf-compute-wps/issues/214

outputs = Outputs.from_owslib(exec.processOutputs)
# *TODO*: returns a list of str instead of dict

outputs = Outputs.from_owslib(exec.processOutputs)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1365767878077374, 'fraction_numerical': 0.025498241500586168, 'mean_word_length': 8.053050397877984, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '290191', 'license': 'Apache-2.0', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1274, 'n_words': 183, 'path': 'examples/notebooks/aims-llnl-wps-demo.ipynb', 'repo_name': 'bird-house/OWSLib-esgfwps', 'size': '3412'}