[Kstars-devel] KDE/kdeedu/kstars/kstars

Akarsh Simha akarshsimha at gmail.com
Wed Jan 14 16:25:42 CET 2009


SVN commit 910996 by asimha:

+ Adding support for comet magnitudes.  

KStars can now pick up H and G parameters (absolute magnitude and
slope parameter) from the comets.dat file if present, and use them to
calculate the magnitude of comets.


+ Fixing formula for comet and asteroid magnitudes

The formula used earlier was applicable only to 2P/Encke and was not
general, and I had mistakenly put that in. Now using the generic
formula.

CCMAIL: kstars-devel at kde.org



 M  +4 -2      kscomet.cpp  
 M  +18 -3     kscomet.h  
 M  +17 -11    ksplanetbase.cpp  
 M  +10 -1     skycomponents/cometscomponent.cpp  
 M  +2 -0      skycomponents/cometscomponent.h  


--- trunk/KDE/kdeedu/kstars/kstars/kscomet.cpp #910995:910996
@@ -25,8 +25,8 @@
 #include "dms.h"
 
 KSComet::KSComet( KStarsData *_kd, const QString &_s, const QString &imfile,
-                  long double _JD, double _q, double _e, dms _i, dms _w, dms _Node, double Tp )
-        : KSPlanetBase(_kd, _s, imfile), kd(_kd), JD(_JD), q(_q), e(_e), i(_i), w(_w), N(_Node) {
+                  long double _JD, double _q, double _e, dms _i, dms _w, dms _Node, double Tp, float _H, float _G )
+    : KSPlanetBase(_kd, _s, imfile), kd(_kd), JD(_JD), q(_q), e(_e), i(_i), w(_w), N(_Node), H(_H), G(_G) {
     setType( 9 ); //Comet
 
     //Find the Julian Day of Perihelion from Tp
@@ -63,6 +63,8 @@
     JDp = o.getPerihelionJD();
     a = q/(1.0 - e);
     P = 365.2568984 * pow(a, 1.5);
+    H = o.getAbsoluteMagnitude();
+    G = o.getSlopeParameter();
     setLongName( o.name2() );
 }    
 
--- trunk/KDE/kdeedu/kstars/kstars/kscomet.h #910995:910996
@@ -35,9 +35,11 @@
 	*@li w     argument of perihelion (w.r.t. J2000.0 ecliptic plane)
 	*@li N     longitude of ascending node (J2000.0 ecliptic)
 	*@li Tp    time of perihelion passage (YYYYMMDD.DDD)
+        *@li H     absolute magnitude
+        *@li G     slope parameter
 	*
 	*@author Jason Harris
-	*@version 1.0
+	*@version 1.1
 	*/
 
 class KStarsData;
@@ -58,10 +60,12 @@
     	*@param w the argument of the orbit's perihelion
     	*@param N the longitude of the orbit's ascending node
     	*@param Tp The date of the most proximate perihelion passage (YYYYMMDD.DDD)
+        *@param H the absolute magnitude
+        *@param G the slope parameter
     	*/
     KSComet( KStarsData *kd, const QString &s, const QString &image_file,
-             long double JD, double q, double e, dms i, dms w, dms N, double Tp );
-
+             long double JD, double q, double e, dms i, dms w, dms N, double Tp, float H, float G );
+    
     /**
      *Copy Constructor
      *@param o  Object to copy into this
@@ -97,7 +101,17 @@
      */
     inline long double getPerihelionJD() { return JDp; }
 
+    /**
+     *@return the slope parameter
+     */
+    inline float getSlopeParameter() { return G; }
 
