<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Sorry, little mistake in coloring the lines. It must be:<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("lat({13}) (closest value) = "+<font
color="#ff0000"><b>lat({13})</b></font>+" Index of
closest_val: "+<font color="#3333ff">lat13</font>)</tt><tt><br>
</tt><tt> print("------------------")</tt><tt><br>
</tt><tt> print("lon({80})</tt><tt><tt> (closest value)</tt> = "+<font
color="#ff0000"><b>lon({80})</b></font>+" Index of
closest_val: "+<font color="#3333ff">lon80</font>)</tt><tt><br>
</tt><tt> print("------------------")</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(""+lat_box)</tt><tt><br>
</tt><tt> print("------------------")</tt><tt><br>
</tt><tt> print(""+lon_box)</tt><tt><br>
</tt><tt> print("--------------------------------------")</tt><tt><br>
</tt><tt><br>
</tt><tt> lat_box2 = lat({lat13-2:lat13+2})</tt><tt> ;-- Don't do
this: this would use the index as latitude value !!<br>
</tt><tt> lon_box2 = lon({lon80-2:lon80+2})</tt><tt> ;-- Don't do
this: this would use the index as longitude value !!</tt><tt><br>
<br>
</tt><tt> print(""+lat_box2)</tt><tt><br>
</tt><tt> print(""+lon_box2)</tt><tt><br>
</tt><tt> print("------------------")</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>
; <--- 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>
; <--- 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't do
this: this would use the index as latitude value !!<br>
</tt><tt>(1) 41.96822026907537</tt><tt><b> </b> </tt><tt>;--
Don't do this: this would use the index as latitude value !!<br>
</tt><tt>(0) 138.75</tt><tt> </tt><tt>;-- Don't do
this: this would use the index as longitude value !!<br>
</tt><tt>(1) 140.625</tt><tt> </tt><tt>;-- Don't do
this: this would use the index as longitude value !!<br>
</tt><tt>(0) ------------------</tt><br>
<br>
<br>
<br>
<div class="moz-cite-prefix">Am 26.01.16 um 15:43 schrieb Karin
Meier-Fleischer:<br>
</div>
<blockquote cite="mid:56A7860B.9030101@dkrz.de" type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
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("lat({13}) (closest value) = "+<font
color="#ff0000"><b>lat({13})</b></font>+" Index of
closest_val: "+<font color="#3333ff">lat13</font>)</tt><tt><br>
</tt><tt> print("------------------")</tt><tt><br>
</tt><tt> print("lon({80})</tt><tt><tt> (closest value)</tt> = "+<font
color="#ff0000"><b>lon({80})</b></font>+" Index of
closest_val: "+<font color="#3333ff">lon80</font>)</tt><tt><br>
</tt><tt> print("------------------")</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(""+lat_box)</tt><tt><br>
</tt><tt> print("------------------")</tt><tt><br>
</tt><tt> print(""+lon_box)</tt><tt><br>
</tt><tt> print("--------------------------------------")</tt><tt><br>
</tt><tt><br>
</tt><tt> lat_box2 = <font color="#009900"><b>lat({lat13-2:lat13+2})</b></font></tt><tt>
;-- Don'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't do this: this would use the index as longitude value
!!</tt><tt><br>
<br>
</tt><tt> print(""+lat_box2)</tt><tt><br>
</tt><tt> print(""+lon_box2)</tt><tt><br>
</tt><tt> print("------------------")</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>
; <--- 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>
; <--- 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'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'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'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'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 class="moz-cite-prefix">Am 26.01.16 um 15:13 schrieb Guido
Cioni:<br>
</div>
<blockquote
cite="mid:4C82BA4D-AB78-4BD7-886D-59DE76CAA8B8@gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
Shouldn’t the coordinate subscripting do the same thing?
<div class="">Like say <font class="" face="Menlo">{lat13-2:lat13+2,
lon80-2:lon80+2}</font></div>
<div class="">
<div class="">
<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; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class=""><br
class="Apple-interchange-newline">
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; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class=""><a
moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://guidocioni.altervista.org"><a class="moz-txt-link-freetext" href="http://guidocioni.altervista.org">http://guidocioni.altervista.org</a></a> </div>
</div>
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 26 Jan 2016, at 15:04, Karin
Meier-Fleischer <<a moz-do-not-send="true"
href="mailto:meier-fleischer@dkrz.de" class="">meier-fleischer@dkrz.de</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type" class="">
<div bgcolor="#FFFFFF" text="#000000" class=""> Hi
Krishna,<br class="">
<br class="">
you can use the function <b class=""><tt class="">closest_val</tt></b>
to retrieve an index of an value.<br class="">
<br class="">
<tt class=""> lat13 = closest_val(13,lat)</tt><tt
class=""><br class="">
</tt><tt class=""> lon80 = closest_val(80,lon)</tt><br
class="">
<br class="">
<tt class=""> print("Index: "+lat13+" -
"+lat(lat13))</tt><tt class=""><br class="">
</tt><tt class=""> print("Index: "+lon80+" -
"+lon(lon80))</tt><br class="">
<br class="">
To plot 2 more grid boxes of lat/lon than you can use
e.g.<br class="">
<br class="">
<tt class=""> plot = gsn_csm_contour_map(wks,
var(lat13-2:lat13+2,lon80-2:lon80+2),res)</tt><br
class="">
<br class="">
<br class="">
Bye,<br class="">
Karin<br class="">
<br class="">
<div class="moz-cite-prefix">Am 26.01.16 um 14:13
schrieb Krishna C:<br class="">
</div>
<blockquote
cite="mid:CAPtvbpvETbPM7KnKA0qcq9f1se6Z5nPfdtbe+LUwVZHVCX9F1w@mail.gmail.com"
type="cite" class="">
<div dir="ltr" class="">
<div class="">Hi <br class="">
<br class="">
<br class="">
</div>
<div class="">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 class="">
</div>
<div class="">Please correct if i am wrong. <br
class="">
</div>
</div>
<div class="gmail_extra"><br class="" clear="all">
<div class="">
<div class="gmail_signature">
<div dir="ltr" class="">
<div style="text-align:left" class=""><font
class="" size="2"><span
style="font-family:times new
roman,serif" class=""><font class=""
size="2">R</font>egards<br class="">
</span></font></div>
<div style="text-align:left" class=""><font
class="" face="verdana,sans-serif"><font
class="" size="2"><span
style="font-family:times new
roman,serif" class="">-Krishna-</span></font></font><br
class="">
</div>
</div>
</div>
</div>
<br class="">
<div class="gmail_quote">On Tue, Jan 26, 2016 at
5:14 PM, Guido Cioni <span dir="ltr" class=""><<a
moz-do-not-send="true"
class="moz-txt-link-abbreviated"
href="mailto:guidocioni@gmail.com"><a class="moz-txt-link-abbreviated" href="mailto:guidocioni@gmail.com">guidocioni@gmail.com</a></a>></span>
wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0
0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<p dir="ltr" class="">Yes there is, but you
should have a look at the documentation on
the page ;-)<br class="">
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'll
definitely find a way </p>
<div class="gmail_quote">
<div class="">
<div class="h5">Il 26 gen 2016 11:52 AM,
"Krishna C" <<a
moz-do-not-send="true"
href="mailto:chandrakrishna.90@gmail.com"
target="_blank" class=""><a class="moz-txt-link-abbreviated" href="mailto:chandrakrishna.90@gmail.com">chandrakrishna.90@gmail.com</a></a>>
ha scritto:<br type="attribution"
class="">
</div>
</div>
<blockquote class="gmail_quote"
style="margin:0 0 0 .8ex;border-left:1px
#ccc solid;padding-left:1ex">
<div class="">
<div class="h5">
<div dir="ltr" class="">
<div class="">
<div class="">Hi,<br class="">
<br class="">
<br class="">
</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 class="">
<br class="">
</div>
<div class="">With warm regards<br
class="">
<br class="">
</div>
<div class="">
<div class="">
<div class="">
<div class="">
<div class="">
<div class="">
<div dir="ltr" class="">
<div
style="text-align:left"
class=""><font
class="" size="2"><span
style="font-family:times
new roman,serif"
class=""><br
class="">
</span></font></div>
<div
style="text-align:left"
class=""><font
class=""
face="verdana,sans-serif"><font
class=""
size="2"><span
style="font-family:times
new
roman,serif"
class="">-Krishna-</span></font></font><br
class="">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br class="">
</div>
</div>
_______________________________________________<br class="">
ncl-talk mailing list<br class="">
<a moz-do-not-send="true"
href="mailto:ncl-talk@ucar.edu"
target="_blank" class="">ncl-talk@ucar.edu</a><br
class="">
List instructions, subscriber options,
unsubscribe:<br class="">
<a moz-do-not-send="true"
href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk"
rel="noreferrer" target="_blank"
class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br
class="">
<br class="">
</blockquote>
</div>
</blockquote>
</div>
<br class="">
</div>
<br class="">
<fieldset class="mimeAttachmentHeader"></fieldset>
<br class="">
<pre class="" wrap="">_______________________________________________
ncl-talk mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
</blockquote>
<br class="">
</div>
_______________________________________________<br
class="">
ncl-talk mailing list<br class="">
<a moz-do-not-send="true"
href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br
class="">
List instructions, subscriber options, unsubscribe:<br
class="">
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br
class="">
</div>
</blockquote>
</div>
</div>
</blockquote>
<br>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Dipl. Geophys. Karin Meier-Fleischer
Visualization, NCL
Application Support
Deutsches Klimarechenzentrum GmbH (DKRZ)
Bundesstrasse 45a - D20146 Hamburg - Germany
Phone: +49 (0)40 460094 126
Fax: +49 (0)40 460094 270
E-Mail: <a class="moz-txt-link-abbreviated" href="mailto:meier-fleischer@dkrz.de">meier-fleischer@dkrz.de</a>
URL: <a class="moz-txt-link-abbreviated" href="http://www.dkrz.de">www.dkrz.de</a>
Geschäftsführer: Prof. Dr. Thomas Ludwig
Sitz der Gesellschaft: Hamburg
Amtsgericht Hamburg HRB 39784
</pre>
</body>
</html>