#!/bin/perl
#--------------------------------------------------------------------
# 可視の時刻(UT)分布解析
# $ ../rep2ccr.pl katsuura-CCR-AER-6deg.txt > result_katsuura_ccr.dat
#--------------------------------------------------------------------
my @item,@DTN;

# 変数にSTKレポート格納
for($i=0;$i<=90;$i++){
    $DTN[$i] = 0;
}
open(IN0,"<$ARGV[0]") || die "can't open $ARGV[0]\n";
@l0 = <IN0>;
foreach $i (@l0)
{
    chomp($i);
    $i =~ s/\t/\s/g;
    @item = split(/\s */,$i);
    
	if ($item[0] eq "Mean" && $item[1] eq "Elevation"){
		#print "$item[2]\n";
		$DTN[int($item[2] + 0.5)]++;
	}
	
}
close(IN0);

print "#deg,num\n";
for($i=0;$i<=90;$i++){
    print "$i,$DTN[$i]\n";
}

exit;

sub dtn_time()
{
    # 時刻分布を解析
    my @tmp;
    my ($hh,$mm,$ss);
    
    @tmp = @_;

    ($hh,$mm,$ss) = &div_time($tmp[3]);
	if ($hh == "") {$hh = 999;}
    return $hh;
}

sub div_time()
{
    # [:]で区切られた時刻を分割
    my @hms;
    @hms = split(/\:/,$_[0]);
    
    return ($hms[0],$hms[1],$hms[2]);
}
