JPLFile Class Reference

JPL ephem file. More...

#include <orsa_file_jpl.h>

Collaboration diagram for JPLFile:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 JPLFile (std::string)
 ~JPLFile ()
bool GoodFile () const
void GetEph (const UniverseTypeAwareTime &date, JPL_planets target, JPL_planets center, Vector &position, Vector &velocity)
void GetEph (const UniverseTypeAwareTime &date, JPL_planets target, Vector &position, Vector &velocity)
const UniverseTypeAwareTimeEphemStart ()
const UniverseTypeAwareTimeEphemEnd ()
double GetMass (JPL_planets planet)
double GetAU_MKS ()
double GetMSun_MKS ()
double GetMJupiter_MKS ()
double GetMEarth_MKS ()
double GetMMoon_MKS ()
double GetC_MKS ()
double GetREarth_MKS ()
double GetRMoon_MKS ()
double GetTag (std::string)

Detailed Description

JPL ephem file.

Definition at line 100 of file orsa_file_jpl.h.


Constructor & Destructor Documentation

JPLFile std::string   ) 
 

Definition at line 52 of file orsa_file_jpl.cc.

References JPLFile::GetTag(), ORSA_ERROR, and orsa::remove_leading_trailing_spaces().

00052                               : calc_velocity(true) {
00053     
00054     int N=0; // number of elements in nam[][6] and val[]
00055     const int max_N = 256;
00056     char nam[max_N][6];
00057     double val[max_N];
00058     
00059     // jpl_database = (jpl_eph_data *) jpl_init_ephemeris(name.c_str(),nam,val);
00060     jpl_database = (void *) jpl_init_ephemeris(name.c_str(),NULL,NULL);
00061     
00062     if (jpl_database != 0) {
00063       N = ((jpl_eph_data*)jpl_database)->ncon;
00064       if (N > max_N) {
00065         ORSA_ERROR("assumed max_N=%i is smaller than N=%i. Please recompile with a bigger max_N.",max_N,N);
00066         exit(0);
00067       }
00068       jpl_close_ephemeris((jpl_eph_data *)jpl_database);
00069       
00070       // jpl_database = (void *) jpl_init_ephemeris(name.c_str(),nam,val);
00071       jpl_database = (void *) jpl_init_ephemeris(name.c_str(),nam,val);
00072     }
00073     
00074     if (jpl_database==0) {
00075       ORSA_ERROR("Can't open JPL ephemeris file [%s]",name.c_str());
00076       // exit is too much, should handle better this problem
00077       // exit(0);
00078       return;
00079     }
00080     
00081     // jpl_eph_data *jpldb = (jpl_eph_data *) jpl_database;
00082     // ephem_start.SetTime(FromUnits(jpldb->ephem_start,DAY));
00083     // ephem_end.SetTime(  FromUnits(jpldb->ephem_end,  DAY));
00084     
00085     bool_ephem_start_computed = bool_ephem_end_computed = false;  
00086     
00087     map_tag = new map<std::string,double>;
00088     
00089     // fill map_tag, DON'T REMOVE
00090     {
00091       string tag;
00092       char ctag[7];
00093       ctag[6] = 0;
00094       // cerr << "N: " << N << endl;
00095       for (int l = 0; l < N; l ++) {
00096         memcpy(ctag, nam[l], 6);
00097         tag = ctag;
00098         remove_leading_trailing_spaces(tag);
00099         (*map_tag)[tag] = val[l];
00100 #if 0
00101         printf(" [l=%03i][%s] = %20.12e\n",l,tag.c_str(),val[l]);
00102         printf(" map_tag[%s] = %20.12e\n",tag.c_str(),(*map_tag)[tag]);
00103         printf(" map_tag[%s] = %20.12e\n",tag.c_str(),GetTag(tag));
00104 #endif
00105       } 
00106     } 
00107   }

Here is the call graph for this function:

~JPLFile  ) 
 

Definition at line 109 of file orsa_file_jpl.cc.

00109                     {
00110     if (jpl_database != 0) jpl_close_ephemeris((jpl_eph_data *)jpl_database);
00111     if (map_tag) delete map_tag;
00112   }


Member Function Documentation

const UniverseTypeAwareTime & EphemEnd  ) 
 

Definition at line 119 of file orsa_file_jpl.cc.

Referenced by JPLFile::GetEph(), and orsa::SetupSolarSystem().

00119                                                   {
00120     if (!bool_ephem_end_computed) ComputeEphemEnd();
00121     return ephem_end;
00122   }

const UniverseTypeAwareTime & EphemStart  ) 
 

Definition at line 114 of file orsa_file_jpl.cc.

Referenced by JPLFile::GetEph(), and orsa::SetupSolarSystem().

00114                                                     {
00115     if (!bool_ephem_start_computed) ComputeEphemStart();
00116     return ephem_start;
00117   }

double GetAU_MKS  ) 
 

Definition at line 136 of file orsa_file_jpl.cc.

References JPLFile::GetTag().

Referenced by JPLFile::GetMEarth_MKS(), JPLFile::GetMJupiter_MKS(), JPLFile::GetMMoon_MKS(), and JPLFile::GetMSun_MKS().

00136                             {
00137     return (GetTag("AU")*1.0e3);
00138   }

Here is the call graph for this function:

double GetC_MKS  ) 
 

Definition at line 176 of file orsa_file_jpl.cc.

References JPLFile::GetTag().

00176                            {
00177     return (GetTag("CLIGHT")*1.0e3);
00178   }

Here is the call graph for this function:

void GetEph const UniverseTypeAwareTime date,
JPL_planets  target,
Vector position,
Vector velocity
[inline]
 

Definition at line 113 of file orsa_file_jpl.h.

References JPLFile::GetEph().

00113                                                                                                                      {
00114       GetEph(date, target, default_ephem_center, position, velocity);       
00115     }

Here is the call graph for this function:

void GetEph const UniverseTypeAwareTime date,
JPL_planets  target,
JPL_planets  center,
Vector position,
Vector velocity
 

Definition at line 254 of file orsa_file_jpl.cc.

References orsa::AU, orsa::DAY, orsa::ECLIPTIC, JPLFile::EphemEnd(), JPLFile::EphemStart(), orsa::ET, orsa::FromUnits(), Angle::GetRad(), Universe::GetReferenceSystem(), orsa::LIBRATIONS, orsa::NUTATIONS, orsa::obleq_J2000(), ORSA_WARNING, and orsa::universe.

Referenced by JPLFile::GetEph(), JPLBody::JPLBody(), and JPLBody::SetEpoch().

00254                                                                                                                                        {
00255     double  xv[6];   
00256     
00257     jpl_eph_data * jpldb = (jpl_eph_data *) jpl_database;
00258     
00259     if ( (date < EphemStart()) ||
00260          (date > EphemEnd()) ) {
00261       ORSA_WARNING("requested time out of the jpl database range");
00262       return;
00263     }
00264     
00265     jpl_pleph(jpldb,date.GetDate().GetJulian(ET),target,center,xv,calc_velocity ? 1 : 0);
00266     
00267     if ((target==NUTATIONS) || 
00268         (target==LIBRATIONS)) {
00269       // no units correction needed, are radians
00270       position.Set(xv[0],xv[1],xv[2]);
00271       velocity.Set(xv[3],xv[4],xv[5]);
00272       return;
00273     }
00274     
00275     // position (from AU)
00276     xv[0] = FromUnits(xv[0],AU);
00277     xv[1] = FromUnits(xv[1],AU);
00278     xv[2] = FromUnits(xv[2],AU);
00279     //
00280     position.Set(xv[0],xv[1],xv[2]);
00281     
00282     if (calc_velocity) {
00283       // velocity (from AU/DAY)
00284       xv[3] = FromUnits(xv[3],AU);
00285       xv[4] = FromUnits(xv[4],AU);
00286       xv[5] = FromUnits(xv[5],AU);
00287       //
00288       xv[3] = FromUnits(xv[3],DAY,-1);
00289       xv[4] = FromUnits(xv[4],DAY,-1);
00290       xv[5] = FromUnits(xv[5],DAY,-1);
00291       //
00292       velocity.Set(xv[3],xv[4],xv[5]);
00293     }
00294     
00295     // THIS IS THE ONLY CORRECT ROTATION:
00296     // from mean equatorial J2000 (ICRF) to mean ecliptic J2000
00297     if (universe->GetReferenceSystem() == ECLIPTIC) {
00298       Angle obl = obleq_J2000();
00299       position.rotate(0.0,-obl.GetRad(),0.0);
00300       velocity.rotate(0.0,-obl.GetRad(),0.0);
00301     }
00302   }

