<div dir="ltr"><div class="gmail_default" style="font-size:small">[I meant to post this back to ncl-talk.  Please post all follow-up back to the list.]</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_extra"><div class="gmail_quote">On Sun, Oct 25, 2015 at 10:40 PM, Mary Haley <span dir="ltr">&lt;<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</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"><div style="font-size:small">Alan,</div><div style="font-size:small"><br></div><div style="font-size:small">What exactly is happening when you try to run this script? It shouldn&#39;t matter if you are using &quot;.gt&quot; versus &quot;.ge.&quot;, for example, but it&#39;s hard to debug your script without knowing what kind of error you&#39;re getting.</div><div style="font-size:small"><br></div><div style="font-size:small">Have you visit the &quot;system&quot; examples page, which show various scripting &quot;tricks&quot; that might help:</div><div style="font-size:small"><br></div><div><a href="http://www.ncl.ucar.edu/Applications/system.shtml" target="_blank">http://www.ncl.ucar.edu/Applications/system.shtml</a><span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div><br></div><div>--Mary</div><div><br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 23, 2015 at 6:31 PM, Alan Rhoades <span dir="ltr">&lt;<a href="mailto:alan.m.rhoades@gmail.com" target="_blank">alan.m.rhoades@gmail.com</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">PS  <span style="font-size:12.8px">For some reason, I&#39;ve been having trouble creating an elevational band using the where function by using .gt. and .lt. in tandem.  Currently, the bash/NCL script I sent you only uses the where function for either .lt. or .gt. elevational masking.  The ideal situation would be to create elevational bands between 0 m to 500 m, 500 m to 1000 m, etc.  I tried using a starting elevation and bounding elevation in the attached bash/NCL script, but it wasn&#39;t working properly for some reason.  </span><br><br><span style="font-size:12.8px">I&#39;ve tried the following without success...</span><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">${range}_${period}_${var}_${data}_${elev}_a = where(PHIS_${data}_${range}.ge.${elev} .and. </span><span style="font-size:12.8px">PHIS_${data}_${range}.le.${bound}</span><span style="font-size:12.8px">,${range}_${period}_${var}_${data}_${elev}_a@_FillValue,${range}_${period}_${var}_${data}_${elev}_a)</span></div><div><br></div><span style="font-size:12.8px">Have you ever heard of any issues doing this?  It may be an issue with my bash script, but I can&#39;t seem to track down the reason why.<br></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 23, 2015 at 5:24 PM, Alan Rhoades <span dir="ltr">&lt;<a href="mailto:alan.m.rhoades@gmail.com" target="_blank">alan.m.rhoades@gmail.com</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">Hi Mary,<div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">After tinkering around with your idea, I decided to figure out a way to do what I wanted in a bash script.  <span style="font-size:12.8px">It took me a bit of time, but I was able to put together the attached bash script that writes an NCL script and plots across several distinctions (i.e., mountain ranges, four variables, four elevation classes, and three climatological time periods).  I quickly realized when I was doing the elevation classes that making an NCL script outside of bash scripting was becoming a little cumbersome because of all of the variables at play and I needed a way to create dynamic naming conventions for prefix/suffix for a given NCL variable.</span><span style="font-size:12.8px">  FWIW, I attached the bash script to this email along with a printout made by it.  I use the plotter as a visual check to make sure that elevational band masks are working (see attached *pdf for more details).  </span></div><div style="font-size:12.8px"><br>Thanks again for your help!  Hope you have a good weekend.</div></div><span><font color="#888888"><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">AR</div></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 20, 2015 at 3:11 PM, Mary Haley <span dir="ltr">&lt;<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</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"><div style="font-size:small">AR,</div><div style="font-size:small"><br></div><div style="font-size:small">You can&#39;t do dynamic variables the way you&#39;ve written it, but there may be a way to do what you want, if I could know more about what you need to do with such a variable. The special &quot;$...$&quot; type of syntax can be used when referencing file variables, both reading and writing.</div><div style="font-size:small"><br></div><div style="font-size:small">For example, if you need to write the results of stat_dispersion to a NetCDF file, then you might do something like:</div><div style="font-size:small"><br></div><div style="font-size:small"><div><font face="monospace, monospace">;------------------------------------------------------</font></div><div><font face="monospace, monospace">;  OPEN NEW NETCDF FOR WRITING</font></div><div><font face="monospace, monospace">;------------------------------------------------------</font></div></div><div style="font-size:small">  <font face="monospace, monospace">output_filename = &quot;<a href="http://test.nc" target="_blank">test.nc</a>&quot;</font></div><div style="font-size:small"><font face="monospace, monospace"> system(&quot;rm -rf &quot; + output_filename)</font></div><div style="font-size:small"><font face="monospace, monospace"> fout = addfile(output_filename,&quot;c&quot;)</font></div><div style="font-size:small"><font face="monospace, monospace"><br></font></div><div><span><div><font face="monospace, monospace">;------------------------------------------------------</font></div><div><font face="monospace, monospace">;  STAT DISPERSION</font></div><div><font face="monospace, monospace">;------------------------------------------------------</font></div><div><font face="monospace, monospace"> opt = True</font></div><div><font face="monospace, monospace"> opt@PrintStat = True</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> vars = (/&quot;SNOWFALL&quot;,&quot;SNOWC&quot;,&quot;SWE&quot;,&quot;TSA&quot;/)</font></div><div><font face="monospace, monospace"> elev = (/&quot;500&quot;,&quot;1000&quot;,&quot;1500&quot;,&quot;2000&quot;/)</font></div><div><font face="monospace, monospace"> nvars = dimsizes(vars)-1</font></div><div><font face="monospace, monospace"> nelev = dimsizes(elev)-1</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> do n=0,nvars</font></div><div><font face="monospace, monospace"> do k=0,nelev</font></div></span><div><font face="monospace, monospace">   varname = &quot;</font><span style="font-family:monospace,monospace">Sierra_STAT_VR_CESM_28_HIST_&quot;</span><span style="font-family:monospace,monospace">+vars(n)+elev(k)</span></div><span><div><font face="monospace, monospace"> print(&quot;VR-CESM28 - HISTORICAL - AVG DJF Sierra Nevada &quot;+elev(k)+&quot; &quot;+vars(n)+&quot;&quot;)</font></div><div><font face="monospace, monospace"><br></font></div></span><div><font face="monospace, monospace">;---Write calculation directly to NetCDF file</font></div><div><font face="monospace, monospace"> fout-&gt;$varname$ = stat_dispersion(oned_+vars(n)+_VR_CESM_28_HIST_+elev(k)+,opt)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> end do</font></div><div><font face="monospace, monospace"> end do</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Note that this is a very inefficient way to write a NetCDF file. Mostly I just want to show how to use the $...$ syntax.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">If this doesn&#39;t answer your question, please post back to ncl-talk.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">--Mary</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div></div><div style="font-size:small"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Tue, Oct 20, 2015 at 12:33 PM, Alan Rhoades <span dir="ltr">&lt;<a href="mailto:alan.m.rhoades@gmail.com" target="_blank">alan.m.rhoades@gmail.com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div>Hello,</div><div><br></div><div>I&#39;m currently trying to make dynamic variable names within NCL (i.e., with unique prefix and/or suffix, but consistent patterns for each variable).  I&#39;ve tried to track down a solution for my current problem via the NCL archives, but can&#39;t seem to find it.  A post in 2010 said that this type of NCL scripting wasn&#39;t yet possible, but I was curious if an update had occurred.  </div><div><br></div><div><div>I&#39;m trying to do the following...</div><div><br></div><div>Assess several different mountain ranges</div><div>With four different variables (SNOWFALL, SNOWC, SWE, TSA)</div><div>Across four different elevation classes (500 m, 1000 m, 1500 m, 2000 m)</div><div><br></div><div>This is my current stab at making the dynamic variable names within NCL, but of course, it isn&#39;t working (although the print statement is working, the NCL functions just don&#39;t like the syntax used to name the dynamic variable names).  Here is a snippet of the code...</div></div><div><br></div><div>;------------------------------------------------------</div><div>;  STAT DISPERSION</div><div>;------------------------------------------------------</div><div> opt = True</div><div> opt@PrintStat = True</div><div><br></div><div> vars = (/&quot;SNOWFALL&quot;,&quot;SNOWC&quot;,&quot;SWE&quot;,&quot;TSA&quot;/)</div><div> elev = (/&quot;500&quot;,&quot;1000&quot;,&quot;1500&quot;,&quot;2000&quot;/)</div><div> nvars = dimsizes(vars)-1</div><div> nelev = dimsizes(elev)-1</div><div><br></div><div> do n=0,nvars</div><div> do k=0,nelev</div><div> print(&quot;VR-CESM28 - HISTORICAL - AVG DJF Sierra Nevada &quot;+elev(k)+&quot; &quot;+vars(n)+&quot;&quot;)</div><div> Sierra_STAT_VR_CESM_28_HIST_+vars(n)+elev(k)+ = stat_dispersion(oned_+vars(n)+_VR_CESM_28_HIST_+elev(k)+,opt)</div><div><br></div><div> end do</div><div> end do</div><div><br></div><div>Do you have any advice on how to move forward on this?  I have heard that it is possible to read in variable names via a shell script into NCL, but I can&#39;t track down an example of how to do this either.</div><div><br></div><div>Thanks in advance,</div><div><br></div><div>AR</div><span><font color="#888888"><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font color="#006600"><div style="font-weight:bold"><br></div><div><font color="#006600" size="2"><b>Alan Rhoades</b></font></div></font><div><div><b><font color="#000000" size="1">PhD Student, Atmospheric Science Graduate Group</font></b></div><div><b><font color="#000000" size="1">Climate Change Water and Society (CCWAS) NSF IGERT Trainee</font></b></div><div><b><font color="#000000" size="1">University of California, Davis</font></b></div><div><span style="font-family:arial,sans-serif;background-color:rgb(255,255,255)"><u><b><a href="https://www.linkedin.com/pub/alan-rhoades/22/5bb/52a" target="_blank"><font color="#0000ff" size="1">LinkedIn</font></a></b></u></span></div><div><span style="font-family:arial,sans-serif;background-color:rgb(255,255,255)"><u><b><font size="1"><a href="mailto:alan.m.rhoades@gmail.com" target="_blank">alan.m.rhoades@gmail.com</a> </font></b></u></span></div><div><span style="font-family:arial,sans-serif;background-color:rgb(255,255,255)"><u><b><a href="mailto:amrhoades@ucdavis.edu" target="_blank"><font size="1">amrhoades@ucdavis.edu</font></a></b></u></span></div></div><div><font color="#003300" size="1"><b><br></b></font></div><div><b><i><font color="#006600" size="1">&quot;It’s all really there. That’s what really gets you. But you gotta stop and think about it to really get the pleasure about the complexity, the inconceivable nature of nature.&quot;</font></i></b></div><div><b><i><font color="#006600" size="1">Richard Feynman</font></i></b></div></div></div></div></div></div></div>
</font></span></div>
<br></div></div>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font color="#006600"><div style="font-weight:bold"><br></div><div><font color="#006600" size="2"><b>Alan Rhoades</b></font></div></font><div><div><b><font color="#000000" size="1">PhD Student, Atmospheric Science Graduate Group</font></b></div><div><b><font color="#000000" size="1">Climate Change Water and Society (CCWAS) NSF IGERT Trainee</font></b></div><div><b><font color="#000000" size="1">University of California, Davis</font></b></div><div><span style="font-family:arial,sans-serif;background-color:rgb(255,255,255)"><u><b><a href="https://www.linkedin.com/pub/alan-rhoades/22/5bb/52a" target="_blank"><font color="#0000ff" size="1">LinkedIn</font></a></b></u></span></div><div><span style="font-family:arial,sans-serif;background-color:rgb(255,255,255)"><u><b><font size="1"><a href="mailto:alan.m.rhoades@gmail.com" target="_blank">alan.m.rhoades@gmail.com</a> </font></b></u></span></div><div><span style="font-family:arial,sans-serif;background-color:rgb(255,255,255)"><u><b><a href="mailto:amrhoades@ucdavis.edu" target="_blank"><font size="1">amrhoades@ucdavis.edu</font></a></b></u></span></div></div><div><font color="#003300" size="1"><b><br></b></font></div><div><b><i><font color="#006600" size="1">&quot;It’s all really there. That’s what really gets you. But you gotta stop and think about it to really get the pleasure about the complexity, the inconceivable nature of nature.&quot;</font></i></b></div><div><b><i><font color="#006600" size="1">Richard Feynman</font></i></b></div></div></div></div></div></div></div>
</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font color="#006600"><div style="font-weight:bold"><br></div><div><font color="#006600" size="2"><b>Alan Rhoades</b></font></div></font><div><div><b><font color="#000000" size="1">PhD Student, Atmospheric Science Graduate Group</font></b></div><div><b><font color="#000000" size="1">Climate Change Water and Society (CCWAS) NSF IGERT Trainee</font></b></div><div><b><font color="#000000" size="1">University of California, Davis</font></b></div><div><span style="font-family:arial,sans-serif;background-color:rgb(255,255,255)"><u><b><a href="https://www.linkedin.com/pub/alan-rhoades/22/5bb/52a" target="_blank"><font color="#0000ff" size="1">LinkedIn</font></a></b></u></span></div><div><span style="font-family:arial,sans-serif;background-color:rgb(255,255,255)"><u><b><font size="1"><a href="mailto:alan.m.rhoades@gmail.com" target="_blank">alan.m.rhoades@gmail.com</a> </font></b></u></span></div><div><span style="font-family:arial,sans-serif;background-color:rgb(255,255,255)"><u><b><a href="mailto:amrhoades@ucdavis.edu" target="_blank"><font size="1">amrhoades@ucdavis.edu</font></a></b></u></span></div></div><div><font color="#003300" size="1"><b><br></b></font></div><div><b><i><font color="#006600" size="1">&quot;It’s all really there. That’s what really gets you. But you gotta stop and think about it to really get the pleasure about the complexity, the inconceivable nature of nature.&quot;</font></i></b></div><div><b><i><font color="#006600" size="1">Richard Feynman</font></i></b></div></div></div></div></div></div></div>
</div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>