// Useful functions - mostly using CCfits #ifndef HAVE_HEASP #include "heasp.h" #endif #ifndef HAVE_SPio #include "SPio.h" #endif #define HAVE_SPutils 1 // Read the units associated with a column void SPreadColUnits(ExtHDU&, string, string&); // Write the units associated with a column void SPwriteColUnits(Table&, string, string); // returns the tform string for the longest string in the input vector. string SPstringTform(const vector& Data); // copy from infile to outfile all HDUs which are not manipulated by this library Integer SPcopyHDUs(string infile, string outfile); // copy non-critical columns from infile to outfile for the HDUnumber instance // of the HDUname HDU. // note that the SPcopyCols do not do anything yet since they are waiting for // a change to CCfits Integer SPcopyCols(string infile, string outfile, string HDUname, Integer HDUnumber); // copy non-critical columns from infile to outfile from the HDUnumber instance // of the HDUname HDU to the outHDUnumber instance of the outHDUname HDU. Integer SPcopyCols(string infile, string outfile, string HDUname, string outHDUname, Integer HDUnumber, Integer outHDUnumber); // copy non-critical keywords from infile to outfile for the HDUnumber instance // of the HDUname HDU. Integer SPcopyKeys(string infile, string outfile, string HDUname, Integer HDUnumber); // copy non-critical keywords from infile to outfile from the HDUnumber instance // of the HDUname HDU to the outHDUnumber instance of the outHDUname HDU. Integer SPcopyKeys(string infile, string outfile, string HDUname, string outHDUname, Integer HDUnumber, Integer outHDUnumber); // write the creating program and version id string into the CREATOR keyword in the // specified file Integer SPwriteCreator(string filename, string HDUname, string creator); Integer SPwriteCreator(string filename, string HDUname, Integer HDUnumber, string creator); // find the numbers of any extensions containing keyword keyname=keyvalue vector SPfindExtensions(string filename, string keyname, string value, Integer& Status); // Check whether valid X units bool isValidXUnits(string xUnits); // Calculate the unit conversion factor for energy/wavelength Integer calcXfactor(string xUnits, bool& isWave, Real& xFactor); // Check whether valid Y units bool isValidYUnits(string yUnits); // Calculate the unit conversion factor for the flux Integer calcYfactor(string yUnits, bool& isEnergy, bool& perWave, bool& perEnergy, Real& yFactor); // Add to the error stack void SPreportError(int errorNumber, string optionalString); // Output error stack string SPgetErrorStack(); // Clear error stack void SPclearErrorStack(); // Read a text file and place each row into its own element of a vector vector SPreadStrings(const string& filename); // Divide a string into substrings delimited using delim vector SPtokenize(const string & str, const string & delim); // Partial match a string from a vector of strings string SPmatchString(const string& str, const vector& strArray, int& nmatch); // convert a string into a Real bool SPstring2Real(const string& str, Real& value); // convert a string into an Integer bool SPstring2Integer(const string& str, Integer& value); // calculate factors for shifting an array void SPcalcShift(const vector& Low, const vector& High, const vector& vStart, const vector& vEnd, const vector& vShift, const vector& vFactor, vector >& fromIndex, vector >& Fraction);