1 | /*
|
---|
2 | *+
|
---|
3 | * Name:
|
---|
4 | * palPreces
|
---|
5 |
|
---|
6 | * Purpose:
|
---|
7 | * Precession - either FK4 or FK5 as required.
|
---|
8 |
|
---|
9 | * Language:
|
---|
10 | * Starlink ANSI C
|
---|
11 |
|
---|
12 | * Type of Module:
|
---|
13 | * Library routine
|
---|
14 |
|
---|
15 | * Invocation:
|
---|
16 | * void palPreces ( const char sys[3], double ep0, double ep1,
|
---|
17 | * double *ra, double *dc );
|
---|
18 |
|
---|
19 | * Arguments:
|
---|
20 | * sys = const char [3] (Given)
|
---|
21 | * Precession to be applied: FK4 or FK5. Case insensitive.
|
---|
22 | * ep0 = double (Given)
|
---|
23 | * Starting epoch.
|
---|
24 | * ep1 = double (Given)
|
---|
25 | * Ending epoch
|
---|
26 | * ra = double * (Given & Returned)
|
---|
27 | * On input the RA mean equator & equinox at epoch ep0. On exit
|
---|
28 | * the RA mean equator & equinox of epoch ep1.
|
---|
29 | * dec = double * (Given & Returned)
|
---|
30 | * On input the dec mean equator & equinox at epoch ep0. On exit
|
---|
31 | * the dec mean equator & equinox of epoch ep1.
|
---|
32 |
|
---|
33 | * Description:
|
---|
34 | * Precess coordinates using the appropriate system and epochs.
|
---|
35 |
|
---|
36 | * Authors:
|
---|
37 | * PTW: Patrick T. Wallace
|
---|
38 | * TIMJ: Tim Jenness (JAC, Hawaii)
|
---|
39 | * {enter_new_authors_here}
|
---|
40 |
|
---|
41 | * Notes:
|
---|
42 | * - Uses palPrec for FK5 data and palPrebn for FK4 data.
|
---|
43 | * - The epochs are Besselian if SYSTEM='FK4' and Julian if 'FK5'.
|
---|
44 | * For example, to precess coordinates in the old system from
|
---|
45 | * equinox 1900.0 to 1950.0 the call would be:
|
---|
46 | * palPreces( "FK4", 1900.0, 1950.0, &ra, &dc );
|
---|
47 | * - This routine will NOT correctly convert between the old and
|
---|
48 | * the new systems - for example conversion from B1950 to J2000.
|
---|
49 | * For these purposes see palFk425, palFk524, palFk45z and
|
---|
50 | * palFk54z.
|
---|
51 | * - If an invalid SYSTEM is supplied, values of -99D0,-99D0 will
|
---|
52 | * be returned for both RA and DC.
|
---|
53 |
|
---|
54 | * History:
|
---|
55 | * 2012-03-02 (TIMJ):
|
---|
56 | * Initial version
|
---|
57 | * Adapted with permission from the Fortran SLALIB library.
|
---|
58 | * {enter_further_changes_here}
|
---|
59 |
|
---|
60 | * Copyright:
|
---|
61 | * Copyright (C) 1995 Rutherford Appleton Laboratory
|
---|
62 | * Copyright (C) 2012 Science and Technology Facilities Council.
|
---|
63 | * All Rights Reserved.
|
---|
64 |
|
---|
65 | * Licence:
|
---|
66 | * This program is free software; you can redistribute it and/or
|
---|
67 | * modify it under the terms of the GNU General Public License as
|
---|
68 | * published by the Free Software Foundation; either version 3 of
|
---|
69 | * the License, or (at your option) any later version.
|
---|
70 | *
|
---|
71 | * This program is distributed in the hope that it will be
|
---|
72 | * useful, but WITHOUT ANY WARRANTY; without even the implied
|
---|
73 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
---|
74 | * PURPOSE. See the GNU General Public License for more details.
|
---|
75 | *
|
---|
76 | * You should have received a copy of the GNU General Public License
|
---|
77 | * along with this program; if not, write to the Free Software
|
---|
78 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
---|
79 | * MA 02110-1301, USA.
|
---|
80 |
|
---|
81 | * Bugs:
|
---|
82 | * {note_any_bugs_here}
|
---|
83 | *-
|
---|
84 | */
|
---|
85 |
|
---|
86 | #include "pal.h"
|
---|
87 | #include "pal1sofa.h"
|
---|
88 |
|
---|
89 | #include <string.h>
|
---|
90 |
|
---|
91 | void palPreces ( const char sys[3], double ep0, double ep1,
|
---|
92 | double *ra, double *dc ) {
|
---|
93 |
|
---|
94 | double pm[3][3];
|
---|
95 | double v1[3];
|
---|
96 | double v2[3];
|
---|
97 |
|
---|
98 | /* Generate appropriate precession matrix */
|
---|
99 | if ( strncasecmp( "FK4", sys, 3 ) == 0 ) {
|
---|
100 | palPrebn( ep0, ep1, pm );
|
---|
101 | } else if (strncasecmp( "FK5", sys, 3 ) == 0 ) {
|
---|
102 | palPrec( ep0, ep1, pm );
|
---|
103 | } else {
|
---|
104 | *ra = -99.0;
|
---|
105 | *dc = -99.0;
|
---|
106 | return;
|
---|
107 | }
|
---|
108 |
|
---|
109 | /* Convert RA,Dec to x,y,z */
|
---|
110 | eraS2c( *ra, *dc, v1 );
|
---|
111 |
|
---|
112 | /* Precess */
|
---|
113 | eraRxp( pm, v1, v2 );
|
---|
114 |
|
---|
115 | /* Back to RA,Dec */
|
---|
116 | eraC2s( v2, ra, dc );
|
---|
117 | *ra = eraAnp( *ra );
|
---|
118 | }
|
---|