<div dir="ltr"><div class="gmail_default" style="font-size:small">Hi folks,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Just a minor correction here. Since this is WRF data, we have specific functions for extracting the index locations of a grid given lat/lon values.  See &quot;wrf_user_ll_to_ij&quot;:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style=""><a href="http://www.ncl.ucar.edu/Document/Functions/WRF_arw/wrf_user_ll_to_ij.shtml">http://www.ncl.ucar.edu/Document/Functions/WRF_arw/wrf_user_ll_to_ij.shtml<br></a></div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="">This is similar to closest_val, except you give both lon, lat points (in that order) and it gives you the i,j index values back in one call.</div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="">You can see a graphical example of this function at:</div><div class="gmail_default" style=""><br></div><div class="gmail_default" style=""><a href="http://www.ncl.ucar.edu/Applications/wrfdebug.shtml">http://www.ncl.ucar.edu/Applications/wrfdebug.shtml<br></a></div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="">(example wrf_debug_4.ncl)</div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="">Good luck,</div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="">--Mary</div><div class="gmail_default" style=""><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 26, 2016 at 7:47 AM, Karin Meier-Fleischer <span dir="ltr">&lt;<a href="mailto:meier-fleischer@dkrz.de" target="_blank">meier-fleischer@dkrz.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Sorry, little mistake in coloring the lines. It must be:<div><div class="h5"><br>
    <br>
    <tt>  <font color="#3333ff"><b>lat13</b></font>  = 
      closest_val(13,lat)</tt><tt>       ;-- return index of closest
      latitude to 13 deg<br>
    </tt><tt>  <font color="#3333ff"><b>lon80</b></font>  = 
      closest_val(80,lon)</tt><tt>       ;-- return index of closest
      longitude to 80 deg<br>
    </tt><tt><br>
    </tt><tt>  print(&quot;lat({13}) (closest value) = &quot;+<font color="#ff0000"><b>lat({13})</b></font>+&quot;   Index of
      closest_val: &quot;+<font color="#3333ff">lat13</font>)</tt><tt><br>
    </tt><tt>  print(&quot;------------------&quot;)</tt><tt><br>
    </tt><tt>  print(&quot;lon({80})</tt><tt><tt> (closest value)</tt> = &quot;+<font color="#ff0000"><b>lon({80})</b></font>+&quot;   Index of
      closest_val: &quot;+<font color="#3333ff">lon80</font>)</tt><tt><br>
    </tt><tt>  print(&quot;------------------&quot;)</tt><tt><br>
    </tt><tt><br>
    </tt><tt>  lat_box = <font color="#009900">lat(lat13-2:lat13+2)</font></tt><tt>    
      ;-- using indices to get the lats around lat 13 deg.<br>
    </tt><tt>  lon_box = <font color="#009900">lon(lon80-2:lon80+2)</font></tt><tt>    
      ;-- using indices to get the lons around lon 80 deg.<br>
    </tt><tt><br>
    </tt><tt>  print(&quot;&quot;+lat_box)</tt><tt><br>
    </tt><tt>  print(&quot;------------------&quot;)</tt><tt><br>
    </tt><tt>  print(&quot;&quot;+lon_box)</tt><tt><br>
    </tt><tt>  print(&quot;--------------------------------------&quot;)</tt><tt><br>
    </tt><tt><br>
    </tt><tt>  lat_box2 = lat({lat13-2:lat13+2})</tt><tt>   ;-- Don&#39;t do
      this: this would use the index as latitude value !!<br>
    </tt><tt>  lon_box2 = lon({lon80-2:lon80+2})</tt><tt>   ;-- Don&#39;t do
      this: this would use the index as longitude value !!</tt><tt><br>
      <br>
    </tt><tt>  print(&quot;&quot;+lat_box2)</tt><tt><br>
    </tt><tt>  print(&quot;&quot;+lon_box2)</tt><tt><br>
    </tt><tt>  print(&quot;------------------&quot;)</tt><br>
    <br>
    It will returns, e.g<br>
    <br>
    <tt>(0)    lat({13})</tt><tt><tt> (closest value)</tt> = <font color="#ff0000"><b>12.12418712345578</b></font>   Index of
      closest_val: <font color="#3333ff"><b>41</b></font></tt><tt><br>
    </tt><tt>(0)    ------------------</tt><tt><br>
    </tt><tt>(0)    lon({80})</tt><tt><tt> (closest value)</tt> = <font color="#ff0000"><b>80.625</b></font>              Index of
      closest_val: <font color="#3333ff"><b>139</b></font></tt><tt><br>
    </tt><tt>(0)    ------------------</tt><tt><br>
    </tt><tt>(0)    <font color="#009900">15.85470386969488</font></tt><tt><br>
    </tt><tt>(1)    <font color="#009900">13.98944571235667</font></tt><tt><br>
    </tt><tt>(2)    <font color="#009900">12.12418712345578</font></tt><tt>      

      ; &lt;--- closest value<br>
    </tt><tt>(3)    <font color="#009900">10.25892816800639</font></tt><tt><br>
    </tt><tt>(4)    <font color="#009900">8.393668907692385</font></tt><tt><br>
    </tt><tt>(0)    ------------------</tt><tt><br>
    </tt><tt>(0)    <font color="#009900">76.875</font></tt><tt><br>
    </tt><tt>(1)    <font color="#009900">78.75</font></tt><tt><br>
    </tt><tt>(2)    <font color="#009900">80.625</font></tt><tt>                 

      ; &lt;--- closest value<br>
    </tt><tt>(3)    <font color="#009900">82.5</font></tt><tt><br>
    </tt><tt>(4)   <font color="#009900"> 84.375</font></tt><tt><br>
    </tt><tt>(0)    --------------------------------------</tt><tt><br>
    </tt><tt>(0)    40.1029793042494</tt><tt>    </tt><tt>;-- Don&#39;t do
      this: this would use the index as latitude value !!<br>
    </tt><tt>(1)    41.96822026907537</tt><tt><b> </b>  </tt><tt>;--
      Don&#39;t do this: this would use the index as latitude value !!<br>
    </tt><tt>(0)    138.75</tt><tt>              </tt><tt>;-- Don&#39;t do
      this: this would use the index as longitude value !!<br>
    </tt><tt>(1)    140.625</tt><tt>             </tt><tt>;-- Don&#39;t do
      this: this would use the index as longitude value !!<br>
    </tt><tt>(0)    ------------------</tt><br>
    <br>
    <br>
    <br>
    </div></div><div>Am 26.01.16 um 15:43 schrieb Karin
      Meier-Fleischer:<br>
    </div><div><div class="h5">
    <blockquote type="cite">
      
      Do you mean something like  <tt>var({lat13-2:lat13+2},{lon80-2:lon80+2})</tt> 
      ?<br>
      <br>
      Then the answer is no, the coordinate subscripting gets the value
      of the <br>
      closest grid cell and not the indices.<br>
      <br>
      <tt>lat({13})</tt> will use the latitude value which is the
      closest to 13 degrees, e.g. 12.12418.<br>
      <br>
      Let us assume the following snippet of a script:<br>
      <br>
      <tt>  <font color="#3333ff"><b>lat13</b></font>  = 
        closest_val(13,lat)</tt><tt>       ;-- return index of closest
        latitude to 13 deg<br>
      </tt><tt>  <font color="#3333ff"><b>lon80</b></font>  = 
        closest_val(80,lon)</tt><tt>       ;-- return index of closest
        longitude to 80 deg<br>
      </tt><tt><br>
      </tt><tt>  print(&quot;lat({13}) (closest value) = &quot;+<font color="#ff0000"><b>lat({13})</b></font>+&quot;   Index of
        closest_val: &quot;+<font color="#3333ff">lat13</font>)</tt><tt><br>
      </tt><tt>  print(&quot;------------------&quot;)</tt><tt><br>
      </tt><tt>  print(&quot;lon({80})</tt><tt><tt> (closest value)</tt> = &quot;+<font color="#ff0000"><b>lon({80})</b></font>+&quot;   Index of
        closest_val: &quot;+<font color="#3333ff">lon80</font>)</tt><tt><br>
      </tt><tt>  print(&quot;------------------&quot;)</tt><tt><br>
      </tt><tt><br>
      </tt><tt>  lat_box = lat(<font color="#3333ff">lat13</font>-2:<font color="#3333ff">lat13</font>+2)</tt><tt>     ;-- using indices
        to get the lats around lat 13 deg.<br>
      </tt><tt>  lon_box = lon(<font color="#3333ff">lon80</font>-2:<font color="#3333ff">lon80</font>+2)</tt><tt>     ;-- using indices
        to get the lons around lon 80 deg.<br>
      </tt><tt><br>
      </tt><tt>  print(&quot;&quot;+lat_box)</tt><tt><br>
      </tt><tt>  print(&quot;------------------&quot;)</tt><tt><br>
      </tt><tt>  print(&quot;&quot;+lon_box)</tt><tt><br>
      </tt><tt>  print(&quot;--------------------------------------&quot;)</tt><tt><br>
      </tt><tt><br>
      </tt><tt>  lat_box2 = <font color="#009900"><b>lat({lat13-2:lat13+2})</b></font></tt><tt>  

        ;-- Don&#39;t do this: this would use the index as latitude value !!<br>
      </tt><tt>  lon_box2 = <font color="#009900"><b>lon({lon80-2:lon80+2})</b></font></tt><tt>
          ;-- Don&#39;t do this: this would use the index as longitude value
        !!</tt><tt><br>
        <br>
      </tt><tt>  print(&quot;&quot;+lat_box2)</tt><tt><br>
      </tt><tt>  print(&quot;&quot;+lon_box2)</tt><tt><br>
      </tt><tt>  print(&quot;------------------&quot;)</tt><br>
      <br>
      It will returns, e.g<br>
      <br>
      <tt>(0)    lat({13})</tt><tt><tt> (closest value)</tt> = <font color="#ff0000"><b>12.12418712345578</b></font>   Index of
        closest_val: <font color="#3333ff"><b>41</b></font></tt><tt><br>
      </tt><tt>(0)    ------------------</tt><tt><br>
      </tt><tt>(0)    lon({80})</tt><tt><tt> (closest value)</tt> = <font color="#ff0000"><b>80.625</b></font>              Index of
        closest_val: <font color="#3333ff"><b>139</b></font></tt><tt><br>
      </tt><tt>(0)    ------------------</tt><tt><br>
      </tt><tt>(0)    <font color="#009900">15.85470386969488</font></tt><tt><br>
      </tt><tt>(1)    <font color="#009900">13.98944571235667</font></tt><tt><br>
      </tt><tt>(2)    <font color="#009900">12.12418712345578</font></tt><tt>      

        ; &lt;--- closest value<br>
      </tt><tt>(3)    <font color="#009900">10.25892816800639</font></tt><tt><br>
      </tt><tt>(4)    <font color="#009900">8.393668907692385</font></tt><tt><br>
      </tt><tt>(0)    ------------------</tt><tt><br>
      </tt><tt>(0)    <font color="#009900">76.875</font></tt><tt><br>
      </tt><tt>(1)    <font color="#009900">78.75</font></tt><tt><br>
      </tt><tt>(2)    <font color="#009900">80.625</font></tt><tt>                 

        ; &lt;--- closest value<br>
      </tt><tt>(3)    <font color="#009900">82.5</font></tt><tt><br>
      </tt><tt>(4)   <font color="#009900"> 84.375</font></tt><tt><br>
      </tt><tt>(0)    --------------------------------------</tt><tt><br>
      </tt><tt>(0)    <font color="#3333ff"><b>40.1029793042494</b></font></tt><tt>   

      </tt><tt>;-- Don&#39;t do this: this would use the index as latitude
        value !!<br>
      </tt><tt>(1)    <font color="#3333ff"><b>41.96822026907537</b></font></tt><tt>  

      </tt><tt>;-- Don&#39;t do this: this would use the index as latitude
        value !!<br>
      </tt><tt>(0)    <font color="#3333ff"><b>138.75</b></font></tt><tt>
                     </tt><tt>;-- Don&#39;t do this: this would use the
        index as longitude value !!<br>
      </tt><tt>(1)    <b><font color="#3333ff">140.625</font></b></tt><tt>
                    </tt><tt>;-- Don&#39;t do this: this would use the
        index as longitude value !!<br>
      </tt><tt>(0)    ------------------</tt><br>
      <br>
      <br>
      Hope this helps for understanding coordinate subscripting.<br>
      <br>
      Bye,<br>
      Karin<br>
      <br>
      <br>
      <br>
      <div>Am 26.01.16 um 15:13 schrieb Guido
        Cioni:<br>
      </div>
      <blockquote type="cite">
        
        Shouldn’t the coordinate subscripting do the same thing? 
        <div>Like say <font face="Menlo">{lat13-2:lat13+2,

             lon80-2:lon80+2}</font></div>
        <div>
          <div>
            <div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br>
              Guido Cioni</div>
            <div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="http://guidocioni.altervista.org" target="_blank"></a><a href="http://guidocioni.altervista.org" target="_blank">http://guidocioni.altervista.org</a> </div>
          </div>
          <br>
          <div>
            <blockquote type="cite">
              <div>On 26 Jan 2016, at 15:04, Karin
                Meier-Fleischer &lt;<a href="mailto:meier-fleischer@dkrz.de" target="_blank">meier-fleischer@dkrz.de</a>&gt;

                wrote:</div>
              <br>
              <div>
                
                <div bgcolor="#FFFFFF" text="#000000"> Hi
                  Krishna,<br>
                  <br>
                  you can use the function <b><tt>closest_val</tt></b>
                  to retrieve an index of an value.<br>
                  <br>
                  <tt>  lat13  =  closest_val(13,lat)</tt><tt><br>
                  </tt><tt>  lon80  =  closest_val(80,lon)</tt><br>
                  <br>
                  <tt>  print(&quot;Index: &quot;+lat13+&quot; - 
                    &quot;+lat(lat13))</tt><tt><br>
                  </tt><tt>  print(&quot;Index: &quot;+lon80+&quot; - 
                    &quot;+lon(lon80))</tt><br>
                  <br>
                  To plot 2 more grid boxes of lat/lon than you can use
                  e.g.<br>
                  <br>
                  <tt>  plot = gsn_csm_contour_map(wks,
                    var(lat13-2:lat13+2,lon80-2:lon80+2),res)</tt><br>
                  <br>
                  <br>
                  Bye,<br>
                  Karin<br>
                  <br>
                  <div>Am 26.01.16 um 14:13
                    schrieb Krishna C:<br>
                  </div>
                  <blockquote type="cite">
                    <div dir="ltr">
                      <div>Hi <br>
                        <br>
                        <br>
                      </div>
                      <div>Let us say i need a 2 by 2 box
                        around 13 degree lat and 80 degree lon . How do
                        i know the respective indices.<br>
                      </div>
                      <div>Please correct if i am wrong.  <br>
                      </div>
                    </div>
                    <div class="gmail_extra"><br clear="all">
                      <div>
                        <div>
                          <div dir="ltr">
                            <div style="text-align:left"><font size="2"><span style="font-family:times new roman,serif"><font size="2">R</font>egards<br>
                                </span></font></div>
                            <div style="text-align:left"><font face="verdana,sans-serif"><font size="2"><span style="font-family:times new roman,serif">-Krishna-</span></font></font><br>
                            </div>
                          </div>
                        </div>
                      </div>
                      <br>
                      <div class="gmail_quote">On Tue, Jan 26, 2016 at
                        5:14 PM, Guido Cioni <span dir="ltr">&lt;<a href="mailto:guidocioni@gmail.com" target="_blank"></a><a href="mailto:guidocioni@gmail.com" target="_blank">guidocioni@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">
                          <p dir="ltr">Yes there is, but you
                            should have a look at the documentation on
                            the page ;-)<br>
                            The function that you need is dim_avg_n,
                            then you just need to restrict the latitude
                            and longitude with brackets {43:45}. Again,
                            just go on ncl documentation and you&#39;ll
                            definitely find a way </p>
                          <div class="gmail_quote">
                            <div>
                              <div>Il 26 gen 2016 11:52 AM,
                                &quot;Krishna C&quot; &lt;<a href="mailto:chandrakrishna.90@gmail.com" target="_blank"></a><a href="mailto:chandrakrishna.90@gmail.com" target="_blank">chandrakrishna.90@gmail.com</a>&gt;


                                ha scritto:<br type="attribution">
                              </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>
                                      <div>Hi,<br>
                                        <br>
                                        <br>
                                      </div>
                                      I am trying to extract
                                      precipitation values from WRF
                                      output, over a small 2 by 2 lat 
                                      lon box and average it. Is there
                                      any explicit way of doing it in
                                      ncl<br>
                                      <br>
                                    </div>
                                    <div>With warm regards<br>
                                      <br>
                                    </div>
                                    <div>
                                      <div>
                                        <div>
                                          <div>
                                            <div>
                                              <div>
                                                <div dir="ltr">
                                                  <div style="text-align:left"><font size="2"><span style="font-family:times new roman,serif"><br>
                                                      </span></font></div>
                                                  <div style="text-align:left"><font face="verdana,sans-serif"><font size="2"><span style="font-family:times new roman,serif">-Krishna-</span></font></font><br>
                                                  </div>
                                                </div>
                                              </div>
                                            </div>
                                          </div>
                                        </div>
                                      </div>
                                    </div>
                                  </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>
                        </blockquote>
                      </div>
                      <br>
                    </div>
                    <br>
                    <fieldset></fieldset>
                    <br>
                    <pre>_______________________________________________
ncl-talk mailing list
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
                  </blockquote>
                  <br>
                </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" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
              </div>
            </blockquote>
          </div>
        </div>
      </blockquote>
      <br>
    </blockquote>
    <br>
    </div></div><pre cols="72">-- 
Dipl. Geophys. Karin Meier-Fleischer
Visualization, NCL
Application Support

Deutsches Klimarechenzentrum GmbH (DKRZ)
Bundesstrasse 45a - D20146 Hamburg - Germany

Phone:    <a href="tel:%2B49%20%280%2940%20460094%20126" value="+4940460094126" target="_blank">+49 (0)40 460094 126</a>
Fax:      <a href="tel:%2B49%20%280%2940%20460094%20270" value="+4940460094270" target="_blank">+49 (0)40 460094 270</a>
E-Mail:   <a href="mailto:meier-fleischer@dkrz.de" target="_blank">meier-fleischer@dkrz.de</a>
URL:      <a href="http://www.dkrz.de" target="_blank">www.dkrz.de</a>

Geschäftsführer: Prof. Dr. Thomas Ludwig
Sitz der Gesellschaft: Hamburg
Amtsgericht Hamburg HRB 39784
</pre>
  </div>

<br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">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>