Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

buildstardb.cpp File Reference

#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <assert.h>
#include "stardb.h"

Include dependency graph for buildstardb.cpp:

Go to the source code of this file.

Typedefs

typedef map< uint32, MultistarSystem * > MultistarSystemCatalog

Functions

template<class T>
void binwrite (ostream &out, T x)
void BuildMultistarSystemCatalog ()
static string ComponentDatabaseFile ("h_dm_com.dat")
void ConstrainComponentParallaxes ()
void CorrectErrors ()
void CreateCompanionList ()
HipparcosStarfindStar (uint32 hip)
StellarClass guessSpectralType (float colorIndex, float absMag)
int main (int argc, char *argv[])
static string MainDatabaseFile ("hip_main.dat")
bool operator< (const HipparcosStar &a, const HipparcosStar &b)
static string OrbitalDatabase ("hip_dm_o.dat")
StellarClass ParseStellarClass (char *starType)
bool ReadComponentRecord (istream &in)
bool ReadStarRecord (istream &in)
void ShowStarsWithComponents ()
HipparcosStar TheSun ()

Variables

vector< HipparcosStarcompanions
vector< HipparcosComponentcomponents
static const int HipComponentRecordLength = 239
static const int HipStarRecordLength = 451
static uint32 NullCatalogNumber = 0xffffffff
static uint32 NullCCDMIdentifier = 0xffffffff
vector< HipparcosStar * > starIndex
vector< HipparcosStarstars
MultistarSystemCatalog starSystems


Typedef Documentation

typedef map<uint32, MultistarSystem*> MultistarSystemCatalog
 

Definition at line 162 of file buildstardb.cpp.


Function Documentation

template<class T>
void binwrite ostream &  out,
x
 

Definition at line 69 of file buildstardb.cpp.

Referenced by main(), and HipparcosStar::write().

00070 {
00071     out.write(reinterpret_cast<char*>(&x), sizeof(T));
00072 }

void BuildMultistarSystemCatalog  ) 
 

Definition at line 504 of file buildstardb.cpp.

References MultistarSystem::nStars, NullCCDMIdentifier, MultistarSystem::stars, stars, and starSystems.

Referenced by main().

00505 {
00506     for (vector<HipparcosStar>::iterator iter = stars.begin();
00507          iter != stars.end(); iter++)
00508     {
00509         if (iter->CCDMIdentifier != NullCCDMIdentifier)
00510         {
00511             MultistarSystemCatalog::iterator it =
00512                 starSystems.find(iter->CCDMIdentifier);
00513             if (it == starSystems.end())
00514             {
00515                 MultistarSystem* multiSystem = new MultistarSystem();
00516                 multiSystem->nStars = 1;
00517                 multiSystem->stars[0] = iter;
00518                 starSystems.insert(MultistarSystemCatalog::value_type(iter->CCDMIdentifier, multiSystem));
00519             }
00520             else
00521             {
00522                 MultistarSystem* multiSystem = it->second;
00523                 if (multiSystem->nStars == 4)
00524                 {
00525                     cout << "Number of stars in system exceeds 4\n";
00526                 }
00527                 else
00528                 {
00529                     multiSystem->stars[multiSystem->nStars] = iter;
00530                     multiSystem->nStars++;
00531                 }
00532             }
00533         }
00534     }
00535 }

static string ComponentDatabaseFile "h_dm_com.dat"   )  [static]
 

Referenced by main().

void ConstrainComponentParallaxes  ) 
 

Definition at line 591 of file buildstardb.cpp.

References HipparcosStar::HDCatalogNumber, HipparcosStar::HIPCatalogNumber, MultistarSystem::nStars, NullCatalogNumber, HipparcosStar::parallax, MultistarSystem::stars, and starSystems.

Referenced by main().

