[ncl-talk] How to use time metadata / change time tick labels using gsn_csm_contour?

Hemming, Michael michael.hemming at mpimet.mpg.de
Fri Aug 8 03:16:00 MDT 2014


Hello,

I am creating panel plots using gsn_csm_contour. The data I use has been chosen from a 4d matrix prior to plotting. The metadata is correct for longitude but not for the time axis. I would like to show the time in years, 1-100.

time metadata:

tho = hours, 365_day
potT = days, preleptic_gregorian


Here is my code:


load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

begin

;##########################################################################
;##########################################################################
;-------------------------Temperature Profile------------------------------
;--------------------------------------------------------------------------
;##########################################################################
;##########################################################################

;----------Load in data

;MPIOM

data12              = addfile ("sector.nc", "r")
tho              = data12->tho


variables          = getfilevarnames(data12)

print("                                ")
print(" MPIOM temperature data Information:")
print("                                ")
print(variables)
printVarSummary(tho)

;ICON

noshupw             = addfile ("con.nc", "r")
potT             = noshupw->t_acc
potT&lon             = potT&lon-360     ; Fix the longitudes to be < 360


;variables          = getfilevarnames(noshupw)
print("                                ")
print("ICON temperature data information:")
print("                                ")
print(variables)
printVarSummary(potT)


;--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%
;--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%

;--------------Hovmuller T comparison plots

;--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%
;--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%--%

;http://www.ncl.ucar.edu/Applications/Scripts/lat_time_3.ncl

;*********************************************
; manipulate data for plotting
;*********************************************

dm      = rm_single_dims(tho({depth|7},{lon|-30:-30},lat|:,time|:))
di    = rm_single_dims(potT({depth|7},{lon|-30:-30},lat|:,time|:))

dm30S   = rm_single_dims(tho({depth|7},lon|:,{lat|-30:-30},time|:))
di30S    = rm_single_dims(potT({depth|7},lon|:,{lat|-30:-30},time|:))

dmeq   = rm_single_dims(tho({depth|7},lon|:,{lat|0:0},time|:))
dieq    = rm_single_dims(potT({depth|7},lon|:,{lat|0:0},time|:))

dm30N   = rm_single_dims(tho({depth|7},lon|:,{lat|30:30},time|:))
di30N    = rm_single_dims(potT({depth|7},lon|:,{lat|30:30},time|:))


printVarSummary(dm)
printVarSummary(di)
printVarSummary(dm30S)
printVarSummary(di30S)

;------Plotting

wks = gsn_open_wks("x11", "T)

res                          =    True
res at cnFillOn                        =    True

plot                            =    new(2,graphic)

res at gsnDraw                      = False                          ; don't draw
res at gsnFrame                         = False                          ; don't advance frame

resP                              = True                           ; modify the panel plot
resP at gsnMaximize                        = True
res at tiMainFontHeightF                         = 0.02
resP at txFontHeightF                            = 0.015
resP at txString                     = "Temperature at the surface with time at a longitude of 30W"

res at tiMainString                  =    "M"
plot(0) = gsn_csm_contour(wks,dm,res)

res at tiMainString                  =    "I"
plot(1) = gsn_csm_contour(wks,di,res)

;gsn_panel(wks,plot,(/1,2/),resP)

;----------------------------surface plot


wks = gsn_open_wks("x11", "T_HOVMULLER_MPIOM_ICON_surface_30N")

res                          =    True
res at cnFillOn                        =    True

plot1                            =    new(2,graphic)

res at gsnDraw                      = False                          ; don't draw
res at gsnFrame                         = False                          ; don't advance frame


resP at gsnMaximize                        = True
res at tiMainFontHeightF                         = 0.02
resP at txFontHeightF                            = 0.015
resP at txString                     = "Temperature at the surface with time at a latitude of 30N"
res at lbLabelBarOn        = False
res at cnLevelSelectionMode =  "ManualLevels"
res at cnMinLevelValF       = 3.
res at cnMaxLevelValF       =  7.
res at cnLevelSpacingF      =   0.2
res at cnSpanFillPalette     =   True
resP at gsnPanelLabelBar    = True

res at tiMainString                  =    "M
plot1(0) = gsn_csm_contour(wks,dm30N,res)

res at tiMainString                  =    "I
plot1(1) = gsn_csm_contour(wks,di30N,res)

gsn_panel(wks,plot1,(/1,2/),resP)




I have been told  I can use cd_calendar but this involves creating a new variable 'time' which I would like to avoid. Another option was to change the tick labels but I am not sure how to do this using gsn_csm_contour.

thanks,
Michael

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140808/25ad2ba3/attachment.html 


More information about the ncl-talk mailing list