Ignore:
Timestamp:
05/25/01 16:51:24 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy/catalog
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/catalog/StarCatalog.cc

    r748 r808  
    1616
    1717    //
    18     // calculate observers location (goe)
    19     //
    20     int status;
    21     slaDaf2r(51, 38, 48.0, &fPhi,   &status);
    22     slaDaf2r( 9, 56, 36.0, &fElong, &status);
    23 
    24     cout << "fPhi:   51ø38'48.0\" = " <<  360.0/D2PI*fPhi << endl;
    25     cout << "fElong:  9ø56'36.0\" = " <<  360.0/D2PI*fElong << endl;
    26 
    27     //
    2818    // read index file
    2919    //
     
    7868    cout << "  Az: " << fAltAz.Az() << endl;
    7969
    80     fRaDec = AltAz2RaDec(fAltAz);
     70    fRaDec = sla.CalcRaDec(fAltAz);
    8171
    8272    cout << "Ra: " << 360.0/D2PI*fRaDec.Ra();
     
    8777}
    8878
    89 RaDec StarCatalog::AltAz2RaDec(const AltAz &altaz) const
    90 {
    91     //
    92     // -- observed to apparent --
    93     //  Workaraound for slalib: discard const
    94     //
    95     double r=0, d=0;
    96     slaOapqk ("A", altaz.Az(), DPI/2-altaz.Alt(), (double*)fAoprms, &r, &d);
    97 
    98     //
    99     // -- apparent to mean --
    100     //  Workaraound for slalib: discard const
    101     //
    102     double ra, dec;
    103     slaAmpqk(r, d, (double*)fAmprms, &ra, &dec);
    104 
    105     return RaDec(ra, dec);
    106 }
    107 
    108 AltAz StarCatalog::RaDec2AltAz(const RaDec &radec, const RaDec &rdpm) const
    109 {
    110     //
    111     // ---- Mean to apparent ----
    112     //
    113 
    114     double r=0, d=0;
    115     slaMapqkz(radec.Ra(), radec.Dec(), (double*)fAmprms, &r, &d);
    116     //
    117     // Doesn't work - don't know why
    118     //
    119     //    slaMapqk (radec.Ra(), radec.Dec(), rdpm.Ra(), rdpm.Dec(),
    120     //              0, 0, (double*)fAmprms, &r, &d);
    121     //
    122 
    123     //
    124     // -- apparent to observed --
    125     //
    126     double r1=0;  // ra
    127     double d1=0;  // dec
    128     double h0=0;  // ha
    129 
    130     double zd;
    131     double az;
    132     slaAopqk (r, d, (double*)fAoprms,
    133               &az,    // observed azimuth (radians: N=0,E=90)
    134               &zd,    // observed zenith distance (radians) [-pi/2, pi/2]
    135               &h0,    // observed hour angle (radians)
    136               &d1,    // observed declination (radians)
    137               &r1);   // observed right ascension (radians)
    138 
    139     return AltAz(DPI/2-zd, az);
    140 }
    141 
    142 void StarCatalog::SetRaDec(const RaDec &radec, const RaDec &rdpm)
     79void StarCatalog::SetRaDec(const RaDec &radec)
    14380{
    14481    fRaDec = radec;
    14582    fRaDec *= D2PI/360.0;
    14683
    147     RaDec pm = rdpm * D2PI/360.0;
    148 
    149     fAltAz = RaDec2AltAz(fRaDec, pm);
     84    fAltAz = sla.CalcAltAz(fRaDec);
    15085
    15186    cout << "Alt: " << 360.0/D2PI*fAltAz.Alt() << "  ";
     
    15893void StarCatalog::CalcAltAzRange()
    15994{
    160     char fAlt0[180];
     95    byte fAlt0[180];
    16196
    16297    for (int h=0; h<180; h++)
     
    248183    // check whether altaz north- or south-pole is in the visible region
    249184    //
    250     char img[768*576];
     185    byte img[768*576];
    251186    if (DrawAltAz(0, img, 90, 0))
    252187    {
     
    263198    cout << "fAltMax: " << setw(3) << fAltMax << endl;
    264199}
     200
    265201void StarCatalog::CalcRaDecRange()
    266202{
     
    268204    // calculate range to search in
    269205    //
    270     char fDec[180];
     206    byte fDec[180];
    271207
    272208    for (int h=0; h<180; h++)
     
    279215    double de0, de1;
    280216
     217    const double phi   = sla.GetPhi();
     218    const double alpha = sla.GetAlpha();
    281219    //
    282220    // scan horizontal border
     
    286224        double dx, dy;
    287225        slaDh2e(DPI-x*fPixSize, -fHeight, DPI/2-fAltAz.Alt(), &dx, &dy);
    288         slaDh2e(fAltAz.Az()+dx, -dy, fPhi, &ha0, &de0);
     226        slaDh2e(fAltAz.Az()+dx, -dy, phi, &ha0, &de0);
    289227
    290228        slaDh2e(DPI-x*fPixSize, +fHeight, DPI/2-fAltAz.Alt(), &dx, &dy);
    291         slaDh2e(fAltAz.Az()+dx, -dy, fPhi, &ha1, &de1);
    292 
    293         const int h0 = ((int)(360.0/D2PI*(fAlpha-ha0))+360)%360;
     229        slaDh2e(fAltAz.Az()+dx, -dy, phi, &ha1, &de1);
     230
     231        const int h0 = ((int)(360.0/D2PI*(alpha-ha0))+360)%360;
    294232        const int d0 = (int)(360.0/D2PI*de0);
    295233
     
    299237            fDec[d0+90] = kTRUE;
    300238
    301         const int h1 = ((int)(360.0/D2PI*(fAlpha-ha1))+360)%360;
     239        const int h1 = ((int)(360.0/D2PI*(alpha-ha1))+360)%360;
    302240        const int d1 = (int)(360.0/D2PI*de1);
    303241
     
    315253        double dx, dy;
    316254        slaDh2e(DPI-fWidth, -y*fPixSize, DPI/2-fAltAz.Alt(), &dx, &dy);
    317         slaDh2e(fAltAz.Az()+dx, -dy, fPhi, &ha0, &de0);
     255        slaDh2e(fAltAz.Az()+dx, -dy, phi, &ha0, &de0);
    318256
    319257        slaDh2e(DPI+fWidth, -y*fPixSize, DPI/2-fAltAz.Alt(), &dx, &dy);
    320         slaDh2e(fAltAz.Az()+dx, -dy, fPhi, &ha1, &de1);
    321 
    322         const int h0 = ((int)(360.0/D2PI*(fAlpha-ha0))+360)%360;
     258        slaDh2e(fAltAz.Az()+dx, -dy, phi, &ha1, &de1);
     259
     260        const int h0 = ((int)(360.0/D2PI*(alpha-ha0))+360)%360;
    323261        const int d0 = (int)(360.0/D2PI*de0);
    324262
     
    328266            fDec[d0+90] = kTRUE;
    329267
    330         const int h1 = ((int)(360.0/D2PI*(fAlpha-ha1))+360)%360;
     268        const int h1 = ((int)(360.0/D2PI*(alpha-ha1))+360)%360;
    331269        const int d1 = (int)(360.0/D2PI*de1);
    332270
     
    364302    // check whether radec north- or south-pole is in the visible region
    365303    //
    366     char img[768*576];
     304    byte img[768*576];
    367305    if (DrawRaDec(0, img, 0, 90))
    368306    {
     
    380318}
    381319
    382 void StarCatalog::DrawSCAltAz(char *img, const int color)
     320void StarCatalog::DrawSCAltAz(byte *img, const int color)
    383321{
    384322    //
     
    414352}
    415353
    416 void StarCatalog::DrawSCRaDec(char *img, const int color)
     354void StarCatalog::DrawSCRaDec(byte *img, const int color)
    417355{
    418356    //
     
    446384        }
    447385    }
    448 
    449 //    DrawRaDec(color, img, 37.953, 89.2641, 10);
    450 }
    451 
    452 
    453 void StarCatalog::SetMjd(const double mjd)
    454 {
    455     fMjd   = mjd;
    456     fAlpha = slaGmst(mjd) + fElong;
    457 
    458     cout << "UTC: " << mjd << endl;
    459 
    460     //
    461     // ----- calculate star independent parameters ----------
    462     //
    463     slaMappa(2000.0, fMjd, fAmprms);
    464     slaAoppa(fMjd, 0,                // mjd, UT1-UTC
    465              fElong, fPhi, 148,      // g”ttingen long, lat, height
    466              0, 0,                   // polar motion x, y-coordinate (radians)
    467              273.155, 1013.25, 0.5,  // temp, pressure, humidity
    468              0.2, 0.0065,            // wavelength, tropo lapse rate
    469              fAoprms);
    470 
    471 }
    472 
    473 void StarCatalog::DrawCross(char *img, const int x, const int y)
     386}
     387
     388void StarCatalog::DrawCross(byte *img, const int x, const int y)
    474389{
    475390    for (int dx=-4; dx<5; dx++)
     
    480395}
    481396
    482 void StarCatalog::GetImg(char *img, char *cimg, const double utc,
     397void StarCatalog::GetImg(byte *img, byte *cimg, const double utc,
    483398                         const RaDec &radec)
    484399{
     
    486401    memset(cimg, 0, 768*576);
    487402
    488     SetMjd(utc);
    489 
    490     SetRaDec(radec, RaDec());
     403    sla.Set(utc);
     404    //fAlpha = sla.GetAlpha();
     405    SetRaDec(radec);
    491406
    492407    DrawSCAltAz(cimg, 2<<4);
     
    498413}
    499414
    500 void StarCatalog::GetImg(char *img, char *cimg, const double utc,
     415void StarCatalog::GetImg(byte *img, byte *cimg, const double utc,
    501416                         const AltAz &altaz)
    502417{
     
    504419    memset(cimg, 0, 768*576);
    505420
    506     SetMjd(utc);
    507 
     421    sla.Set(utc);
     422    //fAlpha = sla.GetAlpha();
    508423    SetAltAz(altaz);
    509424
     
    516431}
    517432
    518 void StarCatalog::DrawCircle(int color, char *img, int xx, int yy, int size)
     433void StarCatalog::DrawCircle(int color, byte *img, int xx, int yy, int size)
    519434{
    520435    for (int x=xx-size; x<xx+size+1; x++)
     
    537452}
    538453
    539 Bool_t StarCatalog::DrawAltAz(const int color, char *img, double alt, double az, int size)
     454Bool_t StarCatalog::DrawAltAz(const int color, byte *img, double alt, double az, int size)
    540455{
    541456    //
     
    571486}
    572487
    573 Bool_t StarCatalog::Draw(const int color, char *img, const AltAz &altaz)
     488Bool_t StarCatalog::Draw(const int color, byte *img, const AltAz &altaz)
    574489{
    575490    return DrawAltAz(color, img, altaz.Alt(), altaz.Az());
    576491}
    577492
    578 Bool_t StarCatalog::Draw(const int color, char *img, const SaoFile *sao)
     493Bool_t StarCatalog::Draw(const int color, byte *img, const SaoFile *sao)
    579494{
    580495    //
    581496    // ---- mean to observed ---
    582497    //
    583     AltAz altaz=RaDec2AltAz(sao->GetRaDec(), sao->GetRaDecPm()) * 360.0/D2PI;
     498    AltAz altaz=sla.CalcAltAz(sao->GetRaDec()) * 360.0/D2PI;
    584499
    585500    if (sao->MagV() > fLimitMag)
     
    594509}
    595510
    596 Bool_t StarCatalog::DrawRaDec(const int color, char *img, double ra, double dec, int size)
     511Bool_t StarCatalog::DrawRaDec(const int color, byte *img, double ra, double dec, int size)
    597512{
    598513    //
     
    605520    // radec[rad] -> hadec[rad]
    606521    //
    607     const double ha = fAlpha-ra;
     522    const double ha = sla.GetAlpha()-ra;
    608523
    609524    //
     
    611526    //
    612527    double alt, az;
    613     slaDe2h(ha, dec, fPhi, &az, &alt);
     528    slaDe2h(ha, dec, sla.GetPhi(), &az, &alt);
    614529
    615530    //
     
    622537}
    623538
    624 Bool_t StarCatalog::Draw(const int color, char *img, const RaDec &radec)
     539Bool_t StarCatalog::Draw(const int color, byte *img, const RaDec &radec)
    625540{
    626541    return DrawRaDec(color, img, radec.Ra(), radec.Dec());
    627542}
    628543
    629 void StarCatalog::CalcImg(char *img)
     544void StarCatalog::CalcImg(byte *img)
    630545{
    631546
  • trunk/MagicSoft/Cosy/catalog/StarCatalog.h

    r740 r808  
    88#include "SaoFile.h"
    99#endif
     10#ifndef SLALIB_H
     11#include "Slalib.h"
     12#endif
    1013
    1114#include "coord.h"
     15
     16typedef unsigned char byte;
    1217
    1318class StarCatalog
     
    1823    int      fEntries;
    1924
    20     double   fPhi;      // location of observatory
    21     double   fElong;
     25    Slalib   sla;
     26
     27//    double   fPhi;      // location of observatory
     28//    double   fElong;
    2229
    2330    double   fPixSize;  // [rad/pix] size of one pixel
     
    2835
    2936    AltAz    fAltAz;    // [rad]
    30     char     fAz0[360];
     37    byte     fAz0[360];
    3138    int      fAltMin;
    3239    int      fAltMax;
     
    3441
    3542    RaDec    fRaDec;    // [rad]
    36     char     fRa0[360];
     43    byte     fRa0[360];
    3744    int      fRaCnt;
    3845    int      fDecMin;
    3946    int      fDecMax;
    4047
    41     double   fAlpha;
    42     double   fMjd;
    43     double   fAmprms[21];
    44     double   fAoprms[14];
     48//    double   fAlpha;
     49//    double   fMjd;
     50//    double   fAmprms[21];
     51//    double   fAoprms[14];
    4552
    46     void DrawCross(char *img, const int x, const int y);
    47     void DrawCircle(int color, char *img, int xx, int yy, int size);
     53    void DrawCross(byte *img, const int x, const int y);
     54    void DrawCircle(int color, byte *img, int xx, int yy, int size);
    4855
    49     Bool_t DrawAltAz(const int color, char *img, double alt, double az, int size=0);
    50     Bool_t DrawRaDec(const int color, char *img, double ra,  double dec, int size=0);
     56    Bool_t DrawAltAz(const int color, byte *img, double alt, double az, int size=0);
     57    Bool_t DrawRaDec(const int color, byte *img, double ra,  double dec, int size=0);
    5158
    52     Bool_t Draw(const int color, char *img, const AltAz &altaz);
    53     Bool_t Draw(const int color, char *img, const RaDec &radec);
    54     Bool_t Draw(const int color, char *img, const SaoFile *sao);
     59    Bool_t Draw(const int color, byte *img, const AltAz &altaz);
     60    Bool_t Draw(const int color, byte *img, const RaDec &radec);
     61    Bool_t Draw(const int color, byte *img, const SaoFile *sao);
    5562
    56     void   CalcImg(char *);
     63    void   CalcImg(byte *);
    5764
     65    void   SetRaDec(const RaDec &radec);
    5866    void   SetAltAz(const AltAz &altaz);
    59     void   SetMjd(const double mjd);
    60     void   DrawSCAltAz(char *img, const int color);
    61     void   DrawSCRaDec(char *img, const int color);
    62     void   SetRaDec(const RaDec &radec, const RaDec &rdpm);
    63 
     67//    void   SetMjd(const double mjd);
     68    void   DrawSCAltAz(byte *img, const int color);
     69    void   DrawSCRaDec(byte *img, const int color);
     70 
    6471    void   CalcRaDecRange();
    6572    void   CalcAltAzRange();
    6673
    67     RaDec  AltAz2RaDec(const AltAz &altaz) const;
    68     AltAz  RaDec2AltAz(const RaDec &radec, const RaDec &rdpm) const;
     74//    RaDec  AltAz2RaDec(const AltAz &altaz) const;
     75//    AltAz  RaDec2AltAz(const RaDec &radec, const RaDec &rdpm) const;
    6976
    7077public:
     
    7279    virtual ~StarCatalog();
    7380
    74     void   GetImg(char *img, char *cimg, const double utc,
     81    void   GetImg(byte *img, byte *cimg, const double utc,
    7582                  const RaDec &radec);
    76     void   GetImg(char *img, char *cimg, const double utc,
     83    void   GetImg(byte *img, byte *cimg, const double utc,
    7784                  const AltAz &altaz);
    7885
Note: See TracChangeset for help on using the changeset viewer.