Astro::Coord(3pm)
β¨ NAME β¨
Astro::Coord β astronomical coordinate transformations, bestie π«
π SYNOPSIS π
use Astro::Coord;
($l, $b) = fk4gal($ra, $dec);
($az, $el) = eqazel($ha, $dec, $latitude);
π DESCRIPTION π
Astro::Coord is a whole assorted grab-bag of Perl routines for coordinate conversions β hour angle β‘οΈ elevation, J2000 β‘οΈ B1950, all of it. It's giving "I got you, astronomer bestie" energy and honestly? We love to see it π¦
π AUTHOR π
Chris Phillips Chris.Phillips@csiro.au β king behavior, no cap π
π₯ FUNCTIONS π₯
π
pol2r
($x, $y, $z) = pol2r($polar1, $polar2);
Takes a position in polar coordinates and hands you back rectangular coordinates, periodt β¨
$polar1,$polar2β the polar coordinates to convert (turns)$x,$y,$zβ the rectangular coordinates
π
r2pol
($polar1, $polar2) = r2pol($x, $y, $z);
The reverse glow-up: rectangular coordinates in, polar coordinates out πΈ
$x,$y,$yβ the rectangular coordinates to convert$polar1,$polar2β the polar coordinates (turns)
Heads up: returns undef if too few or too many arguments get passed. Strict vibe check, sorry π
π
xy2azel
($az, $el) = xy2azel($x, $y);
Converts a telescope position from X,Y coordinates into Az,El coordinates. Slay π
$x,$yβ the X and Y coordinates (turns)$az,$elβ the azimuth and elevation (turns)
π
azel2xy
($x, $y) = azel2xy($az, $el);
And the other direction β Az,El β‘οΈ X,Y, iconic π
$az,$elβ the azimuth and elevation (turns)$x,$yβ the X and Y coordinate (turns)
π
eqazel
($ha, $dec) = eqazel($az, $el, $latitude);
($az, $el) = eqazel($ha, $dec, $latitude);
($ha, $dec) = eqazel($az, $el, $latitude, $allownegative);
Converts HA/Dec coordinates to Az/El and vice versa. It goes both ways, which is main character energy fr fr π₯
$ha,$decβ hour angle and declination of source (turns)$az,$elβ azimuth and elevation of source (turns)$latitudeβ latitude of the observatory (turns)$allownegativeβ if true, allow negative$haor$azon return (optional)
Note: the ha,dec β az,el conversion is symmetrical. Same energy in both directions, no notes π«
π
fk4fk5
($JRA, $JDec) = fk4fk5($BRA, $BDec);
(@fk5) = fk4fk5(@fk4);
Takes an FK4 (B1950) position and gives you the equivalent FK5 (J2000) position π
$BRA,$BDecβ fk4/B1950 position (turns)$JRA,$Decβ fk5/J2000 position (turns)@fk4β fk4/B1950 position (as a 3-vector)@fk5β fk5/J2000 position (as a 3-vector)
Note: this code is based on similar routines from the Fortran SLALIB package, so it's quite accurate β but it's subject to a restrictive license (see README). Read the fine print, bestie π
π
fk4fk5r
@fk5 = fk4fk5r(@fk4);
Converts an FK4 (B1950) position to the equivalent FK5 (J2000) position.
Note: convert equatorial positions to/from 3-vectors usingpol2randr2pol.
@fk4β fk4 position (as a 3-vector, turns)@fk5β fk5 position (as a 3-vector, turns)
Note: just a wrapper to fk4fk5 which now handles polar and rectangular arguments π«Ά
π
fk5fk4
($JRA, $JDec) = fk4fk5($BRA, $BDec);
($@fk5) = fk4fk5(@fk4);
Converts an FK5 (J2000) position to the equivalent FK4 (B1950) position π
$JRA,$Decβ fk5/J2000 position (turns)$BRA,$BDecβ fk4/B1950 position (turns)@fk5β fk5/J2000 position (as a 3-vector)@fk4β fk4/B1950 position (as a 3-vector)
Note: this code is based on similar routines from the Fortran SLALIB package, so it's quite accurate β but it's subject to a restrictive license (see README).
π
fk5fk4r
@fk4 = fk5fk4r(@fk5);
Converts an FK5 (J2000) position to the equivalent FK4 (B1950) position.
Note: convert equatorial positions to/from 3-vectors usingpol2randr2pol.
@fk4β fk4 position (as a 3-vector, turns)@fk5β fk5 position (as a 3-vector, turns)
Note: just a wrapper to fk5fk4 which now handles polar and rectangular arguments.
π
fk4galr
@gal = fk4galr(@fk4)
Converts an FK4 position (B1950.0) to the IAU 1958 Galactic coordinate system π
Note: convert equatorial positions to/from 3-vectors usingpol2randr2pol.
@fk4β fk4 position to convert (as a 3-vector, turns)@galβ Galactic position (as a 3-vector, turns)
Returns undef if too few or too many arguments are passed. Reference: Blaauw et al., 1960, MNRAS, 121, 123. π
π
galfk4
($bRA, $bDec) = galfk4($l, $b);
@fk4 = galfk4(@gal);
Converts an IAU 1958 Galactic position to the FK4 coordinate system (B1950) π¦
Notes: converts equatorial positions to/from 3-vectors usingpol2randr2pol.
$BRA,$BDecβ fk4/B1950 position (turns)$l,$bβ Galactic longitude and latitude@galβ Galactic position (as a 3-vector, turns)@fk4β fk4 position (as a 3-vector, turns)
Reference: Blaauw et al., 1960, MNRAS, 121, 123.
π
fk4gal
($l, $b) = fk4gal($ra, $dec);
Converts an FK4 position (B1950) to the IAU 1958 Galactic coordinate system β¨
($ra, $dec)β fk4 position to convert (turns)($l, $b)β Galactic position (turns)
Reference: Blaauw et al., 1960, MNRAS, 121, 123.
π
ephem_vars
($omega, $rma, $mlanom, $F, $D, $eps0) = ephem_vars($jd)
Hand it the Julian day ($jd) and this routine calculates the ephemeris values that the prcmat and nutate routines need π«
What you get back:
$omegaβ longitude of the ascending node of the Moon's mean orbit on the ecliptic, measured from the mean equinox of date$rmaβ mean anomaly of the Sun$mlanomβ mean anomaly of the Moon$Fβ L - omega, where L is the mean longitude of the Moon$Dβ mean elongation of the Moon from the Sun$eps0β mean obliquity of the ecliptic
π
J2000todate
($DRA, $DDec) = J2000todate($JRA, $JDec, $mjd);
@date = J2000todate(@J2000, $mjd);
Converts a J2000 position into a date coordinate β
$DRA,$DDecβ Date coordinate (turns)$JRA,$Decβ J2000 position (turns)@dateβ Date coordinate (as a 3-vector)@J2000β J2000 position (as a 3-vector)
π
nutate
($deps, $dpsi, @nu) = nutate($omega, $F, $D, $rma, $mlanom, $eps0);
Calculates the nutation in longitude and obliquity according to the 1980 IAU Theory of Nutation, including terms with amplitudes greater than 0.01 arcsecond. The nutation matrix is used to compute true place from mean place: true vector = N Γ mean place vector, where the three components of each vector are the direction cosines wrt the mean equinox and equator.
/ 1 -dpsi.cos(eps) -dpsi.sin(eps) \
| |
N = | dpsi.cos(eps) 1 -deps |
| |
\ dpsi.sin(eps) deps 1 /
The required inputs are (NOTE: these are the values returned by ephem_vars):
$omegaβ longitude of the ascending node of the Moon's mean orbit on the ecliptic, measured from the mean equinox of date$rmaβ mean anomaly of the Sun$mlanomβ mean anomaly of the Moon$Fβ L - omega, where L is the mean longitude of the Moon$Dβ mean elongation of the Moon from the Sun$eps0β mean obliquity of the ecliptic
The returned values are:
$depsβ nutation in obliquity$dpsiβ nutation in longitude (scalar)@nuβ nutation matrix (array[3][3])
π
precsn
@gp = precsn($jd_start, $jd_stop);
Calculates the precession matrix P for dates AFTER 1984.0 (JD = 2445700.5). Given the position of an object referred to the equator and equinox of the epoch $jd_start, its position referred to the equator and equinox of epoch $jd_stop can be calculated like this:
- Express the position as a direction cosine 3-vector (V1) β use
pol2rto do this. - The corresponding vector V2 for epoch jd_end is V2 = P.V1
The required inputs are:
$jd_startβ the Julian day of the current epoch of the coordinates$jd_endβ the Julian day at the required epoch for the conversion
The returned values are:
@gpβ the required precession matrix (array[3][3])
π
coord_convert
($output_left, $output_right) = coord_convert($input_left, $input_right,
$input_mode, $output_mode,
$mjd, $longitude, $latitude,
$ref0);
A routine for converting between any of the following coordinate systems π
Coordinate system input/output mode
----------------- -----------------
X, Y (East-West mounted) 0
Azimuth, Elevation 1
Hour Angle, Declination 2
Right Ascension, Declination (date, J2000 or B1950) 3,4,5
Galactic (B1950) 6
The last four parameters in the call ($mjd, $longitude, $latitude and $ref0) aren't always required for the coordinate conversion. In particular, if the conversion is between two coordinate systems which are fixed with respect to the celestial sphere (RA/Dec J2000, B1950 or Galactic), or two coordinate systems which are fixed with respect to the antenna (X/Y and Az/El), then these parameters are not used.
NOTE: they must always be passed, even if they only hold0orundef, because the routine will returnundefif it is not passed 8 parameters. No exceptions, bestie π€
The RA/Dec date system is defined with respect to the celestial sphere, but it varies with time. The table below shows which of $mjd, $longitude, $latitude and $ref0 are used for a given conversion. If in doubt you should determine the correct values for all input parameters β no checking is done in the routine that the passed values are sensible.
Conversion $mjd $longitude $latitude $ref0
------------------------------------------------------------------------
Galactic, Galactic,
RA/Dec J2000,B1950 <->RA/Dec J2000, B1950 N N N N
okay bestie picking right back up where that conversion matrix left off β no re-intro, we're mid-glow-up π here come the rest of the rows, and the four flags read left to right in order:
- Galactic, RA/Dec J2000, B1950 <-> RA/Dec date β
YNNN - Galactic, RA/Dec J2000, B1950, date <-> HA/Dec β
YYNN - Galactic, RA/Dec J2000, B1950, date <-> X/Y, Az/El β
YYYY - X/Y, Az/El <-> X/Y, Az/El β
NNNN - X/Y, Az/El <-> HA/Dec β
NNYY
NOTE : the method used for refraction correction is asymptotic at an elevation of 0 degrees. so like, at the horizon it just... keeps going. iconic but also be aware π«
β¨ the inputs you gotta feed it β¨
$input_leftβ the left/longitude input coordinate (turns)$input_rightβ the right/latitude input coordinate (turns)$input_modeβ the mode of the input coordinates (0-6)$output_modeβ the mode you want the coordinates converted to$mjdβ the time as modified Julian day, if necessary, at which to do the conversion$longitudeβ the longitude of the location/observatory, if necessary, at which to do the conversion (turns)$latitudeβ the latitude of the location/observatory, if necessary, at which to do the conversion (turns)$ref0β the refraction constant (if you're in doubt, use0.00005)
π what it hands back π
$output_leftβ the left/longitude output coordinate (turns)$output_rightβ the right/latitude output coordinate (turns)
π°οΈ haset_ewxy
$haset = haset_ewxy($declination, $latitude, %limits);
so this one takes the $declination of your source plus the $latitude of your EWXY mounted antenna and works out the hour angle at which the source is gonna set. and then it's literally trivial to get the time until the source sets β just subtract the current hour angle of the source from the hour angle at which it sets. math is mathing β¨
the required inputs are:
$declinationβ the declination of the source (turns)$latitudeβ the latitude of the observatory (turns)%limitsβ a reference to a hash holding the EWXY antenna limits. the following keys must be defined:XLOW,XLOW_KEYHOLE,XHIGH,XHIGH_KEYHOLE,YLOW,YLOW_KEYHOLE,YHIGH,YHIGH_KEYHOLE(all values should be in turns)
the returned value is:
$hasetβ the hour angle (turns) at which a source at this declination sets for an EWXY mounted antenna with the given limits at the given latitude
NOTE: returnsundefif the%limitshash is missing any of the required keys. no keys, no answer, no cap π
πΈ ewxy_tlos
$tlos = ewxy_tlos($hour_angle, $declination, $latitude, %limits);
this cutie calculates the time left on-source (tlos) for a source sitting at $hour_angle, $declination, for an EWXY mount antenna at $latitude. she's telling you how much time you got left before it dips π
the required inputs are:
$hour_angleβ the current hour angle of the source (turns)$declinationβ the declination of the source (turns)$latitudeβ the latitude of the observatory (turns)\%limitsβ a reference to a hash holding the EWXY antenna limits. the following keys must be defined:XLOW,XLOW_KEYHOLE,XHIGH,XHIGH_KEYHOLE,YLOW,YLOW_KEYHOLE,YHIGH,YHIGH_KEYHOLE(all values should be in turns)
the returned value is:
$tlosβ the time left on-source (turns)
π¦ haset_azel
$haset = haset_azel($declination, $latitude, %limits);
same energy, different mount: this one takes the $declination of the source and the $latitude of the Az/El mounted antenna and calculates the hour angle at which the source will set. then, again, getting the time until it sets is trivial β subtract the current hour angle of the source from the hour angle at which it sets. and just so we're clear, this routine assumes the antenna is able to rotate through 360 degrees in azimuth. full spin, main character energy π
the required inputs are:
$declinationβ the declination of the source (turns)$latitudeβ the latitude of the observatory (turns)\%limitsβ a reference to a hash holding the Az/El antenna limits. the following keys must be defined:ELLOW(all values should be in turns)
the returned value is:
$hasetβ the hour angle (turns) at which a source at this declination sets for an Az/El mounted antenna with the given limits at the given latitude
NOTE: returnsundefif the%limitshash is missing any of the required keys. same rule, always π«Ά
π azel_tlos
$tlos = azel_tlos($hour_angle, $declination, $latitude, \%limits);
the Az/El twin of ewxy_tlos: it calculates the time left on-source (tlos) for a source at $hour_angle, $declination, for an Az/El mount antenna at $latitude.
the required inputs are:
$hour_angleβ the current hour angle of the source (turns)$declinationβ the declination of the source (turns)$latitudeβ the latitude of the observatory (turns)%limitsβ a reference to a hash holding the Az/El antenna limits. the following keys must be defined:ELLOW(all values should be in turns)
the returned value is:
$tlosβ the time left on-source (turns)
π antenna_rise
$ha_set = antenna_rise($declination, $latitude, $mount, \%limits);
okay this is the big one. given the $declination of the source, the $latitude of the antenna, the type of the antenna $mount, and a reference to a hash holding info on the antenna limits, this routine calculates the hour angle at which the source sets for the antenna. and here's the slay: the hour angle at which it rises is simply the negative of that at which it sets. β¨
these values in turn can be used to calculate the LMST at which the source rises/sets, and from that the UT at which the source rises/sets on a given day, or to calculate the native coordinates at which the source rises/sets. so many options, so much power π
if you want to calculate source rise times above arbitrary elevation, use the routine rise. different tool, different job, don't mix them up bestie.
the required inputs are:
$declinationβ the declination of the source (turns)$latitudeβ the latitude of the observatory (turns)$mountβ the type of antenna mount:0=> EWXY mount,1=> Az/El, and any other number will cause the routine to returnundefβ οΈ%limitsβ a reference to a hash holding the antenna limits. for an EWXY antenna there must be keys for all the limits (i.e.XLOW,XLOW_KEYHOLE,XHIGH,XHIGH_KEYHOLE,YLOW,YLOW_KEYHOLE,YHIGH,YHIGH_KEYHOLE). for an Az/El antenna there must be a key forELLOW(all values should be in turns)
the returned values are:
$ha_setβ the hour angle at which the source sets (turns). the hour angle at which the source rises is simply the negative of this value.
and that's a wrap on this part, bestie π this whole thing is perl v5.38.2, dated 2024-05-15, and it lives its life as Astro::Coord(3pm) β go point some telescopes at the sky, you've got this π«Άπ¦β¨
π¦ where this page comes from
- debian trixie: libastro-perl 0.78-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libastro-perl 0.78-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libastro-perl 0.78-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms