1 | #include "Slalib.h"
|
---|
2 |
|
---|
3 | #include <time.h>
|
---|
4 | #include <iostream.h> // cout
|
---|
5 |
|
---|
6 | #include "coord.h"
|
---|
7 |
|
---|
8 | #include "slalib.h"
|
---|
9 |
|
---|
10 | ClassImp(Slalib);
|
---|
11 |
|
---|
12 | Slalib::Slalib(MObservatory::LocationName_t key) : MObservatory(key)
|
---|
13 | {
|
---|
14 | }
|
---|
15 |
|
---|
16 | Double_t Slalib::Trunc(Double_t val)
|
---|
17 | {
|
---|
18 | /* dint(A) - truncate to nearest whole number towards zero (double) */
|
---|
19 | return val<0 ? TMath::Ceil(val) : TMath::Floor(val);
|
---|
20 | }
|
---|
21 |
|
---|
22 | Double_t Slalib::Round(Double_t val)
|
---|
23 | {
|
---|
24 | /* dnint(A) - round to nearest whole number (double) */
|
---|
25 | return val<0 ? TMath::Ceil(val-0.5) : TMath::Floor(val+0.5);
|
---|
26 | }
|
---|
27 |
|
---|
28 | void Slalib::SetMjd(double mjd)
|
---|
29 | {
|
---|
30 | fTime.SetMjd(mjd);
|
---|
31 | fAlpha = slaGmst(mjd) + GetElong();
|
---|
32 | }
|
---|
33 |
|
---|
34 | ZdAz Slalib::XYZ2ZdAz(double coord[3]) const
|
---|
35 | {
|
---|
36 | //
|
---|
37 | // -- xyz to spherical coordinates --
|
---|
38 | //
|
---|
39 | double ra, dec;
|
---|
40 | slaDcc2s(coord, &ra, &dec);
|
---|
41 |
|
---|
42 | //
|
---|
43 | // radec[rad] -> hadec[rad]
|
---|
44 | //
|
---|
45 | const double ha = fAlpha-ra;
|
---|
46 |
|
---|
47 | //
|
---|
48 | // hadec[rad] -> altaz[rad]
|
---|
49 | //
|
---|
50 | double alt, az;
|
---|
51 | slaDe2h(ha, dec, GetPhi(), &az, &alt);
|
---|
52 |
|
---|
53 | return ZdAz(kPiDiv2-alt, az);
|
---|
54 | }
|
---|
55 | /*
|
---|
56 | Double_t Slalib::Hms2Sec(Int_t deg, UInt_t min, Double_t sec, Char_t sgn)
|
---|
57 | {
|
---|
58 | const Double_t rc = TMath::Sign((60.0 * (60.0 * (Double_t)TMath::Abs(deg) + (Double_t)min) + sec), (Double_t)deg);
|
---|
59 | return sgn=='-' ? -rc : rc;
|
---|
60 | }
|
---|
61 |
|
---|
62 | Double_t Slalib::Dms2Rad(Int_t deg, UInt_t min, Double_t sec, Char_t sgn)
|
---|
63 | {
|
---|
64 | // pi/(180*3600): arcseconds to radians
|
---|
65 | #define DAS2R 4.8481368110953599358991410235794797595635330237270e-6
|
---|
66 | return Hms2Sec(deg, min, sec, sgn)*DAS2R;
|
---|
67 | }
|
---|
68 |
|
---|
69 | Double_t Slalib::Hms2Rad(Int_t hor, UInt_t min, Double_t sec, Char_t sgn)
|
---|
70 | {
|
---|
71 | // pi/(12*3600): seconds of time to radians
|
---|
72 | #define DS2R 7.2722052166430399038487115353692196393452995355905e-5
|
---|
73 | return Hms2Sec(hor, min, sec, sgn)*DS2R;
|
---|
74 | }
|
---|
75 |
|
---|
76 | Double_t Slalib::Dms2Deg(Int_t deg, UInt_t min, Double_t sec, Char_t sgn)
|
---|
77 | {
|
---|
78 | return Hms2Sec(deg, min, sec, sgn)/3600.;
|
---|
79 | }
|
---|
80 |
|
---|
81 | Double_t Slalib::Hms2Deg(Int_t hor, UInt_t min, Double_t sec, Char_t sgn)
|
---|
82 | {
|
---|
83 | return Hms2Sec(hor, min, sec, sgn)/240.;
|
---|
84 | }
|
---|
85 |
|
---|
86 | Double_t Slalib::Dms2Hor(Int_t deg, UInt_t min, Double_t sec, Char_t sgn)
|
---|
87 | {
|
---|
88 | return Hms2Sec(deg, min, sec, sgn)/15.;
|
---|
89 | }
|
---|
90 |
|
---|
91 | Double_t Slalib::Hms2Hor(Int_t hor, UInt_t min, Double_t sec, Char_t sgn)
|
---|
92 | {
|
---|
93 | return Hms2Sec(hor, min, sec, sgn)/3600.;
|
---|
94 | }
|
---|
95 |
|
---|
96 | void Slalib::Day2Hms(Double_t day, Char_t &sgn, UShort_t &hor, UShort_t &min, UShort_t &sec)
|
---|
97 | {
|
---|
98 | // Handle sign
|
---|
99 | sgn = day<0?'-':'+';
|
---|
100 |
|
---|
101 | // Round interval and express in smallest units required
|
---|
102 | Double_t a = Round(86400. * TMath::Abs(day)); // Days to seconds
|
---|
103 |
|
---|
104 | // Separate into fields
|
---|
105 | const Double_t ah = Trunc(a/3600.);
|
---|
106 | a -= ah * 3600.;
|
---|
107 | const Double_t am = Trunc(a/60.);
|
---|
108 | a -= am * 60.;
|
---|
109 | const Double_t as = Trunc(a);
|
---|
110 |
|
---|
111 | // Return results
|
---|
112 | hor = (UShort_t)ah;
|
---|
113 | min = (UShort_t)am;
|
---|
114 | sec = (UShort_t)as;
|
---|
115 | }
|
---|
116 |
|
---|
117 | void Slalib::Rad2Hms(Double_t rad, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec)
|
---|
118 | {
|
---|
119 | Day2Hms(rad/(TMath::Pi()*2), sgn, deg, min, sec);
|
---|
120 | }
|
---|
121 |
|
---|
122 | void Slalib::Rad2Dms(Double_t rad, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec)
|
---|
123 | {
|
---|
124 | Rad2Hms(rad*15, sgn, deg, min, sec);
|
---|
125 | }
|
---|
126 |
|
---|
127 | void Slalib::Deg2Dms(Double_t d, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec)
|
---|
128 | {
|
---|
129 | Day2Hms(d/24, sgn, deg, min, sec);
|
---|
130 | }
|
---|
131 |
|
---|
132 | void Slalib::Deg2Hms(Double_t d, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec)
|
---|
133 | {
|
---|
134 | Rad2Hms(d/360, sgn, deg, min, sec);
|
---|
135 | }
|
---|
136 |
|
---|
137 | void Slalib::Hor2Dms(Double_t h, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec)
|
---|
138 | {
|
---|
139 | Day2Hms(h*15/24, sgn, deg, min, sec);
|
---|
140 | }
|
---|
141 |
|
---|
142 | void Slalib::Hor2Hms(Double_t h, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec)
|
---|
143 | {
|
---|
144 | Day2Hms(h/24, sgn, deg, min, sec);
|
---|
145 | }
|
---|
146 |
|
---|
147 | void Slalib::Day2Hm(Double_t day, Char_t &sgn, UShort_t &hor, Double_t &min)
|
---|
148 | {
|
---|
149 | // Handle sign
|
---|
150 | sgn = day<0?'-':'+';
|
---|
151 |
|
---|
152 | // Round interval and express in smallest units required
|
---|
153 | Double_t a = Round(86400. * TMath::Abs(day)); // Days to seconds
|
---|
154 |
|
---|
155 | // Separate into fields
|
---|
156 | const Double_t ah = Trunc(a/3600.);
|
---|
157 | a -= ah * 3600.;
|
---|
158 |
|
---|
159 | // Return results
|
---|
160 | hor = (UShort_t)ah;
|
---|
161 | min = a/60.;
|
---|
162 | }
|
---|
163 |
|
---|
164 | void Slalib::Rad2Hm(Double_t rad, Char_t &sgn, UShort_t °, Double_t &min)
|
---|
165 | {
|
---|
166 | Day2Hm(rad/(TMath::Pi()*2), sgn, deg, min);
|
---|
167 | }
|
---|
168 |
|
---|
169 | void Slalib::Rad2Dm(Double_t rad, Char_t &sgn, UShort_t °, Double_t &min)
|
---|
170 | {
|
---|
171 | Rad2Hm(rad*15, sgn, deg, min);
|
---|
172 | }
|
---|
173 |
|
---|
174 | void Slalib::Deg2Dm(Double_t d, Char_t &sgn, UShort_t °, Double_t &min)
|
---|
175 | {
|
---|
176 | Day2Hm(d/24, sgn, deg, min);
|
---|
177 | }
|
---|
178 |
|
---|
179 | void Slalib::Deg2Hm(Double_t d, Char_t &sgn, UShort_t °, Double_t &min)
|
---|
180 | {
|
---|
181 | Rad2Hm(d/360, sgn, deg, min);
|
---|
182 | }
|
---|
183 |
|
---|
184 | void Slalib::Hor2Dm(Double_t h, Char_t &sgn, UShort_t °, Double_t &min)
|
---|
185 | {
|
---|
186 | Day2Hm(h*15/24, sgn, deg, min);
|
---|
187 | }
|
---|
188 |
|
---|
189 | void Slalib::Hor2Hm(Double_t h, Char_t &sgn, UShort_t °, Double_t &min)
|
---|
190 | {
|
---|
191 | Day2Hm(h/24, sgn, deg, min);
|
---|
192 | }
|
---|
193 |
|
---|
194 | */
|
---|