#include #include #include #include #include int pixToWCSSingle(wcsprm *wcs, const double *pix, double *world) { /** * pixToWCSSingle(wcsprm *wcs, const double *pix, double *world) * Uses wcs to convert the three-dimensional pixel position referenced by pix * to world coordinates, which are placed in the array world[]. * Assumes that pix only has one point with an x,y,and z pixel positions. * Offsets these pixel values by 1 to account for the C arrays being indexed to 0. */ int nelem=3,npts=1,flag; double *newpix = new double[nelem*npts]; for(int i=0;i0){ 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 = "<cunit[2], outputUnits.c_str(), &scale, &offset, &power); if(flag>0){ if(errmsg==0){ std::cerr << "ERROR : WCSUNITS Error Code = " << flag << ":" << wcsunits_errmsg[flag] << std::endl; if(flag==10) std::cerr << "Tried to get conversion from " << wcs->cunit[2] << " to " << outputUnits.c_str() << std::endl; std::cerr << "Using coordinate value instead\n"; errmsg = 1; } return coord; } else return pow( (coord*scale + offset), power); } double velToCoord(wcsprm *wcs, const float velocity, string outputUnits) { /** * 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. */ double scale, offset, power; int flag = wcsunits( wcs->cunit[2], outputUnits.c_str(), &scale, &offset, &power); if(flag>0){ std::cerr << "ERROR : WCSUNITS Error Code = " << flag << ":" << wcsunits_errmsg[flag] << std::endl; std::cerr << "Using coordinate value instead\n"; return velocity; } else return (pow(velocity, 1./power) - offset) / scale; }