| 1 | #include "StarCatalog.h"
|
|---|
| 2 |
|
|---|
| 3 | #include <iomanip.h> // cout
|
|---|
| 4 | #include <iostream.h> // cout
|
|---|
| 5 |
|
|---|
| 6 | #include <TSystem.h>
|
|---|
| 7 |
|
|---|
| 8 | #include "slalib.h"
|
|---|
| 9 | #include "slamac.h"
|
|---|
| 10 | #include "File.h"
|
|---|
| 11 |
|
|---|
| 12 | StarCatalog::StarCatalog() : SlaStars(), fEntries(0)
|
|---|
| 13 | {
|
|---|
| 14 | // p = pointer to MainFrame (not owner)
|
|---|
| 15 |
|
|---|
| 16 | //
|
|---|
| 17 | // read index file
|
|---|
| 18 | //
|
|---|
| 19 | File idx("sao/sao-sort.idx", "r");
|
|---|
| 20 |
|
|---|
| 21 | if (!idx)
|
|---|
| 22 | exit(0);
|
|---|
| 23 |
|
|---|
| 24 | while (!idx.Eof())
|
|---|
| 25 | {
|
|---|
| 26 | idx.Newline();
|
|---|
| 27 | fEntries++;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | idx.Reset();
|
|---|
| 31 |
|
|---|
| 32 | fSrt = new sort_t[fEntries];
|
|---|
| 33 |
|
|---|
| 34 | for (int i=0; i<fEntries; i++)
|
|---|
| 35 | {
|
|---|
| 36 | fSrt[i].ra = idx.Geti(4);
|
|---|
| 37 | fSrt[i].dec = idx.Geti(4);
|
|---|
| 38 | fSrt[i].nr = idx.Geti(10);
|
|---|
| 39 | idx.Newline();
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | //
|
|---|
| 43 | // open catalog
|
|---|
| 44 | //
|
|---|
| 45 | fSao = new SaoFile("sao/sao-sort.cmp");
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | StarCatalog::~StarCatalog()
|
|---|
| 49 | {
|
|---|
| 50 | delete fSrt;
|
|---|
| 51 | delete fSao;
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | void StarCatalog::SetPixSize(const double pixsize)
|
|---|
| 55 | {
|
|---|
| 56 | fPixSize = D2PI/360.0 * pixsize;
|
|---|
| 57 |
|
|---|
| 58 | fWidth = fPixSize * 768/2;
|
|---|
| 59 | fHeight = fPixSize * 576/2;
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | void StarCatalog::SetAltAz(const AltAz &altaz)
|
|---|
| 63 | {
|
|---|
| 64 | fAltAz = altaz * D2PI/360.0;
|
|---|
| 65 |
|
|---|
| 66 | cout << "Set --> Alt: " << 360.0/D2PI*fAltAz.Alt();
|
|---|
| 67 | cout << " Az: " << fAltAz.Az() << endl;
|
|---|
| 68 |
|
|---|
| 69 | fRaDec = CalcRaDec(fAltAz);
|
|---|
| 70 |
|
|---|
| 71 | cout << "Ra: " << 360.0/D2PI*fRaDec.Ra();
|
|---|
| 72 | cout << " Dec: " << 360.0/D2PI*fRaDec.Dec() << endl;
|
|---|
| 73 |
|
|---|
| 74 | CalcAltAzRange();
|
|---|
| 75 | CalcRaDecRange();
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | void StarCatalog::SetRaDec(const RaDec &radec)
|
|---|
| 79 | {
|
|---|
| 80 | fRaDec = radec;
|
|---|
| 81 | fRaDec *= D2PI/360.0;
|
|---|
| 82 |
|
|---|
| 83 | fAltAz = CalcAltAz(fRaDec);
|
|---|
| 84 |
|
|---|
| 85 | cout << "Alt: " << 360.0/D2PI*fAltAz.Alt() << " ";
|
|---|
| 86 | cout << "Az: " << 360.0/D2PI*fAltAz.Az() << endl;
|
|---|
| 87 |
|
|---|
| 88 | CalcRaDecRange();
|
|---|
| 89 | CalcAltAzRange();
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | void StarCatalog::CalcAltAzRange()
|
|---|
| 93 | {
|
|---|
| 94 | byte fAlt0[180];
|
|---|
| 95 |
|
|---|
| 96 | for (int h=0; h<180; h++)
|
|---|
| 97 | fAlt0[h] = kFALSE;
|
|---|
| 98 |
|
|---|
| 99 | for (int h=0; h<360; h++)
|
|---|
| 100 | fAz0[h] = kFALSE;
|
|---|
| 101 |
|
|---|
| 102 | double az0, alt0;
|
|---|
| 103 | double az1, alt1;
|
|---|
| 104 | //
|
|---|
| 105 | // scan horizontal border
|
|---|
| 106 | //
|
|---|
| 107 | for (int x=-768/2; x<768/2+1; x++)
|
|---|
| 108 | {
|
|---|
| 109 | slaDh2e(DPI+x*fPixSize, -fHeight, DPI/2-fAltAz.Alt(), &az0, &alt0);
|
|---|
| 110 | slaDh2e(DPI+x*fPixSize, +fHeight, DPI/2-fAltAz.Alt(), &az1, &alt1);
|
|---|
| 111 |
|
|---|
| 112 | const int z0 = ((int)(360.0/D2PI*(az0+fAltAz.Az()))+360)%360;
|
|---|
| 113 | const int t0 = (int)(360.0/D2PI*alt0);
|
|---|
| 114 |
|
|---|
| 115 | fAz0[z0] = kTRUE;
|
|---|
| 116 |
|
|---|
| 117 | if (-89<=t0 && t0<=90)
|
|---|
| 118 | fAlt0[90-t0] = kTRUE;
|
|---|
| 119 |
|
|---|
| 120 | const int z1 = ((int)(360.0/D2PI*(az1+fAltAz.Az()))+360)%360;
|
|---|
| 121 | const int t1 = (int)(360.0/D2PI*alt1);
|
|---|
| 122 |
|
|---|
| 123 | fAz0[z1] = kTRUE;
|
|---|
| 124 |
|
|---|
| 125 | if (-89<=t1 && t1<=90)
|
|---|
| 126 | fAlt0[90-t1] = kTRUE;
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | //
|
|---|
| 130 | // scan vertical border
|
|---|
| 131 | //
|
|---|
| 132 | for (int y=-576/2; y<576/2+1; y++)
|
|---|
| 133 | {
|
|---|
| 134 | slaDh2e(DPI-fWidth, y*fPixSize, DPI/2-fAltAz.Alt(), &az0, &alt0);
|
|---|
| 135 | slaDh2e(DPI+fWidth, y*fPixSize, DPI/2-fAltAz.Alt(), &az1, &alt1);
|
|---|
| 136 |
|
|---|
| 137 | const int z0 = ((int)(360.0/D2PI*(az0+fAltAz.Az()))+360)%360;
|
|---|
| 138 | const int t0 = (int)(360.0/D2PI*alt0);
|
|---|
| 139 |
|
|---|
| 140 | fAz0[z0] = kTRUE;
|
|---|
| 141 |
|
|---|
| 142 | if (-89<=t0 && t0<=90)
|
|---|
| 143 | fAlt0[90-t0] = kTRUE;
|
|---|
| 144 |
|
|---|
| 145 | const int z1 = ((int)(360.0/D2PI*(az1+fAltAz.Az()))+360)%360;
|
|---|
| 146 | const int t1 = (int)(360.0/D2PI*alt1);
|
|---|
| 147 |
|
|---|
| 148 | fAz0[z1] = kTRUE;
|
|---|
| 149 |
|
|---|
| 150 | if (-89<=t1 && t1<=90)
|
|---|
| 151 | fAlt0[90-t1] = kTRUE;
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | //
|
|---|
| 155 | // count degrees of azimut
|
|---|
| 156 | //
|
|---|
| 157 | fAzCnt=0;
|
|---|
| 158 | for (int x=0; x<360; x++)
|
|---|
| 159 | if (fAz0[x])
|
|---|
| 160 | fAzCnt++;
|
|---|
| 161 |
|
|---|
| 162 | cout << "fAzCnt: " << setw(3) << fAzCnt << " " << flush;
|
|---|
| 163 |
|
|---|
| 164 | //
|
|---|
| 165 | // calculate min and max of altitude
|
|---|
| 166 | //
|
|---|
| 167 | fAltMin=0;
|
|---|
| 168 | fAltMax=0;
|
|---|
| 169 | for (int y=0; y<180; y++)
|
|---|
| 170 | {
|
|---|
| 171 | if (fAlt0[y])
|
|---|
| 172 | fAltMax = y;
|
|---|
| 173 |
|
|---|
| 174 | if (fAlt0[179-y])
|
|---|
| 175 | fAltMin = 179-y;
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | fAltMin -= 90;
|
|---|
| 179 | fAltMax -= 90;
|
|---|
| 180 |
|
|---|
| 181 | //
|
|---|
| 182 | // check whether altaz north- or south-pole is in the visible region
|
|---|
| 183 | //
|
|---|
| 184 | byte img[768*576];
|
|---|
| 185 | if (DrawAltAz(0, img, 90, 0))
|
|---|
| 186 | {
|
|---|
| 187 | fAltMax=89;
|
|---|
| 188 | cout << "Alt Az Pole1 Inside!" << endl;
|
|---|
| 189 | }
|
|---|
| 190 | if (DrawAltAz(0, img, -90, 0))
|
|---|
| 191 | {
|
|---|
| 192 | fAltMin=-90;
|
|---|
| 193 | cout << "Alt Az Pole2 Inside!" << endl;
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | cout << "fAltMin: " << setw(3) << fAltMin << " ";
|
|---|
| 197 | cout << "fAltMax: " << setw(3) << fAltMax << endl;
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | void StarCatalog::CalcRaDecRange()
|
|---|
| 201 | {
|
|---|
| 202 | //
|
|---|
| 203 | // calculate range to search in
|
|---|
| 204 | //
|
|---|
| 205 | byte fDec[180];
|
|---|
| 206 |
|
|---|
| 207 | for (int h=0; h<180; h++)
|
|---|
| 208 | fDec[h] = kFALSE;
|
|---|
| 209 |
|
|---|
| 210 | for (int h=0; h<360; h++)
|
|---|
| 211 | fRa0[h] = kFALSE;
|
|---|
| 212 |
|
|---|
| 213 | double ha0, ha1;
|
|---|
| 214 | double de0, de1;
|
|---|
| 215 |
|
|---|
| 216 | const double phi = GetPhi();
|
|---|
| 217 | const double alpha = GetAlpha();
|
|---|
| 218 | //
|
|---|
| 219 | // scan horizontal border
|
|---|
| 220 | //
|
|---|
| 221 | for (int x=-768/2; x<768/2+1; x++)
|
|---|
| 222 | {
|
|---|
| 223 | double dx, dy;
|
|---|
| 224 | slaDh2e(DPI-x*fPixSize, -fHeight, DPI/2-fAltAz.Alt(), &dx, &dy);
|
|---|
| 225 | slaDh2e(fAltAz.Az()+dx, -dy, phi, &ha0, &de0);
|
|---|
| 226 |
|
|---|
| 227 | slaDh2e(DPI-x*fPixSize, +fHeight, DPI/2-fAltAz.Alt(), &dx, &dy);
|
|---|
| 228 | slaDh2e(fAltAz.Az()+dx, -dy, phi, &ha1, &de1);
|
|---|
| 229 |
|
|---|
| 230 | const int h0 = ((int)(360.0/D2PI*(alpha-ha0))+360)%360;
|
|---|
| 231 | const int d0 = (int)(360.0/D2PI*de0);
|
|---|
| 232 |
|
|---|
| 233 | fRa0[h0] = kTRUE;
|
|---|
| 234 |
|
|---|
| 235 | if (-90<=d0 && d0<=89)
|
|---|
| 236 | fDec[d0+90] = kTRUE;
|
|---|
| 237 |
|
|---|
| 238 | const int h1 = ((int)(360.0/D2PI*(alpha-ha1))+360)%360;
|
|---|
| 239 | const int d1 = (int)(360.0/D2PI*de1);
|
|---|
| 240 |
|
|---|
| 241 | fRa0[h1] = kTRUE;
|
|---|
| 242 |
|
|---|
| 243 | if (-90<=d1 && d1<=89)
|
|---|
| 244 | fDec[d1+90] = kTRUE;
|
|---|
| 245 | }
|
|---|
| 246 |
|
|---|
| 247 | //
|
|---|
| 248 | // scan vertical border
|
|---|
| 249 | //
|
|---|
| 250 | for (int y=-576/2; y<576/2+1; y++)
|
|---|
| 251 | {
|
|---|
| 252 | double dx, dy;
|
|---|
| 253 | slaDh2e(DPI-fWidth, -y*fPixSize, DPI/2-fAltAz.Alt(), &dx, &dy);
|
|---|
| 254 | slaDh2e(fAltAz.Az()+dx, -dy, phi, &ha0, &de0);
|
|---|
| 255 |
|
|---|
| 256 | slaDh2e(DPI+fWidth, -y*fPixSize, DPI/2-fAltAz.Alt(), &dx, &dy);
|
|---|
| 257 | slaDh2e(fAltAz.Az()+dx, -dy, phi, &ha1, &de1);
|
|---|
| 258 |
|
|---|
| 259 | const int h0 = ((int)(360.0/D2PI*(alpha-ha0))+360)%360;
|
|---|
| 260 | const int d0 = (int)(360.0/D2PI*de0);
|
|---|
| 261 |
|
|---|
| 262 | fRa0[h0] = kTRUE;
|
|---|
| 263 |
|
|---|
| 264 | if (-90<=d0 && d0<=89)
|
|---|
| 265 | fDec[d0+90] = kTRUE;
|
|---|
| 266 |
|
|---|
| 267 | const int h1 = ((int)(360.0/D2PI*(alpha-ha1))+360)%360;
|
|---|
| 268 | const int d1 = (int)(360.0/D2PI*de1);
|
|---|
| 269 |
|
|---|
| 270 | fRa0[h1] = kTRUE;
|
|---|
| 271 |
|
|---|
| 272 | if (-90<=d1 && d1<=89)
|
|---|
| 273 | fDec[d1+90] = kTRUE;
|
|---|
| 274 | }
|
|---|
| 275 |
|
|---|
| 276 | //
|
|---|
| 277 | // count degrees of right ascension
|
|---|
| 278 | //
|
|---|
| 279 | fRaCnt=0;
|
|---|
| 280 | for (int x=0; x<360; x++)
|
|---|
| 281 | if (fRa0[x])
|
|---|
| 282 | fRaCnt++;
|
|---|
| 283 | cout << "fRaCnt: " << setw(3) << fRaCnt << " " << flush;
|
|---|
| 284 |
|
|---|
| 285 | //
|
|---|
| 286 | // calculate min and max of declination
|
|---|
| 287 | //
|
|---|
| 288 | for (int y=0; y<180; y++)
|
|---|
| 289 | {
|
|---|
| 290 | if (fDec[y])
|
|---|
| 291 | fDecMax = y;
|
|---|
| 292 |
|
|---|
| 293 | if (fDec[179-y])
|
|---|
| 294 | fDecMin = 179-y;
|
|---|
| 295 | }
|
|---|
| 296 |
|
|---|
| 297 | fDecMin -= 90;
|
|---|
| 298 | fDecMax -= 90;
|
|---|
| 299 |
|
|---|
| 300 | //
|
|---|
| 301 | // check whether radec north- or south-pole is in the visible region
|
|---|
| 302 | //
|
|---|
| 303 | byte img[768*576];
|
|---|
| 304 | if (DrawRaDec(0, img, 0, 90))
|
|---|
| 305 | {
|
|---|
| 306 | fDecMax=89;
|
|---|
| 307 | cout << "Ra Dec Pole1 Inside!" << endl;
|
|---|
| 308 | }
|
|---|
| 309 | if (DrawRaDec(0, img, 0, -90))
|
|---|
| 310 | {
|
|---|
| 311 | fDecMin=-90;
|
|---|
| 312 | cout << "Ra Dec Pole1 Inside!" << endl;
|
|---|
| 313 | }
|
|---|
| 314 |
|
|---|
| 315 | cout << "fDecMin: " << setw(3) << fDecMin << " ";
|
|---|
| 316 | cout << "fDecMax: " << setw(3) << fDecMax << endl;
|
|---|
| 317 | }
|
|---|
| 318 |
|
|---|
| 319 | void StarCatalog::DrawSCAltAz(byte *img, const int color)
|
|---|
| 320 | {
|
|---|
| 321 | //
|
|---|
| 322 | // ------------ draw az lines ---------------
|
|---|
| 323 | //
|
|---|
| 324 | for (int az=0; az<360; az++)
|
|---|
| 325 | {
|
|---|
| 326 | if (!fAz0[az])
|
|---|
| 327 | continue;
|
|---|
| 328 |
|
|---|
| 329 | for (double alt=fAltMin-1; alt<fAltMax+1; alt+=0.006*(fAltMax-fAltMin))
|
|---|
| 330 | {
|
|---|
| 331 | if ((alt>88 && az%5) || alt>89.5)
|
|---|
| 332 | continue;
|
|---|
| 333 |
|
|---|
| 334 | DrawAltAz(color, img, alt, az);
|
|---|
| 335 | }
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | //
|
|---|
| 339 | // ------------ draw alt lines ---------------
|
|---|
| 340 | //
|
|---|
| 341 | for (int alt=fAltMin; alt<fAltMax+1; alt++)
|
|---|
| 342 | {
|
|---|
| 343 | for (double az=0; az<360; az+=0.004*fAzCnt)
|
|---|
| 344 | {
|
|---|
| 345 | if (!fAz0[(int)az] && !fAz0[(int)(az+359)%360] && !fAz0[(int)(az+1)%360])
|
|---|
| 346 | continue;
|
|---|
| 347 |
|
|---|
| 348 | DrawAltAz(color, img, alt, az);
|
|---|
| 349 | }
|
|---|
| 350 | }
|
|---|
| 351 | }
|
|---|
| 352 |
|
|---|
| 353 | void StarCatalog::DrawSCRaDec(byte *img, const int color)
|
|---|
| 354 | {
|
|---|
| 355 | //
|
|---|
| 356 | // ------------ draw ra lines ---------------
|
|---|
| 357 | //
|
|---|
| 358 | for (int ra=0; ra<360; ra++)
|
|---|
| 359 | {
|
|---|
| 360 | if (!fRa0[ra])
|
|---|
| 361 | continue;
|
|---|
| 362 |
|
|---|
| 363 | for (double dec=fDecMin-1; dec<fDecMax+1; dec+=0.005*(fDecMax-fDecMin))
|
|---|
| 364 | {
|
|---|
| 365 | if ((dec>88 && ra%5) || dec>89.5)
|
|---|
| 366 | continue;
|
|---|
| 367 |
|
|---|
| 368 | DrawRaDec(color, img, ra, dec, ra==0||ra==90);
|
|---|
| 369 | }
|
|---|
| 370 | }
|
|---|
| 371 |
|
|---|
| 372 | //
|
|---|
| 373 | // ------------ draw dec lines ---------------
|
|---|
| 374 | //
|
|---|
| 375 | for (int dec=fDecMin; dec<fDecMax+1; dec++)
|
|---|
| 376 | {
|
|---|
| 377 | for (double ra=0; ra<360; ra+=0.003*fRaCnt)
|
|---|
| 378 | {
|
|---|
| 379 | if (!fRa0[(int)ra])
|
|---|
| 380 | continue;
|
|---|
| 381 |
|
|---|
| 382 | DrawRaDec(color, img, ra, dec, dec==89);
|
|---|
| 383 | }
|
|---|
| 384 | }
|
|---|
| 385 | }
|
|---|
| 386 |
|
|---|
| 387 | void StarCatalog::DrawCross(byte *img, const int x, const int y)
|
|---|
| 388 | {
|
|---|
| 389 | for (int dx=-4; dx<5; dx++)
|
|---|
| 390 | if (dx) img[y*768+x+dx] = 0xff;
|
|---|
| 391 |
|
|---|
| 392 | for (int dy=-4; dy<5; dy++)
|
|---|
| 393 | if (dy) img[(y+dy)*768+x] = 0xff;
|
|---|
| 394 | }
|
|---|
| 395 |
|
|---|
| 396 | void StarCatalog::GetImg(byte *img, byte *cimg, const double utc,
|
|---|
| 397 | const RaDec &radec)
|
|---|
| 398 | {
|
|---|
| 399 | // memset(img, 0, 768*576);
|
|---|
| 400 | memset(cimg, 0, 768*576);
|
|---|
| 401 |
|
|---|
| 402 | SetMjd(utc);
|
|---|
| 403 | //fAlpha = sla.GetAlpha();
|
|---|
| 404 | SetRaDec(radec);
|
|---|
| 405 |
|
|---|
| 406 | DrawSCAltAz(cimg, 2<<4);
|
|---|
| 407 | DrawSCRaDec(cimg, 2);
|
|---|
| 408 |
|
|---|
| 409 | CalcImg(img);
|
|---|
| 410 |
|
|---|
| 411 | DrawCross(img, 768/2, 576/2);
|
|---|
| 412 | }
|
|---|
| 413 |
|
|---|
| 414 | void StarCatalog::GetImg(byte *img, byte *cimg, const double utc,
|
|---|
| 415 | const AltAz &altaz)
|
|---|
| 416 | {
|
|---|
| 417 | // memset(img, 0, 768*576);
|
|---|
| 418 | memset(cimg, 0, 768*576);
|
|---|
| 419 |
|
|---|
| 420 | SetMjd(utc);
|
|---|
| 421 | //fAlpha = sla.GetAlpha();
|
|---|
| 422 | SetAltAz(altaz);
|
|---|
| 423 |
|
|---|
| 424 | CalcRaDecRange();
|
|---|
| 425 | DrawSCRaDec(cimg, 2);
|
|---|
| 426 | DrawSCAltAz(cimg, 2<<4);
|
|---|
| 427 | CalcImg(img);
|
|---|
| 428 |
|
|---|
| 429 | DrawCross(img, 768/2, 576/2);
|
|---|
| 430 | }
|
|---|
| 431 |
|
|---|
| 432 | void StarCatalog::DrawCircle(int color, byte *img, int xx, int yy, int size)
|
|---|
| 433 | {
|
|---|
| 434 | for (int x=xx-size; x<xx+size+1; x++)
|
|---|
| 435 | {
|
|---|
| 436 | if (x<0 || x>767)
|
|---|
| 437 | continue;
|
|---|
| 438 |
|
|---|
| 439 | const float p = xx+size-x;
|
|---|
| 440 | const float q = 2*size - p;
|
|---|
| 441 | const int h = (int)sqrt(p*q);
|
|---|
| 442 |
|
|---|
| 443 | const int y1 = yy-h;
|
|---|
| 444 | if (y1>=0 && y1<576)
|
|---|
| 445 | img[y1*768+x] = color;
|
|---|
| 446 |
|
|---|
| 447 | const int y2 = yy+h;
|
|---|
| 448 | if (y2>=0 && y2<576)
|
|---|
| 449 | img[y2*768+x] = color;
|
|---|
| 450 | }
|
|---|
| 451 | }
|
|---|
| 452 |
|
|---|
| 453 | Bool_t StarCatalog::DrawAltAz(const int color, byte *img, double alt, double az, int size)
|
|---|
| 454 | {
|
|---|
| 455 | //
|
|---|
| 456 | // alt/az[deg] -> alt/az[rad]
|
|---|
| 457 | //
|
|---|
| 458 | alt *= D2PI/360.0;
|
|---|
| 459 | az *= D2PI/360.0;
|
|---|
| 460 |
|
|---|
| 461 | //
|
|---|
| 462 | // alt/az[rad] -> alt/az[pix]
|
|---|
| 463 | //
|
|---|
| 464 | double dx, dy;
|
|---|
| 465 | slaDe2h(az-fAltAz.Az(), -alt, DPI/2-fAltAz.Alt(), &dx, &dy);
|
|---|
| 466 |
|
|---|
| 467 | //
|
|---|
| 468 | // Align alt/az[pix]
|
|---|
| 469 | //
|
|---|
| 470 | const int xx = 767-(int)((fWidth-dx+DPI)/fPixSize);
|
|---|
| 471 | const int yy = (int)((fHeight+dy)/fPixSize);
|
|---|
| 472 |
|
|---|
| 473 | //
|
|---|
| 474 | // Range Check
|
|---|
| 475 | //
|
|---|
| 476 | if (!(0<=xx && xx<768 && 0<=yy && yy<576))
|
|---|
| 477 | return kFALSE;
|
|---|
| 478 |
|
|---|
| 479 | //
|
|---|
| 480 | // Draw
|
|---|
| 481 | //
|
|---|
| 482 | DrawCircle(color, img, xx, yy, size);
|
|---|
| 483 |
|
|---|
| 484 | return kTRUE;
|
|---|
| 485 | }
|
|---|
| 486 |
|
|---|
| 487 | Bool_t StarCatalog::Draw(const int color, byte *img, const AltAz &altaz)
|
|---|
| 488 | {
|
|---|
| 489 | return DrawAltAz(color, img, altaz.Alt(), altaz.Az());
|
|---|
| 490 | }
|
|---|
| 491 |
|
|---|
| 492 | Bool_t StarCatalog::Draw(const int color, byte *img, const SaoFile *sao)
|
|---|
| 493 | {
|
|---|
| 494 | //
|
|---|
| 495 | // ---- mean to observed ---
|
|---|
| 496 | //
|
|---|
| 497 | AltAz altaz=CalcAltAz(sao->GetRaDec()) * 360.0/D2PI;
|
|---|
| 498 |
|
|---|
| 499 | if (sao->MagV() > fLimitMag)
|
|---|
| 500 | return kFALSE;
|
|---|
| 501 |
|
|---|
| 502 | const int mag = (10 - (sao->MagV()>1 ? (int)sao->MagV() : 1))/2;
|
|---|
| 503 |
|
|---|
| 504 | //
|
|---|
| 505 | // ---- imaging -----
|
|---|
| 506 | //
|
|---|
| 507 | return DrawAltAz(color, img, altaz.Alt(), altaz.Az(), mag);
|
|---|
| 508 | }
|
|---|
| 509 |
|
|---|
| 510 | Bool_t StarCatalog::DrawRaDec(const int color, byte *img, double ra, double dec, int size)
|
|---|
| 511 | {
|
|---|
| 512 | //
|
|---|
| 513 | // radec[deg] -> radec[rad]
|
|---|
| 514 | //
|
|---|
| 515 | ra *= D2PI/360.0;
|
|---|
| 516 | dec *= D2PI/360.0;
|
|---|
| 517 |
|
|---|
| 518 | //
|
|---|
| 519 | // radec[rad] -> hadec[rad]
|
|---|
| 520 | //
|
|---|
| 521 | const double ha = GetAlpha()-ra;
|
|---|
| 522 |
|
|---|
| 523 | //
|
|---|
| 524 | // hadec[rad] -> altaz[rad]
|
|---|
| 525 | //
|
|---|
| 526 | double alt, az;
|
|---|
| 527 | slaDe2h(ha, dec, GetPhi(), &az, &alt);
|
|---|
| 528 |
|
|---|
| 529 | //
|
|---|
| 530 | // altaz[rad] -> altaz[deg]
|
|---|
| 531 | //
|
|---|
| 532 | alt *= 360.0/D2PI;
|
|---|
| 533 | az *= 360.0/D2PI;
|
|---|
| 534 |
|
|---|
| 535 | return DrawAltAz(color, img, alt, az, size);
|
|---|
| 536 | }
|
|---|
| 537 |
|
|---|
| 538 | Bool_t StarCatalog::Draw(const int color, byte *img, const RaDec &radec)
|
|---|
| 539 | {
|
|---|
| 540 | return DrawRaDec(color, img, radec.Ra(), radec.Dec());
|
|---|
| 541 | }
|
|---|
| 542 |
|
|---|
| 543 | void StarCatalog::CalcImg(byte *img)
|
|---|
| 544 | {
|
|---|
| 545 |
|
|---|
| 546 | //
|
|---|
| 547 | // --------- search for stars in catalog ----------
|
|---|
| 548 | //
|
|---|
| 549 | int count = 0;
|
|---|
| 550 | int deleted = 0;
|
|---|
| 551 |
|
|---|
| 552 | int idx = 0;
|
|---|
| 553 |
|
|---|
| 554 | while (fSrt[idx].dec<fDecMin)
|
|---|
| 555 | idx++;
|
|---|
| 556 |
|
|---|
| 557 | idx--;
|
|---|
| 558 | while (++idx<fEntries && fSrt[idx].dec<fDecMax+1)
|
|---|
| 559 | {
|
|---|
| 560 | const int ra = fSrt[idx].ra;
|
|---|
| 561 |
|
|---|
| 562 | if (!fRa0[ra])
|
|---|
| 563 | continue;
|
|---|
| 564 |
|
|---|
| 565 | int nr = fSrt[idx].nr;
|
|---|
| 566 | do
|
|---|
| 567 | {
|
|---|
| 568 | //
|
|---|
| 569 | // Get entry from catalog
|
|---|
| 570 | //
|
|---|
| 571 | fSao->GetEntry(nr++);
|
|---|
| 572 |
|
|---|
| 573 | //
|
|---|
| 574 | // Try to draw star into the image (white)
|
|---|
| 575 | //
|
|---|
| 576 | if (!Draw(0xff, img, fSao))
|
|---|
| 577 | deleted++;
|
|---|
| 578 |
|
|---|
| 579 | count++;
|
|---|
| 580 | }
|
|---|
| 581 | while ((int)(360.0/D2PI*fSao->Ra())==ra);
|
|---|
| 582 | }
|
|---|
| 583 |
|
|---|
| 584 | cout << " " << count << "-" << deleted << "=" << count-deleted << " " << flush;
|
|---|
| 585 | }
|
|---|
| 586 |
|
|---|