TotalExpTime.hxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 //-----------------------------------------------------------------------------
00005 // SVN: $Id: TotalExpTime.hxx 4695 2008-04-09 15:18:42Z EckhardSutorius $
00006 //-----------------------------------------------------------------------------
00007 #ifndef TOTALEXPTIME_H
00008 #define TOTALEXPTIME_H
00009 
00010 #include "Constants.h"
00011 #include "DataMethod.hxx"
00012 #include "FitsFile.h"
00013 //-----------------------------------------------------------------------------
00016 template<typename DataType>
00017 class TotalExpTime : public DataMethod<DataType>
00018 {
00019 public:
00022   TotalExpTime(const FitsFile& aFile)
00023     : mFile(aFile)
00024   {
00025     DataMethod<DataType>::methodName = "TotalExpTime";
00026   }
00027 
00029   virtual ~TotalExpTime() { }
00030 
00032   void setSource(IntMap& tbls, IntMap& cols, StringMap units)
00033   {
00034     mExtnumColno = cols[0];
00035     if (mExtnumColno < 0)
00036     {
00037       throw DataMethodException("TotalExpTime method: cannot source");
00038     }
00039   }
00040 
00042   void setTarget(IntMap& cols, StringMap units)
00043   {
00044     mTotalExpTimeColno = cols[0];
00045   }
00046 
00050   void doit(TableData<DataType>& data, int row1, int row2)
00051   {
00052     double extNum, texptime, exptime;
00053     double njitter, nustep;
00054     bool noData = false;
00055 
00056     try
00057     {
00058       // get data from primary header
00059       mFile.movabsHdu(1);
00060       mFile.readKey("NJITTER", njitter);
00061       mFile.readKey("NUSTEP", nustep);
00062       mFile.readKey("EXP_TIME", exptime);
00063     }
00064     catch (FitsIOException)
00065     {
00066       noData = true;
00067     }
00068 
00069     for (int rowNo = row1; rowNo < row2; ++rowNo)
00070     {
00071       if (mFile.getFileName().find(PreSuffixNames::stackSuffix,
00072                                    mFile.getFileName().rfind("/"))
00073           != std::string::npos)
00074       {
00075         // move to the extension
00076         data.value(mExtnumColno, rowNo, extNum);
00077         mFile.movabsHdu(static_cast<int>(extNum));
00078         try
00079         { // if keyword is available get data from its value
00080           mFile.readKey(FitsFile::TEXPTIME, texptime);
00081         }
00082         catch (FitsIOException)
00083         {
00084           texptime = (!noData) ? njitter * nustep * exptime
00085                                : DefaultValues::realdef;
00086         }
00087       }
00088       else
00089       {
00090         texptime = DefaultValues::realdef;
00091       }
00092       data.assign(mTotalExpTimeColno, rowNo, texptime);
00093     }
00094   }
00095 
00096   // No data from raw data included
00097   void doit2(TableData<DataType>& rawData, TableData<DataType>& data, int row1, int row2) { }
00098 
00099 private:
00100   FitsFile mFile;
00101   int mTotalExpTimeColno;
00102   int mExtnumColno;
00103 };
00104 //-----------------------------------------------------------------------------
00105 #endif
00106 //-----------------------------------------------------------------------------
00107 // Change log:
00108 //
00109 // 10-Mar-2008, ETWS: First version.
00110 

Generated on Thu Apr 2 21:52:16 2009 for WfcamSrc by  doxygen 1.5.2