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

Home » Public Forums » archive » Re: array subtraction
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: array subtraction [message #63338] Wed, 05 November 2008 08:39 Go to next message
Spon is currently offline  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 Go to previous messageGo to next message
Wout De Nolf is currently offline  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 #63340 is a reply to message #63339] Wed, 05 November 2008 08:29 Go to previous messageGo to next message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
On Nov 5, 11:15 am, julia.waltersp...@gmail.com wrote:
>> If the data does have a big variation in a better time resolution you
>> should not interpolate. Then you can create for example a mean value for
>> each month.
>
> Hi Reimar,
> each data value is the mean value for one month. so i have one value
> for jan, one for feb etc... so no need to interpolate. I only need to
> know how to tell IDL WHERE to start subtracting one array from the
> other
> cheers,
> juls

What do your time arrays look like? Is the answer going to be finding
the right spot in the two time arrays that match? Maybe you can post
a segment of the arrays and an explanation.


Brian

------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
http://people.bu.edu/balarsen/Home/IDL
Re: array subtraction [message #63342 is a reply to message #63340] Wed, 05 November 2008 08:15 Go to previous messageGo to next message
julia.walterspiel is currently offline  julia.walterspiel
Messages: 35
Registered: July 2008
Member
>
> If the data does have a big variation in a better time resolution you
> should not interpolate. Then you can create for example a mean value for
> each month.
>

Hi Reimar,
each data value is the mean value for one month. so i have one value
for jan, one for feb etc... so no need to interpolate. I only need to
know how to tell IDL WHERE to start subtracting one array from the
other
cheers,
juls
Re: array subtraction [message #63344 is a reply to message #63342] Wed, 05 November 2008 07:58 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
julia.walterspiel@gmail.com schrieb:
> 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

Hi Julia

no not with both eyes closed. It is not easy to give a correct answer.
Well you can substract appels from bananas but this will make no sense.

if the data does not change very fast on a better time resolution you
may want to interpolate the data of one table to the other ones time
base. And you can cut off the region where you don't have a close
mapping in time.

If the data does have a big variation in a better time resolution you
should not interpolate. Then you can create for example a mean value for
each month.

cheers
Reimar
Re: array subtraction [message #63452 is a reply to message #63338] Mon, 10 November 2008 07:59 Go to previous message
julia.walterspiel is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: On-the-fly compilation of routines
Next Topic: Plot: idl_guide4 UK_NCAS-Meteo-Library

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

Current Time: Wed Oct 08 13:44:15 PDT 2025

Total time taken to generate the page: 0.00549 seconds