00592 {
00593     for (MultistarSystemCatalog::iterator iter = starSystems.begin();
00594          iter != starSystems.end(); iter++)
00595     {
00596         MultistarSystem* multiSystem = iter->second;
00597         if (multiSystem->nStars > 1)
00598         {
00599             for (int i = 1; i < multiSystem->nStars; i++)
00600                 multiSystem->stars[i]->parallax = multiSystem->stars[0]->parallax;
00601         }
00602 #if 0
00603         if (multiSystem->nStars > 2)
00604         {
00605             cout << multiSystem->nStars << ": ";
00606             if (multiSystem->stars[0]->HDCatalogNumber != NullCatalogNumber)
00607                 cout << "HD " << multiSystem->stars[0]->HDCatalogNumber;
00608             else
00609                 cout << "HIP " << multiSystem->stars[0]->HIPCatalogNumber;
00610             cout << '\n';
00611         }
00612 #endif
00613     }
00614 }

void CorrectErrors  ) 
 

Definition at line 617 of file buildstardb.cpp.

References stars, and HipparcosStar::stellarClass.

Referenced by main().

00618 {
00619     for (vector<HipparcosStar>::iterator iter = stars.begin();
00620          iter != stars.end(); iter++)
00621     {
00622         // Fix the spectral class of Capella, listed for some reason
00623         // as M1 in the database.
00624         if (iter->HDCatalogNumber == 34029)
00625         {
00626             iter->stellarClass = StellarClass(StellarClass::NormalStar,
00627                                               StellarClass::Spectral_G, 0,
00628                                               StellarClass::Lum_III);
00629         }
00630     }
00631 }

void CreateCompanionList  ) 
 

Definition at line 636 of file buildstardb.cpp.

References HipparcosStar::appMag, HipparcosStar::ascension, HipparcosStar::CCDMIdentifier, companions, components, HipparcosStar::declination, guessSpectralType(), HipparcosStar::HDCatalogNumber, HipparcosStar::HIPCatalogNumber, NullCatalogNumber, HipparcosStar::parallax, HipparcosStar::parallaxError, and HipparcosStar::stellarClass.

00637 {
00638     for (vector<HipparcosComponent>::iterator iter = components.begin();
00639          iter != components.end(); iter++)
00640     {
00641         // Don't insert the reference component, as this star should already
00642         // be in the primary database.
00643         if (iter->componentID != iter->refComponentID)
00644         {
00645             int componentNumber = iter->componentID - 'A';
00646             if (componentNumber > 0 && componentNumber < 8)
00647             {
00648                 HipparcosStar star;
00649 
00650                 star.HDCatalogNumber = NullCatalogNumber;
00651                 star.HIPCatalogNumber = iter->star->HIPCatalogNumber | 
00652                     (componentNumber << 25);
00653 
00654                 star.ascension = iter->ascension;
00655                 star.declination = iter->declination;
00656                 star.parallax = iter->star->parallax;
00657                 star.appMag = iter->appMag;
00658                 if (iter->hasBV)
00659                     star.stellarClass = guessSpectralType(iter->bMag - iter->vMag, 0.0f);
00660                 else
00661                     star.stellarClass = StellarClass(StellarClass::NormalStar,
00662                                                      StellarClass::Spectral_Unknown,
00663                                                      0, StellarClass::Lum_V);
00664 
00665                 star.CCDMIdentifier = iter->star->CCDMIdentifier;
00666                 star.parallaxError = iter->star->parallaxError;
00667 
00668                 companions.insert(companions.end(), star);
00669             }
00670         }
00671     }
00672 }

HipparcosStar* findStar uint32  hip  ) 
 

Definition at line 166 of file buildstardb.cpp.

References HipparcosStar::HIPCatalogNumber, and starIndex.

Referenced by ReadComponentRecord().

00167 {
00168     HIPCatalogComparePredicate pred;
00169 
00170     vector<HipparcosStar*>::iterator iter = lower_bound(starIndex.begin(),
00171                                                         starIndex.end(),
00172                                                         hip, pred);
00173     if (iter == starIndex.end())
00174         return NULL;
00175     HipparcosStar* star = *iter;
00176     if (star->HIPCatalogNumber == hip)
00177         return star;
00178     else
00179         return NULL;
00180 }

