[ncl-talk] Need help in Do looping
Trisanu Banik
baniktrisanu at gmail.com
Tue Sep 24 12:01:02 MDT 2019
Dear Toni
Thank you very much for your reply. I shall check it and let you know
further.
Thanks & Regards
Trisanu
On Tue, 24 Sep, 2019, 9:13 PM Toni Klemm, <toni-klemm at tamu.edu> wrote:
> Sorry, the command for the new variable should be
>
> temp_file = new((/dimsizes(…),dimsizes(…),dimsizes(…)/),float,9.96921e+36)
>
>
> Toni
>
>
>
> *Toni Klemm, Ph.D.*Postdoctoral Research Associate
> Department of Ecosystem Science and Management
> College of Agriculture and Life Sciences
> Texas A&M University, College Station, TX
> www.toni-klemm.de | @toniklemm <http://www.twitter.com/toniklemm>
> Editorial Board member, Early Career Climate Forum
> <http://www.eccforum.org>
>
>
>
>
>
>
>
>
> On Sep 24, 2019, at 10:40 AM, Toni Klemm <toni-klemm at tamu.edu> wrote:
>
> Hi Trisanu,
>
> 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.
>
> Change this line in your if-loop from this
>
> temp_file = spd(i,j,k)
>
> to this
>
> temp_file(i,j,k) = spd(i,j,k)
>
> 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.
>
> Good luck,
> Toni
>
>
>
> *Toni Klemm, Ph.D.*Postdoctoral Research Associate
> Department of Ecosystem Science and Management
> College of Agriculture and Life Sciences
> Texas A&M University, College Station, TX
> www.toni-klemm.de | @toniklemm <http://www.twitter.com/toniklemm>
> Editorial Board member, Early Career Climate Forum
> <http://www.eccforum.org/>
>
>
>
>
>
>
>
>
> On Sep 24, 2019, at 9:52 AM, Trisanu Banik via ncl-talk <ncl-talk at ucar.edu>
> wrote:
>
> Dear All
>
> I need one help related to Do loop in NCL.
>
> 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.
>
> 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.
>
> 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.
>
> Please suggest me how to do the same.
>
>
> Thanks & Regards
> Trisanu
>
> *Trisanu Banik,PhD*
>
> *Research Scientist*
>
> *North Eastern Space Applications Centre (NESAC)*
> *Government of India*
> *Department of Space*
>
> *Umiam-793103, Meghalaya*
> *Mobile-9774837581*
>
> <ncl code.txt>_______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
>
> 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=
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190924/12d1e633/attachment.html>
More information about the ncl-talk
mailing list