Difficulty with N_ELEMENTS command
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Newsgroups: comp.lang.idl-pvwave
From:
Andrew King <andrewkin... @gmail.com>
Date: Thu, 9 Feb 2012 20:03:12 -0800 (PST)
Local: Thurs, Feb 9 2012 11:03 pm
Subject: Difficulty with N_ELEMENTS command
Hi.
I'm trying to create an array of the number of elements that satisfy a
certain criterion as below.
FOR m=0,nyears-1 DO BEGIN
exceed_freq(m)=N_ELEMENTS(WHERE(precip_day(m,*) gt smoothed(*)))
ENDFOR
The problem I have is that for some years in my program there are no
elements that satisfy this criterion, however the value returned in
the array 'exceed_freq' is 1 instead of 0.
I would appreciate any comments.
Thanks,
Andrew
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.lang.idl-pvwave
From:
Gianguido Cianci <gianguido.cia... @gmail.com>
Date: Thu, 9 Feb 2012 20:21:03 -0800 (PST)
Local: Thurs, Feb 9 2012 11:21 pm
Subject: Re: Difficulty with N_ELEMENTS command
Try:
FOR m=0,nyears-1 DO BEGIN dummy=WHERE(precip_day[m,*] gt smoothed, n)
exceed_freq[m]=n ENDFOR
Hope it helps.
G
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.lang.idl-pvwave
From:
Gianguido Cianci <gianguido.cia... @gmail.com>
Date: Thu, 9 Feb 2012 20:28:06 -0800 (PST)
Local: Thurs, Feb 9 2012 11:28 pm
Subject: Re: Difficulty with N_ELEMENTS command
You could also try "the IDL" way:
s=size(precip_day, /dim)
smoothed2=rebin(smoothed, s, /sample)
test=precip_day gt smoothed2
exceed_freq=total(test, 1)
Look mum! No loops!!
G
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.lang.idl-pvwave
From:
Andrew King <andrewkin... @gmail.com>
Date: Thu, 9 Feb 2012 20:32:52 -0800 (PST)
Local: Thurs, Feb 9 2012 11:32 pm
Subject: Re: Difficulty with N_ELEMENTS command
On Feb 10, 3:28 pm, Gianguido Cianci <gianguido.cia... @gmail.com>
wrote:
> You could also try "the IDL" way:
> s=size(precip_day, /dim)
> smoothed2=rebin(smoothed, s, /sample)
> test=precip_day gt smoothed2
> exceed_freq=total(test, 1)
> Look mum! No loops!!
> G
Works perfectly now. Thanks very much.
Andrew
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.lang.idl-pvwave
From:
Yngvar Larsen <larsen.yng... @gmail.com>
Date: Sun, 12 Feb 2012 11:14:33 -0800 (PST)
Local: Sun, Feb 12 2012 2:14 pm
Subject: Re: Difficulty with N_ELEMENTS command
On Feb 10, 5:03 am, Andrew King <andrewkin... @gmail.com> wrote:
> Hi.
> I'm trying to create an array of the number of elements that satisfy a
> certain criterion as below.
> FOR m=0,nyears-1 DO BEGIN
> exceed_freq(m)=N_ELEMENTS(WHERE(precip_day(m,*) gt smoothed(*)))
> ENDFOR
> The problem I have is that for some years in my program there are no
> elements that satisfy this criterion, however the value returned in
> the array 'exceed_freq' is 1 instead of 0.
> I would appreciate any comments.
A one-liner soulution (mostly because it fun :) could be
exceed_freq = total(precip_day gt
transpose(smoothed[*,lindgen(nyears)]), 2)
or
exceed_freq = total(transpose(precip_day) gt
smoothed[*,lindgen(nyears)], 1)
--
Yngvar
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.lang.idl-pvwave
From:
Yngvar Larsen <larsen.yng... @gmail.com>
Date: Sun, 12 Feb 2012 11:21:30 -0800 (PST)
Local: Sun, Feb 12 2012 2:21 pm
Subject: Re: Difficulty with N_ELEMENTS command
On Feb 12, 8:14 pm, Yngvar Larsen <larsen.yng... @gmail.com> wrote:
> A one-liner soulution (mostly because it fun :) could be
> exceed_freq = total(precip_day gt
> transpose(smoothed[*,lindgen(nyears)]), 2)
> or
> exceed_freq = total(transpose(precip_day) gt
> smoothed[*,lindgen(nyears)], 1)
> --
> Yngvar
Ironically, Google Groups decided that my one-liners really should be
two-liners :)
--
Yngvar
You must
Sign in before you can post messages.
You do not have the permission required to post.