[ncl-talk] [Help] multi panel plots

Mary Haley haley at ucar.edu
Wed Mar 8 08:53:02 MST 2017


Hi Cho,

Guido is correct about the do loop screwing up the workstation.

Each plot has a "parent" workstation, and if you change workstations for
each plot, then by the time you get to the gsn_panel call, the only plot
associated with "wks" at that point is the last plot.

In general, you want to keep "do" loops as clean as possible, because they
can be slow.

One other thing to consider is using "addfiles" to read all the files at
once, instead of reading one file at a time with "addfile".  I don't know
if that will work in your case, however, because I'm not familiar with your
data. Also, if you have a lot of files, or really large arrays on each
file, then "addfile" may still be your best bet.

A shout-out to Guido for catching the workstation issue!

--Mary


On Wed, Mar 8, 2017 at 2:46 AM, Guido Cioni <guidocioni at gmail.com> wrote:

> Hey,
> In order to debug I would suggest you to move everything that does not
> have to change in every interaction (like the plot resources and the call
> to the workstation)  out of the do loop. That can cause problems given that
> you're overwriting the same variable over and over.
> Second, use the := operator when reading files and defining variables so
> that you're sure that you're overwriting the old ones.
> I'm pretty sure it's the call to the workstation in every loop that is
> screwing up everything ☺️
>
>
> Il 8 mar 2017 5:42 AM, 조익현 <ehcho at kma.go.kr> ha scritto:
>
>> Dear NCL users,
>>
>>
>> I have a question about multi panel plots.
>>
>> I'm trying to get  multi panel plots(3x3) using loop of 9 GRIB files,
>>
>> but it displays only last one output(plot(8)) on 3x3 panel.
>>
>>
>> The basic structure is the following
>> ;;;
>> do i1 = 0, 8
>>   grib file read and define resource
>>   plot(i1) =  gsn_csm_contour_map
>> end do
>>
>>  resP = True
>>   gsn_panel(wks,plot,(/3,3/),resP)
>> ;;;;
>>
>>
>> Any help will be appreciated.
>>
>> Cho
>>
>>
>>
>> ========================================== here is the script
>>
>> 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
>>
>>
>>
>>   ANLTIM = "2017030700 <(201)%20703-0700>"
>>
>>   plot=new(9,graphic)
>>
>>   do i1 = 0,8
>>   i=i1*12
>>   timestep = sprinti("%0.3i", i)
>>
>>   dir = "/op/nwp/post/EXTJ/ECMW/OPER/DAIN/201703/0700/"
>>    pr = "e025_v025_nhem_h"+timestep+"."+ANLTIM+"00.gb1"
>>     a = addfile(dir+pr+".grb1", "r")
>>
>>   lat = a->g0_lat_0({30:50})
>>   lon = a->g0_lon_1({110:140})
>>
>>   slp = a->MSL_GDS0_SFC({30:50},{110:140})*0.01
>>
>>   slp!0   = "lat"
>>   slp!1   = "lon"
>>   slp&lon =  lon
>>   slp&lat =  lat
>>
>>   wks = gsn_open_wks("x11","output")
>>   gsn_define_colormap(wks, "WhiteYellowOrangeRed")
>>
>> ;;========================================================
>> ;; PLOT
>> ;;========================================================
>>   res = True
>>   res at gsnDraw             = False
>>   res at gsnFrame            = False
>>
>>   res at mpLimitMode                    = "Corners"
>>   res at mpLeftCornerLatF               = 32.0
>>   res at mpRightCornerLatF              = 43.0
>>   res at mpLeftCornerLonF               = 119.5
>>   res at mpRightCornerLonF              = 134.0
>>
>>   res at mpProjection ="LambertConformal"
>>   res at mpLambertParallel1F            = 30.0
>>   res at mpLambertParallel2F            = 60.0
>>   res at mpLambertMeridianF             = 126.0
>>
>>   res at tfDoNDCOverlay      = False
>>   res at gsnAddCyclic        = False
>>
>>   res at cnInfoLabelOn = False
>>   res at cnLineLabelInterval = 2
>> ; res at cnMonoLineThickness = False
>>   res at cnFillOn = False
>>
>>   wrf_smooth_2d(slp,9)
>>   plot(i1) = gsn_csm_contour_map(wks,slp,res)
>>
>> end do
>>
>> ;;;;;;;;;;;;;;;;;;;;;
>> ;;;; Panel Plot ;;;;;
>> ;;;;;;;;;;;;;;;;;;;;;
>>   resP = True
>>   gsn_panel(wks,plot,(/3,3/),resP)
>> end
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
> _______________________________________________
> 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/20170308/690d3255/attachment.html 


More information about the ncl-talk mailing list