Beispiel #1
0
 def make_literal_input(self):
     literal = inout.inputs.LiteralInput(
         identifier="complexinput",
         title='MyComplex',
         data_type='string',
         workdir=self.tmp_dir,
         abstract="some description",
         keywords=['kw1', 'kw2'],
         metadata=[Metadata("special data")],
         uoms=['metre', 'unity'],
         min_occurs=2,
         max_occurs=5,
         mode=MODE.STRICT,
         allowed_values=[
             AllowedValue(value='something'),
             AllowedValue(value='something else'),
             AnyValue()
         ],
         default="something else",
         default_type=SOURCE_TYPE.DATA,
     )
     literal.data = 'something'
     literal.uom = UOM('unity')
     literal.as_reference = False
     return literal
    def test_allowedvalues_ranges_validator(self):
        """Test allowed values - ranges"""

        allowed_value = AllowedValue()
        allowed_value.allowed_type = ALLOWEDVALUETYPE.RANGE
        allowed_value.minval = 1
        allowed_value.maxval = 11
        allowed_value.spacing = 2
        allowed_value.range_closure = RANGECLOSURETYPE.OPEN

        inpt = get_input(allowed_values = [allowed_value])

        inpt.data = 1
        self.assertTrue(validate_allowed_values(inpt, MODE.SIMPLE), 'Range OPEN closure')

        inpt.data = 12
        self.assertFalse(validate_allowed_values(inpt, MODE.SIMPLE), 'Value too big')

        inpt.data = 5
        self.assertTrue(validate_allowed_values(inpt, MODE.SIMPLE), 'Spacing not fit')

        inpt.data = 4
        self.assertFalse(validate_allowed_values(inpt, MODE.SIMPLE), 'Spacing fits')

        inpt.data = 11
        allowed_value.range_closure = RANGECLOSURETYPE.OPEN
        self.assertTrue(validate_allowed_values(inpt, MODE.SIMPLE), 'Open Range')

        allowed_value.range_closure = RANGECLOSURETYPE.OPENCLOSED
        self.assertFalse(validate_allowed_values(inpt, MODE.SIMPLE), 'OPENCLOSED Range')

        inpt.data = 1
        allowed_value.range_closure = RANGECLOSURETYPE.CLOSEDOPEN
        self.assertFalse(validate_allowed_values(inpt, MODE.SIMPLE), 'CLOSEDOPEN Range')
    def test_allowedvalues_values_validator(self):
        """Test allowed values - values"""
        allowed_value = AllowedValue()
        allowed_value.allowed_type = ALLOWEDVALUETYPE.VALUE
        allowed_value.value = 1

        inpt = get_input(allowed_values = [allowed_value])
        self.assertTrue(validate_allowed_values(inpt, MODE.SIMPLE), 'Allowed value 1 allowed')

        inpt.data = 2
        self.assertFalse(validate_allowed_values(inpt, MODE.SIMPLE), 'Allowed value 2 NOT allowed')
Beispiel #4
0
    def from_json(cls, json_input):
        allowed_values = []
        for allowed_value in json_input['allowed_values']:
            if allowed_value['type'] == 'anyvalue':
                allowed_values.append(AnyValue())
            elif allowed_value['type'] == 'novalue':
                allowed_values.append(NoValue())
            elif allowed_value['type'] == 'valuesreference':
                allowed_values.append(ValuesReference.from_json(allowed_value))
            elif allowed_value['type'] == 'allowedvalue':
                allowed_values.append(AllowedValue.from_json(allowed_value))

        json_input_copy = deepcopy(json_input)
        json_input_copy['allowed_values'] = allowed_values
        json_input_copy['uoms'] = [
            basic.UOM(uom.get('uom')) for uom in json_input.get('uoms', [])
        ]

        data = json_input_copy.pop('data', None)
        uom = json_input_copy.pop('uom', None)
        metadata = json_input_copy.pop('metadata', [])
        json_input_copy.pop('type')
        json_input_copy.pop('any_value', None)
        json_input_copy.pop('values_reference', None)

        instance = cls(**json_input_copy)

        instance.metadata = [Metadata.from_json(d) for d in metadata]
        instance.data = data
        if uom:
            instance.uom = basic.UOM(uom['uom'])

        return instance
Beispiel #5
0
def test_cwl2wps_io_null_or_array_of_enums():
    """
    I/O `CWL` with ``["null", "<enum-type>", "<array-enum-type>]`` must be parsed as `WPS` with parameters
    ``minOccurs=0``, ``maxOccurs>1`` and ``allowedValues`` as restricted set of values.
    """
    allowed_values = ["A", "B", "C"]
    io_info = {
        "name":
        "test",
        "type": [
            "null",  # minOccurs=0
            {
                "type": "enum",
                "symbols": allowed_values
            },  # if maxOccurs=1, only this variant would be provided
            {
                "type": "array",
                "items": {
                    "type": "enum",
                    "symbols": allowed_values
                }
            },  # but also this for maxOccurs>1
        ],
    }
    wps_io = cwl2wps_io(io_info, WPS_INPUT)
    assert isinstance(wps_io, LiteralInput)
    assert wps_io.min_occurs == 0
    assert wps_io.max_occurs == PACKAGE_ARRAY_MAX_SIZE
    assert wps_io.data_type == "string"
    assert wps_io.allowed_values == [
        AllowedValue(value=val) for val in allowed_values
    ]
Beispiel #6
0
    def test_literal_allowed_values_input(self):
        """Test all around allowed_values
        """
        literal = LiteralInput(
            'foo',
            'Foo',
            data_type='integer',
            uoms=['metre'],
            allowed_values=(1, 2, (5, 10), (12, 4, 24),
                            AllowedValue(allowed_type=ALLOWEDVALUETYPE.RANGE,
                                         minval=30,
                                         maxval=33,
                                         range_closure='closed-open')))
        doc = literal.describe_xml()

        allowed_values = xpath_ns(doc, './LiteralData/ows:AllowedValues')
        self.assertEqual(len(allowed_values), 1)

        allowed_value = allowed_values[0]

        values = xpath_ns(allowed_value, './ows:Value')
        ranges = xpath_ns(allowed_value, './ows:Range')

        self.assertEqual(len(values), 2)
        self.assertEqual(len(ranges), 3)
    def __init__(self):
        """Sample."""
        inputs = [
            LiteralInput(
                'sentinel_products',
                'Sentine Product IDs',
                data_type='string',
                abstract="""
                helper:sentinel_product_select
                """,
            ),
            ComplexInput(
                'geojson',
                'GeoJSON region',
                supported_formats=[Format('application/vnd.geo+json')],
                abstract="GeoJson",
                mode=MODE.SIMPLE,
                max_occurs=1),
            LiteralInput('ranged',
                         'Ranged Value',
                         abstract="""
                Sample of allowed_value usage
                """,
                         data_type='integer',
                         allowed_values=AllowedValue(
                             allowed_type=ALLOWEDVALUETYPE.RANGE,
                             minval=0,
                             maxval=100),
                         max_occurs=1)
        ]
        outputs = [
            LiteralOutput(
                'none',
                'Nothing',
                data_type='string',
                abstract="""
                Empty ouput.
                """,
            )
        ]

        super(InputDemos, self).__init__(
            identifier='input_demos',
            abstract="""
            Input demonstrators.
            """,
            version='0.1',
            title="Input Demos",
            profile='',
            metadata=[Metadata('Sample'),
                      Metadata('Input')],
            inputs=inputs,
            outputs=outputs,
        )
Beispiel #8
0
 def test_literal_allowed_values_input(self):
     """Test all around allowed_values
     """
     literal = LiteralInput(
         'foo',
         'Foo',
         data_type='integer',
         uoms=['metre'],
         allowed_values=(1, 2, (5, 10), (12, 4, 24),
                         AllowedValue(allowed_type=ALLOWEDVALUETYPE.RANGE,
                                      minval=30,
                                      maxval=33,
                                      range_closure='closed-open')))
     data = literal.json
     assert len(data["allowed_values"]) == 5
     assert data["allowed_values"][0]["value"] == 1
     assert data["allowed_values"][0]["range_closure"] == "closed"
