[Kstars-devel] Asteroid magnitudes

Akarsh Simha akarshsimha at gmail.com
Tue Dec 18 16:20:07 CET 2007


Hi all

Please find a patch attached that fixes asteroid magnitudes.

The magnitude set to the absolute magnitude for asteroids directly.

The modified version uses a formula for comet nuclei described here
on Seichii Yoshida's site:
http://www.aerith.net/astro/Encke-nucleus.html
which relates the magnitude to phase, and "orbital" elements
H (Absolute Magnitude) and G (Slope Parameter).

The patch retrieves 'G' from the data files (which was not used earlier)
and also defines a modified constructor in KSAsteroid which accepts
the slope parameter in addition. It also adds a bit to ksplanetbase.cpp
which implements the magnitude calculations for asteroids.

The estimates are not very good, but they are reasonable. While the
SB What's Observable site (http://ssd.jpl.nasa.gov/sbwobs.cgi) puts Ceres
and Vesta at 7.93 and 7.97 respectively, and KStars with the patch puts it
at 8.3 and 7.9 respectively.

Regards
Akarsh.
-------------- next part --------------
Index: kstars/ksasteroid.cpp
===================================================================
--- kstars/ksasteroid.cpp	(revision 750025)
+++ kstars/ksasteroid.cpp	(working copy)
@@ -26,10 +26,17 @@
 
 KSAsteroid::KSAsteroid( KStarsData *_kd, const QString &s, const QString &imfile,
                         long double _JD, double _a, double _e, dms _i, dms _w, dms _Node, dms _M, double _H )
-        : KSPlanetBase(_kd, s, imfile), kd(_kd), JD(_JD), a(_a), e(_e), H(_H), i(_i), w(_w), M(_M), N(_Node) {
+	: KSPlanetBase(_kd, s, imfile), kd(_kd), JD(_JD), a(_a), e(_e), H(_H), i(_i), w(_w), M(_M), N(_Node) {
+    KSAsteroid(_kd, s, imfile, _JD, _a, _e, _i, _w, _Node, _M, _H, -1); // Set G to -1 - G can never be negative in reality.
+}
 
+KSAsteroid::KSAsteroid( KStarsData *_kd, const QString &s, const QString &imfile,
+                        long double _JD, double _a, double _e, dms _i, dms _w, dms _Node, dms _M, double _H, double _G )
+        : KSPlanetBase(_kd, s, imfile), kd(_kd), JD(_JD), a(_a), e(_e), H(_H), G(_G), i(_i), w(_w), M(_M), N(_Node) {
+
     setType( 10 ); //Asteroid
-    setMag( H );
+    this -> H = H;
+    this -> G = G;
     //Compute the orbital Period from Kepler's 3rd law:
     P = 365.2568984 * pow(a, 1.5); //period in days
 }
@@ -122,6 +129,7 @@
     return true;
 }
 
+
 //Unused virtual function from KSPlanetBase
 bool KSAsteroid::loadData() { return false; }
 
Index: kstars/ksplanetbase.h
===================================================================
--- kstars/ksplanetbase.h	(revision 750025)
+++ kstars/ksplanetbase.h	(working copy)
@@ -324,8 +324,6 @@
      *@short Computes the visual magnitude for the major planets.
      *@param num pointer to a ksnumbers object. Needed for the saturn rings contribution to 
      *           saturn's magnitude.
-     *@param Earth pointer to an Earth object. Needed to know the distance between the Earth and the
-     *             Sun.
      */
     void findMagnitude(const KSNumbers *num);
 
Index: kstars/skycomponents/asteroidscomponent.cpp
===================================================================
--- kstars/skycomponents/asteroidscomponent.cpp	(revision 750025)
+++ kstars/skycomponents/asteroidscomponent.cpp	(working copy)
@@ -52,7 +52,7 @@
 
     QString line, name;
     int mJD;
-    double a, e, dble_i, dble_w, dble_N, dble_M, H;
+    double a, e, dble_i, dble_w, dble_N, dble_M, H, G;
     long double JD;
 
     KSFileReader fileReader;
@@ -73,11 +73,12 @@
         dble_N = line.mid( 72, 9 ).toDouble();
         dble_M = line.mid( 82, 11 ).toDouble();
         H = line.mid( 94, 5 ).toDouble();
+		G = line.mid( 102, 4 ).toDouble();
 
         JD = double( mJD ) + 2400000.5;
 
         ast = new KSAsteroid( data, name, QString(), JD, a, e, dms(dble_i),
-                              dms(dble_w), dms(dble_N), dms(dble_M), H );
+                              dms(dble_w), dms(dble_N), dms(dble_M), H, G );
         ast->setAngularSize( 0.005 );
         objectList().append( ast );
 
