comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » newbie sees iterative solution, wants to know the IDL Way
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
newbie sees iterative solution, wants to know the IDL Way [message #61538] Sun, 20 July 2008 21:28
Tom Roche is currently offline  Tom Roche
Messages: 11
Registered: July 2008
Junior Member
<best viewed in monospace font/>

From what I read, iteration is not the way to go with IDL. So I'm
wondering, how to translate the following iterative solution:

I'm reading netCDF data with dimensions={time, lat, lon}, from which I
want to get the "seasonality" such that, for each spacetime, I get the
proportion of the total over time at that point in space. E.g. if I
had input data for 4 space points (j,k) @ 2 time points (i):

(k=0) j=0 j=1
i=0: 0 1
i=1: 2 3

(k=1)
i=0: 4 5
i=1: 6 7

it would map to

0 1/4
1 3/4

2/5 5/12
3/5 7/12

My coding background is such that I quickly see an iterative solution
like

nTime=size of time dimension;
nLat=size of latitude dimension;
nLon=size of longitude dimension;

create array summing[nLat][nLon];
for (int i = 0; i < nTime; i++)
for (int j = 0; j < nLat; j++)
for (int k = 0; k < nLon; k++)
// gotta handle input=NaN
if (isNumber(input[i][j][k]))
summing[j][k] += input[i][j][k];

create array seasonality[nTime][nLat][nLon];
for (int i = 0; i < nTime; i++)
for (int j = 0; j < nLat; j++)
for (int k = 0; k < nLon; k++)
// gotta handle input=NaN, summing={0, NaN}
if (isNumber(input[i][j][k]) &&
isNumber(summing[j][k]) &&
(input[i][j][k] != 0))
seasonality[i][j][k] = input[i][j][k] / summing[j][k];

Is there a better, IDLer way?

TIA, Tom Roche <Tom_Roche@pobox.com>
[Message index]
 
Read Message
Previous Topic: Re: plot,lat,lon
Next Topic: X11 Leopard MacOSX

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 07:20:25 PDT 2025

Total time taken to generate the page: 1.12538 seconds