<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Can you tell me what is the final goal? Otherwise it is really difficult to give you advices :)&nbsp;<div class=""><br class=""><div class="">Are you <u class="">sure</u> that your script is working correctly? As far as I understand the <font face="Menlo" class="">mask</font> function acts only on the values where the mask array condition is true, so in your case <font face="Menlo" class="">T2_masked</font> should be untouched, i.e. <font face="Menlo" class="">T2_masked=T2</font>. Have you tried printing or plotting the difference <font face="Menlo" class="">T2-T2_masked</font>?You should instead mask all the points that <u class="">DO NOT</u> have <font face="Menlo" class="">LU_INDEX=2</font>, as I previously suggested. Furthermore, you should set the <font face="Menlo" class="">FillValue</font> BEFORE calling mask, otherwise the <font face="Menlo" class="">True</font>, <font face="Menlo" class="">False</font> conditions will not apply correctly. If you are more confident with the <font face="Menlo" class="">where</font> syntax use something like this</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">where( LU_INDEX=2, T2(time_i,:,:), T2@_FilllValue)</font></div><div class=""><br class=""></div><div class="">However you would need to do that for every time instant with a loop...</div><div class=""><br class=""></div><div class="">Now to the other question. <u class="">Are you really sure</u> that you want to SUBSET your data given a certain condition? If you just need to extract statistics from those data having the original array masked is the best way to go as NCL will deal with Missing Values without problems. If you instead try to subset your data you will end up with a weird shaped array, as the LU_INDEX=2 condition, I believe, is not spatially coherent like say a box or a circle. One way to go would be to convert the temperature array to a 1-D one with <font face="Menlo" class="">ndtooned</font> (<a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/ndtooned.shtml" class="">https://www.ncl.ucar.edu/Document/Functions/Built-in/ndtooned.shtml</a>), apply the <font face="Menlo" class="">ind</font> function and then convert back to a multidimensional array (Example 3 at this page is useful&nbsp;<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/minind.shtml" class="">http://www.ncl.ucar.edu/Document/Functions/Built-in/minind.shtml</a>). But really, it is cumbersome and useless depending on what is your final goal.&nbsp;</div><div class=""><br class=""></div><div class="">I think there are a lot of examples on the online guide.</div><div class=""><br class=""></div><div class="">Good Luck&nbsp;</div><div class=""><div class=""><div class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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-caps: 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 href="http://guidocioni.altervista" class="">http://guidocioni.altervista</a>.org</div>

