1 #include "erfa.h"
2
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)3 int eraStarpm(double ra1, double dec1,
4 double pmr1, double pmd1, double px1, double rv1,
5 double ep1a, double ep1b, double ep2a, double ep2b,
6 double *ra2, double *dec2,
7 double *pmr2, double *pmd2, double *px2, double *rv2)
8 /*
9 ** - - - - - - - - - -
10 ** e r a S t a r p m
11 ** - - - - - - - - - -
12 **
13 ** Star proper motion: update star catalog data for space motion.
14 **
15 ** Given:
16 ** ra1 double right ascension (radians), before
17 ** dec1 double declination (radians), before
18 ** pmr1 double RA proper motion (radians/year), before
19 ** pmd1 double Dec proper motion (radians/year), before
20 ** px1 double parallax (arcseconds), before
21 ** rv1 double radial velocity (km/s, +ve = receding), before
22 ** ep1a double "before" epoch, part A (Note 1)
23 ** ep1b double "before" epoch, part B (Note 1)
24 ** ep2a double "after" epoch, part A (Note 1)
25 ** ep2b double "after" epoch, part B (Note 1)
26 **
27 ** Returned:
28 ** ra2 double right ascension (radians), after
29 ** dec2 double declination (radians), after
30 ** pmr2 double RA proper motion (radians/year), after
31 ** pmd2 double Dec proper motion (radians/year), after
32 ** px2 double parallax (arcseconds), after
33 ** rv2 double radial velocity (km/s, +ve = receding), after
34 **
35 ** Returned (function value):
36 ** int status:
37 ** -1 = system error (should not occur)
38 ** 0 = no warnings or errors
39 ** 1 = distance overridden (Note 6)
40 ** 2 = excessive velocity (Note 7)
41 ** 4 = solution didn't converge (Note 8)
42 ** else = binary logical OR of the above warnings
43 **
44 ** Notes:
45 **
46 ** 1) The starting and ending TDB dates ep1a+ep1b and ep2a+ep2b are
47 ** Julian Dates, apportioned in any convenient way between the two
48 ** parts (A and B). For example, JD(TDB)=2450123.7 could be
49 ** expressed in any of these ways, among others:
50 **
51 ** epna epnb
52 **
53 ** 2450123.7 0.0 (JD method)
54 ** 2451545.0 -1421.3 (J2000 method)
55 ** 2400000.5 50123.2 (MJD method)
56 ** 2450123.5 0.2 (date & time method)
57 **
58 ** The JD method is the most natural and convenient to use in
59 ** cases where the loss of several decimal digits of resolution
60 ** is acceptable. The J2000 method is best matched to the way
61 ** the argument is handled internally and will deliver the
62 ** optimum resolution. The MJD method and the date & time methods
63 ** are both good compromises between resolution and convenience.
64 **
65 ** 2) In accordance with normal star-catalog conventions, the object's
66 ** right ascension and declination are freed from the effects of
67 ** secular aberration. The frame, which is aligned to the catalog
68 ** equator and equinox, is Lorentzian and centered on the SSB.
69 **
70 ** The proper motions are the rate of change of the right ascension
71 ** and declination at the catalog epoch and are in radians per TDB
72 ** Julian year.
73 **
74 ** The parallax and radial velocity are in the same frame.
75 **
76 ** 3) Care is needed with units. The star coordinates are in radians
77 ** and the proper motions in radians per Julian year, but the
78 ** parallax is in arcseconds.
79 **
80 ** 4) The RA proper motion is in terms of coordinate angle, not true
81 ** angle. If the catalog uses arcseconds for both RA and Dec proper
82 ** motions, the RA proper motion will need to be divided by cos(Dec)
83 ** before use.
84 **
85 ** 5) Straight-line motion at constant speed, in the inertial frame,
86 ** is assumed.
87 **
88 ** 6) An extremely small (or zero or negative) parallax is interpreted
89 ** to mean that the object is on the "celestial sphere", the radius
90 ** of which is an arbitrary (large) value (see the eraStarpv
91 ** function for the value used). When the distance is overridden in
92 ** this way, the status, initially zero, has 1 added to it.
93 **
94 ** 7) If the space velocity is a significant fraction of c (see the
95 ** constant VMAX in the function eraStarpv), it is arbitrarily set
96 ** to zero. When this action occurs, 2 is added to the status.
97 **
98 ** 8) The relativistic adjustment carried out in the eraStarpv function
99 ** involves an iterative calculation. If the process fails to
100 ** converge within a set number of iterations, 4 is added to the
101 ** status.
102 **
103 ** Called:
104 ** eraStarpv star catalog data to space motion pv-vector
105 ** eraPvu update a pv-vector
106 ** eraPdp scalar product of two p-vectors
107 ** eraPvstar space motion pv-vector to star catalog data
108 **
109 ** Copyright (C) 2013-2014, NumFOCUS Foundation.
110 ** Derived, with permission, from the SOFA library. See notes at end of file.
111 */
112 {
113 double pv1[2][3], tl1, dt, pv[2][3], r2, rdv, v2, c2mv2, tl2,
114 pv2[2][3];
115 int j1, j2, j;
116
117
118 /* RA,Dec etc. at the "before" epoch to space motion pv-vector. */
119 j1 = eraStarpv(ra1, dec1, pmr1, pmd1, px1, rv1, pv1);
120
121 /* Light time when observed (days). */
122 tl1 = eraPm(pv1[0]) / ERFA_DC;
123
124 /* Time interval, "before" to "after" (days). */
125 dt = (ep2a - ep1a) + (ep2b - ep1b);
126
127 /* Move star along track from the "before" observed position to the */
128 /* "after" geometric position. */
129 eraPvu(dt + tl1, pv1, pv);
130
131 /* From this geometric position, deduce the observed light time (days) */
132 /* at the "after" epoch (with theoretically unneccessary error check). */
133 r2 = eraPdp(pv[0], pv[0]);
134 rdv = eraPdp(pv[0], pv[1]);
135 v2 = eraPdp(pv[1], pv[1]);
136 c2mv2 = ERFA_DC*ERFA_DC - v2;
137 if (c2mv2 <= 0) return -1;
138 tl2 = (-rdv + sqrt(rdv*rdv + c2mv2*r2)) / c2mv2;
139
140 /* Move the position along track from the observed place at the */
141 /* "before" epoch to the observed place at the "after" epoch. */
142 eraPvu(dt + (tl1 - tl2), pv1, pv2);
143
144 /* Space motion pv-vector to RA,Dec etc. at the "after" epoch. */
145 j2 = eraPvstar(pv2, ra2, dec2, pmr2, pmd2, px2, rv2);
146
147 /* Final status. */
148 j = (j2 == 0) ? j1 : -1;
149
150 return j;
151
152 }
153 /*----------------------------------------------------------------------
154 **
155 **
156 ** Copyright (C) 2013-2014, NumFOCUS Foundation.
157 ** All rights reserved.
158 **
159 ** This library is derived, with permission, from the International
160 ** Astronomical Union's "Standards of Fundamental Astronomy" library,
161 ** available from http://www.iausofa.org.
162 **
163 ** The ERFA version is intended to retain identical functionality to
164 ** the SOFA library, but made distinct through different function and
165 ** file names, as set out in the SOFA license conditions. The SOFA
166 ** original has a role as a reference standard for the IAU and IERS,
167 ** and consequently redistribution is permitted only in its unaltered
168 ** state. The ERFA version is not subject to this restriction and
169 ** therefore can be included in distributions which do not support the
170 ** concept of "read only" software.
171 **
172 ** Although the intent is to replicate the SOFA API (other than
173 ** replacement of prefix names) and results (with the exception of
174 ** bugs; any that are discovered will be fixed), SOFA is not
175 ** responsible for any errors found in this version of the library.
176 **
177 ** If you wish to acknowledge the SOFA heritage, please acknowledge
178 ** that you are using a library derived from SOFA, rather than SOFA
179 ** itself.
180 **
181 **
182 ** TERMS AND CONDITIONS
183 **
184 ** Redistribution and use in source and binary forms, with or without
185 ** modification, are permitted provided that the following conditions
186 ** are met:
187 **
188 ** 1 Redistributions of source code must retain the above copyright
189 ** notice, this list of conditions and the following disclaimer.
190 **
191 ** 2 Redistributions in binary form must reproduce the above copyright
192 ** notice, this list of conditions and the following disclaimer in
193 ** the documentation and/or other materials provided with the
194 ** distribution.
195 **
196 ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
197 ** the International Astronomical Union nor the names of its
198 ** contributors may be used to endorse or promote products derived
199 ** from this software without specific prior written permission.
200 **
201 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
202 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
203 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
204 ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
205 ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
206 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
207 ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
208 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
209 ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
210 ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
211 ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
212 ** POSSIBILITY OF SUCH DAMAGE.
213 **
214 */
215