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

Home » Public Forums » archive » WHERE Function
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: where function [message #74523 is a reply to message #4152] Sun, 23 January 2011 13:12 Go to previous message
jeanh is currently offline  jeanh
Messages: 79
Registered: November 2009
Member
On 23/01/2011 3:26 PM, smuzz wrote:
> Hi --
>
> I am a beginner programmer trying to write a code involving the where
> function. My dataset includes call detections made by whales from 1
> month. I am trying to search within this dataset for a particular call
> type, let's call it a moan. Then I want to search 1 hour before or
> after a detected moan and tally up all the other whale calls I hear --
> this is the part I am stuck on. How do you use the where function to
> search 1 hour before or after? I am only familiar with using gt and
> lt.
>
> This is what I have so far...
>
> n=n_elements(auto) ; auto is my dataset with all whale calls
>
> for i=0, n-1 do begin
> k = where(auto(*).manual_species eq 0 and auto(*).manual_call_type eq
> 1 and auto(*).time gt stime and auto(*).time lt etime,kcount) ; this
> is looking for all moans within a specified start and end time of the
> 1 month study
>
> if(kcount gt 0) then begin
>
> j=where(auto(*).mdist lt 3.0 and auto(*).avg_amplitude ge 12.0 and
> auto(*).time gt stime and auto(*).time lt etime and
> auto(*).manual_species eq 7 and auto(*).manual_call_type eq
> 1,jcount) ; this is looking for all other whale calls within the
> dataset
>
> ....right now j is tallying up all the calls in the dataset, but now I
> want to add in a part asking for only calls that occur 1 hour before
> or after a moan detection?
>
> Any ideas?
>
> Thanks, smuzz

Hi Smuzz,

glad to see I am not the only one working this Sunday :-)

First, sorry, but the 1st loop is useless ( for i=0, n-1 do begin)
... indeed, you are never using i!

Here is what you want to do (it could probably be optimized though)

1) Select the entries from the dataset that have the proper time (month)
and call type. Count the number of results

2) Loop through these results, and make your 2nd selection by
adding/removing time

3) process

------------------------
to use your code, it would look like this

k = where(auto(*).manual_species eq 0 and auto(*).manual_call_type eq
1 and auto(*).time gt stime and auto(*).time lt etime,kcount) ; this
is looking for all moans within a specified start and end time of the
1 month study

for entry = 0, kcount -1 do begin
linkedWhalesID = where(auto(*).mdist lt 3.0 and auto(*).avg_amplitude
ge 12.0 and
auto(*).time gt auto[k[entry]].time - 60 and auto(*).time lt
auto[k[entry]].time + 60 and
auto(*).manual_species eq 7 and auto(*).manual_call_type eq
1,jcount)

WhalesToAnalyze = auto[linkedWhalesID]
endfor


Jean
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: where function
Next Topic: Need help with map projection conversion in ENVI

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

Current Time: Sat Nov 01 06:09:45 PDT 2025

Total time taken to generate the page: 2.16090 seconds