//============================================================================= // General test for the SP3EphemerisStore // Makes sure SP3EphemerisStore can be instantiated and can load // a file; also ensures that nonexistent files throw an exception //============================================================================= int SP3ESTest(void) { TUDEF( "SP3EphemerisStore", "Constructor" ); // Verify the consturctor builds the SP3EphemerisStore object try { SP3EphemerisStore store; TUPASS("SP3EphemerisStore object successfully created"); } catch (...) { TUFAIL("SP3EphemerisStore object could not be created"); } SP3EphemerisStore store; // Verify opening an empty file throws an error try { store.loadFile(inputNotaFile); TUFAIL("Opening an empty file did not throw an exception"); } catch (Exception& e) { TUPASS("Opening an empty file threw the correct exception"); } catch (...) { TUFAIL("Opening an empty file caused an unexpected exception"); } // Verify opening a file works with no errors try { /* fstream smoo; smoo.open(inputSP3Data.c_str(),std::ios::in); testFramework.assert(smoo, "plain file open fail", __LINE__); smoo.close(); cerr << "-------------------------" << endl; */ store.loadFile(inputSP3Data); // cerr << "-------------------------" << endl; TUPASS("Opening a valid file works with no exceptions"); } catch (...) { // cerr << "-------------------------" << endl; TUFAIL("Exception thrown when opening a valid file"); } // Write the dump of the loaded file ofstream DumpData; DumpData.open (outputDataDump.c_str()); store.dump(DumpData,1); DumpData.close(); return testFramework.countFails(); }
//------------------------------------------------------------------------------------ // Configure(1) // open and read navigation files // open and read headers of all observation files int Initialize(void) throw(Exception) { try { size_t i; // global pEph will point to one of these static GPSEphemerisStore BCEphList; static SP3EphemerisStore SP3EphList; if(CI.Verbose) oflog << "BEGIN Configure(1)" << " at total time " << fixed << setprecision(3) << double(clock()-totaltime)/double(CLOCKS_PER_SEC) << " seconds." << endl; if(CI.Frequency == 1) wave = wl1; if(CI.Frequency == 2) wave = wl2; // NB wave should never be used for L3 -- see warning in CommandInput.cpp else if(CI.Frequency == 3) wave = wl1; // open nav files, if any, and read EphemerisStore into EphLists if(CI.NavFileNames.size() > 0) { if(!CI.NavPath.empty()) for(i=0; i<CI.NavFileNames.size(); i++) CI.NavFileNames[i] = CI.NavPath + "/" + CI.NavFileNames[i]; // fill ephemeris store -- this routine in RinexUtilities.cpp FillEphemerisStore(CI.NavFileNames, SP3EphList, BCEphList); } // read all headers and store information in Station object ReadAllObsHeaders(); // use the information gathered in ReadAllObsHeaders to determine DT // if the user did not specify --DT, set it // else if the --DT the user chose is too small, reset it // else leave --DT alone double DT=-1.0; for(i=0; i<ObsFileList.size(); i++) { if(ObsFileList[i].dt > DT) DT = ObsFileList[i].dt; if(ObsFileList[i].firstTime > CI.BegTime) CI.BegTime = ObsFileList[i].firstTime; } if(CI.DataInterval == -1) { CI.DataInterval = DT; if(CI.Verbose) oflog << "DDBase has determined the data interval (--DT) to be " << CI.DataInterval << " seconds." << endl; } else if(CI.DataInterval < DT) { CI.DataInterval = DT; oflog << "Warning - DDBase has changed the data interval (--DT) to " << CI.DataInterval << " seconds." << endl; } // dump SP3 store to log if(SP3EphList.size()) { if(CI.Verbose) SP3EphList.dump(oflog,0); } else if(CI.Verbose) oflog << "SP3 Ephemeris store is empty" << endl; // dump BCE store to log if(BCEphList.size()) { // this causes the CorrectedEphemerisRange routines to pick the // closest TOE in either future or past of the epoch, rather // than the closest in the past -- see GPSEphemerisStore.hpp BCEphList.SearchNear(); if(CI.Debug) BCEphList.dump(oflog,1); else if(CI.Verbose) BCEphList.dump(oflog,0); } else if(CI.Verbose) oflog << "BC Ephemeris store is empty" << endl; // assign pointer // NB SP3 takes precedence if(SP3EphList.size()) pEph = &SP3EphList; else if(BCEphList.size()) pEph = &BCEphList; else { cerr << "Initialize ERROR: no ephemeris. Abort." << endl; oflog << "Initialize ERROR: no ephemeris. Abort." << endl; return 1; } // open all EOP files and fill the EOPstore if(!CI.EOPPath.empty()) for(i=0; i<CI.EOPFileNames.size(); i++) CI.EOPFileNames[i] = CI.EOPPath + "/" + CI.EOPFileNames[i]; if(CI.EOPFileNames.size() > 0) { for(i=0; i<CI.EOPFileNames.size(); i++) EOPList.addFile(CI.EOPFileNames[i]); } else { try { EOPList.addIERSFile("finals.daily"); } catch(FileMissingException& fme) { string msg("DDBase was unable to find any Earth Orientation parameters:\n" " either add option --EOPFile <file> or put file 'finals.daily' in the" " current directory.\n (http://maia.usno.navy.mil/ser7/finals.daily)\n"); cerr << msg; oflog << msg; GPSTK_RETHROW(fme); } } if(EOPList.size()) { if(CI.Debug) EOPList.dump(1,oflog); else if(CI.Verbose) EOPList.dump(0,oflog); } else oflog << "Warning - no Earth Orientation Parameters were input\n"; // add path to output files if(!CI.OutPath.empty()) { if(!CI.OutputClkFile.empty()) CI.OutputClkFile = CI.OutPath + "/" + CI.OutputClkFile; if(!CI.OutputDDDFile.empty()) CI.OutputDDDFile = CI.OutPath + "/" + CI.OutputDDDFile; if(!CI.OutputTDDFile.empty()) CI.OutputTDDFile = CI.OutPath + "/" + CI.OutputTDDFile; if(!CI.OutputRawFile.empty()) CI.OutputRawFile = CI.OutPath + "/" + CI.OutputRawFile; if(!CI.OutputRawDDFile.empty()) CI.OutputRawDDFile = CI.OutPath + "/" + CI.OutputRawDDFile; if(!CI.OutputPRSFile.empty()) CI.OutputPRSFile = CI.OutPath + "/" + CI.OutputPRSFile; if(!CI.OutputDDRFile.empty()) CI.OutputDDRFile = CI.OutPath + "/" + CI.OutputDDRFile; } // assign trop model for RAIM (model for DD est assigned in Configure(2)) // NB using another, like Saastamoinen, here, is problematic because it // requires height, latitude and DOY input, [ this because RAIM calls // CI.pTropModel->correction(elevation) ], and that info is different for // different sites and not all available. CI.pTropModel = &TropModelSimple; // TD per site CI.pTropModel->setWeather(CI.DefaultTemp,CI.DefaultPress,CI.DefaultRHumid); // Define first and last epochs FirstEpoch = CommonTime::BEGINNING_OF_TIME; LastEpoch = CommonTime::END_OF_TIME; return 0; } catch(Exception& e) { GPSTK_RETHROW(e); } catch(std::exception& e) { Exception E("std except: "+string(e.what())); GPSTK_THROW(E); } catch(...) { Exception e("Unknown exception"); GPSTK_THROW(e); } }