Here is the call graph for this function:

double GetMass JPL_planets  planet  ) 
 

Definition at line 188 of file orsa_file_jpl.cc.

References orsa::AU, orsa::DAY, orsa::EARTH, orsa::EARTH_MOON_BARYCENTER, orsa::FromUnits(), orsa::GetG(), JPLFile::GetTag(), orsa::JUPITER, orsa::MARS, orsa::MERCURY, orsa::MOON, orsa::NEPTUNE, orsa::PLUTO, orsa::SATURN, orsa::SUN, orsa::URANUS, and orsa::VENUS.

Referenced by orsa::local_mass().

00188                                                   {
00189     
00190     // const double file_G = FromUnits( FromUnits( FromUnits(val[17],AU,3),MSUN,-1),DAY,-2);
00191     // cerr << "JPLFile::GetMass G=" << file_G << endl;
00192     
00193     // const double EMRAT = val[7]; // Earth/Moon mass ratio
00194     const double EMRAT = GetTag("EMRAT");
00195     
00196     double GM=0;
00197     
00198     switch(planet) {
00199     case MERCURY:
00200       GM = GetTag("GM1");
00201       break;
00202     case VENUS:
00203       GM = GetTag("GM2");
00204       break;
00205     case MARS:
00206       GM = GetTag("GM4");
00207       break;
00208     case JUPITER:
00209       GM = GetTag("GM5");
00210       break;
00211     case SATURN:
00212       GM = GetTag("GM6");
00213       break;
00214     case URANUS:
00215       GM = GetTag("GM7");
00216       break;
00217     case NEPTUNE: 
00218       GM = GetTag("GM8");
00219       break;
00220     case PLUTO:   
00221       GM = GetTag("GM9");
00222       break;
00223     case EARTH:
00224       GM = GetTag("GMB")*EMRAT/(1+EMRAT);
00225       break;
00226     case MOON:
00227       GM = GetTag("GMB")/(1+EMRAT);
00228       break;
00229     case EARTH_MOON_BARYCENTER:
00230       GM = GetTag("GMB");
00231       break;
00232     case SUN:
00233       GM = GetTag("GMS");
00234       break;
00235     default:
00236       GM = 0;
00237       break;
00238     }
00239     //
00240     // take the right units
00241     GM = FromUnits(FromUnits(GM,AU,3),DAY,-2);
00242     
00243     // return (GM/file_G);
00244     return (GM/GetG());
00245   }

Here is the call graph for this function:

double GetMEarth_MKS  ) 
 

Definition at line 154 of file orsa_file_jpl.cc.

References JPLFile::GetAU_MKS(), orsa::GetG_MKS(), and JPLFile::GetTag().

00154                                 {
00155     // const double EMRAT = val[7]; // Earth/Moon mass ratio
00156     const double EMRAT = GetTag("EMRAT");
00157     // return ((val[10]*EMRAT/(1+EMRAT))*pow(AU_MKS,3)*pow(24*3600.0,-2)/G_MKS);
00158     // return ((GetTag("GMB")*EMRAT/(1+EMRAT))*pow(AU_MKS,3.0)*pow(24*3600.0,-2.0)/G_MKS);
00159     // return ((GetTag("GMB")*EMRAT/(1+EMRAT))*secure_pow(GetAU_MKS(),3.0)*secure_pow(24*3600.0,-2.0)/GetG_MKS());
00160     const double au_mks = GetAU_MKS();
00161     const double day_to_second = 24*3600.0;
00162     return ((GetTag("GMB")*EMRAT/(1+EMRAT))*(au_mks*au_mks*au_mks)/(day_to_second*day_to_second)/GetG_MKS());
00163   }

Here is the call graph for this function:

double GetMJupiter_MKS  ) 
 

Definition at line 147 of file orsa_file_jpl.cc.

References JPLFile::GetAU_MKS(), orsa::GetG_MKS(), and JPLFile::GetTag().