Beispiel #9
0
    def __init__(self):
        inputs = [
            LiteralInput('count',
                         'Number of output files',
                         abstract='The number of generated output files.',
                         data_type='integer',
                         default=2,
                         allowed_values=[AllowedValue(minval=1, maxval=10)])
        ]
        outputs = [
            ComplexOutput('output',
                          'METALINK v3 output',
                          abstract='Testing metalink v3 output',
                          as_reference=True,
                          supported_formats=[FORMATS.METALINK]),
            ComplexOutput('output_meta4',
                          'METALINK v4 output',
                          abstract='Testing metalink v4 output',
                          as_reference=True,
                          supported_formats=[FORMATS.META4])
        ]

        super(MultipleOutputs, self).__init__(
            self._handler,
            identifier='multiple_outputs',
            title='Multiple Outputs',
            abstract='Produces multiple files and returns a document'
            ' with references to these files.',
            metadata=[
                MetadataUrl(
                    'User Guide',
                    'https://emu.readthedocs.io/en/latest/processes.html',
                    anonymous=True),
            ],
            version='1.1',
            inputs=inputs,
            outputs=outputs,
            store_supported=True,
            status_supported=True)
Beispiel #10
0
    def from_json(cls, json_input):

        allowed_values = []
        for allowed_value in json_input['allowed_values']:
            if allowed_value['type'] == 'anyvalue':
                allowed_values.append(AnyValue())
            elif allowed_value['type'] == 'novalue':
                allowed_values.append(NoValue())
            elif allowed_value['type'] == 'valuesreference':
                allowed_values.append(ValuesReference())
            elif allowed_value['type'] == 'allowedvalue':
                allowed_values.append(
                    AllowedValue(allowed_type=allowed_value['allowed_type'],
                                 value=allowed_value['value'],
                                 minval=allowed_value['minval'],
                                 maxval=allowed_value['maxval'],
                                 spacing=allowed_value['spacing'],
                                 range_closure=allowed_value['range_closure']))

        json_input['allowed_values'] = allowed_values
        json_input['uoms'] = [
            basic.UOM(uom.get('uom')) for uom in json_input.get('uoms', [])
        ]

        data = json_input.pop('data', None)
        uom = json_input.pop('uom', None)
        metadata = json_input.pop('metadata', [])
        json_input.pop('type')
        json_input.pop('any_value', None)
        json_input.pop('values_reference', None)

        instance = cls(**json_input)

        instance.metadata = [Metadata.from_json(d) for d in metadata]
        instance.data = data
        if uom:
            instance.uom = basic.UOM(uom['uom'])

        return instance
Beispiel #11
0
    def __init__(self):
        inputs = [
            LiteralInput(
                'dry_run',
                'Dry run mode. Default false',
                data_type='boolean',
                default=False,
            ),
            LiteralInput(
                'count',
                'Number of Files (Limit 10)',
                abstract=
                'How many files do you want to download? The limit is 10',
                data_type='integer',
                allowed_values=[AllowedValue(minval=1, maxval=20)],
                default=1,
                mode=MODE.SIMPLE),
        ]
        outputs = [
            LiteralOutput('output', 'Output response', data_type='string')
        ]

        super(SimpleDryRun, self).__init__(
            self._handler,
            identifier='simple_dry_run',
            title='Simple Dry Run',
            abstract='A dummy download as simple dry-run example.',
            metadata=[
                MetadataUrl(
                    'User Guide',
                    'https://emu.readthedocs.io/en/latest/processes.html',
                    anonymous=True),
            ],
            version='1.0',
            inputs=inputs,
            outputs=outputs,
            store_supported=True,
            status_supported=True)
