from IPython.display import Image
Image(url='https://vesg.ipsl.upmc.fr/thredds/fileServer/IPSLFS/jservon/CliMAF_Notebooks_html/CliMAF-logo-small.png')
from climaf.api import *
clog('critical') # min verbosity = critical < warning < info < debug = max verbosity
dat = ds(project='CMIP5', model='CNRM-CM5', experiment='historical', frequency='monthly', version='v20130101',
period='1980-2005', variable='tos', realm='ocean' )
summary(dat)
myplot = plot(time_average(dat))
iplot(myplot)
myplot = plot(time_average(dat),
title='My CliMAF plot',
gsnLeftString=dat.variable,
gsnCenterString=dat.period,
gsnRightString=dat.model)
iplot(myplot)
myplot = plot(time_average(dat),
# -- Title
title='My CliMAF plot',
tiMainFontHeightF=0.03,#default = 0.025
# -- Subtitles
gsnLeftString=dat.variable,
gsnCenterString=dat.period,
gsnRightString=dat.model,
gsnStringFontHeightF=0.02, #default=0.012
)
iplot(myplot)
myplot = plot(time_average(dat),
# -- Title
title='My CliMAF plot',
tiMainFontHeightF=0.03,#default = 0.025
# -- Subtitles
gsnLeftString=dat.variable,
gsnCenterString=dat.period,
gsnRightString=dat.model,
gsnStringFontHeightF=0.02, #default=0.012
# -- Colorpalette
color='WhViBlGrYeOrRe',
# -- Add contours
contours=1,
# -- Isolines
min=-1,max=30,delta=1,
# -- And add an offset to switch from K to degC
offset = -273.15
)
iplot(myplot)
myplot = plot(regridn(time_average(dat),cdogrid='r360x180'),
# -- Title
title='My CliMAF plot',
tiMainFontHeightF=0.03,#default = 0.025
# -- Subtitles
gsnLeftString=dat.variable,
gsnCenterString=dat.period,
gsnRightString=dat.model,
gsnStringFontHeightF=0.02, #default=0.012
# -- Colorpalette
color='WhViBlGrYeOrRe',
# -- Add contours
contours=1,
# -- Isolines
min=-1,max=30,delta=1,
# -- And add an offset to switch from K to degC
offset = -273.15,
# -- Longitude in the middle of the plot
mpCenterLonF=200,
# -- Grey on lands
focus='ocean'
)
iplot(myplot)
myplot = plot(regridn(time_average(dat),cdogrid='r360x180'),
# -- Title
title='My CliMAF plot',
tiMainFontHeightF=0.03,#default = 0.025
# -- Subtitles
gsnLeftString=dat.variable,
gsnCenterString=dat.period,
gsnRightString=dat.model,
gsnStringFontHeightF=0.02, #default=0.012
# -- Colorpalette
color='WhViBlGrYeOrRe',
# -- Add contours
contours=1,
# -- Isolines
min=-1,max=30,delta=1,
# -- And add an offset to switch from K to degC
offset = -273.15,
# -- Longitude in the middle of the plot
mpCenterLonF=200,
# -- Grey on lands
focus='ocean',
# -- OPTIONS
options='pmLabelBarWidthF=0.065'
#options='pmLabelBarWidthF=0.065|'+\
# 'pmLabelBarOrthogonalPosF=0.01|'+\
# 'lbLabelFontHeightF=0.01|'+\
# 'tmXBLabelFontHeightF=0.01|'+\
# 'tmYLLabelFontHeightF=0.01'
)
iplot(myplot)
myplot = plot(regridn(time_average(dat),cdogrid='r90x45'), # --> Interpolate to coarser grid to see the raster
# -- Title
title='Raster plot with CliMAF',
tiMainFontHeightF=0.03,#default = 0.025
# -- Subtitles
gsnLeftString=dat.variable,
gsnCenterString=dat.period,
gsnRightString=dat.model,
gsnStringFontHeightF=0.02, #default=0.012
# -- Colorpalette
color='WhViBlGrYeOrRe',
# -- deactivate the contours
# contours=1,
# -- Isolines
min=-1,max=30,delta=1,
# -- And add an offset to switch from K to degC
offset = -273.15,
# -- Longitude in the middle of the plot
mpCenterLonF=200,
# -- Grey on lands
focus='ocean',
# -- Use OPTIONS for the argument of the Raster plot
options='cnFillMode=RasterFill|cnRasterSmoothingOn=False'
)
iplot(myplot)
# --> Set proj to 'NH' or 'SH'; the two additionnal characters set the last latitude visible
projNH = 'NH20'
myplotNH = plot(regridn(clim_average(dat,'ANM'),cdogrid='r360x180'),
# -- Title
title=projNH+' plot',
tiMainFontHeightF=0.03,#default = 0.025
# -- Subtitles
gsnLeftString=dat.variable,
gsnCenterString=dat.period,
gsnRightString=dat.model,
gsnStringFontHeightF=0.02, #default=0.012
# -- Colorpalette
color='WhViBlGrYeOrRe',
# -- Add contours
contours=1,
# -- Isolines
min=-1,max=30,delta=1,
# -- And add an offset to switch from K to degC
offset = -273.15,
# -- Longitude in the middle of the plot
mpCenterLonF=200,
# -- Grey on lands
focus='ocean',
# -- Northern Hemisphere projection
proj=projNH
)
projSH = 'SH60'
myplotSH = plot(regridn(clim_average(dat,'ANM'),cdogrid='r360x180'),
# -- Title
title=projSH+' plot',
tiMainFontHeightF=0.03,#default = 0.025
# -- Subtitles
gsnLeftString=dat.variable,
gsnCenterString=dat.period,
gsnRightString=dat.model,
gsnStringFontHeightF=0.02, #default=0.012
# -- Colorpalette
color='WhViBlGrYeOrRe',
# -- Add contours
contours=1,
# -- Isolines
min=-1,max=30,delta=1,
# or: colors='-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30'
# -- And add an offset to switch from K to degC
offset = -273.15,
# -- Longitude in the middle of the plot
mpCenterLonF=200,
# -- Grey on lands
focus='ocean',
# -- Northern Hemisphere projection
proj=projSH,
)
iplot(cpage(fig_lines=[[myplotNH,myplotSH]]))
# -- Get an auxillary file
aux = ds(project='CMIP5', model='CNRM-CM5', experiment='historical', frequency='monthly', version='v20130101',
period='1980-2005', variable='sic')#, realm='ocean' )
summary(aux)
# --> Provide the auxillary field as a second argument
myplotNH = plot(time_average(dat),
# -- Auxillary field provided as a second argument
time_average(aux),
# -- Add contours
contours='1 5 10 15',
# -- Handle options on the auxillary field
aux_options='cnLineThicknessF=8|cnLineColor=Red',
# -- Title
title='SST + Sea Ice contours',
tiMainFontHeightF=0.03,#default = 0.025
# -- Subtitles
gsnLeftString=dat.variable,
gsnCenterString=dat.period,
gsnRightString=dat.model,
gsnStringFontHeightF=0.02, #default=0.012
# -- Colorpalette
color='WhViBlGrYeOrRe',
# -- Isolines
min=-1,max=30,delta=1,
# -- And add an offset to switch from K to degC
offset = -273.15,
# -- Longitude in the middle of the plot
mpCenterLonF=200,
# -- Grey on lands
focus='ocean',
# -- Northern Hemisphere projection
proj='NH50'
)
iplot(myplotNH)
tauu = ds(project='CMIP5', model='CNRM-CM5', experiment='historical', frequency='monthly', version='v20130101',
period='1980-2005', variable='tauuo')
tauv = ds(project='CMIP5', model='CNRM-CM5', experiment='historical', frequency='monthly', version='v20130101',
period='1980-2005', variable='tauvo')
summary(tauv)
myplot = plot(regridn(time_average(dat),cdogrid='r360x180'),
# -- Specific to the plot of wind vectors:
None,
time_average(tauu),time_average(tauv),
vcRefLengthF=0.005, vcRefMagnitudeF=0.03,vcMinDistanceF=0.01,vcLineArrowColor='White',
# -- Title
title='My CliMAF plot',
tiMainFontHeightF=0.03,#default = 0.025
# -- Subtitles
gsnLeftString=dat.variable,
gsnCenterString=dat.period,
gsnRightString=dat.model,
gsnStringFontHeightF=0.02, #default=0.012
# -- Colorpalette
color='WhViBlGrYeOrRe',
# -- Add contours
contours=1,
# -- Isolines
min=-1,max=30,delta=1,
# -- And add an offset to switch from K to degC
offset = -273.15,
# -- Longitude in the middle of the plot
mpCenterLonF=200,
# -- Grey on lands
focus='ocean'
)
iplot(myplot)
myplot = plot(regridn(time_average(dat),cdogrid='r360x180'),
# -- Pattern
regridn(time_average(dat),cdogrid='r360x180'),
shade_above = 298,
#shade_below = 5,
#offset_aux = -273.15,
#shading_options='gsnShadeHigh=6',
# https://www.ncl.ucar.edu/Document/Graphics/Images/fillpatterns.png
# -- Title
title='My CliMAF plot',
tiMainFontHeightF=0.03,#default = 0.025
# -- Subtitles
gsnLeftString=dat.variable,
gsnCenterString=dat.period,
gsnRightString=dat.model,
gsnStringFontHeightF=0.02, #default=0.012
# -- Colorpalette
color='WhViBlGrYeOrRe',
# -- Add contours
#contours=1,
# -- Isolines
min=-1,max=30,delta=1,
# -- And add an offset to switch from K to degC
offset = -273.15,
# -- Longitude in the middle of the plot
mpCenterLonF=200,
# -- Grey on lands
focus='ocean'
)
iplot(myplot)
rgrd_dat = regridn(time_average(dat),cdogrid='r360x180')
myplot = plot(llbox(rgrd_dat,lonmin=-90,lonmax=20,latmin=0,latmax=90), title='North Atlantic')
iplot(myplot)
# -- A zonal field
## Add the contours of an auxillary file
ua_dat = ds(project='CMIP5', model='CNRM-CM5', experiment='historical', frequency='monthly', version='latest',
period='1980-2005', variable='ua')#, realm='ocean' )
summary(ua_dat)
zonmean_plot = plot(zonmean(clim_average(ua_dat,'ANM')),title='Zonal Wind Speed',contours=1,y='lin')
iplot(zonmean_plot)
see all projections here: https://www.ncl.ucar.edu/Document/Graphics/map_projections.shtml
pp = dict(gsnLeftString=dat.variable,
gsnCenterString=dat.period,
gsnRightString=dat.model)
proj = 'CylindricalEqualArea'
p1 = plot(time_average(dat), title=proj, proj=proj, **pp)
proj = 'Robinson'
p2 = plot(time_average(dat), title=proj, proj=proj, **pp)
proj = 'Mollweide'
p3 = plot(time_average(dat), title=proj, proj=proj, **pp)
proj = 'Orthographic'
p4 = plot(time_average(dat), title=proj, proj=proj, **pp)
iplot(cpage(fig_lines = [[p1,p2],[p3,p4]]))
pp = dict(gsnLeftString=dat.variable,
gsnCenterString=dat.period,
gsnRightString=dat.model,
)
p1 = plot(time_average(dat), proj='Satellite',
title='mpSatelliteDistF=3.0',
options='mpCenterLonF=-40.|mpCenterLatF=45.|mpSatelliteDistF=3.0',
**pp
)
p2 = plot(time_average(dat), proj='Satellite',
title='mpSatelliteDistF=2.0',
options='mpCenterLonF=-40.|mpCenterLatF=45.|mpSatelliteDistF=2.0',
**pp
)
p3 = plot(time_average(dat), proj='Satellite',
title='mpSatelliteDistF=5.0',
options='mpCenterLonF=-40.|mpCenterLatF=45.|mpSatelliteDistF=5.0',
**pp
)
p4 = plot(time_average(dat), proj='Satellite',
title='mpCenterLonF=130.|mpCenterLatF=-25.',
options='mpCenterLonF=130.|mpCenterLatF=-25.|mpSatelliteDistF=3.0',
**pp
)
p5 = plot(time_average(dat), proj='Satellite',
title='mpCenterLonF=295.|mpCenterLatF=-10.',
options='mpCenterLonF=295.|mpCenterLatF=-10.|mpSatelliteDistF=3.0',
**pp
)
iplot(cpage(fig_lines=[[p1,p2,p3],[p4,p5,None]]))