void palMappa( double eq, double date, double amprms[21] ){ /* Local constants */ /* Gravitational radius of the Sun x 2 (2*mu/c**2, AU) */ const double GR2 = 2.0 * 9.87063e-9; /* Local Variables; */ int i; double ebd[ 3 ], ehd[ 3 ], eh[ 3 ], e, vn[ 3 ], vm; /* Initialise so that unsused values are returned holding zero */ memset( amprms, 0, 21*sizeof( *amprms ) ); /* Time interval for proper motion correction. */ amprms[ 0 ] = eraEpj( PAL__MJD0, date ) - eq; /* Get Earth barycentric and heliocentric position and velocity. */ palEvp( date, eq, ebd, &rms[ 1 ], ehd, eh ); /* Heliocentric direction of Earth (normalized) and modulus. */ eraPn( eh, &e, &rms[ 4 ] ); /* Light deflection parameter */ amprms[7] = GR2 / e; /* Aberration parameters. */ for( i = 0; i < 3; i++ ) { amprms[ i + 8 ] = ebd[ i ]*PAL__CR; } eraPn( &rms[8], &vm, vn ); amprms[ 11 ] = sqrt( 1.0 - vm*vm ); /* NPB matrix. */ palPrenut( eq, date, (double(*)[ 3 ]) &rms[ 12 ] ); }
double eraPap(double a[3], double b[3]) /* ** - - - - - - - ** e r a P a p ** - - - - - - - ** ** Position-angle from two p-vectors. ** ** Given: ** a double[3] direction of reference point ** b double[3] direction of point whose PA is required ** ** Returned (function value): ** double position angle of b with respect to a (radians) ** ** Notes: ** ** 1) The result is the position angle, in radians, of direction b with ** respect to direction a. It is in the range -pi to +pi. The ** sense is such that if b is a small distance "north" of a the ** position angle is approximately zero, and if b is a small ** distance "east" of a the position angle is approximately +pi/2. ** ** 2) The vectors a and b need not be of unit length. ** ** 3) Zero is returned if the two directions are the same or if either ** vector is null. ** ** 4) If vector a is at a pole, the result is ill-defined. ** ** Called: ** eraPn decompose p-vector into modulus and direction ** eraPm modulus of p-vector ** eraPxp vector product of two p-vectors ** eraPmp p-vector minus p-vector ** eraPdp scalar product of two p-vectors ** ** Copyright (C) 2013-2015, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double am, au[3], bm, st, ct, xa, ya, za, eta[3], xi[3], a2b[3], pa; /* Modulus and direction of the a vector. */ eraPn(a, &am, au); /* Modulus of the b vector. */ bm = eraPm(b); /* Deal with the case of a null vector. */ if ((am == 0.0) || (bm == 0.0)) { st = 0.0; ct = 1.0; } else { /* The "north" axis tangential from a (arbitrary length). */ xa = a[0]; ya = a[1]; za = a[2]; eta[0] = -xa * za; eta[1] = -ya * za; eta[2] = xa*xa + ya*ya; /* The "east" axis tangential from a (same length). */ eraPxp(eta, au, xi); /* The vector from a to b. */ eraPmp(b, a, a2b); /* Resolve into components along the north and east axes. */ st = eraPdp(a2b, xi); ct = eraPdp(a2b, eta); /* Deal with degenerate cases. */ if ((st == 0.0) && (ct == 0.0)) ct = 1.0; } /* Position angle. */ pa = atan2(st, ct); return pa; }
int eraStarpv(double ra, double dec, double pmr, double pmd, double px, double rv, double pv[2][3]) /* ** - - - - - - - - - - ** e r a S t a r p v ** - - - - - - - - - - ** ** Convert star catalog coordinates to position+velocity vector. ** ** Given (Note 1): ** ra double right ascension (radians) ** dec double declination (radians) ** pmr double RA proper motion (radians/year) ** pmd double Dec proper motion (radians/year) ** px double parallax (arcseconds) ** rv double radial velocity (km/s, positive = receding) ** ** Returned (Note 2): ** pv double[2][3] pv-vector (AU, AU/day) ** ** Returned (function value): ** int status: ** 0 = no warnings ** 1 = distance overridden (Note 6) ** 2 = excessive speed (Note 7) ** 4 = solution didn't converge (Note 8) ** else = binary logical OR of the above ** ** Notes: ** ** 1) The star data accepted by this function are "observables" for an ** imaginary observer at the solar-system barycenter. Proper motion ** and radial velocity are, strictly, in terms of barycentric ** coordinate time, TCB. For most practical applications, it is ** permissible to neglect the distinction between TCB and ordinary ** "proper" time on Earth (TT/TAI). The result will, as a rule, be ** limited by the intrinsic accuracy of the proper-motion and ** radial-velocity data; moreover, the pv-vector is likely to be ** merely an intermediate result, so that a change of time unit ** would cancel out overall. ** ** In accordance with normal star-catalog conventions, the object's ** right ascension and declination are freed from the effects of ** secular aberration. The frame, which is aligned to the catalog ** equator and equinox, is Lorentzian and centered on the SSB. ** ** 2) The resulting position and velocity pv-vector is with respect to ** the same frame and, like the catalog coordinates, is freed from ** the effects of secular aberration. Should the "coordinate ** direction", where the object was located at the catalog epoch, be ** required, it may be obtained by calculating the magnitude of the ** position vector pv[0][0-2] dividing by the speed of light in ** AU/day to give the light-time, and then multiplying the space ** velocity pv[1][0-2] by this light-time and adding the result to ** pv[0][0-2]. ** ** Summarizing, the pv-vector returned is for most stars almost ** identical to the result of applying the standard geometrical ** "space motion" transformation. The differences, which are the ** subject of the Stumpff paper referenced below, are: ** ** (i) In stars with significant radial velocity and proper motion, ** the constantly changing light-time distorts the apparent proper ** motion. Note that this is a classical, not a relativistic, ** effect. ** ** (ii) The transformation complies with special relativity. ** ** 3) Care is needed with units. The star coordinates are in radians ** and the proper motions in radians per Julian year, but the ** parallax is in arcseconds; the radial velocity is in km/s, but ** the pv-vector result is in AU and AU/day. ** ** 4) The RA proper motion is in terms of coordinate angle, not true ** angle. If the catalog uses arcseconds for both RA and Dec proper ** motions, the RA proper motion will need to be divided by cos(Dec) ** before use. ** ** 5) Straight-line motion at constant speed, in the inertial frame, ** is assumed. ** ** 6) An extremely small (or zero or negative) parallax is interpreted ** to mean that the object is on the "celestial sphere", the radius ** of which is an arbitrary (large) value (see the constant PXMIN). ** When the distance is overridden in this way, the status, ** initially zero, has 1 added to it. ** ** 7) If the space velocity is a significant fraction of c (see the ** constant VMAX), it is arbitrarily set to zero. When this action ** occurs, 2 is added to the status. ** ** 8) The relativistic adjustment involves an iterative calculation. ** If the process fails to converge within a set number (IMAX) of ** iterations, 4 is added to the status. ** ** 9) The inverse transformation is performed by the function ** eraPvstar. ** ** Called: ** eraS2pv spherical coordinates to pv-vector ** eraPm modulus of p-vector ** eraZp zero p-vector ** eraPn decompose p-vector into modulus and direction ** eraPdp scalar product of two p-vectors ** eraSxp multiply p-vector by scalar ** eraPmp p-vector minus p-vector ** eraPpp p-vector plus p-vector ** ** Reference: ** ** Stumpff, P., 1985, Astron.Astrophys. 144, 232-240. ** ** Copyright (C) 2013-2015, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { /* Smallest allowed parallax */ static const double PXMIN = 1e-7; /* Largest allowed speed (fraction of c) */ static const double VMAX = 0.5; /* Maximum number of iterations for relativistic solution */ static const int IMAX = 100; int i, iwarn; double w, r, rd, rad, decd, v, x[3], usr[3], ust[3], vsr, vst, betst, betsr, bett, betr, dd, ddel, ur[3], ut[3], d = 0.0, del = 0.0, /* to prevent */ odd = 0.0, oddel = 0.0, /* compiler */ od = 0.0, odel = 0.0; /* warnings */ /* Distance (AU). */ if (px >= PXMIN) { w = px; iwarn = 0; } else { w = PXMIN; iwarn = 1; } r = ERFA_DR2AS / w; /* Radial velocity (AU/day). */ rd = ERFA_DAYSEC * rv * 1e3 / ERFA_DAU; /* Proper motion (radian/day). */ rad = pmr / ERFA_DJY; decd = pmd / ERFA_DJY; /* To pv-vector (AU,AU/day). */ eraS2pv(ra, dec, r, rad, decd, rd, pv); /* If excessive velocity, arbitrarily set it to zero. */ v = eraPm(pv[1]); if (v / ERFA_DC > VMAX) { eraZp(pv[1]); iwarn += 2; } /* Isolate the radial component of the velocity (AU/day). */ eraPn(pv[0], &w, x); vsr = eraPdp(x, pv[1]); eraSxp(vsr, x, usr); /* Isolate the transverse component of the velocity (AU/day). */ eraPmp(pv[1], usr, ust); vst = eraPm(ust); /* Special-relativity dimensionless parameters. */ betsr = vsr / ERFA_DC; betst = vst / ERFA_DC; /* Determine the inertial-to-observed relativistic correction terms. */ bett = betst; betr = betsr; for (i = 0; i < IMAX; i++) { d = 1.0 + betr; del = sqrt(1.0 - betr*betr - bett*bett) - 1.0; betr = d * betsr + del; bett = d * betst; if (i > 0) { dd = fabs(d - od); ddel = fabs(del - odel); if ((i > 1) && (dd >= odd) && (ddel >= oddel)) break; odd = dd; oddel = ddel; } od = d; odel = del; } if (i >= IMAX) iwarn += 4; /* Replace observed radial velocity with inertial value. */ w = (betsr != 0.0) ? d + del / betsr : 1.0; eraSxp(w, usr, ur); /* Replace observed tangential velocity with inertial value. */ eraSxp(d, ust, ut); /* Combine the two to obtain the inertial space velocity. */ eraPpp(ur, ut, pv[1]); /* Return the status. */ return iwarn; }
void eraLtecm(double epj, double rm[3][3]) /* ** - - - - - - - - - ** e r a L t e c m ** - - - - - - - - - ** ** ICRS equatorial to ecliptic rotation matrix, long-term. ** ** Given: ** epj double Julian epoch (TT) ** ** Returned: ** rm double[3][3] ICRS to ecliptic rotation matrix ** ** Notes: ** ** 1) The matrix is in the sense ** ** E_ep = rm x P_ICRS, ** ** where P_ICRS is a vector with respect to ICRS right ascension ** and declination axes and E_ep is the same vector with respect to ** the (inertial) ecliptic and equinox of epoch epj. ** ** 2) P_ICRS is a free vector, merely a direction, typically of unit ** magnitude, and not bound to any particular spatial origin, such ** as the Earth, Sun or SSB. No assumptions are made about whether ** it represents starlight and embodies astrometric effects such as ** parallax or aberration. The transformation is approximately that ** between mean J2000.0 right ascension and declination and ecliptic ** longitude and latitude, with only frame bias (always less than ** 25 mas) to disturb this classical picture. ** ** 3) The Vondrak et al. (2011, 2012) 400 millennia precession model ** agrees with the IAU 2006 precession at J2000.0 and stays within ** 100 microarcseconds during the 20th and 21st centuries. It is ** accurate to a few arcseconds throughout the historical period, ** worsening to a few tenths of a degree at the end of the ** +/- 200,000 year time span. ** ** Called: ** eraLtpequ equator pole, long term ** eraLtpecl ecliptic pole, long term ** eraPxp vector product ** eraPn normalize vector ** ** References: ** ** Vondrak, J., Capitaine, N. and Wallace, P., 2011, New precession ** expressions, valid for long time intervals, Astron.Astrophys. 534, ** A22 ** ** Vondrak, J., Capitaine, N. and Wallace, P., 2012, New precession ** expressions, valid for long time intervals (Corrigendum), ** Astron.Astrophys. 541, C1 ** ** Copyright (C) 2013-2017, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { /* Frame bias (IERS Conventions 2010, Eqs. 5.21 and 5.33) */ const double dx = -0.016617 * ERFA_DAS2R, de = -0.0068192 * ERFA_DAS2R, dr = -0.0146 * ERFA_DAS2R; double p[3], z[3], w[3], s, x[3], y[3]; /* Equator pole. */ eraLtpequ(epj, p); /* Ecliptic pole (bottom row of equatorial to ecliptic matrix). */ eraLtpecl(epj, z); /* Equinox (top row of matrix). */ eraPxp(p, z, w); eraPn(w, &s, x); /* Middle row of matrix. */ eraPxp(z, x, y); /* Combine with frame bias. */ rm[0][0] = x[0] - x[1]*dr + x[2]*dx; rm[0][1] = x[0]*dr + x[1] + x[2]*de; rm[0][2] = - x[0]*dx - x[1]*de + x[2]; rm[1][0] = y[0] - y[1]*dr + y[2]*dx; rm[1][1] = y[0]*dr + y[1] + y[2]*de; rm[1][2] = - y[0]*dx - y[1]*de + y[2]; rm[2][0] = z[0] - z[1]*dr + z[2]*dx; rm[2][1] = z[0]*dr + z[1] + z[2]*de; rm[2][2] = - z[0]*dx - z[1]*de + z[2]; }
int eraPvstar(double pv[2][3], double *ra, double *dec, double *pmr, double *pmd, double *px, double *rv) /* ** - - - - - - - - - - ** e r a P v s t a r ** - - - - - - - - - - ** ** Convert star position+velocity vector to catalog coordinates. ** ** Given (Note 1): ** pv double[2][3] pv-vector (AU, AU/day) ** ** Returned (Note 2): ** ra double right ascension (radians) ** dec double declination (radians) ** pmr double RA proper motion (radians/year) ** pmd double Dec proper motion (radians/year) ** px double parallax (arcsec) ** rv double radial velocity (km/s, positive = receding) ** ** Returned (function value): ** int status: ** 0 = OK ** -1 = superluminal speed (Note 5) ** -2 = null position vector ** ** Notes: ** ** 1) The specified pv-vector is the coordinate direction (and its rate ** of change) for the date at which the light leaving the star ** reached the solar-system barycenter. ** ** 2) The star data returned by this function are "observables" for an ** imaginary observer at the solar-system barycenter. Proper motion ** and radial velocity are, strictly, in terms of barycentric ** coordinate time, TCB. For most practical applications, it is ** permissible to neglect the distinction between TCB and ordinary ** "proper" time on Earth (TT/TAI). The result will, as a rule, be ** limited by the intrinsic accuracy of the proper-motion and ** radial-velocity data; moreover, the supplied pv-vector is likely ** to be merely an intermediate result (for example generated by the ** function eraStarpv), so that a change of time unit will cancel ** out overall. ** ** In accordance with normal star-catalog conventions, the object's ** right ascension and declination are freed from the effects of ** secular aberration. The frame, which is aligned to the catalog ** equator and equinox, is Lorentzian and centered on the SSB. ** ** Summarizing, the specified pv-vector is for most stars almost ** identical to the result of applying the standard geometrical ** "space motion" transformation to the catalog data. The ** differences, which are the subject of the Stumpff paper cited ** below, are: ** ** (i) In stars with significant radial velocity and proper motion, ** the constantly changing light-time distorts the apparent proper ** motion. Note that this is a classical, not a relativistic, ** effect. ** ** (ii) The transformation complies with special relativity. ** ** 3) Care is needed with units. The star coordinates are in radians ** and the proper motions in radians per Julian year, but the ** parallax is in arcseconds; the radial velocity is in km/s, but ** the pv-vector result is in AU and AU/day. ** ** 4) The proper motions are the rate of change of the right ascension ** and declination at the catalog epoch and are in radians per Julian ** year. The RA proper motion is in terms of coordinate angle, not ** true angle, and will thus be numerically larger at high ** declinations. ** ** 5) Straight-line motion at constant speed in the inertial frame is ** assumed. If the speed is greater than or equal to the speed of ** light, the function aborts with an error status. ** ** 6) The inverse transformation is performed by the function eraStarpv. ** ** Called: ** eraPn decompose p-vector into modulus and direction ** eraPdp scalar product of two p-vectors ** eraSxp multiply p-vector by scalar ** eraPmp p-vector minus p-vector ** eraPm modulus of p-vector ** eraPpp p-vector plus p-vector ** eraPv2s pv-vector to spherical ** eraAnp normalize angle into range 0 to 2pi ** ** Reference: ** ** Stumpff, P., 1985, Astron.Astrophys. 144, 232-240. ** ** Copyright (C) 2013-2016, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double r, x[3], vr, ur[3], vt, ut[3], bett, betr, d, w, del, usr[3], ust[3], a, rad, decd, rd; /* Isolate the radial component of the velocity (AU/day, inertial). */ eraPn(pv[0], &r, x); vr = eraPdp(x, pv[1]); eraSxp(vr, x, ur); /* Isolate the transverse component of the velocity (AU/day, inertial). */ eraPmp(pv[1], ur, ut); vt = eraPm(ut); /* Special-relativity dimensionless parameters. */ bett = vt / ERFA_DC; betr = vr / ERFA_DC; /* The inertial-to-observed correction terms. */ d = 1.0 + betr; w = 1.0 - betr*betr - bett*bett; if (d == 0.0 || w < 0) return -1; del = sqrt(w) - 1.0; /* Apply relativistic correction factor to radial velocity component. */ w = (betr != 0) ? (betr - del) / (betr * d) : 1.0; eraSxp(w, ur, usr); /* Apply relativistic correction factor to tangential velocity */ /* component. */ eraSxp(1.0/d, ut, ust); /* Combine the two to obtain the observed velocity vector (AU/day). */ eraPpp(usr, ust, pv[1]); /* Cartesian to spherical. */ eraPv2s(pv, &a, dec, &r, &rad, &decd, &rd); if (r == 0.0) return -2; /* Return RA in range 0 to 2pi. */ *ra = eraAnp(a); /* Return proper motions in radians per year. */ *pmr = rad * ERFA_DJY; *pmd = decd * ERFA_DJY; /* Return parallax in arcsec. */ *px = ERFA_DR2AS / r; /* Return radial velocity in km/s. */ *rv = 1e-3 * rd * ERFA_DAU / ERFA_DAYSEC; /* OK status. */ return 0; }
/* Note that the arguments are flipped */ void palDvn ( double v[3], double uv[3], double *vm ) { eraPn( v, vm, uv ); }
void eraPmpx(double rc, double dc, double pr, double pd, double px, double rv, double pmt, double pob[3], double pco[3]) /* ** - - - - - - - - ** e r a P m p x ** - - - - - - - - ** ** Proper motion and parallax. ** ** Given: ** rc,dc double ICRS RA,Dec at catalog epoch (radians) ** pr double RA proper motion (radians/year; Note 1) ** pd double Dec proper motion (radians/year) ** px double parallax (arcsec) ** rv double radial velocity (km/s, +ve if receding) ** pmt double proper motion time interval (SSB, Julian years) ** pob double[3] SSB to observer vector (au) ** ** Returned: ** pco double[3] coordinate direction (BCRS unit vector) ** ** Notes: ** ** 1) The proper motion in RA is dRA/dt rather than cos(Dec)*dRA/dt. ** ** 2) The proper motion time interval is for when the starlight ** reaches the solar system barycenter. ** ** 3) To avoid the need for iteration, the Roemer effect (i.e. the ** small annual modulation of the proper motion coming from the ** changing light time) is applied approximately, using the ** direction of the star at the catalog epoch. ** ** References: ** ** 1984 Astronomical Almanac, pp B39-B41. ** ** Urban, S. & Seidelmann, P. K. (eds), Explanatory Supplement to ** the Astronomical Almanac, 3rd ed., University Science Books ** (2013), Section 7.2. ** ** Called: ** eraPdp scalar product of two p-vectors ** eraPn decompose p-vector into modulus and direction ** ** Copyright (C) 2013-2017, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { /* Km/s to au/year */ const double VF = ERFA_DAYSEC*ERFA_DJM/ERFA_DAU; /* Light time for 1 au, Julian years */ const double AULTY = ERFA_AULT/ERFA_DAYSEC/ERFA_DJY; int i; double sr, cr, sd, cd, x, y, z, p[3], dt, pxr, w, pdz, pm[3]; /* Spherical coordinates to unit vector (and useful functions). */ sr = sin(rc); cr = cos(rc); sd = sin(dc); cd = cos(dc); p[0] = x = cr*cd; p[1] = y = sr*cd; p[2] = z = sd; /* Proper motion time interval (y) including Roemer effect. */ dt = pmt + eraPdp(p,pob)*AULTY; /* Space motion (radians per year). */ pxr = px * ERFA_DAS2R; w = VF * rv * pxr; pdz = pd * z; pm[0] = - pr*y - pdz*cr + w*x; pm[1] = pr*x - pdz*sr + w*y; pm[2] = pd*cd + w*z; /* Coordinate direction of star (unit vector, BCRS). */ for (i = 0; i < 3; i++) { p[i] += dt*pm[i] - pxr*pob[i]; } eraPn(p, &w, pco); /* Finished. */ }