TotalExpTime.hxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 //-----------------------------------------------------------------------------
00005 // SVN: $Id: TotalExpTime.hxx 7109 2010-06-17 17:54:34Z NicholasCross $
00006 //-----------------------------------------------------------------------------
00007 #ifndef TOTALEXPTIME_H
00008 #define TOTALEXPTIME_H
00009 
00010 #include "Constants.h"
00011 #include "DataMethod.hxx"
00012 #include "FitsFile.h"
00013 #include "Logger.h"
00014 //-----------------------------------------------------------------------------
00017 template<typename DataType>
00018 class TotalExpTime : public DataMethod<DataType>
00019 {
00020 public:
00023   Logger log;
00024   TotalExpTime(const FitsFile& aFile)
00025     : mFile(aFile)
00026   {
00027     DataMethod<DataType>::methodName = "TotalExpTime";
00028   }
00029 
00031   virtual ~TotalExpTime() { }
00032 
00034   void setSource(IntMap& tbls, IntMap& cols, StringMap units)
00035   {
00036     mExtnumColno = cols[0];
00037     if (mExtnumColno < 0)
00038     {
00039       throw DataMethodException("TotalExpTime method: cannot source");
00040     }
00041   }
00042 
00044   void setTarget(IntMap& cols, StringMap units)
00045   {
00046     mTotalExpTimeColno = cols[0];
00047   }
00048 
00052   void doit(TableData<DataType>& data, int row1, int row2)
00053   {
00054     double extNum, texptime, exptime;
00055     double njitter, nustep, noffset;
00056     bool noData = false;
00057     bool noOffs = false;
00058 
00059     try
00060     {
00061       // get data from primary header
00062       if (mFile.isTile()) {
00063         mFile.movabsHdu(2);
00064       } else {
00065         mFile.movabsHdu(1);
00066       }
00067       mFile.readKey(FitsFile::cEXP_TIME, exptime);
00068       mFile.readKey("NJITTER", njitter);
00069       mFile.readKey("NUSTEP", nustep);
00070     }
00071     catch (FitsIOException)
00072     {
00073       noData = true;
00074     }
00075 
00076     try
00077     {
00078       // get data from primary header
00079       if (mFile.isTile()) {
00080         mFile.movabsHdu(2);
00081       } else {
00082         mFile.movabsHdu(1);
00083       }
00084       mFile.readKey("NOFFSETS", noffset);
00085     }
00086     catch (FitsIOException)
00087     {
00088       noOffs = true;
00089     }
00090     // Calculate offset value. 1, if not tile.
00091     double offVal = (!noOffs && mFile.isTile()) ? noffset/3. : 1.;
00092     
00093     for (int rowNo = row1; rowNo < row2; ++rowNo)
00094     {
00095       if (mFile.getFileName().find(PreSuffixNames::stackSuffix,
00096                                    mFile.getFileName().rfind("/"))
00097           != std::string::npos)
00098       {
00099         // move to the extension
00100         data.value(mExtnumColno, rowNo, extNum);
00101         mFile.movabsHdu(static_cast<int>(extNum));
00102         try
00103         { // if keyword is available get data from its value
00104           mFile.readKey(FitsFile::TEXPTIME, texptime);
00105         }
00106         catch (FitsIOException)
00107         {
00108           texptime = (!noData) ? njitter * nustep * exptime * offVal
00109                                : DefaultValues::realdef;
00110         }
00111       }
00112       else
00113       {
00114         texptime = DefaultValues::realdef;
00115       }
00116       data.assign(mTotalExpTimeColno, rowNo, texptime);
00117     }
00118   }
00119 
00120   // No data from raw data included
00121   void doit2(TableData<DataType>& rawData, TableData<DataType>& data, int row1, int row2) { }
00122 
00123 private:
00124   FitsFile mFile;
00125   int mTotalExpTimeColno;
00126   int mExtnumColno;
00127 };
00128 //-----------------------------------------------------------------------------
00129 #endif
00130 //-----------------------------------------------------------------------------
00131 // Change log:
00132 //
00133 // 10-Mar-2008, ETWS: First version.
00134 
Generated on Mon Oct 4 10:38:34 2010 for WfcamSrc by  doxygen 1.6.3