[ncl-talk] Fwd: sub: Any help to plot ascii
dale zuri
dalezuri at gmail.com
Tue Mar 30 07:55:21 MDT 2021
---------- Forwarded message ---------
From: dale zuri <dalezuri at gmail.com>
Date: Mon, Mar 29, 2021 at 7:02 PM
Subject: sub: Any help to plot ascii
To: Ncl-talk <ncl-talk at ucar.edu>
Dear NCL user,
could someone help me fix this?
I appreciate your time and help.
Thanks
DZ
nlat=720
nlon=1440
fname = "avhrr_seaice"
data = asciiread("avhrr_seaice",(/nlat*nlon,2/),"float")
lat = data(::nlon,0)
printVarSummary(lat)
lon = data(0:nlon-1,1)
printVarSummary(lon)
temp12D = onedtond(data(:,0),(/nlat,nlon/)) ; convert 1D array to a 2D array
temp22D = onedtond(data(:,1),(/nlat,nlon/)) ; convert 1D array to a 2D array
; Assign named dimensions
lat!0 = "lat"
lon!0 = "lon"
temp12D!0 = "lat"
temp12D!1 = "lon"
temp22D!0 = "lat"
temp22D!1 = "lon"
; Assign coordinate variables
lat&lat = lat
lon&lon = lon
temp22D&lat = lat
temp22D&lon = lon
temp12D&lat = lat
temp12D&lon = lon
temp12D&lat at units = "degrees_north"
temp12D&lon at units = "degrees_east"
temp22D&lat at units = "degrees_north"
temp22D&lon at units = "degrees_east"
printVarSummary(temp12D)
printVarSummary(temp22D)
wks = gsn_open_wks("x11","test") ; send graphics to PNG file
plot = new(2,graphic)
cmap = read_colormap_file("UKM_hadcrut"); choose colormap
res = True ; plot mods desired
res at cnFillOn = True ; turn on color
;res at mpShapeMode = "FreeAspect"
res at vpWidthF = 0.3
res at vpHeightF = 0.2
; res at cnFillPalette 2 = "grads_rainbow" ; choose colormap
res at cnFillPalette = cmap ; choose colormap
res at gsnPolar = "NH" ; specify the hemisphere
res at gsnDraw = False
res at gsnFrame = False
res at gsnTickMarksOn = False
res at mpMinLatF = 50 ; specify min lat
; res at mpMinLatF = minlatt ; specify min lat
;res at mpMaxLatF = maxlatt
res at trGridType = "TriangularMesh"
res at cnLinesOn = False ; True is default
;res at mpFillOn = False ; turns off continent gray
res at cnLineLabelsOn = False ; True is default
res at mpGridAndLimbOn = False
res at mpLabelFontHeightF = "22"
res at mpPerimLineThicknessF = 2
res at mpOutlineOn = True
; res at mpLandFillColor = "tan"
;res at tiMainString = ""+type+"-"+mon+""
res at lbLabelBarOn = False ; turn off individual lb's
res at gsnLeftString = "" ; no titles
res at gsnRightString = ""
res at tiXAxisString = ""
res at tiYAxisString = ""
res at cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
res at cnMinLevelValF = 0;0 ; set min contour level
res at cnMaxLevelValF = 100 ;6 ; set max contour level
res at cnLevelSpacingF = 10;0.5 ; set contour spacing
;res at lbOrientation = "Horizontal"
;res at lbLabelFontHeightF = 0.014
;res at lbLabelFont = "22"
; res at lbTitleString = ""+type+""
; res at lbTitleString = " (deg C)" ; bar title
; res at lbTitlePosition = "Right" ; title
location
; res at lbTitleDirection = "Across" ; letter
angle
; res at lbTitleAngleF = 90. ; title
angle
; res at lbTitleFontHeightF = 0.02 ; font
height
res at gsnStringFont = "helvetica-bold" ; will be used for
gsnCenterString later
res at gsnCenterStringFontHeightF = 0.014
res at gsnCenterString = "NDJFM"
plot(0) = gsn_csm_contour_map_polar(wks,temp12D(:,0),res)
res at gsnCenterString = "JJAS"
plot(1) = gsn_csm_contour_map_polar(wks,temp22D(:,1),res)
;********************************
;;;;;Contour plot;;;;;;;;;;;;;;;
;********************************
; panel plot only resources
;********************************
; panel plot only resources
; panel plot only resources
resP = True ; modify the panel plot
resP at gsnMaximize = True ; large format
resP at gsnPanelLabelBar = True ; add common colorbar
resP at lbLabelFontHeightF = 0.012
resP at gsnPanelBottom = 0.2;;;increases figure size ;
shrink panel plot by setting bottom edge of plot
resP at gsnPanelTop = 0.9 ; shrink panel plot by
setting top edge of plot
resP at pmLabelBarWidthF = 0.50 ; make thinner/small number
; resP at pmLabelBarHeightF = 0.05
resP at pmLabelBarHeightF = 0.08
resP at pmLabelBarOrthogonalPosF = -0.016
; resP at gsnPanelYWhiteSpacePercent = 5. ; increase spacing along
Y-axis between panel plots
resP at gsnPanelYWhiteSpacePercent = 2;;increases the figure size ;
increase spacing along Y-axis between panel plots
res at lbLabelFontHeightF = 0.018
resP at lbLabelFont = "22"
; resP at lbTitleString = ""+tic+""
resP at cnLinesOn = False ; turn off contour lines
resP at lbLabelFont = "helvetica-bold" ; add common colorbar
resP at lbTitleFont = "helvetica-bold" ; add common colorbar
resP at lbTitleFontHeightF= .015 ; make title smaller
resP at cnLineLabelsOn = False
resP at txFontHeightF = 0.03
resP at txFont = "helvetica-bold"
gsn_panel(wks,plot,(/1,2/),resP)
;---This will maximize the size of all the paneled stuff.
;end do
end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210330/efdec1d7/attachment.html>
More information about the ncl-talk
mailing list