Index: trunk/MagicSoft/Cosy/catalog/StarCatalog.cc
===================================================================
--- trunk/MagicSoft/Cosy/catalog/StarCatalog.cc	(revision 748)
+++ trunk/MagicSoft/Cosy/catalog/StarCatalog.cc	(revision 808)
@@ -16,14 +16,4 @@
 
     //
-    // calculate observers location (goe)
-    //
-    int status;
-    slaDaf2r(51, 38, 48.0, &fPhi,   &status);
-    slaDaf2r( 9, 56, 36.0, &fElong, &status);
-
-    cout << "fPhi:   51ø38'48.0\" = " <<  360.0/D2PI*fPhi << endl;
-    cout << "fElong:  9ø56'36.0\" = " <<  360.0/D2PI*fElong << endl;
-
-    //
     // read index file
     //
@@ -78,5 +68,5 @@
     cout << "  Az: " << fAltAz.Az() << endl;
 
-    fRaDec = AltAz2RaDec(fAltAz);
+    fRaDec = sla.CalcRaDec(fAltAz);
 
     cout << "Ra: " << 360.0/D2PI*fRaDec.Ra();
@@ -87,65 +77,10 @@
 }
 
-RaDec StarCatalog::AltAz2RaDec(const AltAz &altaz) const
-{
-    //
-    // -- observed to apparent --
-    //  Workaraound for slalib: discard const
-    //
-    double r=0, d=0;
-    slaOapqk ("A", altaz.Az(), DPI/2-altaz.Alt(), (double*)fAoprms, &r, &d);
-
-    //
-    // -- apparent to mean --
-    //  Workaraound for slalib: discard const
-    //
-    double ra, dec;
-    slaAmpqk(r, d, (double*)fAmprms, &ra, &dec);
-
-    return RaDec(ra, dec);
-}
-
-AltAz StarCatalog::RaDec2AltAz(const RaDec &radec, const RaDec &rdpm) const
-{
-    //
-    // ---- Mean to apparent ----
-    //
-
-    double r=0, d=0;
-    slaMapqkz(radec.Ra(), radec.Dec(), (double*)fAmprms, &r, &d);
-    //
-    // Doesn't work - don't know why
-    //
-    //    slaMapqk (radec.Ra(), radec.Dec(), rdpm.Ra(), rdpm.Dec(),
-    //              0, 0, (double*)fAmprms, &r, &d);
-    //
-
-    //
-    // -- apparent to observed --
-    //
-    double r1=0;  // ra
-    double d1=0;  // dec
-    double h0=0;  // ha
-
-    double zd;
-    double az;
-    slaAopqk (r, d, (double*)fAoprms,
-              &az,    // observed azimuth (radians: N=0,E=90)
-              &zd,    // observed zenith distance (radians) [-pi/2, pi/2]
-              &h0,    // observed hour angle (radians)
-              &d1,    // observed declination (radians)
-              &r1);   // observed right ascension (radians)
-
-    return AltAz(DPI/2-zd, az);
-}
-
-void StarCatalog::SetRaDec(const RaDec &radec, const RaDec &rdpm)
+void StarCatalog::SetRaDec(const RaDec &radec)
 {
     fRaDec = radec;
     fRaDec *= D2PI/360.0;
 
-    RaDec pm = rdpm * D2PI/360.0;
-
-    fAltAz = RaDec2AltAz(fRaDec, pm);
+    fAltAz = sla.CalcAltAz(fRaDec);
 
     cout << "Alt: " << 360.0/D2PI*fAltAz.Alt() << "  ";
@@ -158,5 +93,5 @@
 void StarCatalog::CalcAltAzRange()
 {
-    char fAlt0[180];
+    byte fAlt0[180];
 
     for (int h=0; h<180; h++)
@@ -248,5 +183,5 @@
     // check whether altaz north- or south-pole is in the visible region
     //
-    char img[768*576];
+    byte img[768*576];
     if (DrawAltAz(0, img, 90, 0))
     {
@@ -263,4 +198,5 @@
     cout << "fAltMax: " << setw(3) << fAltMax << endl;
 }
+
 void StarCatalog::CalcRaDecRange()
 {
@@ -268,5 +204,5 @@
     // calculate range to search in
     //
-    char fDec[180];
+    byte fDec[180];
 
     for (int h=0; h<180; h++)
@@ -279,4 +215,6 @@
     double de0, de1;
 
+    const double phi   = sla.GetPhi();
+    const double alpha = sla.GetAlpha();
     //
     // scan horizontal border
@@ -286,10 +224,10 @@
         double dx, dy;
         slaDh2e(DPI-x*fPixSize, -fHeight, DPI/2-fAltAz.Alt(), &dx, &dy);
-        slaDh2e(fAltAz.Az()+dx, -dy, fPhi, &ha0, &de0);
+        slaDh2e(fAltAz.Az()+dx, -dy, phi, &ha0, &de0);
 
         slaDh2e(DPI-x*fPixSize, +fHeight, DPI/2-fAltAz.Alt(), &dx, &dy);
-        slaDh2e(fAltAz.Az()+dx, -dy, fPhi, &ha1, &de1);
-
-        const int h0 = ((int)(360.0/D2PI*(fAlpha-ha0))+360)%360;
+        slaDh2e(fAltAz.Az()+dx, -dy, phi, &ha1, &de1);
+
+        const int h0 = ((int)(360.0/D2PI*(alpha-ha0))+360)%360;
         const int d0 = (int)(360.0/D2PI*de0);
 
@@ -299,5 +237,5 @@
             fDec[d0+90] = kTRUE;
 
-        const int h1 = ((int)(360.0/D2PI*(fAlpha-ha1))+360)%360;
+        const int h1 = ((int)(360.0/D2PI*(alpha-ha1))+360)%360;
         const int d1 = (int)(360.0/D2PI*de1);
 
@@ -315,10 +253,10 @@
         double dx, dy;
         slaDh2e(DPI-fWidth, -y*fPixSize, DPI/2-fAltAz.Alt(), &dx, &dy);
-        slaDh2e(fAltAz.Az()+dx, -dy, fPhi, &ha0, &de0);
+        slaDh2e(fAltAz.Az()+dx, -dy, phi, &ha0, &de0);
 
         slaDh2e(DPI+fWidth, -y*fPixSize, DPI/2-fAltAz.Alt(), &dx, &dy);
-        slaDh2e(fAltAz.Az()+dx, -dy, fPhi, &ha1, &de1);
-
-        const int h0 = ((int)(360.0/D2PI*(fAlpha-ha0))+360)%360;
+        slaDh2e(fAltAz.Az()+dx, -dy, phi, &ha1, &de1);
+
+        const int h0 = ((int)(360.0/D2PI*(alpha-ha0))+360)%360;
         const int d0 = (int)(360.0/D2PI*de0);
 
@@ -328,5 +266,5 @@
             fDec[d0+90] = kTRUE;
 
-        const int h1 = ((int)(360.0/D2PI*(fAlpha-ha1))+360)%360;
+        const int h1 = ((int)(360.0/D2PI*(alpha-ha1))+360)%360;
         const int d1 = (int)(360.0/D2PI*de1);
 
@@ -364,5 +302,5 @@
     // check whether radec north- or south-pole is in the visible region
     //
-    char img[768*576];
+    byte img[768*576];
     if (DrawRaDec(0, img, 0, 90))
     {
@@ -380,5 +318,5 @@
 }
 
-void StarCatalog::DrawSCAltAz(char *img, const int color)
+void StarCatalog::DrawSCAltAz(byte *img, const int color)
 {
     //
@@ -414,5 +352,5 @@
 }
 
-void StarCatalog::DrawSCRaDec(char *img, const int color)
+void StarCatalog::DrawSCRaDec(byte *img, const int color)
 {
     //
@@ -446,30 +384,7 @@
         }
     }
-
-//    DrawRaDec(color, img, 37.953, 89.2641, 10);
-}
-
-
-void StarCatalog::SetMjd(const double mjd)
-{
-    fMjd   = mjd;
-    fAlpha = slaGmst(mjd) + fElong;
-
-    cout << "UTC: " << mjd << endl;
-
-    //
-    // ----- calculate star independent parameters ----------
-    //
-    slaMappa(2000.0, fMjd, fAmprms);
-    slaAoppa(fMjd, 0,                // mjd, UT1-UTC
-             fElong, fPhi, 148,      // gttingen long, lat, height
-             0, 0,                   // polar motion x, y-coordinate (radians)
-             273.155, 1013.25, 0.5,  // temp, pressure, humidity
-             0.2, 0.0065,            // wavelength, tropo lapse rate
-             fAoprms);
-
-}
-
-void StarCatalog::DrawCross(char *img, const int x, const int y)
+}
+
+void StarCatalog::DrawCross(byte *img, const int x, const int y)
 {
     for (int dx=-4; dx<5; dx++)
@@ -480,5 +395,5 @@
 }
 
