SloanCoords.hxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 //-----------------------------------------------------------------------------
00005 // CVS: $Revision: 4695 $, $Date: 2008-04-09 16:18:42 +0100 (Wed, 09 Apr 2008) $, $Author: EckhardSutorius $
00006 //-----------------------------------------------------------------------------
00007 #ifndef SLOANCOORDS_H
00008 #define SLOANCOORDS_H
00009 
00010 #include <cmath>
00011 
00012 #include "Constants.h"
00013 #include "Converter.h"
00014 #include "DataMethod.hxx"
00015 #include "StringOps.h"
00016 //-----------------------------------------------------------------------------
00019 template<typename DataType>
00020 class SloanCoords : public DataMethod<DataType>
00021 {
00022 public:
00024   SloanCoords() { DataMethod<DataType>::methodName = "SloanCoords"; }
00025 
00027   virtual ~SloanCoords() { }
00028 
00029   //---------------------------------------------------------------------------
00031   void setSource(IntMap& tbls, IntMap& cols, StringMap units)
00032   {
00033     raColno  = cols[0];
00034     decColno = cols[1];
00035 
00036     // Require radians for the calculation
00037     decFact = converter.getFactor(units[0], "RADIANS");
00038     raFact  = converter.getFactor(units[1], "RADIANS");
00039 
00040     // Constants for the co-ordinate transformation
00041     degToRad = converter.getFactor("degrees", "radians");
00042     raOffset = -95.0*degToRad;
00043     etaOffset = +32.5*degToRad;
00044   }
00045   //---------------------------------------------------------------------------
00048   void setTarget(IntMap& cols, StringMap units)
00049   {
00050     lambdaColno = cols[0];
00051     etaColno = cols[1];
00052 
00053     // Check required output units for lambda and eta
00054     lFact = converter.getFactor("RADIANS", units[0]);
00055     eFact = converter.getFactor("RADIANS", units[1]);
00056   }
00057   //---------------------------------------------------------------------------
00059   void doit(TableData<DataType>& data, int row1, int row2)
00060   {
00061     for (int rowNo = row1; rowNo < row2; ++rowNo)
00062     {
00063       // Input RA and DEC
00064       double ra, dec;
00065       data.value(raColno, rowNo, ra);
00066       data.value(decColno, rowNo, dec);
00067 
00068       // Convert RA and DEC to radians
00069       ra  *= raFact;
00070       dec *= decFact;
00071 
00072       double x = cos(ra + raOffset)*cos(dec);
00073       double y = sin(ra + raOffset)*cos(dec);
00074       double z = sin(dec);
00075 
00076       Numeric lambda = -1.0 * asin(x) * lFact;
00077       Numeric eta = (atan2(z,y) - etaOffset) * eFact;
00078 
00079       if (eta < -180.0) eta += 360.0;
00080       if (eta > 180.0) eta -= 360.0;
00081 
00082       // Assign to correct columns
00083       data.assign(lambdaColno, rowNo, lambda);
00084       data.assign(etaColno, rowNo, eta);
00085     }
00086   }
00087 
00088   // No data from raw data included
00089   void doit2(TableData<DataType>& rawData, TableData<DataType>& data, int row1, int row2) { }
00090   //---------------------------------------------------------------------------
00091 private:
00092   int lambdaColno, etaColno, raColno, decColno;
00093   double decFact, raFact, lFact, eFact;
00094   double degToRad, raOffset, etaOffset;
00095   Converter converter;
00096 };
00097 //-----------------------------------------------------------------------------
00098 #endif
00099 //-----------------------------------------------------------------------------
00100 // Change log:
00101 //
00102 // 27-May-2004,  IAB: Original version; "Not complete as I can't find
00103 //                    the formula."
00104 //  4-Aug-2004,  NCH: Added in co-ordinate transformations from
00105 //                    Stoughton et al., Astronomical Journal, 123, 485 (2002)
00106 // 28-Oct-2005, ETWS: Changed to SDSSPix code to take care of the
00107 //                    singularity at the pole.
00108 // 22-Mar-2007,  RSC: Robustified against dodgy WCS values.
00109 //  2-May-2007,  RSC: Reverted to original design of allowing dodgy WCS values.
00110 //  7-Apr-2008, ETWS: Upgraded to use new detection table layout.

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