</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 14 Mar 2017, at 10:06, Imran Hosen &lt;<a href="mailto:hosen.imran09@gmail.com" class="">hosen.imran09@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class="">Dear Guido and Barry,<br class=""><br class=""></div>Thank you so much for your heartfelt and prompt response. Yes, your suggestions are working fine for my script.<br class=""><br class=""></div>Guido, your assumption is absolutely right. According your suggestion I wrote the script as follows:<br class=""><br class=""></div>T2 = f_1-&gt;T2(:,:,:)<br class=""></div>LU_INDEX = f_1-&gt;LU_INDEX(0,:,:)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; (LU_INDEX = landuse index)<br class=""></div>T2_masked = mask(T2,(LU_INDEX.eq.2), True)<br class=""></div>T2_masked@_FillValue = -9999<br class=""></div>print(T2_masked)<br class=""><br class=""></div>The script works fine and it is extracting both real values and FillValues (missing values). <b class="">But, I want to extract only real values</b>. I have seen that "<b class="">ind</b>" function can be used for extracting real values for <b class="">one-dimensional array</b>. Could you please suggest me what function I can use to extract the real values for <b class="">two-dimensional array</b>.<br class=""><br class=""></div><div class="">Your further suggestion will be highly appreciated.<br class=""><br class=""></div><div class="">Kind regards,<br class=""></div><div class="">Imran<br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Mar 14, 2017 at 6:55 PM, Guido Cioni <span dir="ltr" class="">&lt;<a href="mailto:guidocioni@gmail.com" target="_blank" class="">guidocioni@gmail.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi Imran,<div class="">unfortunately I’m not really an expert of WRF, so I’m going to give you a general hint which may work. You should be more precise next time as generally people do not know what is LU_INDEX and what is its structure ;)&nbsp;</div><div class=""><br class=""></div><div class="">I assume that you want to extract temperature, which is 3-D (time, lat, lon) using a mask array LU_INDEX which is 2-D (lat, lon). Again, if this assumption is wrong please be more specific. You have many choices, but I believe that for the sake of clarity you may want to go for an array which has the same dimensions but missing values where LU_INDEX is not 2. So you may want to do something like this:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">T2_masked=mask(T2, LU_INDEX.ne.2, False).</font></div><div class=""><br class=""></div><div class="">You need to have a Missing Value attribute set for the T2 variable of course. As a result you will get an array with the same dimensions, so that it’s easier to compare with the original one, but with Missing Values where your condition is False, so that for every computation these points will not be considered. You can achieve something similar with the where function. Please have a look here (<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/mask.shtml" target="_blank" class="">http://www.ncl.ucar.edu/<wbr class="">Document/Functions/Built-in/<wbr class="">mask.shtml</a>).</div><div class=""><br class=""></div><div class="">Cheers</div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="h5"><div class="">Il giorno 14 mar 2017, alle ore 04:38, Imran Hosen &lt;<a href="mailto:hosen.imran09@gmail.com" target="_blank" class="">hosen.imran09@gmail.com</a>&gt; ha scritto:</div><br class="m_-4721575193858994257Apple-interchange-newline"></div></div><div class=""><div class=""><div class="h5"><div dir="ltr" class=""><div class=""><div class="">Dear NCL users,<br class=""><br class=""></div>Good day!<br class=""><br class=""></div>I'm a new user of NCL. I want to extract temperature (T2) from wrfout file for the specific grid points where the LU_INDEX = 2.<br clear="all" class=""><div class=""><div class=""><div class=""><br class=""><div class="m_-4721575193858994257gmail_signature" data-smartmail="gmail_signature"><div class="">For example,<br class=""></div><div class="">f = addfile("./<a href="http://wrfout.nc/" target="_blank" class="">wrfout.nc</a>)<br class=""></div><div class="">T2 = f-&gt;T2(:,:,:)<br class=""><br class=""></div><div class="">It will extract temperature for whole domain for all time steps. In my case, I only want to extract temperature for all time steps but for the specific grids which grids represent LU_INDEX = 2.<br class=""><br class=""></div><div class="">Could you please suggest how to do it. I would grateful to you if anyone please share a script.<br class=""><br class=""></div><div class="">Thanks in advance.<br class=""><br class=""></div><div class="">Kind regards,<br class=""></div><div class="">Imran<br class=""></div><div class=""><br class=""></div></div>
</div></div></div></div></div></div><span class="">
______________________________<wbr class="">_________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" target="_blank" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class=""><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank" class="">http://mailman.ucar.edu/<wbr class="">mailman/listinfo/ncl-talk</a><br class=""></span></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""><br clear="all" class=""><br class="">-- <br class=""><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div style="font-size:small;font-family:arial" class=""><b style="color:rgb(0,153,0);font-family:'arial black',sans-serif" class="">Md. Imran Hosen</b><br class=""></div><div style="font-size:small;font-family:arial" class=""><span style="color:rgb(204,51,204)" class="">PhD Student&nbsp;</span></div><div class=""><font color="#cc33cc" style="font-family:arial;font-size:small" class="">Victoria University</font></div><div class=""><span style="color:rgb(204,51,204);font-family:arial;font-size:small" class="">College of Engineering and Science</span><font face="arial" size="2" class=""><br style="color:rgb(204,51,204)" class=""></font><font color="#cc33cc" face="arial" size="2" class="">Footscray&nbsp;Park Campus</font></div><div class=""><font color="#cc33cc" face="arial" size="2" class="">Victoria, Australia</font><br style="color:rgb(204,51,204)" class=""><span style="font-family:arial;font-size:small;color:rgb(204,51,204)" class="">Mob. +61470371562</span></div><br class=""><br class=""></div></div>
</div>
</div></blockquote></div><br class=""></div></div></div></body></html>