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

Home » Public Forums » archive » Re: data criteria
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: data criteria [message #67844 is a reply to message #67738] Wed, 26 August 2009 01:00 Go to previous message
anil is currently offline  anil
Messages: 34
Registered: August 2009
Member
On 24 Ağustos, 18:14, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
> anil wrote:
>> Hi all,
>> I do not have much information about programming or algorithms
>> (actually IDL is my first programming language), so my question may
>> rather be simple but i could not figure it out , so here we go:
>> .......
>> So I want to take the lines from the first line up to 12.654200(since
>> the difference is more than 0.3)
>> What i have done so far is :
>
>> pro a
>> ;window, 0, retain=2
>
>> file_array=file_search('/home/......../0587', '0587.*.txt',
>> count=num_file)
>> for i=0,num_file-1 do begin
>> file=file_array(i)
>
>> nrows = File_Lines(file)
>
>> data=fltarr(5,nrows)
>
>> OpenR, lun, file, /GET_LUN
>> ReadF, lun, data
>> Free_Lun, lun
>
>> p=data(0,*)
>> t=data(1,*)
>> s=data(2,*)
>> q=data(3,*)
>> d=data(4,*)
>> close,lun
>> free_lun, lun
>
>> 1st try
>> ;for k=1,nrows-2 do begin k=k+1
>> ;ml=where((d(k+1)-d(k)) gt 0.3,ss)
>> ;endfor
>
>> 2nd try
>> ;k=1
>> ;repeat begin ml=(d(k)-d(k-1))
>> ;k=k+1
>> ;endrep until (ml gt 0.3)
>> ;print,d(0:k)
>
>> free_lun,lun
>> endfor
>
>> close,/All
>> end
>
>> Neither of them work ! I used an if-then-else statement  too but could
>> not solve my problem.
>> I would really appreciate any help. Thanks in advance,
>> ANIL
>
> Hi Anil,
>
> the problem with your code is that you are not using not saving ML... so
> you erase it in each loop.
>
> You could do it this way:
>
> toKeepIDX = where(d - shift(d,-1) ge 0.3)
> goodData = data[*,toKeepIDX]
> and/or:  goodA = a[toKeepIDX]   goodB = b[toKeeIDX] etc
>
> In the first line, you compare each entry with its previous one and you
> select ALL entries according to your criterion. Next, you extract the
> data itself.
>
> This will bring a problem for the first entry of course. Also, keep in
> mind the case where you don't have the .3 of different between 3
> consecutive values ( 1, 1.01, 1.02, 1.03 etc)
>
> Jean

I see you are right about the ML. Thanks a lot for replying
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Digits in IDL
Next Topic: Re: SKIP the window "press click to continue" using the VIRTUAL MACHINE

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

Current Time: Fri Oct 10 14:17:29 PDT 2025

Total time taken to generate the page: 1.27997 seconds