<div dir="ltr">Hi:<div><br></div><div>I used the mask command to remove data I did not want to map. I am not sure what the values become in the masked area.</div><div><br></div><div>Another way to do this is for a single time loop</div><div><br></div><div>lu_index = LU_INDEX(time,:,:)</div><div>my_t2 = lu_index</div><div>my_t2 = -9999</div><div>; assuming t2 has dimensions of space, not time.</div><div><br></div><div>dims2d = dimsizes(lu_index)</div><div><br></div><div>do j = 1, dims2d(0)</div><div>do i = 1, dims2d(1)</div><div><br></div><div>if (lu_index(j,i).eq.1) then</div><div>my_t2(j,i) = t2(j,i)</div><div>end if</div><div>end do</div><div>end do</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 14, 2017 at 11:24 AM, Guido Cioni <span dir="ltr"><<a href="mailto:guidocioni@gmail.com" target="_blank">guidocioni@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Can you tell me what is the final goal? Otherwise it is really difficult to give you advices :) <div><br><div>Are you <u>sure</u> that your script is working correctly? As far as I understand the <font face="Menlo">mask</font> function acts only on the values where the mask array condition is true, so in your case <font face="Menlo">T2_masked</font> should be untouched, i.e. <font face="Menlo">T2_masked=T2</font>. Have you tried printing or plotting the difference <font face="Menlo">T2-T2_masked</font>?You should instead mask all the points that <u>DO NOT</u> have <font face="Menlo">LU_INDEX=2</font>, as I previously suggested. Furthermore, you should set the <font face="Menlo">FillValue</font> BEFORE calling mask, otherwise the <font face="Menlo">True</font>, <font face="Menlo">False</font> conditions will not apply correctly. If you are more confident with the <font face="Menlo">where</font> syntax use something like this</div><div><br></div><div><font face="Menlo">where( LU_INDEX=2, T2(time_i,:,:), T2@_FilllValue)</font></div><div><br></div><div>However you would need to do that for every time instant with a loop...</div><div><br></div><div>Now to the other question. <u>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">ndtooned</font> (<a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/ndtooned.shtml" target="_blank">https://www.ncl.ucar.edu/<wbr>Document/Functions/Built-in/<wbr>ndtooned.shtml</a>), apply the <font face="Menlo">ind</font> function and then convert back to a multidimensional array (Example 3 at this page is useful <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/minind.shtml" target="_blank">http://www.ncl.ucar.<wbr>edu/Document/Functions/Built-<wbr>in/minind.shtml</a>). But really, it is cumbersome and useless depending on what is your final goal. </div><div><br></div><div>I think there are a lot of examples on the online guide.</div><div><br></div><div>Good Luck </div><div><div><span class="HOEnZb"><font color="#888888"><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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br class="m_-1082405776634214611Apple-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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="http://guidocioni.altervista" target="_blank">http://guidocioni.altervista</a>.<wbr>org</div>
</div></font></span><div><div class="h5">
<br><div><blockquote type="cite"><div>On 14 Mar 2017, at 10:06, Imran Hosen <<a href="mailto:hosen.imran09@gmail.com" target="_blank">hosen.imran09@gmail.com</a>> wrote:</div><br class="m_-1082405776634214611Apple-interchange-newline"><div><div dir="ltr"><div><div><div><div><div><div><div><div><div>Dear Guido and Barry,<br><br></div>Thank you so much for your heartfelt and prompt response. Yes, your suggestions are working fine for my script.<br><br></div>Guido, your assumption is absolutely right. According your suggestion I wrote the script as follows:<br><br></div>T2 = f_1->T2(:,:,:)<br></div>LU_INDEX = f_1->LU_INDEX(0,:,:) ; (LU_INDEX = landuse index)<br></div>T2_masked = mask(T2,(LU_INDEX.eq.2), True)<br></div>T2_masked@_FillValue = -9999<br></div>print(T2_masked)<br><br></div>The script works fine and it is extracting both real values and FillValues (missing values). <b>But, I want to extract only real values</b>. I have seen that "<b>ind</b>" function can be used for extracting real values for <b>one-dimensional array</b>. Could you please suggest me what function I can use to extract the real values for <b>two-dimensional array</b>.<br><br></div><div>Your further suggestion will be highly appreciated.<br><br></div><div>Kind regards,<br></div><div>Imran<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 14, 2017 at 6:55 PM, Guido Cioni <span dir="ltr"><<a href="mailto:guidocioni@gmail.com" target="_blank">guidocioni@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Imran,<div>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 ;) </div><div><br></div><div>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><br></div><div><font face="Menlo">T2_masked=mask(T2, LU_INDEX.ne.2, False).</font></div><div><br></div><div>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">http://www.ncl.ucar.edu/Docum<wbr>ent/Functions/Built-in/mask.<wbr>shtml</a>).</div><div><br></div><div>Cheers</div><div><br></div><div><br><div><blockquote type="cite"><div><div class="m_-1082405776634214611h5"><div>Il giorno 14 mar 2017, alle ore 04:38, Imran Hosen <<a href="mailto:hosen.imran09@gmail.com" target="_blank">hosen.imran09@gmail.com</a>> ha scritto:</div><br class="m_-1082405776634214611m_-4721575193858994257Apple-interchange-newline"></div></div><div><div><div class="m_-1082405776634214611h5"><div dir="ltr"><div><div>Dear NCL users,<br><br></div>Good day!<br><br></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"><div><div><div><br><div class="m_-1082405776634214611m_-4721575193858994257gmail_signature" data-smartmail="gmail_signature"><div>For example,<br></div><div>f = addfile("./<a href="http://wrfout.nc/" target="_blank">wrfout.nc</a>)<br></div><div>T2 = f->T2(:,:,:)<br><br></div><div>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><br></div><div>Could you please suggest how to do it. I would grateful to you if anyone please share a script.<br><br></div><div>Thanks in advance.<br><br></div><div>Kind regards,<br></div><div>Imran<br></div><div><br></div></div>
</div></div></div></div></div></div><span>
______________________________<wbr>_________________<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/mailma<wbr>n/listinfo/ncl-talk</a><br></span></div></blockquote></div><br></div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="m_-1082405776634214611gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div style="font-size:small;font-family:arial"><b style="color:rgb(0,153,0);font-family:'arial black',sans-serif">Md. Imran Hosen</b><br></div><div style="font-size:small;font-family:arial"><span style="color:rgb(204,51,204)">PhD Student </span></div><div><font color="#cc33cc" style="font-family:arial;font-size:small">Victoria University</font></div><div><span style="color:rgb(204,51,204);font-family:arial;font-size:small">College of Engineering and Science</span><font face="arial" size="2"><br style="color:rgb(204,51,204)"></font><font color="#cc33cc" face="arial" size="2">Footscray Park Campus</font></div><div><font color="#cc33cc" face="arial" size="2">Victoria, Australia</font><br style="color:rgb(204,51,204)"><span style="font-family:arial;font-size:small;color:rgb(204,51,204)">Mob. <a href="tel:+61%20470%20371%20562" value="+61470371562" target="_blank">+61470371562</a></span></div><br><br></div></div>
</div>
</div></blockquote></div><br></div></div></div></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Barry H. Lynn, Ph.D<div><div>Senior Lecturer,</div><div><div><span style="color:rgb(136,136,136)">The Institute of the Earth Science, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">The Hebrew University of Jerusalem, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Givat Ram, Jerusalem 91904, Israel </span><br style="color:rgb(136,136,136)"></div><span style="color:rgb(136,136,136)">Tel: 972 547 231 170</span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Fax: (972)-25662581</span></div></div><div><span style="color:rgb(136,136,136)"><br></span></div><div>C.E.O, Weather It Is, LTD<br>Weather and Climate Focus<br><a href="http://weather-it-is.com" target="_blank">http://weather-it-is.com</a><br>Jerusalem, Israel<br>Local: 02 930 9525<br>Cell: 054 7 231 170<br>Int-IS: x972 2 930 9525<br>US 914 432 3108<br></div></div></div>
</div>