annotate 2.4/src/direction_filter.pl @ 16:8eb7d93f7e58 draft

Uploaded
author plus91-technologies-pvt-ltd
date Sat, 31 May 2014 11:23:36 -0400
parents e3609c8714fb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
1 use Getopt::Long;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
2 my ($v);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
3
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
4 GetOptions ("v|verbose" => \$v); # flag
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
5
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
6
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
7
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
8 open (FILE,"$ARGV[0]") or die "Cant find file\n\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
9 my $dist=0;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
10 my $pos=0;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
11 my @max=0;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
12 my @events=0;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
13
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
14 while(<FILE>){
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
15 $dist=0;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
16 @first=split(/\s+/,$_);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
17 $numEvents=($_=~tr/\|//)+1;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
18 $dist=$first[1]-$pos;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
19 push(@max,$_);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
20 push(@events,$numEvents);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
21 #print "STARTING_POS=$pos\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
22 if(($dist<500)||eof()){
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
23 until (($dist>500)||eof()){
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
24 $newline=<FILE>;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
25 @second=split(/\s+/,$newline);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
26 $numEvents=($newline=~tr/\|//)+1;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
27 push(@max,$newline);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
28 push(@events,$numEvents);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
29 if($v){print "DIST=$dist\nSEC1=@second[1] POS1=$pos;\n";}
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
30 my $tmp=$pos;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
31 $pos=@second[1];
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
32 $dist=@second[1]-$tmp;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
33 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
34 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
35 if ($v){print "Corrected dist= $dist\n" if ($v)};
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
36 #Get the last values since they don't count
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
37 $NL=pop(@max);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
38 $NE=pop(@events);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
39 my $idxMax = 0;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
40 #Get the index of the largest value in array
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
41 if ($v){print "Picking from events:\n"};
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
42 $events[$idxMax] > $events[$_] or $idxMax = $_ for 1 .. $#events;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
43
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
44 my $val=@max[$idxMax];
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
45 print "$val" unless ($val=~/^0$/) ;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
46
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
47
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
48 @max=$NL;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
49 @events=$NE;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
50 my @tmp=split(/\s+/,$NL);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
51 $pos=$tmp[1];
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
52 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
53
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
54 close FILE;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
55