+    /**
+     *@return the absolute magnitude
+     */
+    inline float getAbsoluteMagnitude() { return H; }
+
+
 protected:
     /**Calculate the geocentric RA, Dec coordinates of the Comet.
     	*@note reimplemented from KSPlanetBase
@@ -111,6 +125,7 @@
     KStarsData *kd;
     long double JD, JDp;
     double q, e, a, P;
+    float H, G;
     dms i, w, N;
 
 };
--- trunk/KDE/kdeedu/kstars/kstars/ksplanetbase.cpp #910995:910996
@@ -29,6 +29,7 @@
 #include "Options.h"
 #include "skymap.h"
 #include "ksasteroid.h"
+#include "kscomet.h"
 #include "kspluto.h"
 #include "ksplanet.h"
 #include "kssun.h"
@@ -141,7 +142,7 @@
         if ( Trail.size() > MAXTRAIL ) Trail.takeFirst();
     }
 
-    if ( isMajorPlanet() || type() == SkyObject::ASTEROID )
+    if ( isMajorPlanet() || type() == SkyObject::ASTEROID || type() == SkyObject::COMET )
         findMagnitude(num);
 }
 
@@ -338,17 +339,22 @@
     if( name() == i18n( "Pluto" ) )
         magnitude = -1.01 + param + 0.041*phase;
 
-    if( type() == SkyObject::ASTEROID ) {
-        // Asteroid
-        KSAsteroid *me = (KSAsteroid *)this;
-        double phi1 = exp( -3.33 * pow(tan(phase_rad/2), 0.63) );
-        double phi2 = exp( -1.87 * pow(tan(phase_rad/2), 1.22) );
+    if( type() == SkyObject::ASTEROID || type() == SkyObject::COMET ) {
+        // Asteroid or Comet
         double H, G;
-        H = me -> getAbsoluteMagnitude();
-        G = me -> getSlopeParameter();
-        magnitude = H + param - 2.5 * log10( (1 - G) * phi1 + G * phi2 );
+        if( type() == SkyObject::ASTEROID ) {
+            KSAsteroid *me = (KSAsteroid *)this;
+            H = me -> getAbsoluteMagnitude();
+            G = me -> getSlopeParameter();
+        }
+        else {
+            KSComet *me = (KSComet *) this;
+            H = me -> getAbsoluteMagnitude();
+            G = me -> getSlopeParameter();
+        }
+        if( H > -100.0 && G > -100.0 ) {
+            magnitude = H + 5 * log10( rearth() ) + 2.5 * G * log10( rsun() );
+        }
     }
-    
     setMag(magnitude);
 }
-
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/cometscomponent.cpp #910995:910996
@@ -51,6 +51,8 @@
             QString line, name;
             int mJD;
             double q, e, dble_i, dble_w, dble_N, Tp;
+            float H, G;
+            bool ok;
             long double JD;
             KSComet *com = 0;
 
@@ -65,9 +67,16 @@
             dble_N = line.mid( 86, 9 ).toDouble();
             Tp = line.mid( 96, 14 ).toDouble();
 
+            // Read the Absolute Magnitude (H) and Slope Parameter (G).
+            // These might not be available in the data file always and we must be open to that fact
+            H = line.mid( 124, 4 ).toFloat( &ok );
+            if( !ok ) H = -101.0; // Any absolute mag brighter than -100 should be treated as nonsense
+            G = line.mid( 129, 4 ).toFloat( &ok );
+            if( !ok ) G = -101.0; // Same with slope parameter.
+
             JD = double( mJD ) + 2400000.5;
 
-            com = new KSComet( data, name, QString(), JD, q, e, dms(dble_i), dms(dble_w), dms(dble_N), Tp );
+            com = new KSComet( data, name, QString(), JD, q, e, dms(dble_i), dms(dble_w), dms(dble_N), Tp, H, G );
             com->setAngularSize( 0.005 );
 
             objectList().append( com );
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/cometscomponent.h #910995:910996
@@ -69,6 +69,8 @@
     	*@li 76-84 argument of perihelion in degrees [double]
     	*@li 86-94 Longitude of the Ascending Node in degrees [double]
     	*@li 82-93 Date of most proximate perihelion passage (YYYYMMDD.DDD) [double]
+        *@li 124-127 Absolute magnitude [float]
+        *@li 129-132 Slope parameter [float]
         *
         *@note See KSComet constructor for more details.
     	*/


More information about the Kstars-devel mailing list