FACT++  1.0
pmsafe.c
Go to the documentation of this file.
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-2015, 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 /* Proper motion in one year (radians). */
123  pm = eraSeps(ra1, dec1, ra1+pmr1, dec1+pmd1);
124 
125 /* Override the parallax to reduce the chances of a warning status. */
126  jpx = 0;
127  px1a = px1;
128  pm *= F;
129  if (px1a < pm) {jpx = 1; px1a = pm;}
130  if (px1a < PXMIN) {jpx = 1; px1a = PXMIN;}
131 
132 /* Carry out the transformation using the modified parallax. */
133  j = eraStarpm(ra1, dec1, pmr1, pmd1, px1a, rv1,
134  ep1a, ep1b, ep2a, ep2b,
135  ra2, dec2, pmr2, pmd2, px2, rv2);
136 
137 /* Revise and return the status. */
138  if ( !(j%2) ) j += jpx;
139  return j;
140 
141 /* Finished. */
142 
143 }
144 /*----------------------------------------------------------------------
145 **
146 **
147 ** Copyright (C) 2013-2015, NumFOCUS Foundation.
148 ** All rights reserved.
149 **
150 ** This library is derived, with permission, from the International
151 ** Astronomical Union's "Standards of Fundamental Astronomy" library,
152 ** available from http://www.iausofa.org.
153 **
154 ** The ERFA version is intended to retain identical functionality to
155 ** the SOFA library, but made distinct through different function and
156 ** file names, as set out in the SOFA license conditions. The SOFA
157 ** original has a role as a reference standard for the IAU and IERS,
158 ** and consequently redistribution is permitted only in its unaltered
159 ** state. The ERFA version is not subject to this restriction and
160 ** therefore can be included in distributions which do not support the
161 ** concept of "read only" software.
162 **
163 ** Although the intent is to replicate the SOFA API (other than
164 ** replacement of prefix names) and results (with the exception of
165 ** bugs; any that are discovered will be fixed), SOFA is not
166 ** responsible for any errors found in this version of the library.
167 **
168 ** If you wish to acknowledge the SOFA heritage, please acknowledge
169 ** that you are using a library derived from SOFA, rather than SOFA
170 ** itself.
171 **
172 **
173 ** TERMS AND CONDITIONS
174 **
175 ** Redistribution and use in source and binary forms, with or without
176 ** modification, are permitted provided that the following conditions
177 ** are met:
178 **
179 ** 1 Redistributions of source code must retain the above copyright
180 ** notice, this list of conditions and the following disclaimer.
181 **
182 ** 2 Redistributions in binary form must reproduce the above copyright
183 ** notice, this list of conditions and the following disclaimer in
184 ** the documentation and/or other materials provided with the
185 ** distribution.
186 **
187 ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
188 ** the International Astronomical Union nor the names of its
189 ** contributors may be used to endorse or promote products derived
190 ** from this software without specific prior written permission.
191 **
192 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
193 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
194 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
195 ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
196 ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
197 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
198 ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
199 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
200 ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
201 ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
202 ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
203 ** POSSIBILITY OF SUCH DAMAGE.
204 **
205 */
double eraSeps(double al, double ap, double bl, double bp)
Definition: seps.c:3
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)
Definition: starpm.c:3
int eraPmsafe(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)
Definition: pmsafe.c:3