source: trunk/FACT++/pal/palAmpqk.c@ 19779

Last change on this file since 19779 was 18712, checked in by tbretz, 8 years ago
Updated to PAL 0.9.7 (adds mainly light deflection to abberation which was previously missing)
File size: 4.6 KB
Line 
1/*
2*+
3* Name:
4* palAmpqk
5
6* Purpose:
7* Convert star RA,Dec from geocentric apparent to mean place.
8
9* Language:
10* Starlink ANSI C
11
12* Type of Module:
13* Library routine
14
15* Invocation:
16* void palAmpqk ( double ra, double da, double amprms[21],
17* double *rm, double *dm )
18
19* Arguments:
20* ra = double (Given)
21* Apparent RA (radians).
22* da = double (Given)
23* Apparent Dec (radians).
24* amprms = double[21] (Given)
25* Star-independent mean-to-apparent parameters (see palMappa):
26* (0) time interval for proper motion (Julian years)
27* (1-3) barycentric position of the Earth (AU)
28* (4-6) heliocentric direction of the Earth (unit vector)
29* (7) (grav rad Sun)*2/(Sun-Earth distance)
30* (8-10) abv: barycentric Earth velocity in units of c
31* (11) sqrt(1-v*v) where v=modulus(abv)
32* (12-20) precession/nutation (3,3) matrix
33* rm = double (Returned)
34* Mean RA (radians).
35* dm = double (Returned)
36* Mean Dec (radians).
37
38* Description:
39* Convert star RA,Dec from geocentric apparent to mean place. The "mean"
40* coordinate system is in fact close to ICRS. Use of this function
41* is appropriate when efficiency is important and where many star
42* positions are all to be transformed for one epoch and equinox. The
43* star-independent parameters can be obtained by calling the palMappa
44* function.
45
46* Note:
47* Iterative techniques are used for the aberration and
48* light deflection corrections so that the routines
49* palAmp (or palAmpqk) and palMap (or palMapqk) are
50* accurate inverses; even at the edge of the Sun's disc
51* the discrepancy is only about 1 nanoarcsecond.
52
53* Authors:
54* PTW: Pat Wallace (STFC)
55* TIMJ: Tim Jenness
56* {enter_new_authors_here}
57
58* History:
59* 2012-02-13 (PTW):
60* Initial version.
61* Adapted with permission from the Fortran SLALIB library.
62* 2016-12-19 (TIMJ):
63* Add in light deflection (was missed in the initial port).
64* {enter_further_changes_here}
65
66* Copyright:
67* Copyright (C) 2000 Rutherford Appleton Laboratory
68* Copyright (C) 2012 Science and Technology Facilities Council.
69* Copyright (C) 2016 Tim Jenness
70* All Rights Reserved.
71
72* Licence:
73* This program is free software: you can redistribute it and/or
74* modify it under the terms of the GNU Lesser General Public
75* License as published by the Free Software Foundation, either
76* version 3 of the License, or (at your option) any later
77* version.
78*
79* This program is distributed in the hope that it will be useful,
80* but WITHOUT ANY WARRANTY; without even the implied warranty of
81* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82* GNU Lesser General Public License for more details.
83*
84* You should have received a copy of the GNU Lesser General
85* License along with this program. If not, see
86* <http://www.gnu.org/licenses/>.
87
88* Bugs:
89* {note_any_bugs_here}
90*-
91*/
92
93#include "pal.h"
94#include "pal1sofa.h"
95
96void palAmpqk ( double ra, double da, double amprms[21], double *rm,
97 double *dm ){
98
99/* Local Variables: */
100 double ab1; /* sqrt(1-v*v) where v=modulus of Earth vel */
101 double abv[3]; /* Earth velocity wrt SSB (c, FK5) */
102 double p1[3], p2[3], p3[3]; /* work vectors */
103 double ab1p1, p1dv, p1dvp1, w;
104 double gr2e, pde, pdep1, ehn[3], p[3];
105 int i, j;
106
107/* Unpack some of the parameters */
108 gr2e = amprms[7];
109 ab1 = amprms[11];
110 for( i = 0; i < 3; i++ ) {
111 ehn[i] = amprms[i + 4];
112 abv[i] = amprms[i + 8];
113 }
114
115/* Apparent RA,Dec to Cartesian */
116 eraS2c( ra, da, p3 );
117
118/* Precession and nutation */
119 eraTrxp( (double(*)[3]) &amprms[12], p3, p2 );
120
121/* Aberration */
122 ab1p1 = ab1 + 1.0;
123 for( i = 0; i < 3; i++ ) {
124 p1[i] = p2[i];
125 }
126 for( j = 0; j < 2; j++ ) {
127 p1dv = eraPdp( p1, abv );
128 p1dvp1 = 1.0 + p1dv;
129 w = 1.0 + p1dv / ab1p1;
130 for( i = 0; i < 3; i++ ) {
131 p1[i] = ( p1dvp1 * p2[i] - w * abv[i] ) / ab1;
132 }
133 eraPn( p1, &w, p3 );
134 for( i = 0; i < 3; i++ ) {
135 p1[i] = p3[i];
136 }
137 }
138
139/* Light deflection */
140 for( i = 0; i < 3; i++ ) {
141 p[i] = p1[i];
142 }
143 for( j = 0; j < 5; j++ ) {
144 pde = eraPdp( p, ehn );
145 pdep1 = 1.0 + pde;
146 w = pdep1 - gr2e*pde;
147 for( i = 0; i < 3; i++ ) {
148 p[i] = (pdep1*p1[i] - gr2e*ehn[i])/w;
149 }
150 eraPn( p, &w, p2 );
151 for( i = 0; i < 3; i++ ) {
152 p[i] = p2[i];
153 }
154 }
155
156/* Mean RA,Dec */
157 eraC2s( p, rm, dm );
158 *rm = eraAnp( *rm );
159}
Note: See TracBrowser for help on using the repository browser.