StellarClass guessSpectralType float  colorIndex,
float  absMag
 

Definition at line 538 of file buildstardb.cpp.

Referenced by CreateCompanionList().

00539 {
00540     StellarClass::SpectralClass specClass = StellarClass::Spectral_Unknown;
00541     float subclass = 0.0f;
00542 
00543     if (colorIndex < -0.25f)
00544     {
00545         specClass = StellarClass::Spectral_O;
00546         subclass = (colorIndex + 0.5f) / 0.25f;
00547     }
00548     else if (colorIndex < 0.0f)
00549     {
00550         specClass = StellarClass::Spectral_B;
00551         subclass = (colorIndex + 0.25f) / 0.25f;
00552     }
00553     else if (colorIndex < 0.25f)
00554     {
00555         specClass = StellarClass::Spectral_A;
00556         subclass = (colorIndex - 0.0f) / 0.25f;
00557     }
00558     else if (colorIndex < 0.6f)
00559     {
00560         specClass = StellarClass::Spectral_F;
00561         subclass = (colorIndex - 0.25f) / 0.35f;
00562     }
00563     else if (colorIndex < 0.85f)
00564     {
00565         specClass = StellarClass::Spectral_G;
00566         subclass = (colorIndex - 0.6f) / 0.25f;
00567     }
00568     else if (colorIndex < 1.4f)
00569     {
00570         specClass = StellarClass::Spectral_K;
00571         subclass = (colorIndex - 0.85f) / 0.55f;
00572     }
00573     else
00574     {
00575         specClass = StellarClass::Spectral_M;
00576         subclass = (colorIndex - 1.4f) / 1.0f;
00577     }
00578 
00579     if (subclass < 0.0f)
00580         subclass = 0.0f;
00581     else if (subclass > 1.0f)
00582         subclass = 1.0f;
00583 
00584     return StellarClass(StellarClass::NormalStar,
00585                         specClass,
00586                         (unsigned int) (subclass * 9.99f),
00587                         StellarClass::Lum_V);
00588 }

int main int  argc,
char *  argv[]
 

Definition at line 694 of file buildstardb.cpp.

References binwrite(), BuildMultistarSystemCatalog(), companions, ComponentDatabaseFile(), components, ConstrainComponentParallaxes(), CorrectErrors(), MainDatabaseFile(), NullCatalogNumber, ReadComponentRecord(), ReadStarRecord(), ShowStarsWithComponents(), starIndex, stars, starSystems, TheSun(), and HipparcosStar::write().

