Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Difficulty with N_ELEMENTS command
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Andrew King  
View profile  
 More options Feb 9, 11:03 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gianguido Cianci  
View profile  
 More options Feb 9, 11:21 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gianguido Cianci  
View profile  
 More options Feb 9, 11:28 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew King  
View profile  
 More options Feb 9, 11:32 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yngvar Larsen  
View profile  
 More options Feb 12, 2:14 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yngvar Larsen  
View profile  
 More options Feb 12, 2:21 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »