/* File : v2v3.c * * Contents : * XY_to_V2V3 : Convert detector X,Y to pupil V2,V3; used by v2v3() * V2V3_to_XY : Convert field V2,V3 to detector X,Y; used by v2v3() * v2v3 : Compute pupil V2,V3 for a given detector X,Y * * Author : John Krist * Date : October 2000 * */ #include #include #include "tinytim.h" /*------------------------------------------------------------------------ * XY_to_V2V3 : * * Convert geometrically distorted detector X,Y pixel position to * V2,V3 field coordinates, with conversion to V2,V3 pupil * coordinates. * * Inputs : * x, y : Detector pixel position * Outputs : * v2, v3 : Position in arcsec in pupil coordinate system * * NOTE : This routine only works for the ACS *-------------------------------------------------------------------------*/ void XY_to_V2V3( float x, float y, float *v2, float *v3 ) { /* NOTE : the negative of Pars.v2,v3 are used below since they * * are in pupil coordinates while the transform coefficients * * are in normal field coordinates. */ /* transforms are relative to the reference position */ x = x - Pars.x_ref; y = y - Pars.y_ref; *v2 = -Pars.v2 + y*Pars.xy_to_v2[0] + x*Pars.xy_to_v2[1] + y*y*Pars.xy_to_v2[2] + x*y*Pars.xy_to_v2[3] + x*x*Pars.xy_to_v2[4] + y*y*y*Pars.xy_to_v2[5] + x*y*y*Pars.xy_to_v2[6] + x*x*y*Pars.xy_to_v2[7] + x*x*x*Pars.xy_to_v2[8]; *v3 = -Pars.v3 + y*Pars.xy_to_v3[0] + x*Pars.xy_to_v3[1] + y*y*Pars.xy_to_v3[2] + x*y*Pars.xy_to_v3[3] + x*x*Pars.xy_to_v3[4] + y*y*y*Pars.xy_to_v3[5] + x*y*y*Pars.xy_to_v3[6] + x*x*y*Pars.xy_to_v3[7] + x*x*x*Pars.xy_to_v3[8]; /* convert to V2,V3 pupil coordinate system */ *v2 = -(*v2); *v3 = -(*v3); } /*------------------------------------------------------------------------ * V2V3_to_XY : * * Convert V2,V3 field coordinates to geometrically distorted detector * X,Y pixel position * * Inputs : * v2, v3 : Field position in arcsec (NOT in pupil coordinate system) * Outputs : * x, y : Detector pixel position * * NOTE : This routine only works for the ACS *-------------------------------------------------------------------------*/ void V2V3_to_XY( float *x, float *y, float v2, float v3 ) { v2 = v2 - (-Pars.v2); v3 = v3 - (-Pars.v3); *x = v3*Pars.v2v3_to_x[0] + v2*Pars.v2v3_to_x[1] + v3*v3*Pars.v2v3_to_x[2] + v2*v3*Pars.v2v3_to_x[3] + v2*v2*Pars.v2v3_to_x[4] + v3*v3*v3*Pars.v2v3_to_x[5] + v2*v3*v3*Pars.v2v3_to_x[6] + v2*v2*v3*Pars.v2v3_to_x[7] + v2*v2*v2*Pars.v2v3_to_x[8]; *y = v3*Pars.v2v3_to_y[0] + v2*Pars.v2v3_to_y[1] + v3*v3*Pars.v2v3_to_y[2] + v2*v3*Pars.v2v3_to_y[3] + v2*v2*Pars.v2v3_to_y[4] + v3*v3*v3*Pars.v2v3_to_y[5] + v2*v3*v3*Pars.v2v3_to_y[6] + v2*v2*v3*Pars.v2v3_to_y[7] + v2*v2*v2*Pars.v2v3_to_y[8]; /* transforms are relative to reference position */ *x = *x + Pars.x_ref; *y = *y + Pars.y_ref; } /*------------------------------------------------------------------------- * v2v3 : * Compute V2,V3 pupil coordinates for a given detector X,Y position; * pupil coordinates are the negative of field coordinates * * Inputs : * camera : camera id number * x, y : position on detector * Outputs : * v2, v3 : v2,v3 pupil coordinates *-------------------------------------------------------------------------*/ void v2v3( int camera, int x, int y, float *v2, float *v3 ) { float t; if ( camera >= 1 && camera <= 8 ) { /* WFPC1 coordinates are 0-799 */ /* convert to arcsec from detector center */ x = (x - 412) * Pars.pixel_size; y = (y - 412) * Pars.pixel_size; /* adjust for detector rotation with respect to OTA */ t = (90 + Pars.theta) * M_PI / 180.0; *v2 = -(x * cos(t) - y * sin(t)) + Pars.v2; *v3 = x * sin(t) + y * cos(t) + Pars.v3; } else if ( camera >= WFPC2_PC && camera <= WFPC2_WFC_4 ) { /* WFPC2 coordinates are 0-799 */ /* convert to arcsec from detector center */ x = (x - 420) * Pars.pixel_size; y = (y - 420) * Pars.pixel_size; /* adjust for detector rotation with respect to OTA */ t = (90 + Pars.theta) * M_PI / 180.0; *v2 = -(x * cos(t) - y * sin(t)) + Pars.v2; *v3 = x * sin(t) + y * cos(t) + Pars.v3; } else if ( camera >= NICMOS_1 && camera <= NICMOS_3 ) { /* NICMOS coordinates are 0-255 */ /* convert to arcsec from detector center */ x = (x - 128) * Pars.pixel_size; y = (y - 128) * Pars.pixel_size; /* adjust for detector rotation with respect to OTA */ t = (90 + Pars.theta) * M_PI / 180.0; *v2 = -(x * cos(t) - y * sin(t)) + Pars.v2; *v3 = x * sin(t) + y * cos(t) + Pars.v3; } else if ( camera >= ACS_WFC1 && camera <= ACS_SBC ) XY_to_V2V3( (float)x, (float)y, v2, v3 ); else { *v2 = Pars.v2; *v3 = Pars.v3; } } /* v2v3 */