<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=""><div class="">Imran,</div><div class="">you should read the documentation carefully. </div><div class="">Look here <a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/dim_avg_n_Wrap.shtml" class="">http://www.ncl.ucar.edu/Document/Functions/Contributed/dim_avg_n_Wrap.shtml</a></div><div class=""><br class=""></div><div class="">[…] <span style="color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13.3333px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class="">Computes the average of all elements of the dimensions indicated by </span><em style="color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13.3333px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255); margin: 0px; padding: 0px;" class="">dims</em><span style="color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13.3333px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class=""> </span><span style="color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13.3333px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class="">for each index of all other dimensions and retains metadata. A</span><span style="color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13.3333px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class=""> </span><a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/wrapper.shtml" style="font-family: verdana, sans-serif; font-size: 13.3333px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255); margin: 0px; padding: 0px; text-decoration: none; color: rgb(133, 45, 133);" class="">wrapper</a><span style="color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13.3333px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class=""> </span><span style="color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13.3333px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class="">function.</span><span style="color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13.3333px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class=""> </span><b style="color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13.3333px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class=""><a href="http://www.ncl.ucar.edu/Document/Language/fillval.shtml" style="margin: 0px; padding: 0px; text-decoration: none; color: rgb(133, 45, 133);" class="">Missing values</a> are ignored.</b><span style="color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13.3333px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class="">[…]</span></div><div class=""><div class=""><br class=""></div><div class="">So Missing Values are NOT used to compute the average. Generally in NCL most of the functions are designed to ignore missing values. If you check the description of a function there is always a note that tells you how missing values are handled.</div><div class=""><br class=""></div><div class="">If you want to check whether the mask function worked you have many options:</div><div class=""><br class=""></div><div class=""><ol class="MailOutline"><li class="">with the <font face="Menlo" class="">print(T2_masked)</font> statement you should get a list of numbers and <font face="Menlo" class="">False</font>;</li><li class="">with the <font face="Menlo" class="">ismissing</font> (<a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/ismissing.shtml" class="">https://www.ncl.ucar.edu/Document/Functions/Built-in/ismissing.shtml</a>) function you can count the number of <font face="Menlo" class="">_FillValue</font> elements in a multidimensional array;</li><li class="">with a simple <font face="Menlo" class="">gsn_csm_contour_map</font> you can plot <font face="Menlo" class="">T2_masked</font> and see whether it contains grey rectangles (the default way of indicating missing values) over a map.</li></ol><div class=""><br class=""></div></div><div class="">Please read the available documentation before writing to NCL-list next time ;) </div><div class=""><br class=""></div><a name="See_also" style="margin: 0px; padding: 0px; color: rgb(0, 64, 255); font-family: verdana, sans-serif; font-size: 13.3333px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class=""></a><span style="font-family: verdana, sans-serif; font-size: 13.3333px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class=""></span></div><br class=""><div><blockquote type="cite" class=""><div class="">Il giorno 15 mar 2017, alle ore 06:02, Imran Hosen <<a href="mailto:hosen.imran09@gmail.com" class="">hosen.imran09@gmail.com</a>> ha scritto:</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=""><div class="">Dear Guido,<br class=""><br class=""></div>Good day!<br class=""><br class=""></div>It seems to me that <b class="">"mask"</b> function is better for me as I am extracting data for 24 hours. I don't want to use "<b class="">where"</b> function as it needs a loop. Finally, I wrote the script as follows:<br class=""><br class="">T2 = f_1->T2(0:24,:,:)<br class="">LU_INDEX = f_1->LU_INDEX(0,:,:) ; (LU_INDEX = landuse index)<br class="">T2_masked = mask(T2,(LU_INDEX.ne.2), False)<br class="">print(T2_masked)<br class=""><br class=""></div><div class="">Then I am trying to get area average temperature for 24 hours and calculated area average as follows:<br class=""><br class=""></div>T2_area_avg = dim_avg_n_Wrap(T2_masked,(/1,2/))<br class=""></div>print(T2_area_avg)<br class=""><br class=""></div>After printing T2_area_avg, I'm getting a set of real values for 24 hours. <br class=""><br class=""></div>But I'm not sure whether T2_area_avg accurately left all missing vales. Also, I'm not getting a way to check which values (only real or both real and missing values) are considered for T2_area_avg calculation. You said that NCL deals with missing values without problem. <b class="">Could you please tell me how NCL is dealing with missing values for calculating T2_area_avg. </b><br class=""><br class=""></div><b class="">Is "dim_avg_n_Wrap" function only considering the real values without missing values??? </b><br class=""><br class=""></div>Ardently looking forward to your further advise.<br class=""><br class=""></div>Kind regards,<br class=""></div>Imran<br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Mar 15, 2017 at 1:08 AM, Imran Hosen <span dir="ltr" class=""><<a href="mailto:hosen.imran09@gmail.com" target="_blank" class="">hosen.imran09@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Hi Guido and Barry,<div class=""><br class=""></div><div class="">Thanks again for your further advices. </div><div class=""><br class=""></div><div class="">Actually, in the study domain, it has 117 rows*117 columns (total 13689 grids). The grids have different land use index (LU_INDEX). I ran simulations using the WRF model for simulating different climate variables. Now, my goal is, I want to plot (XY plot) the hourly temperature difference between the grid cells whose LU_INDEX=2 and LU_INDEX=1. Therefore, I want to extract temperature seperately for the grid cells whose LU_INDEX=2. I'll do same thing for the grid cells whose LU_INDEX=1. Then I will make XY plot, although I never experinced NCL for making XY plot. Hope, now you will understand my goal.</div><div class=""><br class=""></div><div class="">If I use mask function as the script I wrote, then T2_masked = T2 (only for the grid cells where LU_INDEX is not equal to 2), right??? So, I made a mistake in my script, and I should follow your previous suggestion, right??</div><div class=""><br class=""></div><div class="">When I use mask or where function, it is showing both real and FillValue. Really, I want to extract only real values for the grid cells where LU_INDEX=2 and want to escape the FillValues.</div><div class=""><br class=""></div><div class="">Okay, I'll try to implement your advice and let you know the update.</div><div class=""><br class=""></div><div class="">Wish your uninterrupted sound health.</div><div class=""><br class=""></div><div class="">Kind regards,</div><div class="">Imran</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Mar 14, 2017 at 8:24 PM, Guido Cioni <span dir="ltr" class=""><<a href="mailto:guidocioni@gmail.com" target="_blank" class="">guidocioni@gmail.com</a>></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="">Can you tell me what is the final goal? Otherwise it is really difficult to give you advices :) <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" target="_blank" class="">https://www.ncl.ucar.edu/Docu<wbr class="">ment/Functions/Built-in/ndtoon<wbr class="">ed.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 <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/minind.shtml" target="_blank" class="">http://www.ncl.ucar.edu<wbr class="">/Document/Functions/Built-in/<wbr class="">minind.shtml</a>). But really, it is cumbersome and useless depending on what is your final goal. </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 </div><div class=""><div class=""><span class="m_-3989813313867987420HOEnZb"><font color="#888888" class=""><div class="">
<div style="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;" class=""><br class="m_-3989813313867987420m_141544419496345103Apple-interchange-newline">Guido Cioni</div><div style="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;" class=""><a href="http://guidocioni.altervista/" target="_blank" class="">http://guidocioni.altervista</a>.o<wbr class="">rg</div>
</div></font></span><div class=""><div class="m_-3989813313867987420h5">
<br class=""><div class=""><blockquote type="cite" class=""><div class="">On 14 Mar 2017, at 10:06, Imran Hosen <<a href="mailto:hosen.imran09@gmail.com" target="_blank" class="">hosen.imran09@gmail.com</a>> wrote:</div><br class="m_-3989813313867987420m_141544419496345103Apple-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->T2(:,:,:)<br class=""></div>LU_INDEX = f_1->LU_INDEX(0,:,:) ; (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=""><<a href="mailto:guidocioni@gmail.com" target="_blank" class="">guidocioni@gmail.com</a>></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 ;) </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/Docum<wbr class="">ent/Functions/Built-in/mask.sh<wbr class="">tml</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="m_-3989813313867987420m_141544419496345103h5"><div class="">Il giorno 14 mar 2017, alle ore 04:38, Imran Hosen <<a href="mailto:hosen.imran09@gmail.com" target="_blank" class="">hosen.imran09@gmail.com</a>> ha scritto:</div><br class="m_-3989813313867987420m_141544419496345103m_-4721575193858994257Apple-interchange-newline"></div></div><div class=""><div class=""><div class="m_-3989813313867987420m_141544419496345103h5"><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_-3989813313867987420m_141544419496345103m_-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->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/mailma<wbr class="">n/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="m_-3989813313867987420m_141544419496345103gmail_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 </span></div><div class=""><font style="font-family:arial;font-size:small" color="#cc33cc" 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 size="2" face="arial" class=""><br style="color:rgb(204,51,204)" class=""></font><font size="2" color="#cc33cc" face="arial" class="">Footscray Park Campus</font></div><div class=""><font size="2" color="#cc33cc" face="arial" 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. <a href="tel:+61%20470%20371%20562" value="+61470371562" target="_blank" class="">+61470371562</a></span></div><br class=""><br class=""></div></div>
</div>
</div></blockquote></div><br class=""></div></div></div></div></div></div></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="m_-3989813313867987420gmail_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 </span></div><div class=""><font style="font-family:arial;font-size:small" color="#cc33cc" 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 size="2" face="arial" class=""><br style="color:rgb(204,51,204)" class=""></font><font size="2" color="#cc33cc" face="arial" class="">Footscray Park Campus</font></div><div class=""><font size="2" color="#cc33cc" face="arial" 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. <a href="tel:+61%20470%20371%20562" value="+61470371562" target="_blank" class="">+61470371562</a></span></div><br class=""><br class=""></div></div>
</div>
</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 </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 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=""></body></html>