Compute Maximum Temperature to Investigate 2003 European Heat Wave

Graph image

Download Jupyter Notebook file here

#Compute Maximum Temperature to Investigate 2003 European Heat Wave

import cwt, os

class TestWorkflow:

    plotter = cwt.initialize()
    host ="https://edas.nccs.nasa.gov/wps/cwt"
    wps = cwt.WPS( host, log=True,log_file=os.path.expanduser("~/esgf_api.log"), verify=False )

    def spatial_max( self ):

# Set the domain to be Europe, from June 2002 to August 2002
       
        domain_data = { 'id': 'd0', 'lat': {'start':46,'end':47,'crs':'values'},
                        'lon': {'start':5, 'end':15, 'crs':'values'},
                        'time':{'start':'2002-06-01T00:00:00', 'end':'2002-08-31T23:00:00', 'crs':'timestamps'}}

        d0 = cwt.Domain.from_dict(domain_data)

# Set the input data to be monthly ERA-Interim surface temperature data (variable tas)

        inputs = cwt.Variable("collection://cip_eraint_6hr", "tas",domain=d0 )

# Set the operation to be "max", operating over the xy axes

        op_data = { 'name': "xarray.max", 'axes': "xy" }
        op = cwt.Process.from_dict( op_data ) # """:type : Process """
        op.set_inputs( inputs )

        self.wps.execute( op, domains=[d0], async=True )
        dataPath1 = self.wps.download_result(op)

# Set the domain to be Europe, from June 2003 to August 2003

        domain_data = { 'id': 'd1', 'lat': {'start':46,'end':47,'crs':'values'},
                        'lon': {'start':5, 'end':15, 'crs':'values'},
                        'time':{'start':'2003-06-01T00:00:00','end':'2003-08-31T23:00:00', 'crs':'timestamps'}}

        d1 = cwt.Domain.from_dict(domain_data)

# Set the input data to be monthly ERA-Interim surface temperature data (variable tas)

        inputs1 = cwt.Variable("collection://cip_eraint_6hr", "tas",domain=d1 )

# Set the operation to be "max", operating over the xy axes

        op_data1 = { 'name': "xarray.max", 'axes': "xy" }
        op1 = cwt.Process.from_dict( op_data1 ) # """:type : Process """
        op1.set_inputs( inputs1 )

        self.wps.execute( op1, domains=[d1], async=True )
        dataPath2 = self.wps.download_result(op1)

# Plot maximum surface temperature vs time for both 2002 and 2003

        for dataPath in dataPath1:
            self.plotter.mpl_timeplot(dataPath)
        for dataPath in dataPath2:
            self.plotter.mpl_timeplot(dataPath)

executor = TestWorkflow()
executor.spatial_max()