Beispiel #12
0
def test_json2wps_allowed_values():
    for i, (values, expect) in enumerate([
        ({"allowedvalues": [1, 2, 3]},
         [AllowedValue(value=1), AllowedValue(value=2), AllowedValue(value=3)]),
        ({"allowedvalues": ["A", "B"]},
         [AllowedValue(value="A"), AllowedValue(value="B")]),
        ({"allowedvalues": [{"closure": "open", "minimum": 1, "maximum": 5}]},
         [AllowedValue(minval=1, maxval=5, range_closure="open")]),
        ({"allowedvalues": [{"closure": "open-closed", "minimum": 0, "maximum": 6, "spacing": 2}]},
         [AllowedValue(minval=0, maxval=6, spacing=2, range_closure="open-closed")]),
        ({"literalDataDomains": [{"valueDefinition": [1, 2, 3]}]},
         [AllowedValue(value=1), AllowedValue(value=2), AllowedValue(value=3)]),
        ({"literalDataDomains": [{"valueDefinition": ["A", "B"]}]},
         [AllowedValue(value="A"), AllowedValue(value="B")]),
        ({"literalDataDomains": [{"valueDefinition": [{"closure": "open", "minimum": 1, "maximum": 5}]}]},
         [AllowedValue(minval=1, maxval=5, range_closure="open")]),
        ({"literalDataDomains": [
            {"valueDefinition": [{"closure": "open-closed", "minimum": 0, "maximum": 6, "spacing": 2}]}]},
         [AllowedValue(minval=0, maxval=6, spacing=2, range_closure="open-closed")]),
    ]):
        result = json2wps_allowed_values(values)
        assert result == expect, f"Failed test {i}"
    def __init__(self):
        self.variables = ['tas']
        self.frequency = 'mon'

        inputs = [
            *model_experiment_ensemble(model='MPI-ESM-MR',
                                       experiment='rcp85',
                                       ensemble='r1i1p1',
                                       min_occurs=2,
                                       required_variables=self.variables,
                                       required_frequency=self.frequency,
                                       exclude_historical=True),
            *historic_projection_year_ranges(1961, 1990, 2006, 2100),
            LiteralInput(
                'moninf',
                'First month month of the seasonal mean period',
                abstract=
                """First month of the seasonal mean period to be computed, if none the monthly anomalies
                            will be computed.""",
                data_type='string',
                allowed_values=[
                    '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11',
                    '12', 'null'
                ],
                default='6'),
            LiteralInput(
                'monsup',
                'Last month month of the seasonal mean period',
                abstract=
                """Last month of the seasonal mean period to be computed, if none the monthly anomalies
                            will be computed.""",
                data_type='string',
                allowed_values=[
                    '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11',
                    '12'
                ],
                default='6'),
            LiteralInput(
                'agreement_threshold',
                'Agreement Threshold',
                abstract="""Threshold in percent for the minimum agreement
                            between models on the sign of the multi-model mean anomaly for the stipling to be
                            plotted.""",
                data_type='integer',
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE, minval=0, maxval=100),
                default=80),
            LiteralInput(
                'running_mean',
                'Running Mean',
                abstract=
                'Length of the window for which the running mean is computed.',
                data_type='integer',
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE, minval=1, maxval=365),
                default=5),
            LiteralInput(
                'time_series_plot',
                'Time series plot',
                abstract=
                """Either single or maxmin (plot the individual or the mean with shading between the
                                     max and min).""",
                data_type='string',
                allowed_values=['single', 'maxmin'],
                default='single'),
        ]
        self.plotlist = [
            ('tas', [Format('image/png')]),
            ('Area', [Format('image/png')]),
        ]
        outputs = [
            *outputs_from_plot_names(self.plotlist),
            ComplexOutput(
                'data',
                'Data',
                abstract='Generated output data of ESMValTool processing.',
                as_reference=True,
                supported_formats=[FORMATS.NETCDF]),
            ComplexOutput(
                'archive',
                'Archive',
                abstract=
                'The complete output of the ESMValTool processing as an zip archive.',
                as_reference=True,
                supported_formats=[Format('application/zip')]),
            *default_outputs(),
        ]

        super(MultimodelProducts, self).__init__(
            self._handler,
            identifier="multimodel_products",
            title="Generic multi-model products",
            version=runner.VERSION,
            abstract=
            """For the 'generic multi-model diagnostic' the ensemble mean anomaly, and the ensemble
                        variance and agreement are calculated. The results are shown as maps and time series.
                        The estimated calculation time of this process is 1 minute for the default values supplied.
                        For each model choose a projection scenario (e.g. rcp26) and the relevant
                        historical experiment will be added by the WPS process. Also make sure to set the climatology
                        and anomaly start and end years correctly.""",
            metadata=[
                Metadata('ESMValTool', 'http://www.esmvaltool.org/'),
                Metadata(
                    'Documentation',
                    'https://esmvaltool.readthedocs.io/en/v2.0a2/recipes/recipe_multimodel_products.html',
                    role=util.WPS_ROLE_DOC),
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True)
Beispiel #14
0
    def __init__(self):
        self.variables = ['pr', 'ta']
        self.frequency = 'mon'
        inputs = [
            *model_experiment_ensemble(model='bcc-csm1-1',
                                       experiment='historical',
                                       ensemble='r1i1p1',
                                       min_occurs=2,
                                       required_variables=self.variables,
                                       required_frequency=self.frequency),
            LiteralInput(
                'ref_dataset',
                'Reference Dataset',
                abstract='Choose a reference dataset like ERA-Interim.',
                data_type='string',
                allowed_values=['ERA-Interim'],
                default='ERA-Interim',
                min_occurs=1,
                max_occurs=1),
            *year_ranges((2000, 2005), start_year=1979, end_year=2018),
            LiteralInput(
                'extract_levels',
                'Extraction levels',
                abstract='Choose an extraction level for the preprocessor.',
                data_type='float',
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE,
                    minval=0.0,
                    maxval=110000.0),
                default=85000.0),
        ]
        self.plotlist = [
            ('multi_model_mean_ta', [Format('image/png')]),
            ('multi_model_median_ta', [Format('image/png')]),
            ('model1_mean_ta', [Format('image/png')]),
            ('model2_mean_ta', [Format('image/png')]),
            ('reference_model_mean_ta', [Format('image/png')]),
            ('model1_mean_pr', [Format('image/png')]),
            ('model2_mean_pr', [Format('image/png')]),
            ('reference_model_mean_pr', [Format('image/png')]),
        ]

        self.datalist = [
            ('multi_model_mean_ta', [FORMATS.NETCDF]),
            ('multi_model_median_ta', [FORMATS.NETCDF]),
            ('model1_mean_ta', [FORMATS.NETCDF]),
            ('model2_mean_ta', [FORMATS.NETCDF]),
            ('reference_model_mean_ta', [FORMATS.NETCDF]),
            ('model1_mean_pr', [FORMATS.NETCDF]),
            ('model2_mean_pr', [FORMATS.NETCDF]),
            ('reference_model_mean_pr', [FORMATS.NETCDF]),
        ]
        outputs = [
            *outputs_from_plot_names(self.plotlist),
            *outputs_from_data_names(self.datalist),
            ComplexOutput(
                'archive',
                'Archive',
                abstract=
                'The complete output of the ESMValTool processing as an zip archive.',
                as_reference=True,
                supported_formats=[Format('application/zip')]),
            *default_outputs(),
        ]

        super(PreprocessExample, self).__init__(
            self._handler,
            identifier="preproc",
            title="Preprocessing Demo",
            version=runner.VERSION,
            abstract="""The ESMValTool climate data pre-processor can be used to
                        perform all types of climate data pre-processing needed before indices
                        or diagnostics can be calculated. It is a base component for many other
                        diagnostics and metrics shown on this portal. It can be applied to
                        tailor the climate model data to the need of the user for its own
                        calculations.
                        The estimated calculation time of this process is 1 minute for the default values supplied.

                        This preprocessor example requires at least two models to be chosen. Any combination is valid,
                        however, only the first two models will return their output inline. The output of any models
                        beyond the first two are included in the zip file. A reference observational dataset will also
                        be added.
                        """,
            metadata=[
                Metadata('ESMValTool', 'http://www.esmvaltool.org/'),
                Metadata(
                    'Documentation',
                    'https://esmvaltool.readthedocs.io/en/v2.0a2/user_guide2/index.html#esmvaltool-preprocessor',  # noqa
                    role=util.WPS_ROLE_DOC),
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True,
        )
Beispiel #15
0
    def __init__(self):
        """Sample."""
        inputs = [
            ComplexInput(
                'search_polygon',
                'GeoJSON region',
                supported_formats=[Format('application/vnd.geo+json')],
                abstract="GeoJson of region to search",
                mode=MODE.SIMPLE,
                max_occurs=1),
            # BoundingBoxInput(
            # 'search_box', 'Sample BBox input',
            # abstract="""
            # Sample usage of BoundingBox inputs for WPS
            # """,
            # crss=['EPSG:4326'],
            # dimensions=2
            # ),
            LiteralInput('cloud_percentage',
                         'Max cloud Percentage',
                         abstract="""
                Maximum cloud cover in percentage (e.g. 30)
                """,
                         data_type='integer',
                         allowed_values=AllowedValue(
                             allowed_type=ALLOWEDVALUETYPE.RANGE,
                             minval=0,
                             maxval=100),
                         max_occurs=1),
            LiteralInput('start_date',
                         'Start date',
                         abstract="""
                Datestamp in format YYYYMMDD
                """,
                         data_type='integer',
                         max_occurs=1),
            LiteralInput('end_date',
                         'End date',
                         abstract="""
                Datestamp in format YYYYMMDD
                """,
                         data_type='integer',
                         max_occurs=1)
        ]
        outputs = [
            LiteralOutput(
                'output_dir',
                'Workflow data volume path',
                data_type='string',
                abstract="""
                Path to a directory within the Workflow Data volume.
                The service will store all outputs in this dir, then
                provide a reference to the directory which other services
                can use.
                """,
            )
        ]

        super(SentinelDownload, self).__init__(
            identifier='acquisition:sentinelsat',
            abstract="""
            Use sentinelsat python module to download sentinel data
            """,
            version='0.1',
            title="Sentinel 2 Data acquisition",
            metadata=[Metadata('Sample'), Metadata('Test')],
            profile='',
            inputs=inputs,
            outputs=outputs,
        )
Beispiel #16
0
    def __init__(self):
        self.variables = ['pr']
        self.frequency = 'mon'

        inputs = [
            *model_experiment_ensemble(model='MPI-ESM-P',
                                       experiment='historical',
                                       ensemble='r1i1p1',
                                       max_occurs=1,
                                       required_variables=self.variables,
                                       required_frequency=self.frequency),
            *year_ranges((1997, 1997), start_year=1979, end_year=2018),
            LiteralInput('ref_dataset',
                         'Reference Dataset',
                         abstract='Choose a reference dataset like GPCP-SG.',
                         data_type='string',
                         allowed_values=['GPCP-SG'],
                         default='GPCP-SG',
                         min_occurs=1,
                         max_occurs=1),
            LiteralInput('perc_lev',
                         'Quantile',
                         abstract='Quantile in percentage (%).',
                         data_type='integer',
                         allowed_values=AllowedValue(
                             allowed_type=ALLOWEDVALUETYPE.RANGE,
                             minval=0,
                             maxval=100),
                         default=75),
        ]

        outputs = [
            ComplexOutput(
                'model',
                'Model Quantile Data',
                abstract='Generated output data of ESMValTool processing.',
                as_reference=True,
                supported_formats=[FORMATS.NETCDF]),
            ComplexOutput(
                'archive',
                'Archive',
                abstract=
                'The complete output of the ESMValTool processing as a zip archive.',
                as_reference=True,
                supported_formats=[Format('application/zip')]),
            *default_outputs(),
        ]

        super(QuantileBias, self).__init__(
            self._handler,
            identifier="quantile_bias",
            title="Quantile Bias",
            version=runner.VERSION,
            abstract=
            """Diagnostic showing the quantile bias between models and a reference dataset.
                        The estimated calculation time of this process is 1 minute for the default values supplied.
                        """,
            metadata=[
                Metadata('ESMValTool', 'http://www.esmvaltool.org/'),
                Metadata(
                    'Documentation',
                    'https://esmvaltool.readthedocs.io/en/v2.0a2/recipes/recipe_quantilebias.html',
                    role=util.WPS_ROLE_DOC,
                ),
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True)
Beispiel #17
0
    def __init__(self):
        self.variables = ['pr']
        self.frequency = 'day'

        inputs = [
            *model_experiment_ensemble(model='ACCESS1-0',
                                       experiment='historical',
                                       ensemble='r1i1p1',
                                       max_occurs=1,
                                       required_variables=self.variables,
                                       required_frequency=self.frequency),
            *year_ranges((1997, 1999)),
            *region(5, 15, 40, 50),
            LiteralInput(
                'target_grid',
                'Target Grid',
                abstract=
                ('Target grid in degrees (e.g. 1x1) can also be the name of one '
                 'of the datasets to use the grid from that dataset.'),
                data_type='string',
                default='1x1',
            ),
            LiteralInput(
                'scheme',
                'Scheme',
                abstract='Regridding scheme to be used.',
                data_type='string',
                allowed_values=[
                    'linear', 'nearest', 'area_weighted',
                    'unstructured_nearest'
                ],
                default='area_weighted',
            ),
            LiteralInput(
                'slope',
                'Slope',
                abstract=('Spatial spectral slope (set to 0 to compute from'
                          'large scales).'),
                data_type='float',
                default=0.,
            ),
            LiteralInput(
                'nens',
                'No. of ensemble members',
                abstract='Number of ensemble members to be calculated.',
                data_type='integer',
                default=2,
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE, minval=1,
                    maxval=1000),
            ),
            LiteralInput(
                'nf',
                'No. of subdivisions',
                abstract=(
                    'Number of subdivisions for downscaling (e.g. 8 will '
                    'produce output fields with linear resolution '
                    'increased by a factor 8).'),
                data_type='integer',
                default=8,
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE, minval=1,
                    maxval=1000),
            ),
            LiteralInput(
                'conserv_glob',
                'Conserve Global',
                abstract='Conserve precipitation over full domain?',
                data_type='string',
                allowed_values=['true', 'false'],
                default='false',
            ),
            LiteralInput(
                'conserv_smooth',
                'Conserve Smooth',
                abstract=('Conserve precipitation using convolution (if '
                          'neither is chosen box conservation is used)?'),
                data_type='string',
                allowed_values=['true', 'false'],
                default='true',
            ),
        ]

        self.datalist = [
            ('downscaled_data_ensemble_member_1', [FORMATS.NETCDF]),
            ('downscaled_data_ensemble_member_2', [FORMATS.NETCDF]),
        ]
        outputs = [
            *outputs_from_data_names(self.datalist),
            ComplexOutput(
                'archive',
                'Archive',
                abstract=
                'The complete output of the ESMValTool processing as an zip archive.',
                as_reference=True,
                supported_formats=[Format('application/zip')]),
            *default_outputs(),
        ]

        super(RainFARM, self).__init__(
            self._handler,
            identifier="rainfarm",
            title="RainFARM stochastic downscaling",
            version=runner.VERSION,
            abstract=
            """Precipitation extremes and small-scale variability are essential drivers in many climate change
                        impact studies. However, the spatial resolution currently achieved by global and regional
                        climate models is still insufficient to correctly identify the fine structure of precipitation
                        intensity fields. In the absence of a proper physically based representation, this scale gap
                        can be at least temporarily bridged by adopting a stochastic rainfall downscaling technique
                        (Rebora et al, 2006). With this aim, the Rainfall Filtered Autoregressive Model (RainFARM)was
                        developed to apply the stochastic precipitation downscaling method to climate models. The
                        selected region needs to have equal and even number of longitude (in any case it is cut) and
                        latitude grid points (e.g., 2x2, 4x4). Warning: downscaling can reach very high resolution,
                        so select a limited area. Note that only the first two ensemble members are returned as data
                        fields. If applicable, others are available in the output archive.

                        The estimated calculation time of this process is 3 minutes for the default values supplied.
                        """,
            metadata=[
                Metadata('ESMValTool', 'http://www.esmvaltool.org/'),
                Metadata(
                    'Documentation',
                    'https://esmvaltool.readthedocs.io/en/v2.0a2/recipes/recipe_rainfarm.html',
                    role=util.WPS_ROLE_DOC),
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True)
Beispiel #18
0
    def __init__(self):
        self.variables = ['pr']
        self.frequency = 'day'

        inputs = [
            *model_experiment_ensemble(model='ACCESS1-0',
                                       experiment='rcp85',
                                       ensemble='r1i1p1',
                                       min_occurs=2,
                                       max_occurs=100,
                                       required_variables=self.variables,
                                       required_frequency=self.frequency,
                                       exclude_historical=True),
            *year_ranges((1980, 2020)),
            LiteralInput(
                'ref_model',
                'Reference Model',
                abstract='Choose a reference model like ACCESS1-0.',
                data_type='string',
                allowed_values=['ACCESS1-0'],
                default='ACCESS1-0',
                min_occurs=1,
                max_occurs=1,
            ),
            LiteralInput(
                'indices',
                'Indices',
                abstract='Indices to be analysed and plotted.',
                data_type='string',
                allowed_values=[
                    "pa_norm", "hyint", "int_norm", "r95_norm", "wsl_norm", "dsl_norm", "int", "dsl", "wsl"
                ],
                default="hyint",
                min_occurs=1,
                max_occurs=9,
            ),
            LiteralInput(
                'regions',
                'Regions',
                abstract='Regions for timeseries and maps.',
                data_type='string',
                allowed_values=["GL", "GL60", "TR", "SA", "AF", "IN", "EU", "EA", "AU"],
                default="GL",
                min_occurs=1,
                max_occurs=5,
            ),
            LiteralInput(
                'norm_year_start',
                'Norm year start',
                abstract='First year of reference normalization period to be used for normalized indices. \
                Must be inside of model data year range.',
                data_type='integer',
                default=1980,
                allowed_values=AllowedValue(allowed_type=ALLOWEDVALUETYPE.RANGE, minval=1850, maxval=2100)
            ),
            LiteralInput(
                'norm_year_end',
                'Norm year end',
                abstract='Last year of reference normalization period to be used for normalized indices. \
                    Must be inside of model data year range.',
                data_type='integer',
                default=1999,
                allowed_values=AllowedValue(allowed_type=ALLOWEDVALUETYPE.RANGE, minval=1850, maxval=2100)
            ),
        ]

        outputs = [
            ComplexOutput('plot1',
                          'Plot1',
                          abstract='Single panel lon/lat map per individual index, multi-year mean',
                          as_reference=True,
                          supported_formats=[Format('image/png')]),
            ComplexOutput('plot2',
                          'Plot2',
                          abstract='3-panel lon/lat maps per individual index with comparison to reference dataset, \
                multi-year mean',
                          as_reference=True,
                          supported_formats=[Format('image/png')]),
            ComplexOutput('plot3',
                          'Plot3',
                          abstract='multipanel of indices of lon/lat maps with comparison to reference dataset, \
                multi-year mean',
                          as_reference=True,
                          supported_formats=[Format('image/png')]),
            ComplexOutput('plot12',
                          'Plot12',
                          abstract='multipanel of indices with timeseries over multiple regions',
                          as_reference=True,
                          supported_formats=[Format('image/png')]),
            ComplexOutput('plot13',
                          'Plot13',
                          abstract='multipanel of indices with timeseries for multiple models',
                          as_reference=True,
                          supported_formats=[Format('image/png')]),
            ComplexOutput('plot14',
                          'Plot14',
                          abstract='multipanel of indices with summary of trend coefficients over multiple regions',
                          as_reference=True,
                          supported_formats=[Format('image/png')]),
            ComplexOutput('plot15',
                          'Plot15',
                          abstract='multipanel of indices with summary of trend coefficients for multiple models',
                          as_reference=True,
                          supported_formats=[Format('image/png')]),
            ComplexOutput('archive',
                          'Archive',
                          abstract='The complete output of the ESMValTool processing as a zip archive.',
                          as_reference=True,
                          supported_formats=[Format('application/zip')]),
            *default_outputs(),
        ]

        super(HyInt, self).__init__(
            self._handler,
            identifier="hyint",
            title="HyInt - Hydroclimatic intensity and extremes",
            version=runner.VERSION,
            abstract="""HyInt hydroclimatic indices calculation and plotting. The estimated calculation
                        time of this process is 30 minutes for the default values supplied. Selected models
                        should be experiment (eg. "rcp85") and not historical. The historical
                        data will be added automatically.""",
            metadata=[
                Metadata('ESMValTool', 'http://www.esmvaltool.org/'),
                Metadata('Documentation',
                         'https://esmvaltool.readthedocs.io/en/v2.0a2/recipes/recipe_hyint.html',
                         role=util.WPS_ROLE_DOC),
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True)
Beispiel #19
0
    def __init__(self):
        self.variables = ['pr', 'tas']
        self.frequency = 'mon'

        inputs = [
            *model_experiment_ensemble(model='ACCESS1-0',
                                       experiment='historical',
                                       ensemble='r1i1p1',
                                       min_occurs=3,
                                       required_variables=self.variables,
                                       required_frequency=self.frequency),
            *year_ranges((1900, 2005)),
            LiteralInput('variable',
                         'Variable',
                         abstract='Select the variable to simulate.',
                         data_type='string',
                         default='pr',
                         allowed_values=['pr', 'tas']),
            LiteralInput(
                'season',
                'Season',
                abstract='Choose a season like DJF.',
                data_type='string',
                allowed_values=['DJF', 'DJFM', 'NDJFM', 'JJA'],
                default='JJA',
            ),
            LiteralInput(
                'area',
                'Area',
                abstract='Area over which to calculate.',
                data_type='string',
                allowed_values=['EU', 'EAT', 'PNA', 'NH'],
                default='EU',
            ),
            LiteralInput(
                'extreme',
                'Extreme',
                abstract='Extreme metric.',
                data_type='string',
                allowed_values=[
                    '60th_percentile', '75th_percentile', '90th_percentile',
                    'mean', 'maximum', 'std', 'trend'
                ],
                default='75th_percentile',
            ),
            LiteralInput(
                'numclus',
                'Number of Clusters',
                abstract='Number of clusters.',
                data_type='integer',
                default=2,
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE, minval=1,
                    maxval=1000),
            ),
            LiteralInput(
                'perc',
                'Percentage',
                abstract='Percentage of total Variance',
                data_type='integer',
                default='80',
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE, minval=0, maxval=100),
            ),
            LiteralInput(
                'numpcs',
                'Number of PCs',
                abstract=
                'Number of PCs to retain. Has priority over Percentage unless set to 0',
                data_type='integer',
                default='0',
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE, minval=0,
                    maxval=1000),
            ),
        ]
        outputs = [
            ComplexOutput(
                'plot',
                'Output plot',
                abstract='Generated output plot of ESMValTool processing.',
                as_reference=True,
                supported_formats=[Format('image/eps')]),
            ComplexOutput(
                'ens_extreme',
                'ens_extreme',
                abstract='Generated output data of ESMValTool processing.',
                as_reference=True,
                supported_formats=[FORMATS.NETCDF]),
            ComplexOutput(
                'ens_climatologies',
                'ens_climatologies',
                abstract='Generated output data of ESMValTool processing.',
                as_reference=True,
                supported_formats=[FORMATS.NETCDF]),
            ComplexOutput(
                'ens_anomalies',
                'ens_anomalies',
                abstract='Generated output data of ESMValTool processing.',
                as_reference=True,
                supported_formats=[FORMATS.NETCDF]),
            ComplexOutput('statistics',
                          'Statistics',
                          abstract='Clustering Statistics',
                          as_reference=True,
                          supported_formats=[Format('text/plain')]),
            ComplexOutput(
                'archive',
                'Archive',
                abstract=
                'The complete output of the ESMValTool processing as an zip archive.',
                as_reference=True,
                supported_formats=[Format('application/zip')]),
            *default_outputs(),
        ]

        super(EnsClus, self).__init__(
            self._handler,
            identifier="ensclus",
            title="EnsClus - Ensemble Clustering",
            version=runner.VERSION,
            abstract="""Cluster analysis tool based on the k-means algorithm
                for ensembles of climate model simulations. EnsClus group
                ensemble members according to similar characteristics and
                select the most representative member for each cluster. The estimated calculation
                time of this process is 4 minutes for the default values supplied.
                The Ensemble Clustering metric requires at least two models to be chosen,
                choosing more models is supported.
                """,
            metadata=[
                Metadata('ESMValTool', 'http://www.esmvaltool.org/'),
                Metadata(
                    'Documentation',
                    'https://esmvaltool.readthedocs.io/en/v2.0a2/recipes/recipe_ensclus.html',
                    role=util.WPS_ROLE_DOC),
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True)
    def __init__(self):
        self.variables = ['tasmin']
        self.frequency = 'day'

        inputs = [
            *model_experiment_ensemble(model='bcc-csm1-1',
                                       experiment='rcp85',
                                       ensemble='r1i1p1',
                                       max_occurs=1,
                                       required_variables=self.variables,
                                       required_frequency=self.frequency,
                                       exclude_historical=True),
            *historic_projection_year_ranges(1971, 2000, 2060, 2080),
            LiteralInput(
                'quantile',
                'Quantile',
                abstract=
                'Quantile defining the exceedance/non-exceedance threshold.',
                data_type='float',
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE,
                    minval=0.0,
                    maxval=1.0),
                default=0.8),
            LiteralInput(
                'min_duration',
                'Minimum duration',
                abstract=
                'Minimum duration in days of a heatwave/coldwave event.',
                data_type='integer',
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE, minval=1, maxval=366),
                default=5),
            LiteralInput(
                'operator',
                'Operator',
                abstract='Exceedance/non-exceedance of historic threshold.',
                data_type='string',
                allowed_values=['exceedances', 'non-exceedances'],
                default='non-exceedances'),
            LiteralInput('season',
                         'Season',
                         abstract='Choose a season.',
                         data_type='string',
                         allowed_values=['summer', 'winter'],
                         default='winter'),
        ]
        outputs = [
            ComplexOutput(
                'plot',
                'Extreme spell duration tasmin plot',
                abstract='Generated extreme spell duration tasmin plot.',
                as_reference=True,
                supported_formats=[Format('image/png')]),
            ComplexOutput('data',
                          'Extreme spell duration tasmin data',
                          abstract='Extreme spell duration tasmin data.',
                          as_reference=True,
                          supported_formats=[Format('application/zip')]),
            ComplexOutput(
                'archive',
                'Archive',
                abstract=
                'The complete output of the ESMValTool processing as an zip archive.',
                as_reference=True,
                supported_formats=[Format('application/zip')]),
            *default_outputs(),
        ]

        super(HeatwavesColdwaves, self).__init__(
            self._handler,
            identifier="heatwaves_coldwaves",
            title="Heatwave and coldwave duration",
            version=runner.VERSION,
            abstract=
            """Metric showing the duration of heatwaves and coldwaves, to help understand potential changes in
                        energy demand. The estimated calculation time of this process is 4 minutes for the default
                        values supplied.""",
            metadata=[
                Metadata('ESMValTool', 'http://www.esmvaltool.org/'),
                Metadata(
                    'Documentation',
                    'https://esmvaltool.readthedocs.io/en/v2.0a2/recipes/recipe_heatwaves_coldwaves.html',
                    role=util.WPS_ROLE_DOC),
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True)
Beispiel #21
0
    def json(self, value):
        """init this request from json back again

        :param value: the json (not string) representation
        """

        self.operation = value['operation']
        self.version = value['version']
        self.language = value['language']
        self.identifier = value['identifier']
        self.identifiers = value['identifiers']
        self.store_execute = value['store_execute']
        self.status = value['status']
        self.lineage = value['lineage']
        self.outputs = value['outputs']
        self.raw = value['raw']
        self.inputs = {}

        for identifier in value['inputs']:
            inpt = None
            inpt_defs = value['inputs'][identifier]

            for inpt_def in inpt_defs:

                if inpt_def['type'] == 'complex':
                    inpt = ComplexInput(
                        identifier=inpt_def['identifier'],
                        title=inpt_def.get('title'),
                        abstract=inpt_def.get('abstract'),
                        workdir=inpt_def.get('workdir'),
                        data_format=Format(
                            schema=inpt_def['data_format'].get('schema'),
                            extension=inpt_def['data_format'].get('extension'),
                            mime_type=inpt_def['data_format']['mime_type'],
                            encoding=inpt_def['data_format'].get('encoding')),
                        supported_formats=[
                            Format(schema=infrmt.get('schema'),
                                   extension=infrmt.get('extension'),
                                   mime_type=infrmt['mime_type'],
                                   encoding=infrmt.get('encoding'))
                            for infrmt in inpt_def['supported_formats']
                        ],
                        mode=MODE.NONE)
                    inpt.file = inpt_def['file']
                elif inpt_def['type'] == 'literal':

                    allowed_values = []
                    for allowed_value in inpt_def['allowed_values']:
                        if allowed_value['type'] == 'anyvalue':
                            allowed_values.append(AnyValue())
                        elif allowed_value['type'] == 'novalue':
                            allowed_values.append(NoValue())
                        elif allowed_value['type'] == 'valuesreference':
                            allowed_values.append(ValuesReference())
                        elif allowed_value['type'] == 'allowedvalue':
                            allowed_values.append(
                                AllowedValue(
                                    allowed_type=allowed_value['allowed_type'],
                                    value=allowed_value['value'],
                                    minval=allowed_value['minval'],
                                    maxval=allowed_value['maxval'],
                                    spacing=allowed_value['spacing'],
                                    range_closure=allowed_value[
                                        'range_closure']))

                    inpt = LiteralInput(identifier=inpt_def['identifier'],
                                        title=inpt_def.get('title'),
                                        abstract=inpt_def.get('abstract'),
                                        data_type=inpt_def.get('data_type'),
                                        workdir=inpt_def.get('workdir'),
                                        allowed_values=AnyValue,
                                        uoms=inpt_def.get('uoms'),
                                        mode=inpt_def.get('mode'))
                    inpt.uom = inpt_def.get('uom')
                    inpt.data = inpt_def.get('data')

                elif inpt_def['type'] == 'bbox':
                    inpt = BBoxInput(identifier=inpt_def['identifier'],
                                     title=inpt_def['title'],
                                     abstract=inpt_def['abstract'],
                                     crss=inpt_def['crs'],
                                     dimensions=inpt_def['dimensions'],
                                     workdir=inpt_def['workdir'],
                                     mode=inpt_def['mode'])
                    inpt.ll = inpt_def['bbox'][0]
                    inpt.ur = inpt_def['bbox'][1]

            if identifier in self.inputs:
                self.inputs[identifier].append(inpt)
            else:
                self.inputs[identifier] = [inpt]
Beispiel #22
0
    def __init__(self):
        # this list contains variables from multiple reals, which our data finder cannot handle yet.
        # self.variables = ['ta', 'va', 'ua', 'hus', 'tas', 'psl', 'pr', 'tos', 'sic', 'tauu', 'tauv']
        self.variables = ['ta', 'va', 'ua', 'hus', 'tas', 'psl', 'pr']
        self.frequency = 'mon'

        inputs = [
            *model_experiment_ensemble(model='MPI-ESM-MR',
                                       experiment='historical',
                                       ensemble='r1i1p1',
                                       min_occurs=2,
                                       required_variables=self.variables,
                                       required_frequency=self.frequency),
            *year_ranges((1980, 1985), start_year=1979, end_year=2018),
            LiteralInput(
                'region',
                'Region',
                abstract="""Region over which to calculate the metric.""",
                data_type='string',
                allowed_values=[
                    'global', 'trop', 'nhext', 'shext', 'nhtrop', 'shtrop',
                    'nh', 'sh', 'nhmidlat', 'shmidlat', 'nhpolar', 'shpolar',
                    'eq'
                ],
                default='global',
            ),
            LiteralInput(
                'smpi_n_bootstrap',
                'Number of bootstrapping members',
                abstract="""
                    Number of bootstrapping members used to determine uncertainties on model-reference differences
                    (typical number of bootstrapping members: 100).
                """,
                data_type='integer',
                default=100,
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE, minval=1,
                    maxval=1000),
            ),
        ]
        outputs = [
            ComplexOutput(
                'smpi',
                'SMPI plot',
                abstract='Generated output plot of ESMValTool processing.',
                as_reference=True,
                supported_formats=[Format('image/png')]),
            ComplexOutput(
                'archive',
                'Archive',
                abstract=
                'The complete output of the ESMValTool processing as an zip archive.',
                as_reference=True,
                supported_formats=[Format('application/zip')]),
            *default_outputs(),
        ]

        super(SMPI, self).__init__(
            self._handler,
            identifier="smpi",
            title="Single Model Performance index",
            version=runner.VERSION,
            abstract="""
                This diagnostic calculates the Single Model Performance Index (SMPI) following Reichler and Kim (2008).
                The SMPI (called "I2") is based on the comparison of several different climate variables (atmospheric,
                surface and oceanic) between climate model simulations and observations or reanalyses, and it focuses
                on the validation of the time-mean state of climate.
                The estimated calculation time of this process is 10 minutes for the default values supplied.
            """,
            metadata=[
                Metadata('ESMValTool', 'http://www.esmvaltool.org/'),
                Metadata(
                    'Documentation',
                    'https://esmvaltool.readthedocs.io/en/v2.0a2/recipes/recipe_smpi.html',
                    role=util.WPS_ROLE_DOC,
                ),
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True)
    def __init__(self):
        inputs = [
            LiteralInput(
                'moninf',
                'First month month of the seasonal mean period',
                abstract=
                'The first month of the seasonal mean period to be computed, if none the monthly anomalies will be computed.',
                data_type='string',
                allowed_values=[
                    '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11',
                    '12', 'null'
                ],
                default='6'),
            LiteralInput(
                'monsup',
                'Last month month of the seasonal mean period',
                abstract=
                'the last month of the seasonal mean period to be computed, if none the monthly anomalies will be computed.',
                data_type='string',
                allowed_values=[
                    '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11',
                    '12'
                ],
                default='6'),
            LiteralInput(
                'agreement_threshold',
                'Agreement Threshold',
                abstract=
                'Integer between 0 and 100 indicating the threshold in percent for the minimum agreement between models on the sign of the multi-model mean anomaly for the stipling to be plotted.',
                data_type='integer',
                allowed_values=[i for i in range(0, 101)],
                default=80),
            LiteralInput(
                'running_mean',
                'Running Mean',
                abstract=
                'integer indictating the length of the window for the running mean to be computed.',
                data_type='integer',
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE, minval=1, maxval=365),
                default=5),
        ]
        self.plotlist = ['tas', 'Area']
        outputs = [
            *outputs_from_plot_names(self.plotlist),
            ComplexOutput(
                'data',
                'Data',
                abstract='Generated output data of ESMValTool processing.',
                as_reference=True,
                supported_formats=[FORMATS.NETCDF]),
            ComplexOutput(
                'archive',
                'Archive',
                abstract=
                'The complete output of the ESMValTool processing as an zip archive.',
                as_reference=True,
                supported_formats=[Format('application/zip')]),
            *default_outputs(),
        ]

        super(MultimodelProducts, self).__init__(
            self._handler,
            identifier="multimodel_products",
            title="Generic multi-model products",
            version=runner.VERSION,
            abstract="""For the 'generic multi-model diagnostic' the ensemble
                mean anomaly, and the ensemble variance and agreement are
                calculated. The results are shown as maps and time series.""",
            metadata=[
                Metadata('Estimated Calculation Time', '1 minute'),
                Metadata('ESMValTool', 'http://www.esmvaltool.org/'),
                Metadata(
                    'Documentation',
                    'https://esmvaltool.readthedocs.io/en/latest/recipes/recipe_multimodel_products.html',
                    role=util.WPS_ROLE_DOC),
                #                Metadata(
                #                    'Media',
                #                    util.diagdata_url() + '/multimodel_products/bsc_anomaly_timeseries.png',
                #                    role=util.WPS_ROLE_MEDIA),
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True)
Beispiel #24
0
    def __init__(self):
        self.variables = ['tasmax', 'tasmin', 'sfcWind', 'pr']
        self.frequency = 'day'

        inputs = [
            *model_experiment_ensemble(model='MPI-ESM-MR',
                                       experiment='rcp85',
                                       ensemble='r1i1p1',
                                       max_occurs=1,
                                       required_variables=self.variables,
                                       required_frequency=self.frequency),
            *year_ranges((1971, 2000),
                         start_name='start_historical',
                         end_name='end_historical'),
            *year_ranges((2020, 2040),
                         start_name='start_projection',
                         end_name='end_projection'),
            LiteralInput(
                'running_mean',
                'Running Mean',
                abstract=
                'Length of the window for which the running mean is computed.',
                data_type='integer',
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE, minval=1, maxval=365),
                default=5),
            LiteralInput(
                'start_longitude',
                'Start longitude',
                abstract='Minimum longitude.',
                data_type='integer',
                default=-60,
            ),
            LiteralInput(
                'end_longitude',
                'End longitude',
                abstract='Maximum longitude.',
                data_type='integer',
                default=40,
            ),
            LiteralInput(
                'start_latitude',
                'Start latitude',
                abstract='Minimum latitude.',
                data_type='integer',
                default=30,
            ),
            LiteralInput(
                'end_latitude',
                'End latitude',
                abstract='Maximum latitude.',
                data_type='integer',
                default=70,
            ),
        ]
        self.plotlist = [
            ('t10p', [Format('image/png')]),
            ('t90p', [Format('image/png')]),
            ('Wx', [Format('image/png')]),
            ('rx5day', [Format('image/png')]),
            ('cdd', [Format('image/png')]),
            ('combined', [Format('image/png')]),
        ]
        self.datalist = [
            ('t10p', [FORMATS.NETCDF]),
            ('t90p', [FORMATS.NETCDF]),
            ('Wx', [FORMATS.NETCDF]),
            ('rx5day', [FORMATS.NETCDF]),
            ('cdd', [FORMATS.NETCDF]),
            ('combined', [FORMATS.NETCDF]),
        ]
        outputs = [
            *outputs_from_plot_names(self.plotlist),
            *outputs_from_data_names(self.datalist),
            ComplexOutput(
                'archive',
                'Archive',
                abstract=
                'The complete output of the ESMValTool processing as an zip archive.',
                as_reference=True,
                supported_formats=[Format('application/zip')]),
            *default_outputs(),
        ]

        super(ExtremeIndex, self).__init__(
            self._handler,
            identifier="extreme_index",
            title="Combined Climate Extreme Index",
            version=runner.VERSION,
            abstract=
            """Metric showing extreme indices relevant to the insurance industry (heat, cold, wind, flood and
                        drought indices).""",
            metadata=[
                Metadata('ESMValTool', 'http://www.esmvaltool.org/'),
                Metadata(
                    'Documentation',
                    'https://esmvaltool.readthedocs.io/en/version2_development/recipes/recipe_combined_climate_extreme_index.html',  # noqa
                    role=util.WPS_ROLE_DOC),
                # Metadata('Media',
                #          util.diagdata_url() + '/risk_index/insurance_risk_indices.png',
                #          role=util.WPS_ROLE_MEDIA),
                Metadata('Estimated Calculation Time', '2 minutes'),
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True)
Beispiel #25
0
    def __init__(self):
        self.variables = ['pr']
        self.frequency = 'mon'
        inputs = [
            *model_experiment_ensemble(model='MPI-ESM-MR',
                                       experiment='historical',
                                       ensemble='r1i1p1',
                                       max_occurs=1,
                                       required_variables=self.variables,
                                       required_frequency=self.frequency),
            *year_ranges((1950, 2005)),
            LiteralInput(
                'running_mean',
                'Running Mean',
                abstract=
                'Length of the window for which the running mean is computed.',
                data_type='integer',
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE, minval=1, maxval=365),
                default=5),
            LiteralInput(
                'moninf',
                'First month month of the seasonal mean period',
                abstract=
                """First month of the seasonal mean period to be computed, if null the monthly anomalies
                            will be computed.""",
                data_type='string',
                allowed_values=[
                    '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11',
                    '12', 'null'
                ],
                default='1'),
            LiteralInput(
                'monsup',
                'Last month month of the seasonal mean period',
                abstract=
                """Last month of the seasonal mean period to be computed, if null the monthly anomalies
                            will be computed.""",
                data_type='string',
                allowed_values=[
                    '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11',
                    '12', 'null'
                ],
                default='3'),
            LiteralInput(
                'region',
                'Region',
                abstract='Region over which to calculate the metric.',
                data_type='string',
                allowed_values=['NAO', 'Nino3', 'Nino3.4', 'Nino4', 'SOI'],
                default='NAO'),
            LiteralInput(
                'standardized',
                'Standardized',
                abstract=
                'Boolean indictating if standardization should be computed.',
                data_type='boolean',
                default=True),
        ]
        outputs = [
            ComplexOutput('plot',
                          'Combined Indices plot',
                          abstract='Combined Indices plot.',
                          as_reference=True,
                          supported_formats=[Format('image/png')]),
            ComplexOutput('data',
                          'Data',
                          abstract='Generated combined indices data.',
                          as_reference=True,
                          supported_formats=[FORMATS.NETCDF]),
            ComplexOutput(
                'archive',
                'Archive',
                abstract=
                'The complete output of the ESMValTool processing as an zip archive.',
                as_reference=True,
                supported_formats=[Format('application/zip')]),
            *default_outputs(),
        ]

        super(CombinedIndices, self).__init__(
            self._handler,
            identifier="combined_indices",
            title="Single and multi-model indices based on area averages",
            version=runner.VERSION,
            abstract=
            """Metric showning single and multi model indices based on area averages.""",
            metadata=[
                Metadata('ESMValTool', 'http://www.esmvaltool.org/'),
                Metadata(
                    'Documentation',
                    'https://esmvaltool.readthedocs.io/en/version2_development/recipes/recipe_combined_climate_extreme_index.html',  # noqa
                    role=util.WPS_ROLE_DOC),
                Metadata('Estimated Calculation Time', '1 minute'),
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True,
        )
Beispiel #26
0
    def __init__(self):
        inputs = [
            LiteralInput('string',
                         'String',
                         data_type='string',
                         abstract='Enter a simple string.',
                         default="This is just a string",
                         mode=MODE.SIMPLE),
            LiteralInput(
                'int',
                'Integer',
                data_type='integer',
                abstract='Choose an integer number from allowed values.',
                default="7",
                allowed_values=[1, 2, 3, 5, 7, 11]),
            LiteralInput('float',
                         'Float',
                         data_type='float',
                         abstract='Enter a float number.',
                         default="3.14",
                         min_occurs=0,
                         max_occurs=5),
            # TODO: boolean default is not displayed in phoenix
            LiteralInput('boolean',
                         'Boolean',
                         data_type='boolean',
                         abstract='Make your choice :)',
                         default='1'),
            LiteralInput('angle',
                         'Angle',
                         data_type='angle',
                         abstract='Enter an angle [0, 360] :)',
                         default='90'),
            LiteralInput('time',
                         'Time',
                         data_type='time',
                         abstract='Enter a time like 12:00:00',
                         default='12:00:00'),
            LiteralInput('date',
                         'Date',
                         data_type='date',
                         abstract='Enter a date like 2012-05-01',
                         default='2012-05-01'),
            LiteralInput('datetime',
                         'Datetime',
                         data_type='dateTime',
                         abstract='Enter a datetime like 2016-09-02T12:00:00Z',
                         default='2016-09-02T12:00:00Z'),
            LiteralInput('string_choice',
                         'String Choice',
                         data_type='string',
                         abstract='Choose one item form list.',
                         allowed_values=['rock', 'paper', 'scissor'],
                         default='scissor'),
            LiteralInput('string_multiple_choice',
                         'String Multiple Choice',
                         abstract='Choose one or two items from list.',
                         data_type='string',
                         allowed_values=[
                             'sitting duck', 'flying goose', 'happy pinguin',
                             'gentle albatros'
                         ],
                         min_occurs=0,
                         max_occurs=2,
                         default='gentle albatros'),
            LiteralInput(
                'int_range',
                'Integer Range',
                abstract=
                'Choose number from range: 1-10 (step 1), 100-200 (step 10)',
                metadata=[
                    Metadata(
                        'AllowedValue PyWPS Docs',
                        'https://pywps.readthedocs.io/en/master/api.html#pywps.inout.literaltypes.AllowedValue'
                    ),  # noqa
                    Metadata(
                        'AllowedValue Example',
                        'http://docs.opengeospatial.org/is/14-065/14-065.html#98'
                    ),  # noqa
                ],
                data_type='integer',
                default='1',
                allowed_values=[
                    AllowedValue(minval=1, maxval=10),
                    AllowedValue(minval=100, maxval=200, spacing=10)
                ],
                mode=MODE.SIMPLE,
            ),
            LiteralInput(
                'any_value',
                'Any Value',
                abstract='Enter any value.',
                metadata=[
                    Metadata(
                        'AnyValue PyWPS Docs',
                        'https://pywps.readthedocs.io/en/master/api.html#pywps.inout.literaltypes.AnyValue'
                    ),  # noqa
                ],
                allowed_values=AnyValue(),
                default='any value',
                mode=MODE.SIMPLE,
            ),
            LiteralInput(
                'ref_value',
                'Referenced Value',
                abstract='Choose a referenced value',
                metadata=[
                    Metadata(
                        'PyWPS Docs',
                        'https://pywps.readthedocs.io/en/master/_modules/pywps/inout/literaltypes.html'
                    ),  # noqa
                ],
                data_type='string',
                allowed_values=ValuesReference(
                    reference=
                    "https://en.wikipedia.org/w/api.php?action=opensearch&search=scotland&format=json"
                ),  # noqa
                default='Scotland',
                mode=MODE.SIMPLE,
            ),
            # TODO: bbox is not supported yet by owslib
            # BoundingBoxInput('bbox', 'Bounding Box',
            #                  abstract='Bounding Box with EPSG:4326 and EPSG:3035.',
            #                  crss=['epsg:4326', 'epsg:3035'],
            #                  min_occurs=0),
            ComplexInput(
                'text',
                'Text',
                abstract='Enter a URL pointing to a text document (optional)',
                metadata=[Metadata('Info')],
                min_occurs=0,
                supported_formats=[Format('text/plain')]),
            ComplexInput(
                'dataset',
                'Dataset',
                abstract="Enter a URL pointing to a NetCDF file (optional)",
                metadata=[
                    Metadata(
                        'NetCDF Format',
                        'https://en.wikipedia.org/wiki/NetCDF',
                        role=
                        'http://www.opengis.net/spec/wps/2.0/def/process/description/documentation'
                    )
                ],
                min_occurs=0,
                supported_formats=[FORMATS.NETCDF]),
        ]
        outputs = [
            LiteralOutput('string', 'String', data_type='string'),
            LiteralOutput('int', 'Integer', data_type='integer'),
            LiteralOutput('float', 'Float', data_type='float'),
            LiteralOutput('boolean', 'Boolean', data_type='boolean'),
            LiteralOutput('angle', 'Angle', data_type='angle'),
            LiteralOutput('time', 'Time', data_type='time'),
            LiteralOutput('date', 'Date', data_type='date'),
            LiteralOutput('datetime', 'DateTime', data_type='dateTime'),
            LiteralOutput('string_choice', 'String Choice',
                          data_type='string'),
            LiteralOutput('string_multiple_choice',
                          'String Multiple Choice',
                          data_type='string'),
            LiteralOutput('int_range', 'Integer Range', data_type='integer'),
            LiteralOutput('any_value', 'Any Value', data_type='string'),
            LiteralOutput('ref_value', 'Referenced Value', data_type='string'),
            ComplexOutput('text',
                          'Text',
                          abstract='Copy of input text file.',
                          as_reference=False,
                          supported_formats=[
                              FORMATS.TEXT,
                          ]),
            ComplexOutput('dataset',
                          'Dataset',
                          abstract='Copy of input netcdf file.',
                          as_reference=True,
                          supported_formats=[FORMATS.NETCDF, FORMATS.TEXT]),
            BoundingBoxOutput('bbox', 'Bounding Box', crss=['epsg:4326']),
        ]

        super(InOut, self).__init__(
            self._handler,
            identifier="inout",
            title="In and Out",
            version="1.0",
            abstract="Testing all WPS input and output parameters.",
            # profile=['birdhouse'],
            metadata=[
                Metadata('Birdhouse', 'http://bird-house.github.io/'),
                MetadataUrl(
                    'User Guide',
                    'http://emu.readthedocs.io/en/latest/',
                    role=
                    'http://www.opengis.net/spec/wps/2.0/def/process/description/documentation',
                    anonymous=True),
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True)
    def test_combined_validator(self):
        """Test allowed values - ranges and values combination"""

        allowed_value1 = AllowedValue()
        allowed_value1.allowed_type = ALLOWEDVALUETYPE.RANGE
        allowed_value1.minval = 1
        allowed_value1.maxval = 11
        allowed_value1.spacing = 2
        allowed_value1.range_closure = RANGECLOSURETYPE.OPEN

        allowed_value2 = AllowedValue()
        allowed_value2.allowed_type = ALLOWEDVALUETYPE.VALUE
        allowed_value2.value = 15

        inpt = get_input(allowed_values = [allowed_value1, allowed_value2])

        inpt.data = 1
        self.assertTrue(validate_allowed_values(inpt, MODE.SIMPLE), 'Range OPEN closure')

        inpt.data = 15
        self.assertTrue(validate_allowed_values(inpt, MODE.SIMPLE), 'AllowedValue')

        inpt.data = 13
        self.assertFalse(validate_allowed_values(inpt, MODE.SIMPLE), 'Out of range')
Beispiel #28
0
    def __init__(self):
        # more correctly the variable depends on the settings
        self.variables = ['psl', 'tas']
        self.frequency = 'mon'
        inputs = [
            *model_experiment_ensemble(model='ACCESS1-0',
                                       experiment='historical',
                                       ensemble='r1i1p1',
                                       max_occurs=1,
                                       required_variables=self.variables,
                                       required_frequency=self.frequency),
            *year_ranges((1999, 2001)),
            LiteralInput('variable',
                         'Variable',
                         abstract='Select the variable to simulate.',
                         data_type='string',
                         default='psl',
                         allowed_values=['psl', 'tas']),
            *region(-40, 40, 30, 50),
            LiteralInput(
                'beta',
                'Beta',
                abstract='User defined underdispersion (beta >= 0).',
                data_type='float',
                default=0.7,
            ),
            LiteralInput(
                'number_of_members',
                'Number of members',
                abstract='Number of members to be generated.',
                data_type='integer',
                default=2,
                allowed_values=AllowedValue(
                    allowed_type=ALLOWEDVALUETYPE.RANGE, minval=1,
                    maxval=1000),
            ),
        ]
        # self.plotlist = [
        #     'TM90', 'NumberEvents', 'DurationEvents', 'LongBlockEvents', 'BlockEvents', 'ACN', 'CN', 'BI', 'MGI',
        #     'Z500', 'ExtraBlock', 'InstBlock'
        # ]
        outputs = [
            # *outputs_from_plot_names(self.plotlist),
            ComplexOutput('plot',
                          'Toy Model plot',
                          abstract='Generated synthetic model plt.',
                          as_reference=True,
                          supported_formats=[Format('image/jpeg')]),
            ComplexOutput('model',
                          'Toy Model',
                          abstract='Generated synthetic model.',
                          as_reference=True,
                          supported_formats=[FORMATS.NETCDF]),
            ComplexOutput(
                'archive',
                'Archive',
                abstract=
                'The complete output of the ESMValTool processing as an zip archive.',
                as_reference=True,
                supported_formats=[Format('application/zip')]),
            *default_outputs(),
        ]

        super(Toymodel, self).__init__(
            self._handler,
            identifier="toymodel",
            title="Toymodel",
            version=runner.VERSION,
            abstract=
            """The goal of this diagnostic is to simulate single-model ensembles from an observational dataset
                        to investigate the effect of observational uncertainty.
                        The estimated calculation time of this process is 30 seconds for the default values supplied.
                        """,
            metadata=[
                Metadata('ESMValTool', 'http://www.esmvaltool.org/'),
                Metadata(
                    'Documentation',
                    'https://esmvaltool.readthedocs.io/en/v2.0a2/recipes/recipe_toymodel.html',
                    role=util.WPS_ROLE_DOC,
                ),
            ],
            inputs=inputs,
            outputs=outputs,
            status_supported=True,
            store_supported=True)