<div dir="ltr"><div class="gmail_default" style="font-size:small">Rabah,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">There are a series of issues with your script, but not all of them have to do with why your code is taking so long.</div>
<div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">1. You have mpMaxLatF and mpMinLatF set to the same value.</div><div class="gmail_default" style="font-size:small">
<br></div><div class="gmail_default" style="font-size:small">2. You've set gsnDraw to False, which will cause no text strings to be added:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">
<div style="font-family:arial,sans-serif;font-size:13px"> txres@gsnDraw = False ; do not draw the plot</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
3. <span style="font-size:small;font-family:arial">The txres@txFontThicknessF = 10 is going to cause your text strings to be 10x as thick. Do you want this on top of the text being bold-faced?</span></div><div style="font-family:arial,sans-serif;font-size:13px">
<span style="font-size:small;font-family:arial"><br></span></div><div>4. You are adding almost 260,000 strings to the plot. Is what you mean to do? </div><div><br></div><div>5. You are constructing the lat2d/lon2d arrays in two separate do loops. You can make this code simpler by using "conform_dims".</div>
<div><br></div><div>6. Using gsn_add_text is going to cause 259920 graphical objects to be created, because one has to be added for every string you create. This can get very memory intensive.</div><div><br></div><div>If you are only planning to draw this one plot and not resize it later, then I suggest using gsn_text instead of gsn_add_text. This will prevent the individual objects from being created, and will run faster. </div>
<div><br></div><div>See the attached script. I didn't clean up the code to fix the various warnings from setting contour resources when you are only creating a map script, because I figured you were in the middle of debugging this. But, I did clean it up to make it run faster. This script took about 71 seconds on my Mac. If you take out the "txFontThicknessF" setting, then it runs in about 62 seconds.</div>
<div><br></div><div>Note that I put the "gsn_text" call inside a single do loop. This seems to run faster than using a double do loop, or no do loop at all. I think this has to do with trying to add 259,000+ strings to a plot all at once versus adding each string one at a time. Instead, I'm adding 360 strings at a time, for each 720 iterations, which seems to be a happy balance.</div>
<div><br></div><div>--Mary</div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jul 27, 2014 at 1:25 AM, Rabah Hachelaf <span dir="ltr"><<a href="mailto:hachelaf@sca.uqam.ca" target="_blank">hachelaf@sca.uqam.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi NCL users, <div><br></div><div>I am using the ncl script below to plot temperature values from GFS data,</div>
<div>this script works great when i regrid my data to a lower resolution.</div><div>but when i want plotting the whole data (720 x 361 values) and after more than 3 hours, ncl still running without generate any image or error message.</div>
<div>this very strange since NCL is supposed to be a powerful tool. </div><div><br></div><div>Have you any suggest to this problem.</div><div><br></div><div>Thanks a lot.</div><div><br></div><div>Rabah</div><div><br></div>
<div><div>;************************************************</div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" </div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" </div>
<div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" </div><div>;************************************************</div><div> a = addfile("gfs.t00z.pgrb2f00.grib2","r")</div><div>
lon = a->lon_0</div><div> lat = a->lat_0</div><div> tt = short2flt(a->TMP_P0_L100_GLL0({100000},:,:))</div><div> tt = (/tt-273/)</div><div><br></div><div>lat2d= new((/361,720/),float)</div><div>
;********* create 2D lat lon </div><div>do l=0,719</div><div> lat2d(:,l)=lat(:)</div><div>end do</div><div><br></div><div>lon2d= new((/361,720/),float)</div><div>do l=0,360</div><div> lon2d(l,:)=lon(:)</div><div>end do</div>
<div>;******************************************</div><div>wks_type="png"</div><div><br></div><div> wks_type@wkWidth = 4000</div><div> wks_type@wkHeight = 4000</div><div><br></div><div> wks = gsn_open_wks(wks_type,"plot_val") </div>
<div> gsn_define_colormap(wks,"gui_default")</div><div> </div><div> res = True ; plot mods desired</div><div>res@pmTickMarkDisplayMode = "Always"</div><div> res@mpProjection = "Mercator" ; choose projection</div>
<div> res@mpGridAndLimbOn = False ; turn on lat/lon lines</div><div> res@mpPerimOn = True ; turn off box around plot</div><div> res@mpGridLatSpacingF = 45. ; spacing for lat lines</div>
<div> res@mpGridLonSpacingF = 45. ; spacing for lon lines</div><div> res@mpFillOn = False</div><div> res@mpLimitMode = "LatLon"</div><div> res@mpMinLatF = 85.0</div><div>
res@mpMaxLatF =85.0 </div><div> res@mpMinLonF = -180</div><div> res@mpMaxLonF = 180</div><div> </div><div> res@cnFillOn = False ; color plot desired</div>
<div>
res@cnLineLabelsOn = False ; turn off contour lines</div><div><br></div><div> res@vpXF = 0 ; make plot bigger</div><div> res@vpYF = 1 </div><div> res@vpWidthF = 1</div>
<div> res@vpHeightF = 1</div><div>map = gsn_csm_map(wks,res)</div><div> txres = True</div><div> txres@txFontQuality = True</div><div> txres@txFontHeightF = 0.00125</div><div> txres@txFont = "helvetica-bold"</div>
<div> txres@txFontColor =1</div><div> txres@txFontThicknessF= 10</div><div> txres@gsnDraw = False ; do not draw the plot</div><div> txres@gsnFrame = False</div><div>text = gsn_add_text(wks,map,sprintf("%2.0f", tt) , lon2d, lat2d,txres)</div>
<div>draw(wks) ; Now draw map with text strings and</div><div>frame(wks) ; advance the frame</div><div>end</div><span class="HOEnZb"><font color="#888888">-- <br><div dir="ltr"><div>------------------------------</div>
Cordialement,<br>Best regards,<br>Rabah Hachelaf <br>
</div>
</font></span></div></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>