IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8200


Ignore:
Timestamp:
Aug 6, 2006, 11:51:06 AM (20 years ago)
Author:
eugene
Message:

added euler angle rotations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.astro/drizzle.c

    r8128 r8200  
    55static double XO, XX, XY;
    66static double YO, YX, YY;
    7 int ZERO;
     7static int ZERO;
     8
     9static int ROTATE;
     10static double rot_phi, rot_alpha, rot_delta;
     11static double rot_cdp, rot_sdp;
    812
    913int map_output_to_input (int Npix, double df);
     
    1317
    1418Coords coords_in, coords_out;
    15 Buffer *in, *out, *wt;
     19Buffer *in, *out, *wt, *mask;
    1620
    1721int drizzle (int argc, char **argv) {
     
    2327  if ((N = get_argument (argc, argv, "-zero"))) {
    2428    ZERO = TRUE;
     29    remove_argument (N, &argc, argv);
     30  }
     31
     32  ROTATE = FALSE;
     33  if ((N = get_argument (argc, argv, "-roll"))) {
     34    /* -roll phi alpha_pole delta_pole */
     35    /* XXX need to clarify the meaning of phi, alpha, delta */
     36    ROTATE = TRUE;
     37    remove_argument (N, &argc, argv);
     38    rot_phi   = atof (argv[N]);
     39    remove_argument (N, &argc, argv);
     40    rot_alpha = atof (argv[N]);
     41    remove_argument (N, &argc, argv);
     42    rot_delta = atof (argv[N]);
     43    remove_argument (N, &argc, argv);
     44
     45    rot_cdp = cos(RAD_DEG*rot_delta);
     46    rot_sdp = sin(RAD_DEG*rot_delta);
     47  }
     48
     49  mask = NULL;
     50  if ((N = get_argument (argc, argv, "-mask"))) {
     51    remove_argument (N, &argc, argv);
     52    if ((mask = SelectBuffer (argv[N], OLDBUFFER, TRUE)) == NULL) return (FALSE);
    2553    remove_argument (N, &argc, argv);
    2654  }
     
    72100
    73101  int i, j, Ni, No, Nx, Ny, nx, ny;
    74   float *Vin, *Vout, *Vwt;
     102  float *Vin, *Vout, *Vwt, *Vmk;
    75103  double x, y, X, Y;
    76104
     
    80108  Vout = (float *) out[0].matrix.buffer;
    81109  Vwt  = (float *) wt[0].matrix.buffer;
     110  Vmk  = NULL;
     111  Vmk = (mask == NULL) ? NULL : (float *) mask[0].matrix.buffer;
    82112
    83113  nx = in[0].header.Naxis[0];
     
    110140          Ni = (int)x + ((int)y)*nx;
    111141
     142          if (Vmk && Vmk[Ni]) continue;
    112143          Vout[No] += Vin[Ni];
    113144          Vwt[No] ++;
     
    123154
    124155  int i, j, Ni, No, Nx, Ny, nx, ny;
    125   float *Vin, *Vout, *Vwt;
     156  float *Vin, *Vout, *Vwt, *Vmk;
    126157  double x, y, X, Y;
    127158
     
    131162  Vout = (float *) out[0].matrix.buffer;
    132163  Vwt  = (float *) wt[0].matrix.buffer;
     164  Vmk  = NULL;
     165  Vmk = (mask == NULL) ? NULL : (float *) mask[0].matrix.buffer;
    133166
    134167  Nx = in[0].header.Naxis[0];
     
    161194          No = (int)x + ((int)y)*nx;
    162195
     196          if (Vmk && Vmk[Ni]) continue;
    163197          Vout[No] += Vin[Ni];
    164198          Vwt[No] ++;
     
    170204}
    171205
     206int rotate_coords (double *phi, double *theta, double alpha, double delta) {
     207
     208  double sda, cda, cd, sd, sth;
     209  double x, y;
     210 
     211  sda = sin(RAD_DEG*(alpha - rot_alpha));
     212  cda = cos(RAD_DEG*(alpha - rot_alpha));
     213  sd = sin(RAD_DEG*delta);
     214  cd = cos(RAD_DEG*delta);
     215 
     216  sth = -cd*sda*rot_cdp + sd*rot_sdp;
     217  y   = +cd*sda*rot_sdp + sd*rot_cdp;
     218  x   = +cd*cda;
     219
     220  *theta = DEG_RAD*asin(sth);
     221  *phi   = DEG_RAD*atan2(y,x) + rot_phi;
     222 
     223  while (*phi <   0.0) *phi += 360.0;
     224  while (*phi > 360.0) *phi -= 360.0;
     225  return (TRUE);
     226}
     227
    172228/* find the linear astrometric fix between images at this location */
    173229int set_linear_terms (Coords *in, Coords *out, int i, int j, int Npix) {
     
    177233  double Xin, Yin, Xout, Yout;
    178234  double Sx2, Sy2, Sxy, SXx, SXy, SYx, SYy;
    179   double N, r, d;
     235  double N, r, d, phi, theta;
    180236
    181237  Xin = Yin = 0;
     
    201257
    202258    if (!XY_to_RD (&r, &d, Xin, Yin, in)) return (FALSE);
     259    if (ROTATE) {
     260      rotate_coords (&phi, &theta, r, d);
     261      r = phi;
     262      d = theta;
     263    }
    203264    if (!RD_to_XY (&Xout, &Yout, r, d, out)) return (FALSE);
    204265
Note: See TracChangeset for help on using the changeset viewer.