[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: GJD to HJD
A thought. Arne indicates that SLA can do these calculations (I believe),
and there is a perl module which interfaces with SLA
(http://search.cpan.org/doc/TJENNESS/Astro-SLA-0.95/SLA.pm)...
Cheers,
Rob
> -----Original Message-----
> From: Michael Koppelman [mailto:lolife@bitstream.net]
> Sent: Thursday, June 13, 2002 1:58 PM
> To: TASS
> Subject: Re: GJD to HJD
>
>
> I wrote some perl code to do this conversion. I tried to use Dirk's
> fortran code and John's basic code and I was checking them
> against Lew
> Cook's spread sheet.
>
> The perl-ized fortran code does not match Cook's spreadsheet.
> I'm guessing
> this must have to do with operator precedence or something
> like that in
> the perl code. The fortran was pretty basic once I got into it.
>
> The basic code matches Cook's spreadsheet except for the
> sign. For the
> example I'm using, the spreadsheet gets 0.001172325 and the perl-ized
> basic gets -0.0011722. The fortran code, for reference, gets
> -0.00273274334579997.
>
> The code is below. jd2hjd is the fortran code and j2h is the
> basic code.
> Can you see anything odd?
>
> Thanks!
> Michael
>
>
> #!/usr/local/bin/perl
>
> use strict;
>
> # expects ra and dec in decimal degrees: example:
> # echo "2452431.7738252 179.4697 6.3752" | perl helio.pl
>
> while (<STDIN>) {
> chop;
> my $line = $_;
> my( $jd, $ra, $dec ) = split( /\s+/, $line );
> my $correction = &jd2hjd( $jd, $ra, $dec );
> print "JD is $jd\n";
> print "correction is $correction\n";
> print "HJD is ", $jd+$correction, "\n";
> print "----\n";
> $correction = &j2h( $jd, $ra, $dec );
> print "JD is $jd\n";
> print "correction is $correction\n";
> print "HJD is ", $jd+$correction, "\n";
> }
>
> sub jd2hjd {
> my( $jd, $ra, $dec ) = @_;
>
> my $pi = atan2(1,1)*4;
>
> $ra = $ra * $pi / 180;
> $dec = $dec * $pi / 180;
>
> my $n = $jd - 2451545;
> my $l = (4.89495042 + 0.017202792 * $n) % (2*$pi);
> my $g = (6.24004077 + 0.01720197 * $n) % (2*$pi);
> my $theta = $l + 0.0334231 * sin($g) + 0.0003491 * sin(2 * $g);
> my $r = 1.00014 - .01671 * cos($g) - .00014 * cos(2 * $g);
> my $eps = 0.4090877 - 0.000000007 * $n;
> my $a1 = cos($theta) * cos($ra) * cos($dec);
> my $a2 = sin($theta) * (sin($eps) * sin($dec) + cos($eps) *
> cos($dec) * sin($ra));
> my $helio_corr = -0.0057755 * $r * ($a1 + $a2);
> return( $helio_corr );
> }
>
> sub j2h {
> my ($jd, $ra, $dec ) = @_;
>
> my $rad = 57.2957795132;
>
> my $sct = ( $jd - 2451545 ) / 36525;
> my $scl = 280.4659 + (35999.371946 * $sct);
> my $scm = ($scl - 282.9405) - (0.322204 * $sct);
> my $lambda = $scl + (1.9148 * sin($scm / $rad)) + (.02 *
> sin((2 * $scm)
> /$rad));
> my $nu = $lambda - $scl + $scm;
> my $scr = 0.99972 / (1 + (0.01671 * cos($nu / $rad)));
> my $sclong = cos($dec / $rad) * cos($ra / $rad);
> my $scsm = (0.91748 * cos($dec / $rad) * sin($ra /
> $rad)) + (0.39778 *
> sin($dec / $rad));
> my $tau = 0.005775 * $scr * (($sclong * cos($lambda /
> $rad)) + ($scsm
> * sin($lambda / $rad)));
> return( $tau );
> }
>
>