Compute Maximum Temperature to find Heat Waves
Download Jupyter Notebook file here
#Compute Maximum Temperature to find Heat Waves
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 1980 to August 2016
domain_data = { 'id': 'd0', 'lat': {'start':46, 'end':47,'crs':'values'},
'lon': {'start':5, 'end':15, 'crs':'values'},
'time':{'start':'1980-06-01T00:00:00', 'end':'2016-08-31T23:00:00', 'crs':'timestamps'}}
d0 = cwt.Domain.from_dict(domain_data)
# Set the input data to be monthly CFSR surface temperature data (variable tas)
inputs = cwt.Variable("collection://cip_cfsr_mth", "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 )
op.set_inputs( inputs )
self.wps.execute( op, domains=[d0], async=True )
dataPaths = self.wps.download_result(op)
# Plot maximum surface temperature versus time
for dataPath in dataPaths:
self.plotter.mpl_timeplot(dataPath)
executor = TestWorkflow()
executor.spatial_max()
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 1980 to August 2016
domain_data = { 'id': 'd0', 'lat': {'start':46, 'end':47,'crs':'values'},
'lon': {'start':5, 'end':15, 'crs':'values'},
'time':{'start':'1980-06-01T00:00:00', 'end':'2016-08-31T23:00:00', 'crs':'timestamps'}}
d0 = cwt.Domain.from_dict(domain_data)
# Set the input data to be monthly CFSR surface temperature data (variable tas)
inputs = cwt.Variable("collection://cip_cfsr_mth", "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 )
op.set_inputs( inputs )
self.wps.execute( op, domains=[d0], async=True )
dataPaths = self.wps.download_result(op)
# Plot maximum surface temperature versus time
for dataPath in dataPaths:
self.plotter.mpl_timeplot(dataPath)
executor = TestWorkflow()
executor.spatial_max()