00695 {
00696     assert(sizeof(StellarClass) == 2);
00697 
00698     // Read star records from the primary HIPPARCOS catalog
00699     {
00700         ifstream mainDatabase(MainDatabaseFile.c_str(), ios::in | ios::binary);
00701         if (!mainDatabase.good())
00702         {
00703             cout << "Error opening " << MainDatabaseFile << '\n';
00704             exit(1);
00705         }
00706 
00707         cout << "Reading HIPPARCOS data set.\n";
00708         while (mainDatabase.good())
00709         {
00710             ReadStarRecord(mainDatabase);
00711             if (stars.size() % 10000 == 0)
00712                 cout << stars.size() << " records.\n";
00713         }
00714     }
00715     cout << "Read " << stars.size() << " stars from main database.\n";
00716 
00717     cout << "Adding the Sun...\n";
00718     stars.insert(stars.end(), TheSun());
00719 
00720     cout << "Sorting stars...\n";
00721     {
00722         starIndex.reserve(stars.size());
00723         for (vector<HipparcosStar>::iterator iter = stars.begin();
00724              iter != stars.end(); iter++)
00725         {
00726             starIndex.insert(starIndex.end(), iter);
00727         }
00728 
00729         HIPCatalogComparePredicate pred;
00730 
00731         // It may not even be necessary to sort the records, if the
00732         // HIPPARCOS catalog is strictly ordered by catalog number.  I'm not
00733         // sure about this however,
00734         random_shuffle(starIndex.begin(), starIndex.end());
00735         sort(starIndex.begin(), starIndex.end(), pred);
00736     }
00737         
00738     // Read component records
00739     {
00740         ifstream componentDatabase(ComponentDatabaseFile.c_str(),
00741                                    ios::in | ios::binary);
00742         if (!componentDatabase.good())
00743         {
00744             cout << "Error opening " << ComponentDatabaseFile << '\n';
00745             exit(1);
00746         }
00747 
00748         cout << "Reading HIPPARCOS component database.\n";
00749         while (componentDatabase.good())
00750         {
00751             ReadComponentRecord(componentDatabase);
00752         }
00753     }
00754     cout << "Read " << components.size() << " components.\n";
00755 
00756     {    
00757         int aComp = 0, bComp = 0, cComp = 0, dComp = 0, eComp = 0, otherComp = 0;
00758         int bvComp = 0;
00759         for (int i = 0; i < components.size(); i++)
00760         {
00761             switch (components[i].componentID)
00762             {
00763             case 'A':
00764                 aComp++; break;
00765             case 'B':
00766                 bComp++; break;
00767             case 'C':
00768                 cComp++; break;
00769             case 'D':
00770                 dComp++; break;
00771             case 'E':
00772                 eComp++; break;
00773             default:
00774                 otherComp++; break;
00775             }
00776             if (components[i].hasBV && components[i].componentID != 'A')
00777                 bvComp++;
00778         }
00779         
00780         cout << "A:" << aComp << "  B:" << bComp << "  C:" << cComp << "  D:" << dComp << "  E:" << eComp << '\n';
00781         cout << "Components with B-V mag: " << bvComp << '\n';
00782     }
00783 
00784     cout << "Building catalog of multiple star systems.\n";
00785     BuildMultistarSystemCatalog();
00786     
00787     int nMultipleSystems = starSystems.size();
00788     cout << "Stars in multiple star systems: " << nMultipleSystems << '\n';
00789 
00790     ConstrainComponentParallaxes();
00791 
00792     CorrectErrors();
00793 
00794     // CreateCompanionList();
00795     cout << "Companion stars: " << companions.size() << '\n';
00796     cout << "Total stars: " << stars.size() + companions.size() << '\n';
00797 
00798     ShowStarsWithComponents();
00799 
00800     char* outputFile = "stars.dat";
00801     if (argc > 1)
00802         outputFile = argv[1];
00803 
00804     cout << "Writing processed star records to " << outputFile << '\n';
00805     ofstream out(outputFile, ios::out | ios::binary);
00806     if (!out.good())
00807     {
00808         cout << "Error opening " << outputFile << '\n';
00809         exit(1);
00810     }
00811 
00812     binwrite(out, stars.size() + companions.size());
00813     {
00814         vector<HipparcosStar>::iterator iter;
00815         for (iter = stars.begin(); iter != stars.end(); iter++)
00816             iter->write(out);
00817         for (iter = companions.begin(); iter != companions.end(); iter++)
00818             iter->write(out);
00819     }
00820 
00821 #if 0
00822     char* hdOutputFile = "hdxref.dat";
00823     
00824     cout << "Writing out HD cross reference to " << hdOutputFile << '\n';
00825     ofstream hdout(hdOutputFile, ios::out | ios::binary);
00826     if (!out.good())
00827     {
00828         cout << "Error opening " << hdOutputFile << '\n';
00829         exit(1);
00830     }
00831 
00832     {
00833         int nHD = 0;
00834         vector<HipparcosStar>::iterator iter;
00835         for (iter = stars.begin(); iter != stars.end(); iter++)
00836         {
00837             if (iter->HDCatalogNumber != NullCatalogNumber)
00838                 nHD++;
00839         }
00840         binwrite(hdout, nHD);
00841 
00842         cout << nHD << " stars have HD numbers.\n";
00843         
00844         for (iter = stars.begin(); iter != stars.end(); iter++)
00845         {
00846             if (iter->HDCatalogNumber != NullCatalogNumber)
00847             {
00848                 binwrite(hdout, iter->HDCatalogNumber);
00849                 binwrite(hdout, iter->HIPCatalogNumber);
00850             }
00851         }        
00852     }
00853 #endif
00854 
00855     return 0;
00856 }

