GalacticCoords.hxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #ifndef GALACTICCOORDS_H
00008 #define GALACTICCOORDS_H
00009
00010 extern "C"
00011 {
00012 #include "slalib.h"
00013 }
00014 #include <limits>
00015
00016 #include "Constants.h"
00017 #include "Converter.h"
00018 #include "DataMethod.hxx"
00019 #include "Logger.h"
00020 #include "StringOps.h"
00021
00025 template<typename DataType>
00026 class GalacticCoords : public DataMethod<DataType>
00027 {
00028 public:
00030 GalacticCoords() { DataMethod<DataType>::methodName = "GalacticCoords"; }
00031
00033 virtual ~GalacticCoords() { }
00034
00035
00037 void setSource(IntMap& tbls, IntMap& cols, StringMap units)
00038 {
00039 raColno = cols[0];
00040 decColno = cols[1];
00041
00042
00043 mDecFact = converter.getFactor(units[0], "RADIANS");
00044 mRAFact = converter.getFactor(units[1], "RADIANS");
00045 }
00046
00048 void setTarget(IntMap& cols, StringMap units)
00049 {
00050 lColno = cols[0];
00051 bColno = cols[1];
00052
00053
00054 mlFact = converter.getFactor("RADIANS", units[0]);
00055 mbFact = converter.getFactor("RADIANS", units[1]);
00056 }
00057
00059 void doit(TableData<DataType>& data, int row1, int row2)
00060 {
00061 Logger log;
00062 for (int rowNo = row1; rowNo < row2; ++rowNo)
00063 {
00064
00065 double ra, dec;
00066 data.value(raColno, rowNo, ra);
00067 data.value(decColno, rowNo, dec);
00068
00069 double dl, db;
00070
00071 cslaEqgal(ra*mRAFact, dec*mDecFact, &dl, &db);
00072
00073
00074 dl *= mlFact;
00075 db *= mbFact;
00076
00077
00078 if (dl != dl or std::isinf(dl) or
00079 db != db or std::isinf(db))
00080 {
00081 string mess = "WCS error in l, b ";
00082 mess += StringOps::NumToString(lColno) + ",";
00083 mess += StringOps::NumToString(bColno) + " ";
00084 mess += StringOps::NumToString(rowNo) + " : ";
00085 mess += "value replaced with dbl_max";
00086 log.addError(mess);
00087 data.assign(lColno, rowNo, std::numeric_limits<double>::max( )-1);
00088 data.assign(bColno, rowNo, std::numeric_limits<double>::max( )-1);
00089 } else {
00090 data.assign(lColno, rowNo, dl);
00091 data.assign(bColno, rowNo, db);
00092 }
00093 }
00094 }
00095
00096
00097 void doit2(TableData<DataType>& rawData, TableData<DataType>& data, int row1, int row2) { }
00098
00099 private:
00100 int lColno;
00101 int bColno;
00102 int raColno;
00103 int decColno;
00104 double mDecFact;
00105 double mRAFact;
00106 double mlFact;
00107 double mbFact;
00108 Converter converter;
00109 };
00110
00111 #endif
00112
00113
00114
00115
00116
00117
00118