double palRvlg( double r2000, double d2000 ){ /* Local Variables: */ double vb[ 3 ]; /* * * Solar velocity due to Galactic rotation and translation * * Speed = 300 km/s * * Apex = L2,B2 90deg, 0deg * = RA,Dec 21 12 01.1 +48 19 47 J2000.0 * * This is expressed in the form of a J2000.0 x,y,z vector: * * VA(1) = X = -SPEED*COS(RA)*COS(DEC) * VA(2) = Y = -SPEED*SIN(RA)*COS(DEC) * VA(3) = Z = -SPEED*SIN(DEC) */ double va[ 3 ] = { -148.23284, +133.44888, -224.09467 }; /* Convert given J2000 RA,Dec to x,y,z. */ eraS2c( r2000, d2000, vb ); /* Compute dot product with Solar motion vector. */ return eraPdp( va, vb ); }
double palRvlsrd( double r2000, double d2000 ){ /* Local Variables: */ double vb[ 3 ]; /* * Peculiar solar motion from Delhaye 1965: in Galactic Cartesian * coordinates (+9,+12,+7) km/s. This corresponds to about 16.6 km/s * towards Galactic coordinates L2 = 53 deg, B2 = +25 deg, or RA,Dec * 17 49 58.7 +28 07 04 J2000. * * The solar motion is expressed here in the form of a J2000.0 * equatorial Cartesian vector: * * VA(1) = X = -SPEED*COS(RA)*COS(DEC) * VA(2) = Y = -SPEED*SIN(RA)*COS(DEC) * VA(3) = Z = -SPEED*SIN(DEC) */ double va[ 3 ] = { +0.63823, +14.58542, -7.80116 }; /* Convert given J2000 RA,Dec to x,y,z. */ eraS2c( r2000, d2000, vb ); /* Compute dot product with Solar motion vector. */ return eraPdp( va, vb ); }
double palRvlsrk( double r2000, double d2000 ){ /* Local Variables: */ double vb[ 3 ]; /* * Standard solar motion (from Methods of Experimental Physics, ed Meeks, * vol 12, part C, sec 6.1.5.2, p281): * * 20 km/s towards RA 18h Dec +30d (1900). * * The solar motion is expressed here in the form of a J2000.0 * equatorial Cartesian vector: * * VA(1) = X = -SPEED*COS(RA)*COS(DEC) * VA(2) = Y = -SPEED*SIN(RA)*COS(DEC) * VA(3) = Z = -SPEED*SIN(DEC) */ double va[ 3 ] = { -0.29000, +17.31726, -10.00141 }; /* Convert given J2000 RA,Dec to x,y,z. */ eraS2c( r2000, d2000, vb ); /* Compute dot product with Solar motion vector. */ return eraPdp( va, vb ); }
void eraPvdpv(double a[2][3], double b[2][3], double adb[2]) /* ** - - - - - - - - - ** e r a P v d p v ** - - - - - - - - - ** ** Inner (=scalar=dot) product of two pv-vectors. ** ** Given: ** a double[2][3] first pv-vector ** b double[2][3] second pv-vector ** ** Returned: ** adb double[2] a . b (see note) ** ** Note: ** ** If the position and velocity components of the two pv-vectors are ** ( ap, av ) and ( bp, bv ), the result, a . b, is the pair of ** numbers ( ap . bp , ap . bv + av . bp ). The two numbers are the ** dot-product of the two p-vectors and its derivative. ** ** Called: ** eraPdp scalar product of two p-vectors ** ** Copyright (C) 2013-2016, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double adbd, addb; /* a . b = constant part of result. */ adb[0] = eraPdp(a[0], b[0]); /* a . bdot */ adbd = eraPdp(a[0], b[1]); /* adot . b */ addb = eraPdp(a[1], b[0]); /* Velocity part of result. */ adb[1] = adbd + addb; return; }
void palMapqkz ( double rm, double dm, double amprms[21], double *ra, double *da ){ /* Local Variables: */ int i; double ab1, abv[3], p[3], w, p1dv, p2[3], p3[3]; double gr2e, pde, pdep1, ehn[3], p1[3]; /* Unpack scalar and vector parameters. */ ab1 = amprms[11]; gr2e = amprms[7]; for( i = 0; i < 3; i++ ) { abv[i] = amprms[i+8]; ehn[i] = amprms[i+4]; } /* Spherical to x,y,z. */ eraS2c( rm, dm, p ); /* Light deflection (restrained within the Sun's disc) */ pde = eraPdp( p, ehn ); pdep1 = pde + 1.0; w = gr2e / ( pdep1 > 1.0e-5 ? pdep1 : 1.0e-5 ); for( i = 0; i < 3; i++) { p1[i] = p[i] + w * ( ehn[i] - pde * p[i] ); } /* Aberration. */ p1dv = eraPdp( p1, abv ); w = 1.0 + p1dv / ( ab1 + 1.0 ); for( i = 0; i < 3; i++ ) { p2[i] = ( ( ab1 * p1[i] ) + ( w * abv[i] ) ); } /* Precession and nutation. */ eraRxp( (double(*)[3]) &rms[12], p2, p3 ); /* Geocentric apparent RA,dec. */ eraC2s( p3, ra, da ); *ra = eraAnp( *ra ); }
double eraSepp(double a[3], double b[3]) /* ** - - - - - - - - ** e r a S e p p ** - - - - - - - - ** ** Angular separation between two p-vectors. ** ** Given: ** a double[3] first p-vector (not necessarily unit length) ** b double[3] second p-vector (not necessarily unit length) ** ** Returned (function value): ** double angular separation (radians, always positive) ** ** Notes: ** ** 1) If either vector is null, a zero result is returned. ** ** 2) The angular separation is most simply formulated in terms of ** scalar product. However, this gives poor accuracy for angles ** near zero and pi. The present algorithm uses both cross product ** and dot product, to deliver full accuracy whatever the size of ** the angle. ** ** Called: ** eraPxp vector product of two p-vectors ** eraPm modulus of p-vector ** eraPdp scalar product of two p-vectors ** ** Copyright (C) 2013-2016, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double axb[3], ss, cs, s; /* Sine of angle between the vectors, multiplied by the two moduli. */ eraPxp(a, b, axb); ss = eraPm(axb); /* Cosine of the angle, multiplied by the two moduli. */ cs = eraPdp(a, b); /* The angle. */ s = ((ss != 0.0) || (cs != 0.0)) ? atan2(ss, cs) : 0.0; return s; }
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; }
void eraLd(double bm, double p[3], double q[3], double e[3], double em, double dlim, double p1[3]) /* ** - - - - - - ** e r a L d ** - - - - - - ** ** Apply light deflection by a solar-system body, as part of ** transforming coordinate direction into natural direction. ** ** Given: ** bm double mass of the gravitating body (solar masses) ** p double[3] direction from observer to source (unit vector) ** q double[3] direction from body to source (unit vector) ** e double[3] direction from body to observer (unit vector) ** em double distance from body to observer (au) ** dlim double deflection limiter (Note 4) ** ** Returned: ** p1 double[3] observer to deflected source (unit vector) ** ** Notes: ** ** 1) The algorithm is based on Expr. (70) in Klioner (2003) and ** Expr. (7.63) in the Explanatory Supplement (Urban & Seidelmann ** 2013), with some rearrangement to minimize the effects of machine ** precision. ** ** 2) The mass parameter bm can, as required, be adjusted in order to ** allow for such effects as quadrupole field. ** ** 3) The barycentric position of the deflecting body should ideally ** correspond to the time of closest approach of the light ray to ** the body. ** ** 4) The deflection limiter parameter dlim is phi^2/2, where phi is ** the angular separation (in radians) between source and body at ** which limiting is applied. As phi shrinks below the chosen ** threshold, the deflection is artificially reduced, reaching zero ** for phi = 0. ** ** 5) The returned vector p1 is not normalized, but the consequential ** departure from unit magnitude is always negligible. ** ** 6) The arguments p and p1 can be the same array. ** ** 7) To accumulate total light deflection taking into account the ** contributions from several bodies, call the present function for ** each body in succession, in decreasing order of distance from the ** observer. ** ** 8) For efficiency, validation is omitted. The supplied vectors must ** be of unit magnitude, and the deflection limiter non-zero and ** positive. ** ** References: ** ** Urban, S. & Seidelmann, P. K. (eds), Explanatory Supplement to ** the Astronomical Almanac, 3rd ed., University Science Books ** (2013). ** ** Klioner, Sergei A., "A practical relativistic model for micro- ** arcsecond astrometry in space", Astr. J. 125, 1580-1597 (2003). ** ** Called: ** eraPdp scalar product of two p-vectors ** eraPxp vector product of two p-vectors ** ** Copyright (C) 2013-2014, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { int i; double qpe[3], qdqpe, w, eq[3], peq[3]; /* q . (q + e). */ for (i = 0; i < 3; i++) { qpe[i] = q[i] + e[i]; } qdqpe = eraPdp(q, qpe); /* 2 x G x bm / ( em x c^2 x ( q . (q + e) ) ). */ w = bm * ERFA_SRS / em / ERFA_GMAX(qdqpe,dlim); /* p x (e x q). */ eraPxp(e, q, eq); eraPxp(p, eq, peq); /* Apply the deflection. */ for (i = 0; i < 3; i++) { p1[i] = p[i] + w*peq[i]; } /* 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; }
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; }
double palDvdv ( double va[3], double vb[3] ) { return eraPdp( va, vb ); }
int eraStarpm(double ra1, double dec1, double pmr1, double pmd1, double px1, double rv1, double ep1a, double ep1b, double ep2a, double ep2b, double *ra2, double *dec2, double *pmr2, double *pmd2, double *px2, double *rv2) /* ** - - - - - - - - - - ** e r a S t a r p m ** - - - - - - - - - - ** ** Star proper motion: update star catalog data for space motion. ** ** Given: ** ra1 double right ascension (radians), before ** dec1 double declination (radians), before ** pmr1 double RA proper motion (radians/year), before ** pmd1 double Dec proper motion (radians/year), before ** px1 double parallax (arcseconds), before ** rv1 double radial velocity (km/s, +ve = receding), before ** ep1a double "before" epoch, part A (Note 1) ** ep1b double "before" epoch, part B (Note 1) ** ep2a double "after" epoch, part A (Note 1) ** ep2b double "after" epoch, part B (Note 1) ** ** Returned: ** ra2 double right ascension (radians), after ** dec2 double declination (radians), after ** pmr2 double RA proper motion (radians/year), after ** pmd2 double Dec proper motion (radians/year), after ** px2 double parallax (arcseconds), after ** rv2 double radial velocity (km/s, +ve = receding), after ** ** Returned (function value): ** int status: ** -1 = system error (should not occur) ** 0 = no warnings or errors ** 1 = distance overridden (Note 6) ** 2 = excessive velocity (Note 7) ** 4 = solution didn't converge (Note 8) ** else = binary logical OR of the above warnings ** ** Notes: ** ** 1) The starting and ending TDB dates ep1a+ep1b and ep2a+ep2b are ** Julian Dates, apportioned in any convenient way between the two ** parts (A and B). For example, JD(TDB)=2450123.7 could be ** expressed in any of these ways, among others: ** ** epna epnb ** ** 2450123.7 0.0 (JD method) ** 2451545.0 -1421.3 (J2000 method) ** 2400000.5 50123.2 (MJD method) ** 2450123.5 0.2 (date & time method) ** ** The JD method is the most natural and convenient to use in ** cases where the loss of several decimal digits of resolution ** is acceptable. The J2000 method is best matched to the way ** the argument is handled internally and will deliver the ** optimum resolution. The MJD method and the date & time methods ** are both good compromises between resolution and convenience. ** ** 2) 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. ** ** The proper motions are the rate of change of the right ascension ** and declination at the catalog epoch and are in radians per TDB ** Julian year. ** ** The parallax and radial velocity are in the same frame. ** ** 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. ** ** 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 eraStarpv ** function for the value used). 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 in the function eraStarpv), it is arbitrarily set ** to zero. When this action occurs, 2 is added to the status. ** ** 8) The relativistic adjustment carried out in the eraStarpv function ** involves an iterative calculation. If the process fails to ** converge within a set number of iterations, 4 is added to the ** status. ** ** Called: ** eraStarpv star catalog data to space motion pv-vector ** eraPvu update a pv-vector ** eraPdp scalar product of two p-vectors ** eraPvstar space motion pv-vector to star catalog data ** ** Copyright (C) 2013, NumFOCUS Foundation. ** Derived, with permission, from the SOFA library. See notes at end of file. */ { double pv1[2][3], tl1, dt, pv[2][3], r2, rdv, v2, c2mv2, tl2, pv2[2][3]; int j1, j2, j; /* RA,Dec etc. at the "before" epoch to space motion pv-vector. */ j1 = eraStarpv(ra1, dec1, pmr1, pmd1, px1, rv1, pv1); /* Light time when observed (days). */ tl1 = eraPm(pv1[0]) / DC; /* Time interval, "before" to "after" (days). */ dt = (ep2a - ep1a) + (ep2b - ep1b); /* Move star along track from the "before" observed position to the */ /* "after" geometric position. */ eraPvu(dt + tl1, pv1, pv); /* From this geometric position, deduce the observed light time (days) */ /* at the "after" epoch (with theoretically unneccessary error check). */ r2 = eraPdp(pv[0], pv[0]); rdv = eraPdp(pv[0], pv[1]); v2 = eraPdp(pv[1], pv[1]); c2mv2 = DC*DC - v2; if (c2mv2 <= 0) return -1; tl2 = (-rdv + sqrt(rdv*rdv + c2mv2*r2)) / c2mv2; /* Move the position along track from the observed place at the */ /* "before" epoch to the observed place at the "after" epoch. */ eraPvu(dt + (tl1 - tl2), pv1, pv2); /* Space motion pv-vector to RA,Dec etc. at the "after" epoch. */ j2 = eraPvstar(pv2, ra2, dec2, pmr2, pmd2, px2, rv2); /* Final status. */ j = (j2 == 0) ? j1 : -1; return j; }
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. */ }