1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
/* $Id: TwoDLinearWCS.cc,v 1.5 2013-08-07 15:28:51 cgarcia Exp $
*
* This file is part of the VIMOS Pipeline
* Copyright (C) 2002-2012 European Southern Observatory
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* $Author: cgarcia $
* $Date: 2013-08-07 15:28:51 $
* $Revision: 1.5 $
* $Name: not supported by cvs2svn $
*/
#include <cmath>
#include "TwoDLinearWCS.h"
#include "vimoswcs.h"
#include "vimoswcscat.h"
TwoDLinearWCS::TwoDLinearWCS()
{
std::string proj = "TAN";
wcs_ = vimoswcsxinit(0.,0.,0.,0.,0.,0,0,0.,0,0.,
const_cast<char *>(proj.c_str()));
}
TwoDLinearWCS::TwoDLinearWCS
(const double& centralRA, const double& centralDEC, const double& plateScale,
const cpl_size& dimX, const cpl_size& dimY,
const double& rotAngle, bool flip,
const double& epoch, const int equinox)
{
std::string proj = "TAN";
wcs_ = vimoswcsxinit(centralRA, centralDEC, plateScale, dimX/2., dimY/2.,
dimX, dimY, rotAngle, equinox, epoch,
const_cast<char *>(proj.c_str()));
if(!flip) vimoswcsdeltset(wcs_, wcs_->cdelt[0],wcs_->cdelt[1],rotAngle);
else vimoswcsdeltset(wcs_,-wcs_->cdelt[0],wcs_->cdelt[1],rotAngle);
}
TwoDLinearWCS::~TwoDLinearWCS()
{
if(wcs_ != NULL)
vimoswcsfree(wcs_);
}
void TwoDLinearWCS::toWorld
(const double& xPixel, const double& yPixel, double& ra, double& dec) const
{
pix2vimoswcs(wcs_, xPixel, yPixel, &ra, &dec);
ra /= 15.;
}
bool TwoDLinearWCS::toPixel
(const double& ra, const double& dec, double& xPixel, double& yPixel) const
{
int off;
vimoswcs2pix(wcs_, ra * 15., dec, &xPixel, &yPixel, &off);
if(off) return false;
return true;
}
double TwoDLinearWCS::epoch() const
{
return (wcs_->epoch);
}
double TwoDLinearWCS::equinox() const
{
return (wcs_->equinox);
}
double TwoDLinearWCS::plateScale() const
{
double xPixSize=std::fabs(((*wcs_).xinc)*3600.);
double yPixSize=std::fabs(((*wcs_).yinc)*3600.);
return ((xPixSize + yPixSize) / 2.);
}
double TwoDLinearWCS::crpix1() const
{
return wcs_->crpix[0];
}
double TwoDLinearWCS::crpix2() const
{
return wcs_->crpix[1];
}
double TwoDLinearWCS::crval1() const
{
return wcs_->crval[0];
}
double TwoDLinearWCS::crval2() const
{
return wcs_->crval[1];
}
double TwoDLinearWCS::cdelt1() const
{
return wcs_->cdelt[0];
}
double TwoDLinearWCS::cdelt2() const
{
return wcs_->cdelt[1];
}
std::string TwoDLinearWCS::ctype1() const
{
return wcs_->ctype[0];
}
std::string TwoDLinearWCS::ctype2() const
{
return wcs_->ctype[1];
}
std::string TwoDLinearWCS::cunit1() const
{
return wcs_->units[0];
}
std::string TwoDLinearWCS::cunit2() const
{
return wcs_->units[1];
}
double * TwoDLinearWCS::cdMatrix() const
{
return wcs_->cd;
}
double TwoDLinearWCS::orientation() const
{
return wcs_->rot;
}
|