1 | #include "erfa.h"
|
---|
2 |
|
---|
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-2015, 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 | /* RA,Dec etc. at the "before" epoch to space motion pv-vector. */
|
---|
118 | j1 = eraStarpv(ra1, dec1, pmr1, pmd1, px1, rv1, pv1);
|
---|
119 |
|
---|
120 | /* Light time when observed (days). */
|
---|
121 | tl1 = eraPm(pv1[0]) / ERFA_DC;
|
---|
122 |
|
---|
123 | /* Time interval, "before" to "after" (days). */
|
---|
124 | dt = (ep2a - ep1a) + (ep2b - ep1b);
|
---|
125 |
|
---|
126 | /* Move star along track from the "before" observed position to the */
|
---|
127 | /* "after" geometric position. */
|
---|
128 | eraPvu(dt + tl1, pv1, pv);
|
---|
129 |
|
---|
130 | /* From this geometric position, deduce the observed light time (days) */
|
---|
131 | /* at the "after" epoch (with theoretically unneccessary error check). */
|
---|
132 | r2 = eraPdp(pv[0], pv[0]);
|
---|
133 | rdv = eraPdp(pv[0], pv[1]);
|
---|
134 | v2 = eraPdp(pv[1], pv[1]);
|
---|
135 | c2mv2 = ERFA_DC*ERFA_DC - v2;
|
---|
136 | if (c2mv2 <= 0) return -1;
|
---|
137 | tl2 = (-rdv + sqrt(rdv*rdv + c2mv2*r2)) / c2mv2;
|
---|
138 |
|
---|
139 | /* Move the position along track from the observed place at the */
|
---|
140 | /* "before" epoch to the observed place at the "after" epoch. */
|
---|
141 | eraPvu(dt + (tl1 - tl2), pv1, pv2);
|
---|
142 |
|
---|
143 | /* Space motion pv-vector to RA,Dec etc. at the "after" epoch. */
|
---|
144 | j2 = eraPvstar(pv2, ra2, dec2, pmr2, pmd2, px2, rv2);
|
---|
145 |
|
---|
146 | /* Final status. */
|
---|
147 | j = (j2 == 0) ? j1 : -1;
|
---|
148 |
|
---|
149 | return j;
|
---|
150 |
|
---|
151 | }
|
---|
152 | /*----------------------------------------------------------------------
|
---|
153 | **
|
---|
154 | **
|
---|
155 | ** Copyright (C) 2013-2015, NumFOCUS Foundation.
|
---|
156 | ** All rights reserved.
|
---|
157 | **
|
---|
158 | ** This library is derived, with permission, from the International
|
---|
159 | ** Astronomical Union's "Standards of Fundamental Astronomy" library,
|
---|
160 | ** available from http://www.iausofa.org.
|
---|
161 | **
|
---|
162 | ** The ERFA version is intended to retain identical functionality to
|
---|
163 | ** the SOFA library, but made distinct through different function and
|
---|
164 | ** file names, as set out in the SOFA license conditions. The SOFA
|
---|
165 | ** original has a role as a reference standard for the IAU and IERS,
|
---|
166 | ** and consequently redistribution is permitted only in its unaltered
|
---|
167 | ** state. The ERFA version is not subject to this restriction and
|
---|
168 | ** therefore can be included in distributions which do not support the
|
---|
169 | ** concept of "read only" software.
|
---|
170 | **
|
---|
171 | ** Although the intent is to replicate the SOFA API (other than
|
---|
172 | ** replacement of prefix names) and results (with the exception of
|
---|
173 | ** bugs; any that are discovered will be fixed), SOFA is not
|
---|
174 | ** responsible for any errors found in this version of the library.
|
---|
175 | **
|
---|
176 | ** If you wish to acknowledge the SOFA heritage, please acknowledge
|
---|
177 | ** that you are using a library derived from SOFA, rather than SOFA
|
---|
178 | ** itself.
|
---|
179 | **
|
---|
180 | **
|
---|
181 | ** TERMS AND CONDITIONS
|
---|
182 | **
|
---|
183 | ** Redistribution and use in source and binary forms, with or without
|
---|
184 | ** modification, are permitted provided that the following conditions
|
---|
185 | ** are met:
|
---|
186 | **
|
---|
187 | ** 1 Redistributions of source code must retain the above copyright
|
---|
188 | ** notice, this list of conditions and the following disclaimer.
|
---|
189 | **
|
---|
190 | ** 2 Redistributions in binary form must reproduce the above copyright
|
---|
191 | ** notice, this list of conditions and the following disclaimer in
|
---|
192 | ** the documentation and/or other materials provided with the
|
---|
193 | ** distribution.
|
---|
194 | **
|
---|
195 | ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
|
---|
196 | ** the International Astronomical Union nor the names of its
|
---|
197 | ** contributors may be used to endorse or promote products derived
|
---|
198 | ** from this software without specific prior written permission.
|
---|
199 | **
|
---|
200 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
---|
201 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
202 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
---|
203 | ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
---|
204 | ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
205 | ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
---|
206 | ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
207 | ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
---|
208 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
209 | ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
---|
210 | ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
---|
211 | ** POSSIBILITY OF SUCH DAMAGE.
|
---|
212 | **
|
---|
213 | */
|
---|