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