Re: array subtraction [message #63338] |
Wed, 05 November 2008 08:39  |
Spon
Messages: 178 Registered: September 2007
|
Senior Member |
|
|
On Nov 5, 4:29 pm, Wox <s...@nomail.com> wrote:
> On Wed, 5 Nov 2008 07:25:10 -0800 (PST), julia.waltersp...@gmail.com
> wrote:
>
>
>
>> hey guys
>> SOS call from the newbie:
>
>> I've got two data arrays, one of length 134 (=a), the other of length
>> 75 (=b) with monthly cloud cover data from modis terra and aqua.
>> Data from Terra starts feb 2000, data from Aqua starts july 2002.
>
>
> So you only need to get i in this:
> diff = a[i:*]-b
>
Hi,
Well if the time intervals are the same in both arrays (1 month), and
the last data point in both arrays is the same timepoint ('now'),
then I would do it this way:
na = n_elements(a)
nb = n_elements(b)
diff = abs(b-a[na-nb:*]) ; Given a>b as in your example
Or, if you really want a more general solution:
diff = abs(b[(nb-na>0):*] - a[(na-nb>0):*])
Regards,
Chris
|
|
|
Re: array subtraction [message #63339 is a reply to message #63338] |
Wed, 05 November 2008 08:29   |
Wout De Nolf
Messages: 194 Registered: October 2008
|
Senior Member |
|
|
On Wed, 5 Nov 2008 07:25:10 -0800 (PST), julia.walterspiel@gmail.com
wrote:
> hey guys
> SOS call from the newbie:
>
> I've got two data arrays, one of length 134 (=a), the other of length
> 75 (=b) with monthly cloud cover data from modis terra and aqua.
> Data from Terra starts feb 2000, data from Aqua starts july 2002.
>
> I want to calculate and plot the difference in cloud cover for each
> month from Terra and Aqua. so far so good.
>
> the two data arrays are "connected" by two (separate) time arrays c
> (for Terra, feb 2000 - now) and d (for Aqua july 2002 - now).
> that means, my data array "b" starts only somewhere at index so-and-so
> of "a" (not sure where exactly).
> Now, how can I tell IDL to subtract the two arrays at the right point,
> meaning subtract the terra-value on july 2002 from the aqua value on
> the same date?
>
> I'm sure everyone of you can do that with both eyes closed and it
> can't be difficult but I couldn't find any help online.
> thanks!
> juls
So you only need to get i in this:
diff = a[i:*]-b
In general I would say
i=value_locate(c,d[0])
but what format do the time/data arrays have (string, Julian Day
Number,...)?
|
|
|
|
|
|
Re: array subtraction [message #63452 is a reply to message #63338] |
Mon, 10 November 2008 07:59  |
julia.walterspiel
Messages: 35 Registered: July 2008
|
Member |
|
|
hi guys
thanks for your input. Chris, you where right, when both time arrays
have the same end-point ('now'), wich was the case, it's easy.
Fortunately, i could chop them to have the same end-date so your
suggestions worked fine with a couple of small changes.
cheers, juls
|
|
|