Cartesian.hxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 //-----------------------------------------------------------------------------
00005 // CVS: $Revision: 7503 $, $Date: 2010-09-07 16:34:15 +0100 (Tue, 07 Sep 2010) $, $Author: EckhardSutorius $
00006 //-----------------------------------------------------------------------------
00007 #ifndef CARTESIAN_H
00008 #define CARTESIAN_H
00009 
00010 #include <limits>
00011 
00012 #include "Constants.h"
00013 #include "Converter.h"
00014 #include "DataMethod.hxx"
00015 #include "DataOps.h"
00016 #include "Logger.h"
00017 #include "StringOps.h"
00018 //-----------------------------------------------------------------------------
00021 template<typename DataType>
00022 class Cartesian : public DataMethod<DataType>
00023 {
00024 public:
00026   Cartesian() { DataMethod<DataType>::methodName = "Cartesian"; }
00027 
00029   virtual ~Cartesian() {}
00030 
00034   void setSource(IntMap& tbls, IntMap& cols, StringMap units)
00035   {
00036     raColno  = cols[0];
00037     decColno = cols[1];
00038     Converter converter;
00039     mDecFact = converter.getFactor(units[0], "RADIANS");
00040     mRAFact  = converter.getFactor(units[1], "RADIANS");
00041   }
00042 
00045   void setTarget(IntMap& cols, StringMap units)
00046   {
00047     cxColno = cols[0];
00048     cyColno = cols[1];
00049     czColno = cols[2];
00050   }
00051 
00053   void doit(TableData<DataType>& data, int row1, int row2)
00054   {
00055     Logger log;
00056     for (int rowNo = row1; rowNo < row2; ++rowNo)
00057     {
00058       // Input RA and DEC
00059       double ra, dec;
00060       data.value(raColno, rowNo, ra);
00061       data.value(decColno, rowNo, dec);
00062 
00063       // Cartesian components
00064       double cx, cy, cz;
00065       DataOps::calcCartesian(mRAFact * ra, mDecFact * dec, cx, cy, cz);
00066 
00067       // Assign to correct columns
00068       if (cx != cx or std::isinf(cx) or
00069           cy != cy or std::isinf(cy) or
00070           cz != cz or std::isinf(cz))
00071       {
00072         string mess = "WCS error in cx, cy, cz ";
00073         mess += StringOps::NumToString(cxColno) + ",";
00074         mess += StringOps::NumToString(cyColno) + ",";
00075         mess += StringOps::NumToString(czColno) + " ";
00076         mess += StringOps::NumToString(rowNo) + " : ";
00077         mess += "value replaced with dbl_max";
00078         log.addError(mess);
00079         data.assign(cxColno, rowNo, std::numeric_limits<double>::max( )-1);
00080         data.assign(cyColno, rowNo, std::numeric_limits<double>::max( )-1);
00081         data.assign(czColno, rowNo, std::numeric_limits<double>::max( )-1);
00082       } else {
00083         data.assign(cxColno, rowNo, cx);
00084         data.assign(cyColno, rowNo, cy);
00085         data.assign(czColno, rowNo, cz);
00086       }
00087     }
00088   }
00089   // No data from raw data included
00090   void doit2(TableData<DataType>& rawData, TableData<DataType>& data, int row1, int row2) { }
00091 
00092 private:
00093   int cxColno;
00094   int cyColno;
00095   int czColno;
00096   int raColno;
00097   int decColno;
00098   double mDecFact;
00099   double mRAFact;
00100 };
00101 //-----------------------------------------------------------------------------
00102 #endif
00103 //-----------------------------------------------------------------------------
00104 // Change log:
00105 //
00106 // 27-May-2004,  IAB: Original version.
00107 // 22-Mar-2007,  RSC: Robustified against dodgy WCS values.
00108 //  2-May-2007,  RSC: Reverted to original design of allowing dodgy WCS values.
00109 //  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