static string MainDatabaseFile "hip_main.dat"   )  [static]
 

Referenced by main().

bool operator< const HipparcosStar a,
const HipparcosStar b
 

Definition at line 92 of file buildstardb.cpp.

00093 {
00094     return a.HIPCatalogNumber < b.HIPCatalogNumber;
00095 }

static string OrbitalDatabase "hip_dm_o.dat"   )  [static]
 

StellarClass ParseStellarClass char *  starType  ) 
 

Definition at line 183 of file buildstardb.cpp.

Referenced by ReadStarRecord().

00184 {
00185     StellarClass::StarType type = StellarClass::NormalStar;
00186     StellarClass::SpectralClass specClass = StellarClass::Spectral_A;
00187     StellarClass::LuminosityClass lum = StellarClass::Lum_V;
00188     unsigned short number = 5;
00189     int i = 0;
00190 
00191     // Subdwarves (luminosity class VI) are prefixed with sd
00192     if (starType[i] == 's' && starType[i + 1] == 'd')
00193     {
00194         lum = StellarClass::Lum_VI;
00195         i += 2;
00196     }
00197 
00198     switch (starType[i])
00199     {
00200     case 'O':
00201         specClass = StellarClass::Spectral_O;
00202         break;
00203     case 'B':
00204         specClass = StellarClass::Spectral_B;
00205         break;
00206     case 'A':
00207         specClass = StellarClass::Spectral_A;
00208         break;
00209     case 'F':
00210         specClass = StellarClass::Spectral_F;
00211         break;
00212     case 'G':
00213         specClass = StellarClass::Spectral_G;
00214         break;
00215     case 'K':
00216         specClass = StellarClass::Spectral_K;
00217         break;
00218     case 'M':      
00219         specClass = StellarClass::Spectral_M;
00220         break;
00221     case 'R':
00222         specClass = StellarClass::Spectral_R;
00223         break;
00224     case 'N':
00225         specClass = StellarClass::Spectral_S;
00226         break;
00227     case 'S':
00228         specClass = StellarClass::Spectral_N;
00229         break;
00230     case 'W':
00231         i++;
00232         if (starType[i] == 'C')
00233             specClass = StellarClass::Spectral_WC;
00234         else if (starType[i] == 'N')
00235             specClass = StellarClass::Spectral_WN;
00236         else
00237             i--;
00238         break;
00239 
00240     case 'D':
00241         type = StellarClass::WhiteDwarf;
00242         return StellarClass(type, specClass, 0, lum);
00243 
00244     default:
00245         specClass = StellarClass::Spectral_Unknown;
00246         break;
00247     }
00248 
00249     i++;
00250     if (starType[i] >= '0' && starType[i] <= '9')
00251     {
00252         number = starType[i] - '0';
00253     }
00254     else
00255     {
00256         // No number given for spectral class; assume it's a 5 unless
00257         // the star is type O, as O5 stars are exceedingly rare.
00258         if (specClass == StellarClass::Spectral_O)
00259             number = 9;
00260         else
00261             number = 5;
00262     }
00263 
00264     if (lum != StellarClass::Lum_VI)
00265     {
00266         i++;
00267         lum = StellarClass::Lum_V;
00268         while (i < 13 && starType[i] != '\0') {
00269             if (starType[i] == 'I') {
00270                 if (starType[i + 1] == 'I') {
00271                     if (starType[i + 2] == 'I') {
00272                         lum = StellarClass::Lum_III;
00273                     } else {
00274                         lum = StellarClass::Lum_II;
00275                     }
00276                 } else if (starType[i + 1] == 'V') {
00277                     lum = StellarClass::Lum_IV;
00278                 } else if (starType[i + 1] == 'a') {
00279                     if (starType[i + 2] == '0')
00280                         lum = StellarClass::Lum_Ia0;
00281                     else
00282                         lum = StellarClass::Lum_Ia;
00283                 } else if (starType[i + 1] == 'b') {
00284                     lum = StellarClass::Lum_Ib;
00285                 } else {
00286                     lum = StellarClass::Lum_Ib;
00287                 }
00288                 break;
00289             } else if (starType[i] == 'V') {
00290                 if (starType[i + 1] == 'I')
00291                     lum = StellarClass::Lum_VI;
00292                 else
00293                     lum = StellarClass::Lum_V;
00294                 break;
00295             }
00296             i++;
00297         }
00298     }
00299 
00300     return StellarClass(type, specClass, number, lum);
00301 }