-void StarCatalog::GetImg(char *img, char *cimg, const double utc,
+void StarCatalog::GetImg(byte *img, byte *cimg, const double utc,
                          const RaDec &radec)
 {
@@ -486,7 +401,7 @@
     memset(cimg, 0, 768*576);
 
-    SetMjd(utc);
-
-    SetRaDec(radec, RaDec());
+    sla.Set(utc);
+    //fAlpha = sla.GetAlpha();
+    SetRaDec(radec);
 
     DrawSCAltAz(cimg, 2<<4);
@@ -498,5 +413,5 @@
 }
 
-void StarCatalog::GetImg(char *img, char *cimg, const double utc,
+void StarCatalog::GetImg(byte *img, byte *cimg, const double utc,
                          const AltAz &altaz)
 {
@@ -504,6 +419,6 @@
     memset(cimg, 0, 768*576);
 
-    SetMjd(utc);
-
+    sla.Set(utc);
+    //fAlpha = sla.GetAlpha();
     SetAltAz(altaz);
 
@@ -516,5 +431,5 @@
 }
 
-void StarCatalog::DrawCircle(int color, char *img, int xx, int yy, int size)
+void StarCatalog::DrawCircle(int color, byte *img, int xx, int yy, int size)
 {
     for (int x=xx-size; x<xx+size+1; x++)
@@ -537,5 +452,5 @@
 }
 
-Bool_t StarCatalog::DrawAltAz(const int color, char *img, double alt, double az, int size)
+Bool_t StarCatalog::DrawAltAz(const int color, byte *img, double alt, double az, int size)
 {
     //
@@ -571,15 +486,15 @@
 }
 
-Bool_t StarCatalog::Draw(const int color, char *img, const AltAz &altaz)
+Bool_t StarCatalog::Draw(const int color, byte *img, const AltAz &altaz)
 {
     return DrawAltAz(color, img, altaz.Alt(), altaz.Az());
 }
 
-Bool_t StarCatalog::Draw(const int color, char *img, const SaoFile *sao)
+Bool_t StarCatalog::Draw(const int color, byte *img, const SaoFile *sao)
 {
     //
     // ---- mean to observed ---
     //
-    AltAz altaz=RaDec2AltAz(sao->GetRaDec(), sao->GetRaDecPm()) * 360.0/D2PI;
+    AltAz altaz=sla.CalcAltAz(sao->GetRaDec()) * 360.0/D2PI;
 
     if (sao->MagV() > fLimitMag)
@@ -594,5 +509,5 @@
 }
 
-Bool_t StarCatalog::DrawRaDec(const int color, char *img, double ra, double dec, int size)
+Bool_t StarCatalog::DrawRaDec(const int color, byte *img, double ra, double dec, int size)
 {
     //
@@ -605,5 +520,5 @@
     // radec[rad] -> hadec[rad]
     //
-    const double ha = fAlpha-ra;
+    const double ha = sla.GetAlpha()-ra;
 
     //
@@ -611,5 +526,5 @@
     //
     double alt, az;
-    slaDe2h(ha, dec, fPhi, &az, &alt);
+    slaDe2h(ha, dec, sla.GetPhi(), &az, &alt);
 
     //
@@ -622,10 +537,10 @@
 }
 
-Bool_t StarCatalog::Draw(const int color, char *img, const RaDec &radec)
+Bool_t StarCatalog::Draw(const int color, byte *img, const RaDec &radec)
 {
     return DrawRaDec(color, img, radec.Ra(), radec.Dec());
 }
 
-void StarCatalog::CalcImg(char *img)
+void StarCatalog::CalcImg(byte *img)
 {
 
Index: trunk/MagicSoft/Cosy/catalog/StarCatalog.h
===================================================================
--- trunk/MagicSoft/Cosy/catalog/StarCatalog.h	(revision 748)
+++ trunk/MagicSoft/Cosy/catalog/StarCatalog.h	(revision 808)
@@ -8,6 +8,11 @@
 #include "SaoFile.h"
 #endif
+#ifndef SLALIB_H
+#include "Slalib.h"
+#endif
 
 #include "coord.h"
+
+typedef unsigned char byte;
 
 class StarCatalog
@@ -18,6 +23,8 @@
     int      fEntries;
 
-    double   fPhi;      // location of observatory
-    double   fElong;
+    Slalib   sla;
+
+//    double   fPhi;      // location of observatory
+//    double   fElong;
 
     double   fPixSize;  // [rad/pix] size of one pixel
@@ -28,5 +35,5 @@
 
     AltAz    fAltAz;    // [rad]
-    char     fAz0[360];
+    byte     fAz0[360];
     int      fAltMin;
     int      fAltMax;
@@ -34,37 +41,37 @@
 
     RaDec    fRaDec;    // [rad]
-    char     fRa0[360];
+    byte     fRa0[360];
     int      fRaCnt;
     int      fDecMin;
     int      fDecMax;
 
-    double   fAlpha;
-    double   fMjd;
-    double   fAmprms[21];
-    double   fAoprms[14];
+//    double   fAlpha;
+//    double   fMjd;
+//    double   fAmprms[21];
+//    double   fAoprms[14];
 
-    void DrawCross(char *img, const int x, const int y);
-    void DrawCircle(int color, char *img, int xx, int yy, int size);
+    void DrawCross(byte *img, const int x, const int y);
+    void DrawCircle(int color, byte *img, int xx, int yy, int size);
 
-    Bool_t DrawAltAz(const int color, char *img, double alt, double az, int size=0);
-    Bool_t DrawRaDec(const int color, char *img, double ra,  double dec, int size=0);
+    Bool_t DrawAltAz(const int color, byte *img, double alt, double az,  int size=0);
+    Bool_t DrawRaDec(const int color, byte *img, double ra,  double dec, int size=0);
 
-    Bool_t Draw(const int color, char *img, const AltAz &altaz);
-    Bool_t Draw(const int color, char *img, const RaDec &radec);
-    Bool_t Draw(const int color, char *img, const SaoFile *sao);
+    Bool_t Draw(const int color, byte *img, const AltAz &altaz);
+    Bool_t Draw(const int color, byte *img, const RaDec &radec);
+    Bool_t Draw(const int color, byte *img, const SaoFile *sao);
 
-    void   CalcImg(char *);
+    void   CalcImg(byte *);
 
+    void   SetRaDec(const RaDec &radec);
     void   SetAltAz(const AltAz &altaz);
-    void   SetMjd(const double mjd);
-    void   DrawSCAltAz(char *img, const int color);
-    void   DrawSCRaDec(char *img, const int color);
-    void   SetRaDec(const RaDec &radec, const RaDec &rdpm);
-
+//    void   SetMjd(const double mjd);
+    void   DrawSCAltAz(byte *img, const int color);
+    void   DrawSCRaDec(byte *img, const int color);
+  
     void   CalcRaDecRange();
     void   CalcAltAzRange();
 
-    RaDec  AltAz2RaDec(const AltAz &altaz) const;
-    AltAz  RaDec2AltAz(const RaDec &radec, const RaDec &rdpm) const;
+//    RaDec  AltAz2RaDec(const AltAz &altaz) const;
+//    AltAz  RaDec2AltAz(const RaDec &radec, const RaDec &rdpm) const;
 
 public:
@@ -72,7 +79,7 @@
     virtual ~StarCatalog();
 
-    void   GetImg(char *img, char *cimg, const double utc,
+    void   GetImg(byte *img, byte *cimg, const double utc,
                   const RaDec &radec);
-    void   GetImg(char *img, char *cimg, const double utc,
+    void   GetImg(byte *img, byte *cimg, const double utc,
                   const AltAz &altaz);
 