00147                                   {
00148     // return (GetTag("GM5")*secure_pow(GetAU_MKS(),3.0)*secure_pow(24*3600.0,-2.0)/GetG_MKS());
00149     const double au_mks = GetAU_MKS();
00150     const double day_to_second = 24*3600.0;
00151     return (GetTag("GM5")*(au_mks*au_mks*au_mks)/(day_to_second*day_to_second)/GetG_MKS());
00152   }

Here is the call graph for this function:

double GetMMoon_MKS  ) 
 

Definition at line 165 of file orsa_file_jpl.cc.

References JPLFile::GetAU_MKS(), orsa::GetG_MKS(), and JPLFile::GetTag().

00165                                {
00166     // const double EMRAT = val[7]; // Earth/Moon mass ratio
00167     const double EMRAT = GetTag("EMRAT");
00168     // return ((val[10]/(1+EMRAT))*pow(AU_MKS,3)*pow(24*3600.0,-2)/G_MKS);
00169     // return ((GetTag("GMB")/(1+EMRAT))*pow(AU_MKS,3.0)*pow(24*3600.0,-2.0)/G_MKS);
00170     // return ((GetTag("GMB")/(1+EMRAT))*secure_pow(GetAU_MKS(),3.0)*secure_pow(24*3600.0,-2.0)/GetG_MKS());
00171     const double au_mks = GetAU_MKS();
00172     const double day_to_second = 24*3600.0;
00173     return ((GetTag("GMB")/(1+EMRAT))*(au_mks*au_mks*au_mks)/(day_to_second*day_to_second)/GetG_MKS());
00174   }

Here is the call graph for this function:

double GetMSun_MKS  ) 
 

Definition at line 140 of file orsa_file_jpl.cc.

References JPLFile::GetAU_MKS(), orsa::GetG_MKS(), and JPLFile::GetTag().

00140                               {
00141     //return (GetTag("GMS")*secure_pow(GetAU_MKS(),3.0)*secure_pow(24*3600.0,-2.0)/GetG_MKS());
00142     const double au_mks = GetAU_MKS();
00143     const double day_to_second = 24*3600.0;
00144     return (GetTag("GMS")*(au_mks*au_mks*au_mks)/(day_to_second*day_to_second)/GetG_MKS());
00145   }

Here is the call graph for this function:

double GetREarth_MKS  ) 
 

Definition at line 180 of file orsa_file_jpl.cc.

References JPLFile::GetTag().

00180                                 {
00181     return (GetTag("RE")*1.0e3);
00182   }

Here is the call graph for this function:

double GetRMoon_MKS  ) 
 

Definition at line 184 of file orsa_file_jpl.cc.

References JPLFile::GetTag().

00184                                {
00185     return (GetTag("AM")*1.0e3);
00186   }

Here is the call graph for this function:

double GetTag std::string   ) 
 

Definition at line 247 of file orsa_file_jpl.cc.

References orsa::remove_leading_trailing_spaces().

Referenced by JPLFile::GetAU_MKS(), JPLFile::GetC_MKS(), JPLFile::GetMass(), JPLFile::GetMEarth_MKS(), JPLFile::GetMJupiter_MKS(), JPLFile::GetMMoon_MKS(), JPLFile::GetMSun_MKS(), JPLFile::GetREarth_MKS(), JPLFile::GetRMoon_MKS(), JPLFile::JPLFile(), orsa::local_C22(), orsa::local_C31(), orsa::local_C32(), orsa::local_C33(), orsa::local_C41(), orsa::local_C42(), orsa::local_C43(), orsa::local_C44(), orsa::local_J2(), orsa::local_J3(), orsa::local_J4(), orsa::local_S31(), orsa::local_S32(), orsa::local_S33(), orsa::local_S41(), orsa::local_S42(), orsa::local_S43(), and orsa::local_S44().

00247                                    {
00248     remove_leading_trailing_spaces(tag);
00249     return (*map_tag)[tag];
00250   }

Here is the call graph for this function:

bool GoodFile  )  const [inline]
 

Definition at line 107 of file orsa_file_jpl.h.

00107                           {
00108       return (jpl_database != 0);
00109     }


The documentation for this class was generated from the following files:
Generated on Tue Jan 11 15:29:00 2005 for liborsa by  doxygen 1.4.0