SkySubScale.hxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 //-----------------------------------------------------------------------------
00005 // CVS: $Revision: 4785 $, $Date: 2008-05-20 14:19:36 +0100 (Tue, 20 May 2008) $, $Author: RossCollins $
00006 //-----------------------------------------------------------------------------
00007 #ifndef SKYSUBSCALE_HXX
00008 #define SKYSUBSCALE_HXX
00009 
00010 #include <string>
00011 
00012 #include "Constants.h"
00013 #include "DataMethod.hxx"
00014 #include "Logger.h"
00015 //-----------------------------------------------------------------------------
00018 template<typename DataType>
00019 class SkySubScale : public DataMethod<DataType>
00020 {
00021 public:
00023   SkySubScale() { DataMethod<DataType>::methodName = "SkySubScale"; }
00024 
00026   virtual ~SkySubScale() { }
00027 
00028   //---------------------------------------------------------------------------
00030   void setSource(IntMap& aTblMap, IntMap& aColMap, StringMap aUnits)
00031   {
00032     mSourceCol = aColMap[0];
00033     if (mSourceCol < 0)
00034     {
00035       throw DataMethodException("SkySubScale method. Couldn't source");
00036     }
00037   }
00038   //---------------------------------------------------------------------------
00040   void setTarget(IntMap& aColMap, StringMap aUnits)
00041   {
00042     mTargetCol = aColMap[0];
00043   }
00044   //---------------------------------------------------------------------------
00046   void doit(TableData<DataType>& aData, int aFirstRow, int aLastRow)
00047   {
00048     for (int row = aFirstRow; row < aLastRow; ++row)
00049     {
00050       std::string keyStr;
00051       aData.value(mSourceCol, row, keyStr);
00052 
00053       if (keyStr.length() > 0)
00054       {
00055         int begin = keyStr.rfind("scale factor ")+13;
00056         int end = keyStr.rfind("'");
00057         std::string scaleStr = keyStr.substr(begin, end - begin);
00058         double scaleFactor = DefaultValues::realdef;
00059         convertType(scaleStr, scaleFactor);
00060         aData.assign(mTargetCol, row, scaleFactor);
00061       }
00062       else
00063       {
00064         Logger log;
00065         log.addMessage("No skySubScale available.");
00066       }
00067     } // end loop over rows
00068   }
00069 
00070   // No data from raw data included
00071   void doit2(TableData<DataType>& rawData, TableData<DataType>& data, int row1, int row2) { }
00072   //---------------------------------------------------------------------------
00073 private:
00074     int mSourceCol;
00075     int mTargetCol;
00076 };
00077 //-----------------------------------------------------------------------------
00078 #endif
00079 //-----------------------------------------------------------------------------
00080 // Change log:
00081 //
00082 //  6-Jan-2006, ETWS: Original version.
00083 //  6-Mar-2006,  RSC: Fixed bug whereby a zero value is assigned when the FITS
00084 //                    keyword is missing.
00085 //  7-Apr-2008, ETWS: Upgraded to use new detection table layout.
Generated on Mon Oct 4 10:38:34 2010 for WfcamSrc by  doxygen 1.6.3