source: Sophya/trunk/SophyaExt/XephemAstroLib/aberration.c@ 3359

Last change on this file since 3359 was 3111, checked in by cmv, 19 years ago

mise en conformite xephem 3.7.2 cmv 22/11/2006

File size: 4.0 KB
RevLine 
[1457]1/* aberration, Jean Meeus, "Astronomical Algorithms", Willman-Bell, 1995;
2 * based on secular unperturbed Kepler orbit
3 *
[2551]4 * the corrections should be applied to ra/dec and lam/beta at the
[1457]5 * epoch of date.
6 */
7
8#include <stdio.h>
9#include <math.h>
10#include <stdlib.h>
11
12#include "astro.h"
13
14#define ABERR_CONST (20.49552/3600./180.*PI) /* aberr const in rad */
15#define AB_ECL_EOD 0
16#define AB_EQ_EOD 1
17
[2551]18static void ab_aux (double mj, double *x, double *y, double lsn, int mode);
[1457]19
20/* apply aberration correction to ecliptical coordinates *lam and *bet
[2551]21 * (in radians) for a given time m and handily supplied longitude of sun,
[1457]22 * lsn (in radians)
23 */
24void
[2551]25ab_ecl (double mj, double lsn, double *lam, double *bet)
[1457]26{
[2551]27 ab_aux(mj, lam, bet, lsn, AB_ECL_EOD);
[1457]28}
29
30/* apply aberration correction to equatoreal coordinates *ra and *dec
[2551]31 * (in radians) for a given time m and handily supplied longitude of sun,
[1457]32 * lsn (in radians)
33 */
34void
[2551]35ab_eq (double mj, double lsn, double *ra, double *dec)
[1457]36{
[3111]37#if defined(USE_MEEUS_AB_EQ)
38
39 /* this claims to account for earth orbit excentricity and is also
40 * smooth clear to dec=90 but it does not work well backwards with
41 * ap_as()
42 */
[2551]43 ab_aux(mj, ra, dec, lsn, AB_EQ_EOD);
[3111]44
45#else /* use Montenbruck */
46
47 /* this agrees with Meeus to within 0.2 arcsec until dec gets larger
48 * than about 89.9, then grows to 1as at 89.97. but it works very
49 * smoothly with ap_as
50 */
51 double x, y, z; /* equatorial rectangular coords */
52 double vx, vy, vz; /* aberration velocity in rectangular coords */
53 double L; /* helio long of earth */
54 double cL;
55 double r;
56
57
58 sphcart (*ra, *dec, 1.0, &x, &y, &z);
59
60 L = 2*PI*(0.27908 + 100.00214*(mj-J2000)/36525.0);
61 cL = cos(L);
62 vx = -0.994e-4*sin(L);
63 vy = 0.912e-4*cL;
64 vz = 0.395e-4*cL;
65 x += vx;
66 y += vy;
67 z += vz;
68
69 cartsph (x, y, z, ra, dec, &r);
70
71#endif
[1457]72}
73
74/* because the e-terms are secular, keep the real transformation for both
75 * coordinate systems in here with the secular variables cached.
76 * mode == AB_ECL_EOD: x = lam, y = bet (ecliptical)
77 * mode == AB_EQ_EOD: x = ra, y = dec (equatoreal)
78 */
79static void
[2551]80ab_aux (double mj, double *x, double *y, double lsn, int mode)
[1457]81{
[2551]82 static double lastmj = -10000;
[1457]83 static double eexc; /* earth orbit excentricity */
84 static double leperi; /* ... and longitude of perihelion */
85 static char dirty = 1; /* flag for cached trig terms */
86
[2551]87 if (mj != lastmj) {
[1457]88 double T; /* centuries since J2000 */
89
[2551]90 T = (mj - J2000)/36525.;
[1457]91 eexc = 0.016708617 - (42.037e-6 + 0.1236e-6 * T) * T;
92 leperi = degrad(102.93735 + (0.71953 + 0.00046 * T) * T);
[2551]93 lastmj = mj;
[1457]94 dirty = 1;
95 }
96
97 switch (mode) {
98 case AB_ECL_EOD: /* ecliptical coords */
99 {
100 double *lam = x, *bet = y;
101 double dlsun, dlperi;
102
103 dlsun = lsn - *lam;
104 dlperi = leperi - *lam;
105
106 /* valid only for *bet != +-PI/2 */
107 *lam -= ABERR_CONST/cos(*bet) * (cos(dlsun) -
108 eexc*cos(dlperi));
109 *bet -= ABERR_CONST*sin(*bet) * (sin(dlsun) -
110 eexc*sin(dlperi));
111 }
112 break;
113
114 case AB_EQ_EOD: /* equatoreal coords */
115 {
116 double *ra = x, *dec = y;
117 double sr, cr, sd, cd, sls, cls;/* trig values coords */
118 static double cp, sp, ce, se; /* .. and perihel/eclipic */
119 double dra, ddec; /* changes in ra and dec */
120
121 if (dirty) {
122 double eps;
123
124 cp = cos(leperi);
125 sp = sin(leperi);
[2551]126 obliquity(mj, &eps);
[1457]127 se = sin(eps);
128 ce = cos(eps);
129 dirty = 0;
130 }
131
132 sr = sin(*ra);
133 cr = cos(*ra);
134 sd = sin(*dec);
135 cd = cos(*dec);
136 sls = sin(lsn);
137 cls = cos(lsn);
138
139 dra = ABERR_CONST/cd * ( -(cr * cls * ce + sr * sls) +
140 eexc * (cr * cp * ce + sr * sp));
141
142 ddec = se/ce * cd - sr * sd; /* tmp use */
143 ddec = ABERR_CONST * ( -(cls * ce * ddec + cr * sd * sls) +
144 eexc * (cp * ce * ddec + cr * sd * sp) );
145
146 *ra += dra;
147 *dec += ddec;
[3111]148 radecrange (ra, dec);
[1457]149 }
150 break;
151
152 default:
153 printf ("ab_aux: bad mode: %d\n", mode);
[2551]154 abort();
[1457]155 break;
156
157 } /* switch (mode) */
158}
159
160/* For RCS Only -- Do Not Edit */
[3111]161static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: aberration.c,v $ $Date: 2006-11-22 13:53:27 $ $Revision: 1.6 $ $Name: not supported by cvs2svn $"};
Note: See TracBrowser for help on using the repository browser.