[ncl-talk] Creating a fast loop for panels plotting
Dennis Shea
shea at ucar.edu
Wed Jan 16 21:50:18 MST 2019
I would suggest preprocessing the individual year (yyyy) and month (mm)
files into single files for each year and month.
Then looping over these 'mega' [yyyymm] files.
Untested:
; G. Monte 15 Jan 2019
; 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":
;============================================================
; Sample name: amsub_19981026_0454_noaa15_02355_bts.asc
; yyyymmdd hhmn
;============================================================
diri = "/???/???/.../" ; directory for source asc files; "./" current
dir
diro = "/???/???/.../" ; directory for output asc files
yrStrt = 1995 ; initial year
yrLast = 2015 ; last year
mmStrt = 1 ; initial month
mmLast = 12 ; last month
;---Loop over each year and month
do yyyy=yrStrt,yrLast
do mm=mmStrt,mmLast
;---Create output file name for the current month and year
ptho = diro+"AMSUB_"+yyyy+sprinti("%0.2i", mm)+"_NOAA15_BTS.asc"
print(""+ptho) ; test
;---Remove any previous file
system("/bin/rm -f "+ptho)
;---Concatenate all individual year-month files into a single file
system("cat amsub_"+yyyy+sprinti("%0.2i", mm)+"*_bts.asc > "+ptho)
end do ; mm
end do ; yyyy
On Tue, Jan 15, 2019 at 7:34 AM <G.Monte at isac.cnr.it> wrote:
> 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
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190116/2733f6db/attachment.html>
More information about the ncl-talk
mailing list