Astro
view release on metacpan or search on metacpan
Astro/Time.pm view on Meta::CPAN
while ($lst>1.0) {
$lst-= 1;
}
while ($lst < 0.0) {
$lst += 1;
}
return $lst;
}
=item B<cal2lst>
$lst = cal2lst($day, $month, $year, $ut, $longitude);
$lmst = cal2lst($day, $month, $year, $ut, $longitude, $dUT1);
$ltst = cal2lst($day, $month, $year, $ut, $longitude, $dUT1, $eqenx);
Wrapper to mjd2lst using calendar date rather than mjd
=cut
sub cal2lst($$$$$;$$) {
my ($day, $month, $year, $ut, $longitude, $dUT1, $eqenx) = @_;
my $mjd = cal2mjd($day, $month, $year, $ut);
return undef if (!defined $mjd);
return mjd2lst($mjd, $longitude, $dUT1, $eqenx);
}
=item B<dayno2lst>
$lst = dayno2lst($dayno, $year, $ut, $longitude);
$lmst = dayno2lst($dayno, $year, $ut, $longitude, $dUT1);
$ltst = dayno2lst($dayno, $year, $ut, $longitude, $dUT1, $eqenx);
Wrapper to mjd2lst using calendar date rather than mjd
=cut
sub dayno2lst($$$$;$$) {
my ($dayno, $year, $ut, $longitude, $dUT1, $eqenx) = @_;
my $mjd = dayno2mjd($dayno, $year, $ut);
return undef if (!defined $mjd);
return mjd2lst($mjd, $longitude, $dUT1, $eqenx);
}
# Not verified
=item B<rise>
($lst_rise, $lst_set) = rise($ra, $dec, $obslat, $el_limit);
Return the lst rise and set time of the given source
$lst_rise, $lst_set Rise and set time (turns)
$ra, $dec RA and Dec of source (turns)
$obslat Latitude of observatory (turns)
$el_limit Elevation limit of observatory
(turns, 0 horizontal)
Returns 'Circumpolar' if source circumpolar
Returns undef if source never rises
Uses the formula:
cos $z_limit = sin $obslat * sin $dec + cos $obslat * cos $dec
* cos $HA
where:
$z_limit is the zenith angle limit corresponding to $el_limit
$HA is the Hour Angle of the source
NOTE: For maximum accuracy source coordinated should be precessed to
the current date.
=cut
sub rise ($$$$) {
#print "rise: Got @_\n";
my ($ra, $dec, $obslat, $el_limit) = @_;
$ra = turn2rad($ra);
$dec = turn2rad($dec);
$obslat = turn2rad($obslat);
$el_limit = turn2rad($el_limit);
my $z_limit = $PI/2-$el_limit;
#print "Check it\n";
# Check whether the source ever rises or is circumpolar
my $z = acos(sin($obslat)*sin($dec) + cos($obslat)*cos($dec)); # Highest point
return (undef) if ($z>$z_limit);
#print "Got here\n";
$z = acos(sin($obslat)*sin($dec) - cos($obslat)*cos($dec)); # Lowest point
return ('Circumpolar') if ($z<$z_limit);
my $cos_ha = (cos($z_limit) - sin($obslat)*sin($dec))
/(cos($obslat)*cos($dec));
my $ha = acos($cos_ha);
my $lst_rise = $ra - $ha;
my $lst_set = $ra + $ha;
$lst_rise += 2*$PI if ($lst_rise < 0.0);
$lst_set -= 2*$PI if ($lst_set >= 2*$PI);
return rad2turn($lst_rise), rad2turn($lst_set);
}
=item B<lst2mjd>
$mjd = lst2mjd($lmst, $dayno, $year, $longitude);
$mjd = lst2mjd($lmst, $dayno, $year, $longitude, $dUT1);
This routine calculates the modified Julian day number corresponding
to the local mean sidereal time $lmst at $longitude, on a given UT
day number ($dayno). Unless high precision is required dUT1 can be
omitted.
The required inputs are :
$lmst - The local mean sidereal time (turns)
$dayno - The UT day of year for which to do the conversion
$year - The year for which to do the conversion
$longitude - The longitude of the observatory (turns)
( run in 1.930 second using v1.01-cache-2.11-cpan-39bf76dae61 )