void eraPvppv(double a[2][3], double b[2][3], double apb[2][3]) /* ** - - - - - - - - - ** e r a P v p p v ** - - - - - - - - - ** ** Add one pv-vector to another. ** ** Given: ** a double[2][3] first pv-vector ** b double[2][3] second pv-vector ** ** Returned: ** apb double[2][3] a + b ** ** Note: ** It is permissible to re-use the same array for any of the ** arguments. ** ** Called: ** eraPpp p-vector plus p-vector ** ** Copyright (C) 2013-2017, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { eraPpp(a[0], b[0], apb[0]); eraPpp(a[1], b[1], apb[1]); return; }
void eraPvxpv(double a[2][3], double b[2][3], double axb[2][3]) /* ** - - - - - - - - - ** e r a P v x p v ** - - - - - - - - - ** ** Outer (=vector=cross) product of two pv-vectors. ** ** Given: ** a double[2][3] first pv-vector ** b double[2][3] second pv-vector ** ** Returned: ** axb double[2][3] a x b ** ** Notes: ** ** 1) If the position and velocity components of the two pv-vectors are ** ( ap, av ) and ( bp, bv ), the result, a x b, is the pair of ** vectors ( ap x bp, ap x bv + av x bp ). The two vectors are the ** cross-product of the two p-vectors and its derivative. ** ** 2) It is permissible to re-use the same array for any of the ** arguments. ** ** Called: ** eraCpv copy pv-vector ** eraPxp vector product of two p-vectors ** eraPpp p-vector plus p-vector ** ** Copyright (C) 2013-2016, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double wa[2][3], wb[2][3], axbd[3], adxb[3]; /* Make copies of the inputs. */ eraCpv(a, wa); eraCpv(b, wb); /* a x b = position part of result. */ eraPxp(wa[0], wb[0], axb[0]); /* a x bdot + adot x b = velocity part of result. */ eraPxp(wa[0], wb[1], axbd); eraPxp(wa[1], wb[0], adxb); eraPpp(axbd, adxb, axb[1]); return; }
void eraPpsp(double a[3], double s, double b[3], double apsb[3]) /* ** - - - - - - - - ** e r a P p s p ** - - - - - - - - ** ** P-vector plus scaled p-vector. ** ** Given: ** a double[3] first p-vector ** s double scalar (multiplier for b) ** b double[3] second p-vector ** ** Returned: ** apsb double[3] a + s*b ** ** Note: ** It is permissible for any of a, b and apsb to be the same array. ** ** Called: ** eraSxp multiply p-vector by scalar ** eraPpp p-vector plus p-vector ** ** Copyright (C) 2013-2016, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double sb[3]; /* s*b. */ eraSxp(s, b, sb); /* a + s*b. */ eraPpp(a, sb, apsb); return; }
void eraFk52h(double r5, double d5, double dr5, double dd5, double px5, double rv5, double *rh, double *dh, double *drh, double *ddh, double *pxh, double *rvh) /* ** - - - - - - - - - ** e r a F k 5 2 h ** - - - - - - - - - ** ** Transform FK5 (J2000.0) star data into the Hipparcos system. ** ** Given (all FK5, equinox J2000.0, epoch J2000.0): ** r5 double RA (radians) ** d5 double Dec (radians) ** dr5 double proper motion in RA (dRA/dt, rad/Jyear) ** dd5 double proper motion in Dec (dDec/dt, rad/Jyear) ** px5 double parallax (arcsec) ** rv5 double radial velocity (km/s, positive = receding) ** ** Returned (all Hipparcos, epoch J2000.0): ** rh double RA (radians) ** dh double Dec (radians) ** drh double proper motion in RA (dRA/dt, rad/Jyear) ** ddh double proper motion in Dec (dDec/dt, rad/Jyear) ** pxh double parallax (arcsec) ** rvh double radial velocity (km/s, positive = receding) ** ** Notes: ** ** 1) This function transforms FK5 star positions and proper motions ** into the system of the Hipparcos catalog. ** ** 2) The proper motions in RA are dRA/dt rather than ** cos(Dec)*dRA/dt, and are per year rather than per century. ** ** 3) The FK5 to Hipparcos transformation is modeled as a pure ** rotation and spin; zonal errors in the FK5 catalog are not ** taken into account. ** ** 4) See also eraH2fk5, eraFk5hz, eraHfk5z. ** ** Called: ** eraStarpv star catalog data to space motion pv-vector ** eraFk5hip FK5 to Hipparcos rotation and spin ** eraRxp product of r-matrix and p-vector ** eraPxp vector product of two p-vectors ** eraPpp p-vector plus p-vector ** eraPvstar space motion pv-vector to star catalog data ** ** Reference: ** ** F.Mignard & M.Froeschle, Astron. Astrophys. 354, 732-739 (2000). ** ** Copyright (C) 2013, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { int i; double pv5[2][3], r5h[3][3], s5h[3], wxp[3], vv[3], pvh[2][3]; /* FK5 barycentric position/velocity pv-vector (normalized). */ eraStarpv(r5, d5, dr5, dd5, px5, rv5, pv5); /* FK5 to Hipparcos orientation matrix and spin vector. */ eraFk5hip(r5h, s5h); /* Make spin units per day instead of per year. */ for ( i = 0; i < 3; s5h[i++] /= 365.25 ); /* Orient the FK5 position into the Hipparcos system. */ eraRxp(r5h, pv5[0], pvh[0]); /* Apply spin to the position giving an extra space motion component. */ eraPxp(pv5[0], s5h, wxp); /* Add this component to the FK5 space motion. */ eraPpp(wxp, pv5[1], vv); /* Orient the FK5 space motion into the Hipparcos system. */ eraRxp(r5h, vv, pvh[1]); /* Hipparcos pv-vector to spherical. */ eraPvstar(pvh, rh, dh, drh, ddh, pxh, rvh); return; }
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; }
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; }