bool ReadComponentRecord istream &  in  ) 
 

Definition at line 417 of file buildstardb.cpp.

References HipparcosComponent::appMag, HipparcosComponent::ascension, HipparcosComponent::bMag, HipparcosComponent::componentID, components, HipparcosComponent::declination, findStar(), HipparcosComponent::hasBV, HipComponentRecordLength, HipparcosComponent::positionAngle, HipparcosComponent::refComponentID, HipparcosComponent::separation, HipparcosComponent::star, and HipparcosComponent::vMag.

Referenced by main().

00418 {
00419     HipparcosComponent component;
00420     char buf[HipComponentRecordLength];
00421 
00422     in.read(buf, HipComponentRecordLength);
00423 
00424     uint32 hip;
00425     if (sscanf(buf + 42, "%ud", &hip) != 1)
00426     {
00427         cout << "Missing HIP catalog number for component.\n";
00428         return false;
00429     }
00430 
00431     component.star = findStar(hip);
00432     if (component.star == NULL)
00433     {
00434         cout << "Nonexistent HIP catalog number for component.\n";
00435         return false;
00436     }
00437 
00438     if (sscanf(buf + 40, "%c", &component.componentID) != 1)
00439     {
00440         cout << "Missing component identifier.\n";
00441         return false;
00442     }
00443 
00444     if (sscanf(buf + 175, "%c", &component.refComponentID) != 1)
00445     {
00446         cout << "Error reading reference component.\n";
00447         return false;
00448     }
00449     if (component.refComponentID == ' ')
00450         component.refComponentID = component.componentID;
00451 
00452     // Read astrometric information
00453     if (sscanf(buf + 88, "%f", &component.ascension) != 1)
00454     {
00455         cout << "Missing ascension for component.\n";
00456         return false;
00457     }
00458     component.ascension = (float) (component.ascension * 24.0 / 360.0);
00459 
00460     if (sscanf(buf + 101, "%f", &component.declination) != 1)
00461     {
00462         cout << "Missing declination for component.\n";
00463         return false;
00464     }
00465 
00466     // Read photometric information
00467     if (sscanf(buf + 49, "%f", &component.appMag) != 1)
00468     {
00469         cout << "Missing magnitude for component.\n";
00470         return false;
00471     }
00472 
00473     // vMag and bMag may be necessary to guess the spectral type
00474     if (sscanf(buf + 62, "%f", &component.bMag) != 1 ||
00475         sscanf(buf + 69, "%f", &component.vMag) != 1)
00476     {
00477         component.bMag = component.vMag = component.appMag;
00478     }
00479     else
00480     {
00481         component.hasBV = true;
00482     }
00483 
00484     if (component.componentID != component.refComponentID)
00485     {
00486         if (sscanf(buf + 177, "%f", &component.positionAngle) != 1)
00487         {
00488             cout << "Missing position angle for component.\n";
00489             return false;
00490         }
00491         if (sscanf(buf + 185, "%f", &component.separation) != 1)
00492         {
00493             cout << "Missing separation for component.\n";
00494             return false;
00495         }
00496     }
00497 
00498     components.insert(components.end(), component);
00499 
00500     return true;
00501 };

bool ReadStarRecord istream &  in  ) 
 

