from malleefowl.process import WPSProcess from malleefowl import wpslogging as logging logger = logging.getLogger(__name__) class modelUncertainty(WPSProcess): def __init__(self): # definition of this process WPSProcess.__init__( self, identifier="modelUncertainty", title="Robustness of modelled signal change", version="0.1", metadata=[{ "title": "LSCE", "href": "http://www.lsce.ipsl.fr/" }], abstract= "Calculates whether the magnitude of the ensemble mean is larger than the ensemble standard deviation.", ) # input arguments self.resource = self.addComplexInput( identifier="resource", title="NetCDF Files", abstract="NetCDF Files", minOccurs=1, maxOccurs=100, maxmegabites=5000, formats=[{ "mimeType": "application/x-netcdf"
from malleefowl import wpslogging as logging logger = logging.getLogger(__name__) def modelUncertaintyWorker(resource): """retuns the result :param resource: list of pathes to netCDF files """ from cdo import Cdo cdo = Cdo() from flyingpigeon.utils import check_timestepps # check resource for consistency resource_qc = check_timestepps(resource) try: # ensemble mean and magnitude nc_ensmean = cdo.ensmean(input = resource_qc, output = 'nc_ensmean.nc') logger.info('ensmean calculations done') except Exception as e: logger.error('ensmean calculations failed: %s ' % e ) try: #nc_delta = nc_ensmean(lastpt) - nc_ensmean(firstpt) nc_laststep = cdo.seltimestep('-1', input = nc_ensmean, output = 'nc_laststep.nc') nc_firststep = cdo.seltimestep(1, input = nc_ensmean, output = 'nc_firststep.nc') nc_delta = cdo.sub(input = [nc_laststep, nc_firststep], output = 'nc_delta.nc') nc_absdelta = cdo.abs(input = nc_delta, output = 'nc_absdelta.nc') logger.info('delta calculation done') except Exception as e: logger.error('delta calculation failed: %s ' % e )