/** @addtogroup tools */ /**@{*/ /********************************************************************************* * UL - PRIMA project * * "@(#) $Id: $" * * who when what * -------- -------- ---------------------------------------------- * mathar 2007-02-15 created * * NAME * * Charm2StarCat - convert CHARM2 file to PRIMA simulator config file * * SYNOPSIS * cd config ; ../calc/Charm2StarCat charm*.dat | sed 's/nan/0./g' > config.xml * cd config ; ../calc/Charm2StarCat -f charm*.dat > stars.fits * * DESCRIPTION * * If the -f option is used, the output is not generated in XML but in FITS * format. * * FILES * * ENVIRONMENT * * CAUTIONS * * EXAMPLES * * SEE ALSO * * NOTES * * TODO * * BUGS * ********************************************************************************/ #include #include #include #include #include #include #include #include "slalib.h" #include "units.h" #include "prStarCat.C" using namespace std ; using namespace CCfits ; void usage(char *argv[]) { cerr << "usage: " << argv[0] << " ../config/charm2.dat > charm2.fits" << endl ; } int main( int argc, char *argv[]) { if( argc < 2) { usage(argv) ; return 1 ; } char oc ; bool fits = true ; while ( (oc=getopt(argc,argv,"")) != -1 ) { switch(oc) { case '?' : cerr << "Invalid command line option " << optopt << endl ; break ; } } starCat catalog ; /** Loop over all command line arguments and put all stars * into a single large catalogue. */ for(int arg= optind ; arg < argc ; arg++) { Charm2 charm2(argv[arg]) ; for(int i=0 ; i < charm2.N.size() ; i++) { Star star(charm2,i) ; catalog.add(star) ; } } /** Sort the catalog entries according to the stars, using Star::operator<() */ sort(catalog.begin(),catalog.end()) ; if ( fits) catalog.oifits() ; else catalog.xml(cout) ; return 0 ; } /**@}*/ /* $Log:$ */