<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
Dear Travis, Wesley, et al.,&nbsp;
<div><br>
</div>
<div>I have done some testing with the high-res fnexrad 1km radar data, comparing the use of ‘pdef lccr’ (where the interpolation weights are calculated internally) and ‘pdef bilin’ (where interpolation weights are provided by the user in an external file.
 Reading the weights from a file was significantly faster — something like 30x faster!&nbsp;
<div><br>
</div>
<div>The tricky part of taking advantage of this performance gain is creating the pdef file itself, which depends on you being able to calculate non-integer i,j values in the native grid that correspond to each grid point in the destination grid, which is defined
 by what you put in your XDEF and YDEF statements. This is not necessarily simple.&nbsp;</div>
<div><br>
</div>
<div>The good news is that GrADS does this calculation for you every time you open a descriptor with a pdef statement that doesn’t point to an external file — lcc, lccr, nps, sps, etc. I am going to implement a command ‘pdefwrite’ that will write out the interpolation
 weights calculated internally for these types of PDEF entries so that the file can be used with ‘pdef bilin’ instead. The protocol will be something like this:</div>
<div>1. Create a descriptor that has a pdef statement like this:</div>
<div><font face="Courier">pdef 4736 3000 lccr 23.0 -120 1 1 40.0 40.0 -100 1016.2360 1016.150</font></div>
<div>2. Open it with grads</div>
<div>3. Invoke pdefwrite with a file name as an argument</div>
<div>4. Rewrite your descriptor to use this pdef statment instead:</div>
<div><font face="Courier">pdef 4736 3000 bilin stream binary <i>your-filename-here</i></font><br>
<div>5. Don’t change the XDEF and YDEF statements — those match the pdef file you created in step 3.&nbsp;</div>
<div>6. Open the new descriptor with GrADS and start working right away.&nbsp;</div>
<div><br>
</div>
<div>Additional comments on Travis’s email:&nbsp;</div>
<div><br>
</div>
<div>Shade1 may be faster than shade2 in some cases, but it won’t look right with transparent colors because the polygons in the old algorithm overlap. By the way, in the newer versions of GrADS, ‘gxout shaded’ is an alias for shade2, so if you want to use
 shade1 you have to say so explicitly.&nbsp;</div>
<div><br>
</div>
<div>For regridding, the new code in lterp() does just about everything re() does only it is faster and more accurate. It is true that the destination grid definition requires an open file, but I use something like this all the time:</div>
<div>
<div><font face="Courier" size="2">dset ^foo.bin</font></div>
<div><font face="Courier" size="2">options template</font></div>
<div><font face="Courier" size="2">undef -9.99e8</font></div>
<div><font face="Courier" size="2">xdef 90 linear 2 4</font></div>
<div><font face="Courier" size="2">ydef 45 linear -88 4</font></div>
<div><font face="Courier" size="2">tdef 1 linear 01Jan0001 1dy</font></div>
<div><font face="Courier" size="2">zdef 1 linear 1 1</font></div>
<div><font face="Courier" size="2">vars 1</font></div>
<div><font face="Courier" size="2">foo 0 99 foo</font></div>
<div><font face="Courier" size="2">endvars</font></div>
</div>
<div><br>
</div>
<div>You can even create that dummy descriptor on the fly, depending on what destination grid you need at the time. Also, if you are using pdef, it is a waste of resources to use lterp(), just put your desired destination grid in the XDEF and YDEF statements.&nbsp;</div>
<div><br>
</div>
<div>High res data sets take longer to render because they have more data to grind through to calculate where to draw the contours. But if your data is high res, don’t you want to see that reflected in your plot?&nbsp;</div>
<div><br>
</div>
<div>I like ‘gxout grfill’ to really see the finer details in the data. Contours over highly variable data (e.g. temperature in the Rocky Mountains) can look really noisy but grfill lets you see that variability without all the annoying squiggly contour lines.&nbsp;</div>
<div><br>
</div>
<div>Regarding the resolution of the image output — there is no point to write out really high res data to a small image file; you just end up drawing over the same pixel multiple times. If image file dimensions are your limiting factor, then it might make
 sense to downgrade the resolution of your grid. I don’t think the optimal ratio between grid size and image size is 1:1, however. There’s probably a sweet spot somewhere where you can still see all the details in your data and the image size is lean enough.
 I think 800x600 is pretty small, and it is also not quite the same aspect ratio as 11x8.5 so your image will be a bit distorted from what you see in the display window.&nbsp;</div>
<div><br>
</div>
<div>Don’t forget about the utility ‘pngquant' for making the image output files (from v2.1&#43;) less bulky so you can store more of them and they will load faster in a browser.</div>
<div><br>
</div>
<div>—Jennifer</div>
<div><br>
</div>
<div><br>
<div>
<div>On Feb 11, 2016, at 10:40 AM, Wesley Ebisuzaki - NOAA Federal &lt;<a href="mailto:wesley.ebisuzaki@noaa.gov">wesley.ebisuzaki@noaa.gov</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>Travis,<br>
<br>
</div>
&nbsp;&nbsp; I haven't tried this but it may work.<br>
<br>
</div>
&nbsp;&nbsp; Instead of regridding your hi-res lat-lon data, make a new control file<br>
</div>
which has a PDEF .. BILIN.&nbsp; This PDEF would map low_res(i,j) -&gt; hi_res(n*i, n*j)<br>
<br>
</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp; low_res() : the low-res x-y grid which is defined in the low-res ctl file.<br>
</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp; hi_res(): the hi-res grib file grid<br>
</div>
<div><br>
</div>
<div>I don't remember if grids start at grid(0,0) or grid(1,1).&nbsp; If grids start at (1,1) then<br>
</div>
<div>the above formula would have to be changed.<br>
</div>
<div><br>
</div>
<div>Wesley<br>
</div>
<div><br>
<br>
<div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Feb 9, 2016 at 5:37 PM, Travis Wilson - NOAA Federal
<span dir="ltr">&lt;<a href="mailto:travis.wilson@noaa.gov" target="_blank">travis.wilson@noaa.gov</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<p class="MsoNormal" style="margin-bottom:0.0001pt"><span style="font-size:9.5pt;font-family:Arial,sans-serif;background-image:initial;background-repeat:initial">Hi All,</span><span style="font-size:12pt;font-family:'Times New Roman',serif"></span></p>
<div style="margin-bottom: 0.0001pt; background-repeat: initial initial;"><span style="font-size:9.5pt;font-family:Arial,sans-serif">&nbsp;</span><br class="webkit-block-placeholder">
</div>
<p class="MsoNormal" style="margin-bottom:0.0001pt;background-image:initial;background-repeat:initial">
<span style="font-size:9.5pt;font-family:Arial,sans-serif">Attached is a very short ppt on grads performance vs python using grib files.&nbsp; In most cases, grads blows python away.&nbsp; Times are relative to our machine and consider everything from starting grads/opening
 the file, to closing the file. &nbsp;</span></p>
<div style="margin-bottom: 0.0001pt; background-repeat: initial initial;"><span style="font-size:9.5pt;font-family:Arial,sans-serif">&nbsp;</span><br class="webkit-block-placeholder">
</div>
<p class="MsoNormal" style="margin-bottom:0.0001pt;background-image:initial;background-repeat:initial">
<span style="font-size:9.5pt;font-family:Arial,sans-serif">- In particular we have found that shaded1 is much faster.&nbsp; Up to 40% faster on our machines. &nbsp;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;background-image:initial;background-repeat:initial">
<span style="font-size:9.5pt;font-family:Arial,sans-serif">- Wesley Ebisuzaki recommended converting the grib files to a lat/lon grid to eliminate the PDEF entry to significantly speed up the opening time of high resolution grib files.&nbsp;<a href="http://gradsusr.org/pipermail/gradsusr/2016-January/039339.html" target="_blank">http://gradsusr.org/pipermail/gradsusr/2016-January/039339.html</a></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;background-image:initial;background-repeat:initial">
<span style="font-size:9.5pt;font-family:Arial,sans-serif">- Again noted by Wesley, grib packing can have an impact on performance
<a href="http://gradsusr.org/pipermail/gradsusr/2010-May/027683.html" target="_blank">
http://gradsusr.org/pipermail/gradsusr/2010-May/027683.html</a>&nbsp;&nbsp;</span></p>
<div style="margin-bottom: 0.0001pt; background-repeat: initial initial;"><span style="font-size:9.5pt;font-family:Arial,sans-serif">&nbsp;</span><br class="webkit-block-placeholder">
</div>
<p class="MsoNormal" style="margin-bottom:0.0001pt;background-image:initial;background-repeat:initial">
<span style="font-size:9.5pt;font-family:Arial,sans-serif">One thing we show in the ppt is that as the view gets wider (i.e. the number of points that are plotted increase), the slower grads is relative to python.&nbsp; At some point, python will become faster.
 &nbsp; Anyways, to battle with this, regridding (using the re() function) the data within grads significantly speeds up the plotting time (see last slide) when you have a lot of points.&nbsp; As far as I know, you can’t use re() in grads 2.1a3.&nbsp; You do have lterp()
 but a grid is needed.&nbsp; Is there anything that will allow me to lterp to my image dimensions?&nbsp; Say my image dimensions are x800 y600 then lterp would interpolate my high resolution grib file to x800 y600 (or some multiple of) when a view exceeds 800 points
 across.&nbsp; This will significantly speed up the plotting time when viewing a wide view of a high resolution grib file while not degrading the image quality by much (again, see last slide).&nbsp;
</span></p>
<div style="margin-bottom: 0.0001pt; background-repeat: initial initial;"><span style="font-size:9.5pt;font-family:Arial,sans-serif">&nbsp;</span><br class="webkit-block-placeholder">
</div>
<p class="MsoNormal" style="margin-bottom:0.0001pt;background-image:initial;background-repeat:initial">
<span style="font-size:9.5pt;font-family:Arial,sans-serif">Also, if anyone has other performance tips on plotting high resolution grib files we would love to hear them.</span></p>
<div style="margin-bottom: 0.0001pt; background-repeat: initial initial;"><span style="font-size:9.5pt;font-family:Arial,sans-serif">&nbsp;</span><br class="webkit-block-placeholder">
</div>
<p class="MsoNormal" style="margin-bottom:0.0001pt;background-image:initial;background-repeat:initial">
<span style="font-size:9.5pt;font-family:Arial,sans-serif">Thanks,</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;background-image:initial;background-repeat:initial">
<span style="font-size:9.5pt;font-family:Arial,sans-serif">Travis</span></p>
</div>
<br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" rel="noreferrer" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
http://gradsusr.org/mailman/listinfo/gradsusr<br>
</blockquote>
</div>
<br>
<div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="font-size: 12px; orphans: 2; widows: 2;">--</div>
<div style="font-size: 12px; orphans: 2; widows: 2;">Jennifer Miletta Adams<br>
Center for Ocean-Land-Atmosphere Studies (COLA)<br>
George Mason University<br>
<br>
<br>
</div>
</div>
</div>
</div>
<br>
</div>
</div>
</div>
</body>
</html>