-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* using aggregation type * update average tests * using latest daops * use average_time * added average_dim process * added test for average_dim process * added average test with lat/lon * added workflow test for average latlon * added orchestrate test for average latlon * use dims parameter in wps process * update smoke tests for average operator
- Loading branch information
Showing
22 changed files
with
406 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
from .wps_usage import Usage | ||
from .wps_dashboard import DashboardProcess | ||
from .wps_average import Average | ||
from .wps_average_time import AverageByTime | ||
from .wps_average_dim import AverageByDimension | ||
from .wps_orchestrate import Orchestrate | ||
from .wps_subset import Subset | ||
|
||
processes = [ | ||
Usage(), | ||
DashboardProcess(), | ||
Subset(), | ||
Average(), | ||
AverageByTime(), | ||
AverageByDimension(), | ||
Orchestrate(), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import logging | ||
import os | ||
|
||
from pywps import FORMATS, ComplexOutput, Format, LiteralInput, Process | ||
from pywps.app.Common import Metadata | ||
from pywps.app.exceptions import ProcessError | ||
from pywps.inout.outputs import MetaFile, MetaLink4 | ||
|
||
from ..director import wrap_director | ||
from ..utils.input_utils import parse_wps_input | ||
from ..utils.metalink_utils import build_metalink | ||
from ..utils.response_utils import populate_response | ||
from ..utils.average_utils import run_average_by_dim | ||
|
||
LOGGER = logging.getLogger() | ||
|
||
|
||
class AverageByDimension(Process): | ||
def __init__(self): | ||
inputs = [ | ||
LiteralInput( | ||
"collection", | ||
"Collection", | ||
abstract="A dataset identifier or list of comma separated identifiers. " | ||
"Example: c3s-cmip5.output1.ICHEC.EC-EARTH.historical.day.atmos.day.r1i1p1.tas.latest", | ||
data_type="string", | ||
min_occurs=1, | ||
max_occurs=1, | ||
), | ||
LiteralInput( | ||
"dims", | ||
"Dimensions", | ||
abstract="Dimensions used for aggregation. Example: level", | ||
allowed_values=["time", "level", "latitude", "longitude"], | ||
data_type="string", | ||
min_occurs=1, | ||
max_occurs=4, | ||
), | ||
LiteralInput( | ||
"pre_checked", | ||
"Pre-Checked", | ||
data_type="boolean", | ||
abstract="Use checked data only.", | ||
default="0", | ||
min_occurs=1, | ||
max_occurs=1, | ||
), | ||
LiteralInput( | ||
"apply_fixes", | ||
"Apply Fixes", | ||
data_type="boolean", | ||
abstract="Apply fixes to datasets.", | ||
default="1", | ||
min_occurs=1, | ||
max_occurs=1, | ||
), | ||
] | ||
outputs = [ | ||
ComplexOutput( | ||
"output", | ||
"METALINK v4 output", | ||
abstract="Metalink v4 document with references to NetCDF files.", | ||
as_reference=True, | ||
supported_formats=[FORMATS.META4], | ||
), | ||
ComplexOutput( | ||
"prov", | ||
"Provenance", | ||
abstract="Provenance document using W3C standard.", | ||
as_reference=True, | ||
supported_formats=[FORMATS.JSON], | ||
), | ||
ComplexOutput( | ||
"prov_plot", | ||
"Provenance Diagram", | ||
abstract="Provenance document as diagram.", | ||
as_reference=True, | ||
supported_formats=[ | ||
Format("image/png", extension=".png", encoding="base64") | ||
], | ||
), | ||
] | ||
|
||
super(AverageByDimension, self).__init__( | ||
self._handler, | ||
identifier="average_dim", | ||
title="Average by Dimensions", | ||
abstract="Run averaging by dimensions on climate model data.", | ||
metadata=[ | ||
Metadata("DAOPS", "https://github.com/roocs/daops"), | ||
], | ||
version="1.0", | ||
inputs=inputs, | ||
outputs=outputs, | ||
store_supported=True, | ||
status_supported=True, | ||
) | ||
|
||
def _handler(self, request, response): | ||
# show me the environment used by the process in debug mode | ||
LOGGER.debug(f"Environment used in average: {os.environ}") | ||
|
||
# from roocs_utils.exceptions import InvalidParameterValue, MissingParameterValue | ||
collection = parse_wps_input( | ||
request.inputs, "collection", as_sequence=True, must_exist=True | ||
) | ||
|
||
inputs = { | ||
"collection": collection, | ||
"output_dir": self.workdir, | ||
"apply_fixes": parse_wps_input(request.inputs, "apply_fixes", default=True), | ||
"pre_checked": parse_wps_input( | ||
request.inputs, "pre_checked", default=False | ||
), | ||
"dims": parse_wps_input( | ||
request.inputs, "dims", as_sequence=True, default=None | ||
), | ||
} | ||
print(inputs) | ||
|
||
# Let the director manage the processing or redirection to original files | ||
director = wrap_director(collection, inputs, run_average_by_dim) | ||
|
||
ml4 = build_metalink( | ||
"average-dim-result", | ||
"Averaging by dimension result as NetCDF files.", | ||
self.workdir, | ||
director.output_uris, | ||
) | ||
|
||
populate_response( | ||
response, "average_dim", self.workdir, inputs, collection, ml4 | ||
) | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.