Definition at line 322 of file buildstardb.cpp.

References HipparcosStar::appMag, HipparcosStar::ascension, HipparcosStar::CCDMIdentifier, HipparcosStar::declination, HipparcosStar::HDCatalogNumber, HipparcosStar::HIPCatalogNumber, HipStarRecordLength, HipparcosStar::nComponents, HipparcosStar::parallax, HipparcosStar::parallaxError, ParseStellarClass(), stars, HipparcosStar::starsWithCCDM, and HipparcosStar::stellarClass.

Referenced by main().

00323 {
00324     HipparcosStar star;
00325     char buf[HipStarRecordLength];
00326 
00327     in.read(buf, HipStarRecordLength);
00328     
00329     if (sscanf(buf + 2, "%d", &star.HIPCatalogNumber) != 1)
00330     {
00331         cout << "Error reading catalog number.\n";
00332         return false;
00333     }
00334 
00335     sscanf(buf + 390, "%d", &star.HDCatalogNumber);
00336 
00337     if (sscanf(buf + 41, "%f", &star.appMag) != 1)
00338     {
00339         cout << "Error reading magnitude.\n";
00340         return false;
00341     }
00342 
00343     if (sscanf(buf + 79, "%f", &star.parallax) != 1)
00344     {
00345         // cout << "Error reading parallax.\n";
00346     }
00347 
00348     bool coordReadError = false;
00349     if (sscanf(buf + 51, "%f", &star.ascension) != 1)
00350         coordReadError = true;
00351     if (sscanf(buf + 64, "%f", &star.declination) != 1)
00352         coordReadError = true;
00353     star.ascension = (float) (star.ascension * 24.0 / 360.0);
00354 
00355     // Read the lower resolution coordinates in hhmmss form if we failed
00356     // to read the coordinates in degrees.  Not sure why the high resolution
00357     // coordinates are occasionally missing . . .
00358     if (coordReadError)
00359     {
00360         int hh = 0;
00361         int mm = 0;
00362         float seconds;
00363         if (sscanf(buf + 17, "%d %d %f", &hh, &mm, &seconds) != 3)
00364         {
00365             cout << "Error reading ascension.\n";
00366             return false;
00367         }
00368         star.ascension = hh + (float) mm / 60.0f + (float) seconds / 3600.0f;
00369     
00370         char decSign;
00371         int deg;
00372         if (sscanf(buf + 29, "%c%d %d %f", &decSign, &deg, &mm, &seconds) != 4)
00373         {
00374             cout << "Error reading declination.\n";
00375             return false;
00376         }
00377         star.declination = deg + (float) mm / 60.0f + (float) seconds / 3600.0f;
00378         if (decSign == '-')
00379             star.declination = -star.declination;
00380     }
00381 
00382     char* spectralType = buf + 435;
00383     spectralType[12] = '\0';
00384     star.stellarClass = ParseStellarClass(spectralType);
00385 
00386     int asc = 0;
00387     int dec = 0;
00388     char decSign = ' ';
00389     if (sscanf(buf + 327, "%d%c%d", &asc, &decSign, &dec) == 3)
00390     {
00391         if (decSign == '-')
00392             dec = -dec;
00393         star.CCDMIdentifier = asc << 16 | (dec & 0xffff);
00394 
00395         int n = 1;
00396         sscanf(buf + 340, "%d", &n);
00397         star.starsWithCCDM = (uint8) n;
00398         sscanf(buf + 343, "%d", &n);
00399         star.nComponents = (uint8) n;
00400     }
00401 
00402     float parallaxError = 0.0f;
00403     if (sscanf(buf + 119, "%f", &parallaxError) != 0)
00404     {
00405         if (star.parallax < 0.0f || parallaxError / star.parallax > 1.0f)
00406             star.parallaxError = (int8) 255;
00407         else
00408             star.parallaxError = (int8) (parallaxError / star.parallax * 200);
00409     }
00410     
00411     stars.insert(stars.end(), star);
00412 
00413     return true;
00414 }

