<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Sorry, the command for the new variable should be <div class=""><br class=""></div><div class="">temp_file = new((/dimsizes(…),dimsizes(…),dimsizes(…)/),float,<span style="font-variant-ligatures: normal; orphans: 2; text-align: -webkit-right; widows: 2; background-color: rgb(255, 255, 255);" class="">9.96921e+36)</span><div class=""><span style="font-variant-ligatures: normal; orphans: 2; text-align: -webkit-right; widows: 2; background-color: rgb(255, 255, 255);" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: normal; orphans: 2; text-align: -webkit-right; widows: 2; background-color: rgb(255, 255, 255);" class=""><br class=""></span></div><div class=""><div style="text-align: left; orphans: 2; widows: 2;" class=""><span style="background-color: rgb(255, 255, 255);" class="">Toni</span></div><div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div><br class=""><br class=""><b class="">Toni Klemm, Ph.D.<br class=""></b>Postdoctoral Research Associate<br class="">Department of Ecosystem Science and Management<br class="">College of Agriculture and Life Sciences<br class="">Texas A&M University, College Station, TX<br class=""><a href="http://www.toni-klemm.de" class="">www.toni-klemm.de</a> | <a href="http://www.twitter.com/toniklemm" class="">@toniklemm</a><br class="">Editorial Board member, <a href="http://www.eccforum.org" class="">Early Career Climate Forum</a><br class=""><br class=""><br class=""><br class=""><br class=""><br class=""><br class=""><br class=""></div></div></div></div>
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On Sep 24, 2019, at 10:40 AM, Toni Klemm <<a href="mailto:toni-klemm@tamu.edu" class="">toni-klemm@tamu.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Trisanu,<div class=""><br class=""></div><div class=""><div class="">What you’re doing right now is replacing the value in temp_file with each loop, which is why your average at the end is equal to that of the last iteration.</div><div class=""><div class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""></div></div></div></div></div></div><div class=""><br class=""></div><div class="">Change this line in your if-loop from this</div><div class=""><br class=""></div><div class=""><div class=""> temp_file = spd(i,j,k)</div></div><div class=""><br class=""></div><div class="">to this</div><div class=""><br class=""></div><div class=""><div class=""> temp_file(i,j,k) = spd(i,j,k)</div></div><div class=""><br class=""></div><div class="">and before your first do loop create a new variable “temp_file” as an three-dimensional array (temp_file = new((/dimsizes(…),dimsizes(…),dimsizes(…)/),float,) with the dimensions of time and loc.</div><div class=""><br class=""></div><div class="">Good luck,</div><div class="">Toni</div><div class=""><br class=""></div><div class=""><div class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""><b class="">Toni Klemm, Ph.D.<br class=""></b>Postdoctoral Research Associate<br class="">Department of Ecosystem Science and Management<br class="">College of Agriculture and Life Sciences<br class="">Texas A&M University, College Station, TX<br class=""><a href="http://www.toni-klemm.de/" class="">www.toni-klemm.de</a> | <a href="http://www.twitter.com/toniklemm" class="">@toniklemm</a><br class="">Editorial Board member, <a href="http://www.eccforum.org/" class="">Early Career Climate Forum</a><br class=""><br class=""><br class=""><br class=""><br class=""><br class=""><br class=""><br class=""></div></div></div></div>
</div>
<div class=""><br class=""><blockquote type="cite" class=""><div class="">On Sep 24, 2019, at 9:52 AM, Trisanu Banik via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:verdana,sans-serif">Dear All<br class=""></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:verdana,sans-serif">I need one help related to Do loop in NCL. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:verdana,sans-serif">I have attached a code, the target of the code is to take data for few lat, long points represented by Do loops of j and k. Collected data values for the desired lat long need to put in the variable temp_file. Therefore, what I expect temp_file should be populated with all the data values(from spd variable) corresponding to the lat long in 'loc' variable. Here the loop of j and k completes when j and k run from loc(1,0) to loc(1,1) and loc(0,0) to loc(0,1). Once the data has been collected in temp_file, next target is to take average of all the data and put it in the variable final_spd. Here average value is put in the variable temp_avg. The same iteration needs to do for 48 different times. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:verdana,sans-serif">Here what I noticed the loop of j and k each time filled the temp_file with a single value upto its dimension 30 and each iteration of j and k did the same task. Therefore, instead of taking average over various data value corresponding to different lat long it takes average on a single value that arises during the last iteration and put it in the final_spd variable. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:verdana,sans-serif">What I want is to take all the data corresponds to the j and k loop corresponding to a particular time (represented by i loop) and take the average over those data and put it in the final_spd variable and need to do the same task for next 47 hours and put the average in final_spd variable. So what I expect the final_spd variable should have 1 column and 48 different row. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:verdana,sans-serif">Please suggest me how to do the same. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:verdana,sans-serif">Thanks & Regards</div><div class="gmail_default" style="font-family:verdana,sans-serif">Trisanu</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br class=""></div><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div style="text-align:center" class=""><div style="text-align:left" class=""><b class=""><font face="verdana, sans-serif" class="">Trisanu Banik,PhD</font></b></div><div style="text-align:left" class=""><b class=""><font face="verdana, sans-serif" class="">Research Scientist<br class=""></font></b></div><div class="">
</div><div style="text-align:left" class=""><b class=""><font face="verdana, sans-serif" class="">North Eastern Space Applications Centre (NESAC)<br class=""></font></b></div><div style="text-align:left" class=""><font face="verdana, sans-serif" class=""><b style="font-size:12.8px" class=""><span style="font-size:12.8px" class="">Government of India</span></b><br class=""></font></div><div style="text-align:left" class=""><font face="verdana, sans-serif" class=""><b style="font-size:12.8px" class=""><span style="font-size:12.8px" class="">Department of Space</span></b><b style="font-size:12.8px" class=""><span style="font-size:12.8px" class=""><br class=""></span></b></font></div><div style="text-align:left" class=""><b class=""><font face="verdana, sans-serif" class=""><span style="font-size:12.8px" class="">Umiam-793103, Meghalaya</span><br class=""></font></b></div><div style="text-align:left" class=""><b class=""><font face="verdana, sans-serif" class="">Mobile-9774837581</font></b></div><div style="text-align:left" class=""><br class=""></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<span id="cid:f_k0xyaqko0" class=""><ncl code.txt></span>_______________________________________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class=""><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.ucar.edu_mailman_listinfo_ncl-2Dtalk&d=DwICAg&c=u6LDEWzohnDQ01ySGnxMzg&r=zmhRVp0i4wZ5_1Ujh0fnRXAExHgKLTQu0rZLW7PxKA4&m=KcQ3IFUyt22n95ZzVhfXm_CPUrgeT4hH8CQtpL3PR8g&s=xNeSEQbuEzzbPi9PeZMhSLHPcAUX3iHSeX1mr-J9Swk&e=" class="">https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.ucar.edu_mailman_listinfo_ncl-2Dtalk&d=DwICAg&c=u6LDEWzohnDQ01ySGnxMzg&r=zmhRVp0i4wZ5_1Ujh0fnRXAExHgKLTQu0rZLW7PxKA4&m=KcQ3IFUyt22n95ZzVhfXm_CPUrgeT4hH8CQtpL3PR8g&s=xNeSEQbuEzzbPi9PeZMhSLHPcAUX3iHSeX1mr-J9Swk&e=</a> </div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></body></html>