1 | #include "erfa.h"
|
---|
2 |
|
---|
3 | void eraAtoiq(const char *type,
|
---|
4 | double ob1, double ob2, eraASTROM *astrom,
|
---|
5 | double *ri, double *di)
|
---|
6 | /*
|
---|
7 | ** - - - - - - - - -
|
---|
8 | ** e r a A t o i q
|
---|
9 | ** - - - - - - - - -
|
---|
10 | **
|
---|
11 | ** Quick observed place to CIRS, given the star-independent astrometry
|
---|
12 | ** parameters.
|
---|
13 | **
|
---|
14 | ** Use of this function is appropriate when efficiency is important and
|
---|
15 | ** where many star positions are all to be transformed for one date.
|
---|
16 | ** The star-independent astrometry parameters can be obtained by
|
---|
17 | ** calling eraApio[13] or eraApco[13].
|
---|
18 | **
|
---|
19 | ** Given:
|
---|
20 | ** type char[] type of coordinates: "R", "H" or "A" (Note 1)
|
---|
21 | ** ob1 double observed Az, HA or RA (radians; Az is N=0,E=90)
|
---|
22 | ** ob2 double observed ZD or Dec (radians)
|
---|
23 | ** astrom eraASTROM* star-independent astrometry parameters:
|
---|
24 | ** pmt double PM time interval (SSB, Julian years)
|
---|
25 | ** eb double[3] SSB to observer (vector, au)
|
---|
26 | ** eh double[3] Sun to observer (unit vector)
|
---|
27 | ** em double distance from Sun to observer (au)
|
---|
28 | ** v double[3] barycentric observer velocity (vector, c)
|
---|
29 | ** bm1 double sqrt(1-|v|^2): reciprocal of Lorenz factor
|
---|
30 | ** bpn double[3][3] bias-precession-nutation matrix
|
---|
31 | ** along double longitude + s' (radians)
|
---|
32 | ** xpl double polar motion xp wrt local meridian (radians)
|
---|
33 | ** ypl double polar motion yp wrt local meridian (radians)
|
---|
34 | ** sphi double sine of geodetic latitude
|
---|
35 | ** cphi double cosine of geodetic latitude
|
---|
36 | ** diurab double magnitude of diurnal aberration vector
|
---|
37 | ** eral double "local" Earth rotation angle (radians)
|
---|
38 | ** refa double refraction constant A (radians)
|
---|
39 | ** refb double refraction constant B (radians)
|
---|
40 | **
|
---|
41 | ** Returned:
|
---|
42 | ** ri double* CIRS right ascension (CIO-based, radians)
|
---|
43 | ** di double* CIRS declination (radians)
|
---|
44 | **
|
---|
45 | ** Notes:
|
---|
46 | **
|
---|
47 | ** 1) "Observed" Az,El means the position that would be seen by a
|
---|
48 | ** perfect geodetically aligned theodolite. This is related to
|
---|
49 | ** the observed HA,Dec via the standard rotation, using the geodetic
|
---|
50 | ** latitude (corrected for polar motion), while the observed HA and
|
---|
51 | ** RA are related simply through the Earth rotation angle and the
|
---|
52 | ** site longitude. "Observed" RA,Dec or HA,Dec thus means the
|
---|
53 | ** position that would be seen by a perfect equatorial with its
|
---|
54 | ** polar axis aligned to the Earth's axis of rotation. By removing
|
---|
55 | ** from the observed place the effects of atmospheric refraction and
|
---|
56 | ** diurnal aberration, the CIRS RA,Dec is obtained.
|
---|
57 | **
|
---|
58 | ** 2) Only the first character of the type argument is significant.
|
---|
59 | ** "R" or "r" indicates that ob1 and ob2 are the observed right
|
---|
60 | ** ascension and declination; "H" or "h" indicates that they are
|
---|
61 | ** hour angle (west +ve) and declination; anything else ("A" or
|
---|
62 | ** "a" is recommended) indicates that ob1 and ob2 are azimuth (north
|
---|
63 | ** zero, east 90 deg) and zenith distance. (Zenith distance is used
|
---|
64 | ** rather than altitude in order to reflect the fact that no
|
---|
65 | ** allowance is made for depression of the horizon.)
|
---|
66 | **
|
---|
67 | ** 3) The accuracy of the result is limited by the corrections for
|
---|
68 | ** refraction, which use a simple A*tan(z) + B*tan^3(z) model.
|
---|
69 | ** Providing the meteorological parameters are known accurately and
|
---|
70 | ** there are no gross local effects, the predicted observed
|
---|
71 | ** coordinates should be within 0.05 arcsec (optical) or 1 arcsec
|
---|
72 | ** (radio) for a zenith distance of less than 70 degrees, better
|
---|
73 | ** than 30 arcsec (optical or radio) at 85 degrees and better than
|
---|
74 | ** 20 arcmin (optical) or 30 arcmin (radio) at the horizon.
|
---|
75 | **
|
---|
76 | ** Without refraction, the complementary functions eraAtioq and
|
---|
77 | ** eraAtoiq are self-consistent to better than 1 microarcsecond all
|
---|
78 | ** over the celestial sphere. With refraction included, consistency
|
---|
79 | ** falls off at high zenith distances, but is still better than
|
---|
80 | ** 0.05 arcsec at 85 degrees.
|
---|
81 | **
|
---|
82 | ** 4) It is advisable to take great care with units, as even unlikely
|
---|
83 | ** values of the input parameters are accepted and processed in
|
---|
84 | ** accordance with the models used.
|
---|
85 | **
|
---|
86 | ** Called:
|
---|
87 | ** eraS2c spherical coordinates to unit vector
|
---|
88 | ** eraC2s p-vector to spherical
|
---|
89 | ** eraAnp normalize angle into range 0 to 2pi
|
---|
90 | **
|
---|
91 | ** Copyright (C) 2013-2015, NumFOCUS Foundation.
|
---|
92 | ** Derived, with permission, from the SOFA library. See notes at end of file.
|
---|
93 | */
|
---|
94 | {
|
---|
95 | int c;
|
---|
96 | double c1, c2, sphi, cphi, ce, xaeo, yaeo, zaeo, v[3],
|
---|
97 | xmhdo, ymhdo, zmhdo, az, sz, zdo, refa, refb, tz, dref,
|
---|
98 | zdt, xaet, yaet, zaet, xmhda, ymhda, zmhda,
|
---|
99 | f, xhd, yhd, zhd, xpl, ypl, w, hma;
|
---|
100 |
|
---|
101 | /* Coordinate type. */
|
---|
102 | c = (int) type[0];
|
---|
103 |
|
---|
104 | /* Coordinates. */
|
---|
105 | c1 = ob1;
|
---|
106 | c2 = ob2;
|
---|
107 |
|
---|
108 | /* Sin, cos of latitude. */
|
---|
109 | sphi = astrom->sphi;
|
---|
110 | cphi = astrom->cphi;
|
---|
111 |
|
---|
112 | /* Standardize coordinate type. */
|
---|
113 | if ( c == 'r' || c == 'R' ) {
|
---|
114 | c = 'R';
|
---|
115 | } else if ( c == 'h' || c == 'H' ) {
|
---|
116 | c = 'H';
|
---|
117 | } else {
|
---|
118 | c = 'A';
|
---|
119 | }
|
---|
120 |
|
---|
121 | /* If Az,ZD, convert to Cartesian (S=0,E=90). */
|
---|
122 | if ( c == 'A' ) {
|
---|
123 | ce = sin(c2);
|
---|
124 | xaeo = - cos(c1) * ce;
|
---|
125 | yaeo = sin(c1) * ce;
|
---|
126 | zaeo = cos(c2);
|
---|
127 |
|
---|
128 | } else {
|
---|
129 |
|
---|
130 | /* If RA,Dec, convert to HA,Dec. */
|
---|
131 | if ( c == 'R' ) c1 = astrom->eral - c1;
|
---|
132 |
|
---|
133 | /* To Cartesian -HA,Dec. */
|
---|
134 | eraS2c ( -c1, c2, v );
|
---|
135 | xmhdo = v[0];
|
---|
136 | ymhdo = v[1];
|
---|
137 | zmhdo = v[2];
|
---|
138 |
|
---|
139 | /* To Cartesian Az,El (S=0,E=90). */
|
---|
140 | xaeo = sphi*xmhdo - cphi*zmhdo;
|
---|
141 | yaeo = ymhdo;
|
---|
142 | zaeo = cphi*xmhdo + sphi*zmhdo;
|
---|
143 | }
|
---|
144 |
|
---|
145 | /* Azimuth (S=0,E=90). */
|
---|
146 | az = ( xaeo != 0.0 || yaeo != 0.0 ) ? atan2(yaeo,xaeo) : 0.0;
|
---|
147 |
|
---|
148 | /* Sine of observed ZD, and observed ZD. */
|
---|
149 | sz = sqrt ( xaeo*xaeo + yaeo*yaeo );
|
---|
150 | zdo = atan2 ( sz, zaeo );
|
---|
151 |
|
---|
152 | /*
|
---|
153 | ** Refraction
|
---|
154 | ** ----------
|
---|
155 | */
|
---|
156 |
|
---|
157 | /* Fast algorithm using two constant model. */
|
---|
158 | refa = astrom->refa;
|
---|
159 | refb = astrom->refb;
|
---|
160 | tz = sz / zaeo;
|
---|
161 | dref = ( refa + refb*tz*tz ) * tz;
|
---|
162 | zdt = zdo + dref;
|
---|
163 |
|
---|
164 | /* To Cartesian Az,ZD. */
|
---|
165 | ce = sin(zdt);
|
---|
166 | xaet = cos(az) * ce;
|
---|
167 | yaet = sin(az) * ce;
|
---|
168 | zaet = cos(zdt);
|
---|
169 |
|
---|
170 | /* Cartesian Az,ZD to Cartesian -HA,Dec. */
|
---|
171 | xmhda = sphi*xaet + cphi*zaet;
|
---|
172 | ymhda = yaet;
|
---|
173 | zmhda = - cphi*xaet + sphi*zaet;
|
---|
174 |
|
---|
175 | /* Diurnal aberration. */
|
---|
176 | f = ( 1.0 + astrom->diurab*ymhda );
|
---|
177 | xhd = f * xmhda;
|
---|
178 | yhd = f * ( ymhda - astrom->diurab );
|
---|
179 | zhd = f * zmhda;
|
---|
180 |
|
---|
181 | /* Polar motion. */
|
---|
182 | xpl = astrom->xpl;
|
---|
183 | ypl = astrom->ypl;
|
---|
184 | w = xpl*xhd - ypl*yhd + zhd;
|
---|
185 | v[0] = xhd - xpl*w;
|
---|
186 | v[1] = yhd + ypl*w;
|
---|
187 | v[2] = w - ( xpl*xpl + ypl*ypl ) * zhd;
|
---|
188 |
|
---|
189 | /* To spherical -HA,Dec. */
|
---|
190 | eraC2s(v, &hma, di);
|
---|
191 |
|
---|
192 | /* Right ascension. */
|
---|
193 | *ri = eraAnp(astrom->eral + hma);
|
---|
194 |
|
---|
195 | /* Finished. */
|
---|
196 |
|
---|
197 | }
|
---|
198 | /*----------------------------------------------------------------------
|
---|
199 | **
|
---|
200 | **
|
---|
201 | ** Copyright (C) 2013-2015, NumFOCUS Foundation.
|
---|
202 | ** All rights reserved.
|
---|
203 | **
|
---|
204 | ** This library is derived, with permission, from the International
|
---|
205 | ** Astronomical Union's "Standards of Fundamental Astronomy" library,
|
---|
206 | ** available from http://www.iausofa.org.
|
---|
207 | **
|
---|
208 | ** The ERFA version is intended to retain identical functionality to
|
---|
209 | ** the SOFA library, but made distinct through different function and
|
---|
210 | ** file names, as set out in the SOFA license conditions. The SOFA
|
---|
211 | ** original has a role as a reference standard for the IAU and IERS,
|
---|
212 | ** and consequently redistribution is permitted only in its unaltered
|
---|
213 | ** state. The ERFA version is not subject to this restriction and
|
---|
214 | ** therefore can be included in distributions which do not support the
|
---|
215 | ** concept of "read only" software.
|
---|
216 | **
|
---|
217 | ** Although the intent is to replicate the SOFA API (other than
|
---|
218 | ** replacement of prefix names) and results (with the exception of
|
---|
219 | ** bugs; any that are discovered will be fixed), SOFA is not
|
---|
220 | ** responsible for any errors found in this version of the library.
|
---|
221 | **
|
---|
222 | ** If you wish to acknowledge the SOFA heritage, please acknowledge
|
---|
223 | ** that you are using a library derived from SOFA, rather than SOFA
|
---|
224 | ** itself.
|
---|
225 | **
|
---|
226 | **
|
---|
227 | ** TERMS AND CONDITIONS
|
---|
228 | **
|
---|
229 | ** Redistribution and use in source and binary forms, with or without
|
---|
230 | ** modification, are permitted provided that the following conditions
|
---|
231 | ** are met:
|
---|
232 | **
|
---|
233 | ** 1 Redistributions of source code must retain the above copyright
|
---|
234 | ** notice, this list of conditions and the following disclaimer.
|
---|
235 | **
|
---|
236 | ** 2 Redistributions in binary form must reproduce the above copyright
|
---|
237 | ** notice, this list of conditions and the following disclaimer in
|
---|
238 | ** the documentation and/or other materials provided with the
|
---|
239 | ** distribution.
|
---|
240 | **
|
---|
241 | ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
|
---|
242 | ** the International Astronomical Union nor the names of its
|
---|
243 | ** contributors may be used to endorse or promote products derived
|
---|
244 | ** from this software without specific prior written permission.
|
---|
245 | **
|
---|
246 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
---|
247 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
248 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
---|
249 | ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
---|
250 | ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
251 | ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
---|
252 | ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
253 | ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
---|
254 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
255 | ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
---|
256 | ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
---|
257 | ** POSSIBILITY OF SUCH DAMAGE.
|
---|
258 | **
|
---|
259 | */
|
---|