void ShowStarsWithComponents  ) 
 

Definition at line 675 of file buildstardb.cpp.

References HipparcosStar::HDCatalogNumber, HipparcosStar::HIPCatalogNumber, HipparcosStar::nComponents, NullCatalogNumber, and stars.

Referenced by main().

00676 {
00677     cout << "\nStars with >2 components\n";
00678     for (vector<HipparcosStar>::iterator iter = stars.begin();
00679          iter != stars.end(); iter++)
00680     {
00681         if (iter->nComponents > 2)
00682         {
00683             cout << (int) iter->nComponents << ": ";
00684             if (iter->HDCatalogNumber != NullCatalogNumber)
00685                 cout << "HD " << iter->HDCatalogNumber;
00686             else
00687                 cout << "HIP " << iter->HIPCatalogNumber;
00688             cout << '\n';
00689         }
00690     }
00691 }

HipparcosStar TheSun  ) 
 

Definition at line 304 of file buildstardb.cpp.

References HipparcosStar::appMag, HipparcosStar::ascension, HipparcosStar::declination, HipparcosStar::HDCatalogNumber, HipparcosStar::HIPCatalogNumber, HipparcosStar::parallax, and HipparcosStar::stellarClass.

Referenced by main().

00305 {
00306     HipparcosStar star;
00307 
00308     star.HDCatalogNumber = 0;
00309     star.HIPCatalogNumber = 0;
00310     star.ascension = 0.0f;
00311     star.declination = 0.0f;
00312     star.parallax = 1000000.0f;
00313     star.appMag = -15.17f;
00314     star.stellarClass = StellarClass(StellarClass::NormalStar,
00315                                      StellarClass::Spectral_G, 2,
00316                                      StellarClass::Lum_V);
00317 
00318     return star;
00319 }


Variable Documentation

vector<HipparcosStar> companions
 

Definition at line 158 of file buildstardb.cpp.

Referenced by CreateCompanionList(), and main().

vector<HipparcosComponent> components
 

Definition at line 159 of file buildstardb.cpp.

Referenced by celestia_newposition(), CreateCompanionList(), main(), ReadComponentRecord(), and TiledTexture::TiledTexture().

const int HipComponentRecordLength = 239 [static]
 

Definition at line 28 of file buildstardb.cpp.

Referenced by ReadComponentRecord().

const int HipStarRecordLength = 451 [static]
 

Definition at line 27 of file buildstardb.cpp.

Referenced by ReadStarRecord().

uint32 NullCatalogNumber = 0xffffffff [static]
 

Definition at line 31 of file buildstardb.cpp.

Referenced by ConstrainComponentParallaxes(), CreateCompanionList(), HipparcosStar::HipparcosStar(), main(), ShowStarsWithComponents(), and HipparcosStar::write().

uint32 NullCCDMIdentifier = 0xffffffff [static]
 

Definition at line 30 of file buildstardb.cpp.

Referenced by BuildMultistarSystemCatalog(), and HipparcosStar::HipparcosStar().

vector<HipparcosStar*> starIndex
 

Definition at line 160 of file buildstardb.cpp.

Referenced by celestia_getstar(), StarDatabase::createStar(), findStar(), and main().

vector<HipparcosStar> stars
 

Definition at line 157 of file buildstardb.cpp.

Referenced by addStars(), BuildMultistarSystemCatalog(), CorrectErrors(), Universe::getCompletion(), InitStarBrowserItems(), InitStarBrowserLVItems(), listStarEntryChange(), main(), StarBrowser::nearestStar(), ReadStarRecord(), ShowStarsWithComponents(), CelestialBrowser::slotRefresh(), and StarDatabase::StarDatabase().

MultistarSystemCatalog starSystems
 

Definition at line 163 of file buildstardb.cpp.

Referenced by BuildMultistarSystemCatalog(), ConstrainComponentParallaxes(), and main().


Generated on Sat Jan 14 22:33:03 2006 for Celestia by  doxygen 1.4.1