[ncl-talk] Creating a fast loop for panels plotting

G.Monte at isac.cnr.it G.Monte at isac.cnr.it
Tue Jan 15 07:34:17 MST 2019


Dears all,
I have a huge amount of ascii files (even more than 200 per month!) to be
processed for the last twenty years, each of them containing five fields
that can be visualized into a panel plot; here is attached the script used
for a single file, which is named in the variable "fname":

;---------------------------------------------------------------------------
begin

diri  = "./"
fname = "amsub_19981026_0454_noaa15_02355_bts.asc"

n_col = numAsciiCol(diri+fname)
n_var = n_col
n_pt  = numAsciiRow(diri+fname)
dataf  = asciiread(fname,(/n_pt,n_var/),"float")

;---read longitude
lon = dataf (:,3)

;---read latitude
lat = dataf (:,2)

;---read data
tb0 = dataf (:,7)
tb1 = dataf (:,8)
tb2 = dataf (:,9)
tb3 = dataf (:,10)
tb4 = dataf (:,11)

;---define the workstation (plot type and name)
wks = gsn_open_wks("png","./plot_panel")

plot                     = new(5,graphic)

;--set resources
res                     = True
res at gsnAddCyclic        = False
res at gsnFrame            = False
res at gsnDraw             = False

res at mpDataBaseVersion   = "HighRes"
res at mpMinLonF           = -10
res at mpMaxLonF           =  40
res at mpMinLatF           =  25
res at mpMaxLatF           =  55

res at sfXArray            = lon
res at sfYArray            = lat

res at cnFillOn            = True
res at cnLinesOn           = False
res at cnFillPalette       = "rainbow"
res at cnLineLabelsOn      = False
res at cnExplicitLabelBarLabelsOn = True

res at lbLabelBarOn         = True
res at lbLabelsOn           = True
res at lbBoxLinesOn         = True
res at lbBoxSeparatorLinesOn = False
res at lbTitleOn             = True
res at lbTitlePosition       = "Bottom"
res at lbTitleFontHeightF    = 0.015
res at lbTitleOffsetF        = -0.25
res at lbTitleExtentF        = 0.45
res at lbTitleString         = "~F26~[K]"
res at lbLabelStride         = 20

res at cnLevelSelectionMode = "ManualLevels"
res at cnMinLevelValF       = 150.
res at cnMaxLevelValF       = 290.
res at cnLevelSpacingF      = 1.

;-- create the contour map plot
plot(0) = gsn_csm_contour_map(wks,tb0,res)
plot(1) = gsn_csm_contour_map(wks,tb1res)
plot(2) = gsn_csm_contour_map(wks,tb2res)
plot(3) = gsn_csm_contour_map(wks,tb3res)
plot(4) = gsn_csm_contour_map(wks,tb4res)

resP                     = True
resP at txString            = fname
resP at txFontHeightF       = 0.015
resP at gsnMaximize         = True

gsn_panel(wks,plot,(/2,3/),resP)

end
;---------------------------------------------------------------------------

I'm wondering if anyone could suggest me a proper method for creating a
faster loop to rightly process my data for the entire month all at once (I
think that this should be invoked only before reading the ascii files, but
I'm not really sure
)

Thanks in advance!
Giulio Monte



More information about the ncl-talk mailing list