1 | #include "templocator.h"
|
---|
2 | #include <math.h>
|
---|
3 | extern "C" {
|
---|
4 | #include "aa_hadec.h"
|
---|
5 | }
|
---|
6 |
|
---|
7 | #include "fitsio.h"
|
---|
8 | #include "plgalcross.h"
|
---|
9 |
|
---|
10 | #ifndef M_PI
|
---|
11 | #define M_PI 3.14159265358979323846
|
---|
12 | #endif
|
---|
13 |
|
---|
14 | TempLocator tempLocator;
|
---|
15 |
|
---|
16 | TempLocator::TempLocator()
|
---|
17 | {
|
---|
18 | lon = lat = ts = 0;
|
---|
19 | ra = dec = -99999;
|
---|
20 | xSampleNum = -99999;
|
---|
21 | fitsfile* fptr;
|
---|
22 | int status=0;
|
---|
23 | fits_open_file(&fptr, "samplenum_gal_cross.fits", READONLY, &status);
|
---|
24 | int simple, bitpix, naxis;
|
---|
25 | long naxes;
|
---|
26 | long pcount, gcount;
|
---|
27 | int extend;
|
---|
28 | fits_read_imghdr(fptr, 1, &simple, &bitpix, &naxis, &naxes, &pcount, &gcount, &extend, &status);
|
---|
29 | nGalCross = naxes;
|
---|
30 | crossings = new long[nGalCross];
|
---|
31 | int anynul;
|
---|
32 | fits_read_img_lng(fptr, 0, 1, nGalCross, 0, crossings, &anynul, &status);
|
---|
33 | fits_close_file(fptr, &status);
|
---|
34 | fits_report_error(stderr, status); /* print out any error messages */
|
---|
35 | }
|
---|
36 |
|
---|
37 |
|
---|
38 | void TempLocator::setEarthPos(double lon, double lat) {
|
---|
39 | if (this->lon == lon && this->lat == lat) return;
|
---|
40 | this->lon = lon;
|
---|
41 | this->lat = lat;
|
---|
42 | ra = dec = -99999; xSampleNum = -99999;
|
---|
43 | }
|
---|
44 |
|
---|
45 | void TempLocator::setTSid(double ts) {
|
---|
46 | if (this->ts == ts) return;
|
---|
47 | this->ts = ts;
|
---|
48 | ra = dec = -99999; xSampleNum = -99999;
|
---|
49 | }
|
---|
50 |
|
---|
51 | void TempLocator::ComputeZenith() {
|
---|
52 | double ha;
|
---|
53 | aa_hadec (lat * M_PI/180, .5 * M_PI, 0, &ha, &dec);
|
---|
54 | ra = - (ha * 180. / M_PI / 15) + (ts/3600.);
|
---|
55 | dec = dec * 180. / M_PI;
|
---|
56 | }
|
---|
57 |
|
---|
58 | double TempLocator::getAlphaZenith() {
|
---|
59 | if (ra < -100) ComputeZenith();
|
---|
60 | return ra;
|
---|
61 | }
|
---|
62 |
|
---|
63 | double TempLocator::getDeltaZenith() {
|
---|
64 | if (dec < -100) ComputeZenith();
|
---|
65 | return dec;
|
---|
66 | }
|
---|
67 |
|
---|
68 | void TempLocator::findGeomFromGC(int sampleNum) // pour le bolo qui voit les xing
|
---|
69 | {
|
---|
70 | if (sampleNum == xSampleNum) return;
|
---|
71 | if (dec < -100) ComputeZenith();
|
---|
72 |
|
---|
73 | azimBolGC = -9999;
|
---|
74 |
|
---|
75 | // On trouve les croisements juste avant et juste apres notre sampleNum
|
---|
76 | int icross;
|
---|
77 | for (icross=0; icross<nGalCross; icross++) {
|
---|
78 | if (crossings[icross] > sampleNum) break;
|
---|
79 | }
|
---|
80 | if (icross == 0 || icross >= nGalCross) return;
|
---|
81 |
|
---|
82 | // On trouve l'azimut du croisement principal pour notre position actuelle
|
---|
83 | double alpG = 12. + 51./60. + 30./3600.;
|
---|
84 | double delG = 27. + 07./60. + 42./3600.;
|
---|
85 | double azCr1, azCr2;
|
---|
86 | int rc = PlGalCross(ts/3600., lat, (90. - 41.), alpG, delG, azCr1, azCr2);
|
---|
87 |
|
---|
88 | }
|
---|
89 |
|
---|
90 |
|
---|
91 | // ;
|
---|
92 | // ; /\ 4 2
|
---|
93 | // ; elevation || positive scanning, clockwise
|
---|
94 | // ; || 6 1 5 ---------->
|
---|
95 | // ; || == positive azimut
|
---|
96 | // ; || x 3
|
---|
97 | // |----| = 0.78 deg / cos(elev)
|
---|
98 | // bol 1 = 41° elevation
|
---|
99 | |
---|