#include #include #include double pixelToVelocity(wcsprm *wcs, double &x, double &y, double &z) { /** * pixelToVelocity(wcsprm *wcs, double &x, double &y, double &z) * Uses wcs to convert the three-dimensional pixel position (x,y,z) * to world coordinates. * Returns the velocity. */ int *stat = new int[1]; double *pixcrd = new double[3]; double *imgcrd = new double[3]; double *world = new double[3]; double *phi = new double[1]; double *theta = new double[1]; // correct from 0-indexed to 1-indexed pixel array by adding 1 to pixel values. pixcrd[0] = x + 1; pixcrd[1] = y + 1; pixcrd[2] = z + 1; if(int flag=wcsp2s(wcs, 1, 3, pixcrd, imgcrd, phi, theta, world, stat)>0){ std::cerr<<"ERROR : WCS Error Code = "<0){ std::cerr << "ERROR : WCS Error Code = " <0){ std::cerr << "ERROR : WCS Error Code = " <0){ std::cerr << "ERROR : WCS Error Code = " <0){ std::cerr << "ERROR : WCS Error Code = " <ctype[2]; if(ztype!="FREQ") { return coord/1000.; } else{ return C_kms * (wcs->restfrq*wcs->restfrq - coord*coord) / (wcs->restfrq*wcs->restfrq + coord*coord); } } double velToCoord(wcsprm *wcs, const float velocity) { /** * velToCoord(wcsprm *wcs, const double coord) * Convert the velocity given to the appropriate world coordinate for wcs. * Does this by checking the ztype parameter in wcs to see if it is FREQ or otherwise, * and converts accordingly. */ string ztype = wcs->ctype[2]; if(ztype!="FREQ") return velocity * 1000.; else return wcs->restfrq * (1. - velocity/C_kms) / (1. + velocity/C_kms); }