| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/* |
|
2
|
|
|
|
|
|
|
*+ |
|
3
|
|
|
|
|
|
|
* Name: |
|
4
|
|
|
|
|
|
|
* palDe2h |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
* Purpose: |
|
7
|
|
|
|
|
|
|
* Equatorial to horizon coordinates: HA,Dec to Az,E |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
* Language: |
|
10
|
|
|
|
|
|
|
* Starlink ANSI C |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
* Type of Module: |
|
13
|
|
|
|
|
|
|
* Library routine |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
* Invocation: |
|
16
|
|
|
|
|
|
|
* palDe2h( double ha, double dec, double phi, double * az, double * el ); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
* Arguments: |
|
19
|
|
|
|
|
|
|
* ha = double * (Given) |
|
20
|
|
|
|
|
|
|
* Hour angle (radians) |
|
21
|
|
|
|
|
|
|
* dec = double * (Given) |
|
22
|
|
|
|
|
|
|
* Declination (radians) |
|
23
|
|
|
|
|
|
|
* phi = double (Given) |
|
24
|
|
|
|
|
|
|
* Observatory latitude (radians) |
|
25
|
|
|
|
|
|
|
* az = double * (Returned) |
|
26
|
|
|
|
|
|
|
* Azimuth (radians) |
|
27
|
|
|
|
|
|
|
* el = double * (Returned) |
|
28
|
|
|
|
|
|
|
* Elevation (radians) |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
* Description: |
|
31
|
|
|
|
|
|
|
* Convert equatorial to horizon coordinates. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
* Authors: |
|
34
|
|
|
|
|
|
|
* PTW: Pat Wallace (STFC) |
|
35
|
|
|
|
|
|
|
* TIMJ: Tim Jenness (JAC, Hawaii) |
|
36
|
|
|
|
|
|
|
* {enter_new_authors_here} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
* Notes: |
|
39
|
|
|
|
|
|
|
* - All the arguments are angles in radians. |
|
40
|
|
|
|
|
|
|
* - Azimuth is returned in the range 0-2pi; north is zero, |
|
41
|
|
|
|
|
|
|
* and east is +pi/2. Elevation is returned in the range |
|
42
|
|
|
|
|
|
|
* +/-pi/2. |
|
43
|
|
|
|
|
|
|
* - The latitude must be geodetic. In critical applications, |
|
44
|
|
|
|
|
|
|
* corrections for polar motion should be applied. |
|
45
|
|
|
|
|
|
|
* - In some applications it will be important to specify the |
|
46
|
|
|
|
|
|
|
* correct type of hour angle and declination in order to |
|
47
|
|
|
|
|
|
|
* produce the required type of azimuth and elevation. In |
|
48
|
|
|
|
|
|
|
* particular, it may be important to distinguish between |
|
49
|
|
|
|
|
|
|
* elevation as affected by refraction, which would |
|
50
|
|
|
|
|
|
|
* require the "observed" HA,Dec, and the elevation |
|
51
|
|
|
|
|
|
|
* in vacuo, which would require the "topocentric" HA,Dec. |
|
52
|
|
|
|
|
|
|
* If the effects of diurnal aberration can be neglected, the |
|
53
|
|
|
|
|
|
|
* "apparent" HA,Dec may be used instead of the topocentric |
|
54
|
|
|
|
|
|
|
* HA,Dec. |
|
55
|
|
|
|
|
|
|
* - No range checking of arguments is carried out. |
|
56
|
|
|
|
|
|
|
* - In applications which involve many such calculations, rather |
|
57
|
|
|
|
|
|
|
* than calling the present routine it will be more efficient to |
|
58
|
|
|
|
|
|
|
* use inline code, having previously computed fixed terms such |
|
59
|
|
|
|
|
|
|
* as sine and cosine of latitude, and (for tracking a star) |
|
60
|
|
|
|
|
|
|
* sine and cosine of declination. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
* History: |
|
63
|
|
|
|
|
|
|
* 2012-02-08 (TIMJ): |
|
64
|
|
|
|
|
|
|
* Initial version with documentation taken from Fortran SLA |
|
65
|
|
|
|
|
|
|
* Adapted with permission from the Fortran SLALIB library. |
|
66
|
|
|
|
|
|
|
* {enter_further_changes_here} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
* Copyright: |
|
69
|
|
|
|
|
|
|
* Copyright (C) 1995 Rutherford Appleton Laboratory |
|
70
|
|
|
|
|
|
|
* Copyright (C) 2012 Science and Technology Facilities Council. |
|
71
|
|
|
|
|
|
|
* All Rights Reserved. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
* Licence: |
|
74
|
|
|
|
|
|
|
* This program is free software: you can redistribute it and/or |
|
75
|
|
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public |
|
76
|
|
|
|
|
|
|
* License as published by the Free Software Foundation, either |
|
77
|
|
|
|
|
|
|
* version 3 of the License, or (at your option) any later |
|
78
|
|
|
|
|
|
|
* version. |
|
79
|
|
|
|
|
|
|
* |
|
80
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful, |
|
81
|
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
82
|
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
83
|
|
|
|
|
|
|
* GNU Lesser General Public License for more details. |
|
84
|
|
|
|
|
|
|
* |
|
85
|
|
|
|
|
|
|
* You should have received a copy of the GNU Lesser General |
|
86
|
|
|
|
|
|
|
* License along with this program. If not, see |
|
87
|
|
|
|
|
|
|
* . |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
* Bugs: |
|
90
|
|
|
|
|
|
|
* {note_any_bugs_here} |
|
91
|
|
|
|
|
|
|
*- |
|
92
|
|
|
|
|
|
|
*/ |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
#include "pal.h" |
|
95
|
|
|
|
|
|
|
#include "palmac.h" |
|
96
|
|
|
|
|
|
|
#include |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
void |
|
99
|
1
|
|
|
|
|
|
palDe2h ( double ha, double dec, double phi, double *az, double *el) { |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
double sh; |
|
102
|
|
|
|
|
|
|
double ch; |
|
103
|
|
|
|
|
|
|
double sd; |
|
104
|
|
|
|
|
|
|
double cd; |
|
105
|
|
|
|
|
|
|
double sp; |
|
106
|
|
|
|
|
|
|
double cp; |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
double a; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
double x; |
|
111
|
|
|
|
|
|
|
double y; |
|
112
|
|
|
|
|
|
|
double z; |
|
113
|
|
|
|
|
|
|
double r; |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
/* Useful trig functions */ |
|
116
|
1
|
|
|
|
|
|
sh = sin(ha); |
|
117
|
1
|
|
|
|
|
|
ch = cos(ha); |
|
118
|
1
|
|
|
|
|
|
sd = sin(dec); |
|
119
|
1
|
|
|
|
|
|
cd = cos(dec); |
|
120
|
1
|
|
|
|
|
|
sp = sin(phi); |
|
121
|
1
|
|
|
|
|
|
cp = cos(phi); |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
/* Az,El as x,y,z */ |
|
124
|
1
|
|
|
|
|
|
x = -ch * cd * sp + sd * cp; |
|
125
|
1
|
|
|
|
|
|
y = -sh * cd; |
|
126
|
1
|
|
|
|
|
|
z = ch * cd * cp + sd * sp; |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
/* To spherical */ |
|
129
|
1
|
|
|
|
|
|
r = sqrt(x * x + y * y); |
|
130
|
1
|
50
|
|
|
|
|
if (r == 0.) { |
|
131
|
|
|
|
|
|
|
a = 0.; |
|
132
|
|
|
|
|
|
|
} else { |
|
133
|
1
|
|
|
|
|
|
a = atan2(y, x); |
|
134
|
|
|
|
|
|
|
} |
|
135
|
1
|
50
|
|
|
|
|
if (a < 0.) { |
|
136
|
1
|
|
|
|
|
|
a += PAL__D2PI; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
1
|
|
|
|
|
|
*az = a; |
|
139
|
1
|
|
|
|
|
|
*el = atan2(z, r); |
|
140
|
|
|
|
|
|
|
|
|
141
|
1
|
|
|
|
|
|
return; |
|
142
|
|
|
|
|
|
|
} |