IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 12, 2009, 3:53:07 PM (17 years ago)
Author:
eugene
Message:

updates to burntool-and-related from camera svn

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/extsrc/gpcsw/gpcsrc/analysis/libpscoords/pscoords.c

    r23490 r24391  
    2424rcsid[] = "$Id: pscoords.c,v 1.2 2008/09/06 03:26:48 jt Exp jt $";
    2525
     26#define MRAD2 (0.001)   /* Convert from mrad to rad, used for PSC_OFFROT_T */
     27
    2628/* Overall focal plane offset and rotation (um, rad) */
    27 const PSC_OFFROT_T psc_psc_fpoff={0.,0.,0.};
     29PSC_OFFROT_T psc_psc_fpoff={0.,0.,0.};
    2830
    2931/* Offsets and rotations of each OTA (um, millirad) */
    30 const PSC_OFFROT_T psc_otaoff[PSC_NX*PSC_NY]={  /* Offsets and rotations derived o4885 090228 */
     32PSC_OFFROT_T psc_otaoff[PSC_NX*PSC_NY]={        /* Offsets and rotations derived o4885 090516 */
     33   {   0.0,   0.0,  0.00}, {  -6.8, -32.4, -1.30},  /* OTA00 , OTA10 */
     34   {  15.7,-130.7,  0.07}, {  -9.4, -43.5, -1.34},  /* OTA20 , OTA30 */
     35   {  17.8,  71.7, -0.48}, {   7.2,  41.3, -0.82},  /* OTA40 , OTA50 */
     36   {  22.1, -48.3, -1.74}, {   0.0,   0.0,  0.00},  /* OTA60 , OTA70 */
     37   { -23.0, -12.9,  0.68}, { -52.0, -52.2,  0.88},  /* OTA01 , OTA11 */
     38   {  28.8, -10.9, -0.73}, { -22.9,  18.1, -0.89},  /* OTA21 , OTA31 */
     39   { -13.8,  45.9,  0.90}, { -12.2,  49.7, -0.32},  /* OTA41 , OTA51 */
     40   { -31.9,  -9.8, -1.60}, {   1.9,   8.0,  0.53},  /* OTA61 , OTA71 */
     41   { -27.2,  42.6,  2.73}, {   6.5, -52.6,  0.48},  /* OTA02 , OTA12 */
     42   {  10.1, -37.9, -1.53}, {   3.1,-139.0,  1.75},  /* OTA22 , OTA32 */
     43   { -21.4,  25.6, -1.12}, { -13.8,   0.9,  0.02},  /* OTA42 , OTA52 */
     44   {  -1.8, -16.1, -2.06}, {  76.0,  31.7,  1.70},  /* OTA62 , OTA72 */
     45   { -15.7,  24.1,  0.14}, {-104.2, -76.8,  1.97},  /* OTA03 , OTA13 */
     46   {  75.4,  31.8,  1.04}, { -18.7,  14.6,  0.51},  /* OTA23 , OTA33 */
     47   { -30.6,  53.4, -0.78}, {  12.6,  24.4,  0.43},  /* OTA43 , OTA53 */
     48   {   8.0, -34.9,  1.44}, {   6.4, -73.2, -0.93},  /* OTA63 , OTA73 */
     49   { -31.2,  11.2,  0.23}, { -10.3,  -2.1,  0.14},  /* OTA04 , OTA14 */
     50   {  33.2, 207.9, -0.40}, { -75.7,-105.9,  0.93},  /* OTA24 , OTA34 */
     51   {   8.1, -15.9, -0.03}, { -16.1, -13.3, -0.06},  /* OTA44 , OTA54 */
     52   {   4.1,  47.6,  1.26}, {  71.6,  -6.0,  0.42},  /* OTA64 , OTA74 */
     53   { -23.4,  46.7,  2.65}, {  31.1,   5.5, -0.64},  /* OTA05 , OTA15 */
     54   { -43.2,  -6.5,  1.68}, { -26.0, -53.2,  0.00},  /* OTA25 , OTA35 */
     55   { -43.0,   9.1, -0.69}, {  30.1,  69.7,  0.62},  /* OTA45 , OTA55 */
     56   { -48.5,  61.6, -0.51}, {  65.5, -30.1,  0.69},  /* OTA65 , OTA75 */
     57   {   2.5,  57.2,  0.17}, {   0.6,  25.4, -0.91},  /* OTA06 , OTA16 */
     58   { -70.8, -17.4,  1.36}, {  13.6, -24.2,  0.53},  /* OTA26 , OTA36 */
     59   {  -6.8,  28.1, -1.35}, {  20.9,  42.0,  0.19},  /* OTA46 , OTA56 */
     60   {   6.2,  13.2, -1.50}, {  36.5,  48.8, -0.36},  /* OTA66 , OTA76 */
     61   {   0.0,   0.0,  0.00}, {  20.4,   1.7,  0.09},  /* OTA07 , OTA17 */
     62   {  83.8,  11.8, -0.56}, { -26.5, -21.2,  0.56},  /* OTA27 , OTA37 */
     63   { -70.5,   7.2, -1.05}, { -41.2,  -3.6, -1.89},  /* OTA47 , OTA57 */
     64   { -35.0,  49.5, -0.40}, {   0.0,   0.0,  0.00}}; /* OTA67 , OTA77 */
     65
     66/* Offsets and rotations of each OTA (um, millirad) */
     67#ifdef RUN_THREE_V1
     68PSC_OFFROT_T psc_otaoff[PSC_NX*PSC_NY]={        /* Offsets and rotations derived o4885 090228 */
    3169   {   0.0,   0.0,  0.00}, {  20.2, -59.5, -1.23},  /* OTA00 , OTA10 */
    3270   {  28.1,-138.1,  0.18}, {   2.0, -43.6, -1.22},  /* OTA20 , OTA30 */
     
    6199   { -74.8,   0.3, -0.92}, { -44.6,  -1.6, -1.78},  /* OTA47 , OTA57 */
    62100   { -50.3,  72.1, -0.47}, {   0.0,   0.0,  0.00}}; /* OTA67 , OTA77 */
     101#endif
    63102
    64103#ifdef RUN_TWO
     
    136175#endif
    137176
    138 static int DOOFFSET;    /* Do these offsets or no? */
     177static int DOOFFSET=1;  /* Do these offsets or no? */
    139178
    140179#if 0
     
    143182#endif
    144183
    145 /* Enable application of chip offsets? */
     184/* Enable application of chip offsets (um, mrad)? */
     185int psc_load_otaoff(const char *fname)
     186{
     187   int i;
     188   char rbuf[1024];
     189   FILE *fp;
     190   if( (fp=fopen(fname, "r")) == NULL) {
     191      fprintf(stderr, "error: Error opening OTA offset file '%s'\n", fname);
     192      return(-1);
     193   }
     194   for(i=0; i<PSC_NX*PSC_NY; i++) {
     195      if(fgets(rbuf, 1024, fp) == NULL ||
     196         sscanf(rbuf, "%lf %lf %lf", &psc_otaoff[i].dx,
     197                &psc_otaoff[i].dy, &psc_otaoff[i].rot) != 3) {
     198         fprintf(stderr, "error: Error reading OTA offset file '%s' line %d\n",
     199                 fname, i);
     200         fclose(fp);
     201         return(-1);
     202      }
     203   }
     204   fclose(fp);
     205   return(0);
     206}
     207
     208/* Load up a new offset table? */
    146209int psc_do_chipoff(int doit)
    147210{
     
    196259/* Position wrt OTA center after correction for offset and rotation */
    197260   if(DOOFFSET) {
    198       x =  (xp-psc_otaoff[idx].dx)*cos(psc_otaoff[idx].rot*0.001) +
    199          (yp-psc_otaoff[idx].dy)*sin(psc_otaoff[idx].rot*0.001);
    200       y = -(xp-psc_otaoff[idx].dx)*sin(psc_otaoff[idx].rot*0.001) +
    201          (yp-psc_otaoff[idx].dy)*cos(psc_otaoff[idx].rot*0.001);
     261      x =  (xp-psc_otaoff[idx].dx)*cos(psc_otaoff[idx].rot*MRAD2) +
     262         (yp-psc_otaoff[idx].dy)*sin(psc_otaoff[idx].rot*MRAD2);
     263      y = -(xp-psc_otaoff[idx].dx)*sin(psc_otaoff[idx].rot*MRAD2) +
     264         (yp-psc_otaoff[idx].dy)*cos(psc_otaoff[idx].rot*MRAD2);
    202265   } else {
    203266      x = xp;
     
    228291/* Position wrt nominal OTA center after its offset and rotation */
    229292   if(DOOFFSET) {
    230       xp = psc_otaoff[idx].dx + x*cos(psc_otaoff[idx].rot*0.001) - y*sin(psc_otaoff[idx].rot*0.001);
    231       yp = psc_otaoff[idx].dy + x*sin(psc_otaoff[idx].rot*0.001) + y*cos(psc_otaoff[idx].rot*0.001);
     293      xp = psc_otaoff[idx].dx + x*cos(psc_otaoff[idx].rot*MRAD2) - y*sin(psc_otaoff[idx].rot*MRAD2);
     294      yp = psc_otaoff[idx].dy + x*sin(psc_otaoff[idx].rot*MRAD2) + y*cos(psc_otaoff[idx].rot*MRAD2);
    232295   } else {
    233296      xp = x;
     
    292355
    293356/* Evaluate an optical model: arcsec -> microns notionally */
     357/* Offset, scale with quadratic and cubic distortion, rotate */
     358int psc_psoptics2(double x, double y, double dx, double dy, double dpa,
     359         double pscale, double d2, double d3, double *xfp, double *yfp)
     360{
     361   double w2=((x-dx)*(x-dx)+(y-dy)*(y-dy)), w;
     362   w = sqrt(w2);
     363   x = pscale * (1.0 + d2*w + d3*w2) * (x-dx);
     364   y = pscale * (1.0 + d2*w + d3*w2) * (y-dy);
     365/* Apply any extra TP-FP rotation */
     366   *xfp =  x * cos(dpa) + y * sin(dpa);
     367   *yfp = -x * sin(dpa) + y * cos(dpa);
     368   return(0);
     369}
     370
     371/* Evaluate an inverse optical model: microns -> arcsec notionally */
     372/* Offset, scale with *small* quadratic and cubic distortion, rotate */
     373int psc_invoptics2(double xfp, double yfp, double dx, double dy, double dpa,
     374          double pscale, double d2, double d3, double *x, double *y)
     375{
     376   double xp, yp, w;
     377/* Undo any extra TP-FP rotation */
     378   xp = (xfp * cos(dpa) - yfp * sin(dpa)) / pscale;
     379   yp = (xfp * sin(dpa) + yfp * cos(dpa)) / pscale;
     380   w = sqrt(xp*xp+yp*yp);
     381   *x = xp / (1.0 + d2*w + d3*(xp*xp+yp*yp)) + dx;
     382   *y = yp / (1.0 + d2*w + d3*(xp*xp+yp*yp)) + dy;
     383   return(0);
     384}
     385
     386
     387/* Evaluate an optical model: arcsec -> microns notionally */
    294388/* Offset, scale with distortion, rotate */
    295389int psc_psoptics(double x, double y, double dx, double dy, double dpa,
     
    318412   return(0);
    319413}
    320 
    321414
    322415/* Project RA,Dec (a,d) to the tangent plane (x,y) at (a0,d0,pa) [radians] */
Note: See TracChangeset for help on using the changeset viewer.