Copyright (C) 1995-2013 - All Rights Reserved University Corporation for Atmospheric Research NCAR Command Language Version 6.1.2 The use of this software is governed by a License Agreement. See http://www.ncl.ucar.edu/ for more details. + ;-------------------------------------------------------------------------------- + ; This function convert input variable x to type specified by type. + ; Wei Huang + ; May 21, 2012 + ;-------------------------------------------------------------------------------- + + undef("totype") + function totype( varin, type:string ) + local varout + + begin + ;printVarSummary(varin) + ;print(type) + + ;Convert to float + if(type .eq. "float") then + varout = tofloat(varin) + return(varout) + end if + + ;Convert to double + if(type .eq. "double") then + varout = todouble(varin) + return(varout) + end if + + ;Convert to uint + if(type .eq. "uint") then + varout = touint(varin) + return(varout) + end if + + ;Convert to integer + if(type .eq. "int" .or. type .eq. "integer") then + varout = toint(varin) + return(varout) + end if + + ;Convert to char + if(type .eq. "char" .or. type .eq. "character") then + varout = tochar(varin) + return(varout) + end if + + ;Convert to byte + if(type .eq. "byte") then + varout = tobyte(varin) + return(varout) + end if + + ;Convert to short + if(type .eq. "short") then + varout = toshort(varin) + return(varout) + end if + + ;Convert to ushort + if(type .eq. "ushort") then + varout = toushort(varin) + return(varout) + end if + + ;Convert to long + if(type .eq. "long") then + varout = tolong(varin) + return(varout) + end if + + ;Convert to ulong + if(type .eq. "ulong") then + varout = toulong(varin) + return(varout) + end if + + ;Convert to int64 + if(type .eq. "int64") then + varout = toint64(varin) + return(varout) + end if + + ;Convert to uint64 + if(type .eq. "uint64") then + varout = touint64(varin) + return(varout) + end if + + ;Convert to string + if(type .eq. "string") then + varout = tostring(varin) + return(varout) + end if + + print("") + print("WARNING:") + print("CANNOT convert input variable type: <" + typeof(varin) + "> to type: <" + type + ">") + print("The original type: <" + typeof(varin) + "> is returned.") + print("") + + varout = varin + return(varout) + end + Loading file "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" + Loading file "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" + + + begin + + wks = gsn_open_wks("pdf","test9yRlabel") + gsn_define_colormap(wks,"gui_default") ; choose colormap + plot1 = new(1, graphic) + + YL = (/280,300,320,340,360,380,400,420,440/) + X = (/10,15,20,25,30,35,40,45,50/) + + res = True + res@tmYROn = True ; turn on the YR tickmarks + res@tmYRLabelsOn = True ; turn the YR labels on + res@tmYUseLeft = False + res@tmYRMode = "Explicit" ; explicitly set Y-axis labels + res@tmYRValues = (/640.00,2200.00,4200.00,6700.00,8000.00,12500.00,14100.00/) + res@tmYRLabels = (/"640","2200", "4200", "6700", "8000", "12500", "14100"/) + + plot1 = gsn_csm_xy(wks,X,YL,res) + + getvalues plot1 ; retrieve some of the plot resources + "tmYLLabels" : tmYLLabels ; values used by NCL at major tick marks + end getvalues + getvalues plot1 ; retrieve some of the plot resources + "tmYRLabels" : tmYRLabels ; values used by NCL at major tick marks + end getvalues + + printVarSummary(tmYLLabels) + print(tmYLLabels) + printVarSummary(tmYRLabels) + print(tmYRLabels) + + frame(wks) + delete(res) + + end Variable: tmYLLabels Type: string Total Size: 56 bytes 7 values Number of Dimensions: 1 Dimensions and sizes: [7] Coordinates: Variable: tmYLLabels Type: string Total Size: 56 bytes 7 values Number of Dimensions: 1 Dimensions and sizes: [7] Coordinates: (0) 270 (1) 300 (2) 330 (3) 360 (4) 390 (5) 420 (6) 450 Variable: tmYRLabels Type: string Total Size: 56 bytes 7 values Number of Dimensions: 1 Dimensions and sizes: [7] Coordinates: Variable: tmYRLabels Type: string Total Size: 56 bytes 7 values Number of Dimensions: 1 Dimensions and sizes: [7] Coordinates: (0) 640 (1) 2200 (2) 4200 (3) 6700 (4) 8000 (5) 12500 (6) 14100 +