Index: kstars/ksplanetbase.cpp
===================================================================
--- kstars/ksplanetbase.cpp	(revision 750025)
+++ kstars/ksplanetbase.cpp	(working copy)
@@ -29,6 +29,7 @@
 #include "ksnumbers.h"
 #include "Options.h"
 #include "skymap.h"
+#include "ksasteroid.h"
 
 KSPlanetBase::KSPlanetBase( KStarsData *kd, const QString &s, 		const QString &image_file, const QColor &c, double pSize )
         : TrailObject( 2, 0.0, 0.0, 0.0, s ),
@@ -84,7 +85,7 @@
         if ( Trail.size() > MAXTRAIL ) Trail.takeFirst();
     }
 
-    if ( isMajorPlanet() )
+    if ( isMajorPlanet() || type() == 10 )
         findMagnitude(num);
 }
 
@@ -239,7 +240,8 @@
     double earthSun = 1.;
     double cosPhase = (rsun()*rsun() + rearth()*rearth() - earthSun*earthSun)
                       / (2 * rsun() * rearth() );
-    double phase = acos ( cosPhase ) * 180.0 / dms::PI;
+    double phase_rad = acos ( cosPhase ); // Phase in radian - used for asteroid magnitudes
+    double phase = phase_rad * 180.0 / dms::PI;
 
     /* Computation of the visual magnitude (V band) of the planet.
     * Algorithm provided by Pere Planesas (Observatorio Astronomico Nacional)
@@ -280,5 +282,17 @@
     if( name() == "Pluto" )
         magnitude = -1.01 + param + 0.041*phase;
 
+    if( type() == 10 ) {
+	// 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) );
+	double H, G;
+	H = me -> getAbsoluteMagnitude();
+	G = me -> getSlopeParameter();
+	magnitude = H + param - 2.5 * log10( (1 - G) * phi1 + G * phi2 );
+    }
+    
     setMag(magnitude);
 }
+
Index: kstars/ksasteroid.h
===================================================================
--- kstars/ksasteroid.h	(revision 750025)
+++ kstars/ksasteroid.h	(working copy)
@@ -36,6 +36,7 @@
 	*@li N     longitude of ascending node (J2000.0 ecliptic)
 	*@li M     mean anomaly at epoch JD
 	*@li H     absolute magnitude
+	*@li G     slope parameter
 	*
 	*@author Jason Harris
 	*@version 1.0
@@ -48,7 +49,9 @@
 class KSAsteroid : public KSPlanetBase
 {
 public:
+
     /**Constructor.
+	*@note For use by KSPluto, which inherits from this class. Sets the slope parameter to -1.
     	*@p kd pointer to the KStarsData object
     	*@p s the name of the asteroid
     	*@p image_file the filename for an image of the asteroid
@@ -62,7 +65,23 @@
     	*@p H absolute magnitude
     	*/
     KSAsteroid( KStarsData *kd, const QString &s, const QString &image_file,
-                long double JD, double a, double e, dms i, dms w, dms N, dms M, double H );
+                long double JD, double a, double e, dms i, dms w, dms N, dms M, double H);
+    /**Constructor.
+    	*@p kd pointer to the KStarsData object
+    	*@p s the name of the asteroid
+    	*@p image_file the filename for an image of the asteroid
+    	*@p JD the Julian Day for the orbital elements
+    	*@p a the semi-major axis of the asteroid's orbit (AU)
+    	*@p e the eccentricity of the asteroid's orbit
+    	*@p i the inclination angle of the asteroid's orbit
+    	*@p w the argument of the orbit's perihelion
+    	*@p N the longitude of the orbit's ascending node
+    	*@p M the mean anomaly for the Julian Day
+    	*@p H absolute magnitude
+	*@p G slope parameter
+    	*/
+    KSAsteroid( KStarsData *kd, const QString &s, const QString &image_file,
+                long double JD, double a, double e, dms i, dms w, dms N, dms M, double H, double G );
 
     /**Destructor (empty)*/
     virtual ~KSAsteroid() {}
@@ -72,6 +91,13 @@
     	*/
     virtual bool loadData();
 
+    /**This lets other classes like KSPlanetBase access H and G values
+	*Used by KSPlanetBase::FindMagnitude
+	*/
+    double inline getAbsoluteMagnitude() { return H; }
+    double inline getSlopeParameter() { return G; }
+   
+
 protected:
     /**Calculate the geocentric RA, Dec coordinates of the Asteroid.
     	*@note reimplemented from KSPlanetBase
@@ -94,8 +120,9 @@
 private:
     KStarsData *kd;
     long double JD;
-    double a, e, H, P;
+    double a, e, P;
     dms i, w, M, N;
+    double H, G;
 };
 
 #endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.kde.org/pipermail/kstars-devel/attachments/20071218/dad83e8e/attachment.pgp 


More information about the Kstars-devel mailing list