~ubuntu-branches/ubuntu/warty/xplanet/warty

« back to all changes in this revision

Viewing changes to scripts/convertCassini.perl.in

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:14:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040824071400-2dr4qnjbjmm8z3ia
Tags: 1.0.6-1ubuntu1
Build-depend: libtiff4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!@PERL@
 
2
 
 
3
use strict;
 
4
 
 
5
use Math::Trig;
 
6
 
 
7
if (@ARGV)
 
8
{
 
9
    open(INFILE, "<$ARGV[0]") || die("Can't open $ARGV[0]\n");
 
10
 
 
11
    my $flattening = 0.09796;
 
12
    my $omf2 = ((1 - $flattening) * (1 - $flattening));
 
13
    my @months = ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
 
14
    for (my $i = 0; $i < 4; $i++)
 
15
    {
 
16
        <INFILE>;
 
17
    }
 
18
    while (<INFILE>)
 
19
    {
 
20
        my @fields = split(" ", $_);
 
21
        my $year      = $fields[0];
 
22
        my $day       = $fields[1];
 
23
        my $hour      = $fields[2];
 
24
        my $min       = $fields[3];
 
25
        my $sec       = $fields[4];
 
26
        my $lon       = $fields[5];
 
27
        my $lat       = $fields[6];
 
28
        my $localtime = $fields[7];
 
29
        my $rad       = $fields[8];
 
30
 
 
31
        if ($year eq "2000" || $year eq "2004" || $year eq "2008")
 
32
        {
 
33
            $months[1] = 29;
 
34
        }
 
35
        else
 
36
        {
 
37
            $months[1] = 28;
 
38
        }
 
39
 
 
40
        my $month = 0;
 
41
        while ($day > $months[$month])
 
42
        {
 
43
            $day -= $months[$month++];
 
44
        }
 
45
        $month++;
 
46
 
 
47
        # convert planetocentric latitude to planetographic
 
48
        $lat = deg2rad($lat);
 
49
        $lat = atan(tan($lat) / $omf2);
 
50
        $lat = rad2deg($lat);
 
51
 
 
52
        printf("%4.4d%2.2d%2.2d.%2.2d%2.2d%2.2d %10.3f %8.3f %8.3f %8.3f\n",
 
53
               $year, $month, $day, $hour, $min, $sec, $rad, $lat, $lon, $localtime);
 
54
    }
 
55
}
 
56
else
 
57
{
 
58
    print "Use this perl script with tables produced from http://www-pw.physics.uiowa.edu/~jbg/cas.html\n";
 
59
}