void eraP2pv(double p[3], double pv[2][3]) /* ** - - - - - - - - ** e r a P 2 p v ** - - - - - - - - ** ** Extend a p-vector to a pv-vector by appending a zero velocity. ** ** Given: ** p double[3] p-vector ** ** Returned: ** pv double[2][3] pv-vector ** ** Called: ** eraCp copy p-vector ** eraZp zero p-vector ** ** Copyright (C) 2013-2016, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { eraCp(p, pv[0]); eraZp(pv[1]); return; }
void eraPn(double p[3], double *r, double u[3]) /* ** - - - - - - ** e r a P n ** - - - - - - ** ** Convert a p-vector into modulus and unit vector. ** ** Given: ** p double[3] p-vector ** ** Returned: ** r double modulus ** u double[3] unit vector ** ** Notes: ** ** 1) If p is null, the result is null. Otherwise the result is a unit ** vector. ** ** 2) It is permissible to re-use the same array for any of the ** arguments. ** ** Called: ** eraPm modulus of p-vector ** eraZp zero p-vector ** eraSxp multiply p-vector by scalar ** ** Copyright (C) 2013-2016, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double w; /* Obtain the modulus and test for zero. */ w = eraPm(p); if (w == 0.0) { /* Null vector. */ eraZp(u); } else { /* Unit vector. */ eraSxp(1.0/w, p, u); } /* Return the modulus. */ *r = w; return; }
void eraZpv(double pv[2][3]) /* ** - - - - - - - ** e r a Z p v ** - - - - - - - ** ** Zero a pv-vector. ** ** Returned: ** pv double[2][3] pv-vector ** ** Called: ** eraZp zero p-vector ** ** Copyright (C) 2013-2015, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { eraZp(pv[0]); eraZp(pv[1]); return; }
void eraAticq(double ri, double di, eraASTROM *astrom, double *rc, double *dc) /* ** - - - - - - - - - ** e r a A t i c q ** - - - - - - - - - ** ** Quick CIRS RA,Dec to ICRS astrometric place, given the star- ** independent astrometry parameters. ** ** Use of this function is appropriate when efficiency is important and ** where many star positions are all to be transformed for one date. ** The star-independent astrometry parameters can be obtained by ** calling one of the functions eraApci[13], eraApcg[13], eraApco[13] ** or eraApcs[13]. ** ** Given: ** ri,di double CIRS RA,Dec (radians) ** astrom eraASTROM* star-independent astrometry parameters: ** pmt double PM time interval (SSB, Julian years) ** eb double[3] SSB to observer (vector, au) ** eh double[3] Sun to observer (unit vector) ** em double distance from Sun to observer (au) ** v double[3] barycentric observer velocity (vector, c) ** bm1 double sqrt(1-|v|^2): reciprocal of Lorenz factor ** bpn double[3][3] bias-precession-nutation matrix ** along double longitude + s' (radians) ** xpl double polar motion xp wrt local meridian (radians) ** ypl double polar motion yp wrt local meridian (radians) ** sphi double sine of geodetic latitude ** cphi double cosine of geodetic latitude ** diurab double magnitude of diurnal aberration vector ** eral double "local" Earth rotation angle (radians) ** refa double refraction constant A (radians) ** refb double refraction constant B (radians) ** ** Returned: ** rc,dc double ICRS astrometric RA,Dec (radians) ** ** Notes: ** ** 1) Only the Sun is taken into account in the light deflection ** correction. ** ** 2) Iterative techniques are used for the aberration and light ** deflection corrections so that the functions eraAtic13 (or ** eraAticq) and eraAtci13 (or eraAtciq) are accurate inverses; ** even at the edge of the Sun's disk the discrepancy is only about ** 1 nanoarcsecond. ** ** Called: ** eraS2c spherical coordinates to unit vector ** eraTrxp product of transpose of r-matrix and p-vector ** eraZp zero p-vector ** eraAb stellar aberration ** eraLdsun light deflection by the Sun ** eraC2s p-vector to spherical ** eraAnp normalize angle into range +/- pi ** ** Copyright (C) 2013-2015, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { int j, i; double pi[3], ppr[3], pnat[3], pco[3], w, d[3], before[3], r2, r, after[3]; /* CIRS RA,Dec to Cartesian. */ eraS2c(ri, di, pi); /* Bias-precession-nutation, giving GCRS proper direction. */ eraTrxp(astrom->bpn, pi, ppr); /* Aberration, giving GCRS natural direction. */ eraZp(d); for (j = 0; j < 2; j++) { r2 = 0.0; for (i = 0; i < 3; i++) { w = ppr[i] - d[i]; before[i] = w; r2 += w*w; } r = sqrt(r2); for (i = 0; i < 3; i++) { before[i] /= r; } eraAb(before, astrom->v, astrom->em, astrom->bm1, after); r2 = 0.0; for (i = 0; i < 3; i++) { d[i] = after[i] - before[i]; w = ppr[i] - d[i]; pnat[i] = w; r2 += w*w; } r = sqrt(r2); for (i = 0; i < 3; i++) { pnat[i] /= r; } } /* Light deflection by the Sun, giving BCRS coordinate direction. */ eraZp(d); for (j = 0; j < 5; j++) { r2 = 0.0; for (i = 0; i < 3; i++) { w = pnat[i] - d[i]; before[i] = w; r2 += w*w; } r = sqrt(r2); for (i = 0; i < 3; i++) { before[i] /= r; } eraLdsun(before, astrom->eh, astrom->em, after); r2 = 0.0; for (i = 0; i < 3; i++) { d[i] = after[i] - before[i]; w = pnat[i] - d[i]; pco[i] = w; r2 += w*w; } r = sqrt(r2); for (i = 0; i < 3; i++) { pco[i] /= r; } } /* ICRS astrometric RA,Dec. */ eraC2s(pco, &w, dc); *rc = eraAnp(w); /* Finished. */ }
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; }