Changeset 8200
- Timestamp:
- Aug 6, 2006, 11:51:06 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.astro/drizzle.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.astro/drizzle.c
r8128 r8200 5 5 static double XO, XX, XY; 6 6 static double YO, YX, YY; 7 int ZERO; 7 static int ZERO; 8 9 static int ROTATE; 10 static double rot_phi, rot_alpha, rot_delta; 11 static double rot_cdp, rot_sdp; 8 12 9 13 int map_output_to_input (int Npix, double df); … … 13 17 14 18 Coords coords_in, coords_out; 15 Buffer *in, *out, *wt ;19 Buffer *in, *out, *wt, *mask; 16 20 17 21 int drizzle (int argc, char **argv) { … … 23 27 if ((N = get_argument (argc, argv, "-zero"))) { 24 28 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); 25 53 remove_argument (N, &argc, argv); 26 54 } … … 72 100 73 101 int i, j, Ni, No, Nx, Ny, nx, ny; 74 float *Vin, *Vout, *Vwt ;102 float *Vin, *Vout, *Vwt, *Vmk; 75 103 double x, y, X, Y; 76 104 … … 80 108 Vout = (float *) out[0].matrix.buffer; 81 109 Vwt = (float *) wt[0].matrix.buffer; 110 Vmk = NULL; 111 Vmk = (mask == NULL) ? NULL : (float *) mask[0].matrix.buffer; 82 112 83 113 nx = in[0].header.Naxis[0]; … … 110 140 Ni = (int)x + ((int)y)*nx; 111 141 142 if (Vmk && Vmk[Ni]) continue; 112 143 Vout[No] += Vin[Ni]; 113 144 Vwt[No] ++; … … 123 154 124 155 int i, j, Ni, No, Nx, Ny, nx, ny; 125 float *Vin, *Vout, *Vwt ;156 float *Vin, *Vout, *Vwt, *Vmk; 126 157 double x, y, X, Y; 127 158 … … 131 162 Vout = (float *) out[0].matrix.buffer; 132 163 Vwt = (float *) wt[0].matrix.buffer; 164 Vmk = NULL; 165 Vmk = (mask == NULL) ? NULL : (float *) mask[0].matrix.buffer; 133 166 134 167 Nx = in[0].header.Naxis[0]; … … 161 194 No = (int)x + ((int)y)*nx; 162 195 196 if (Vmk && Vmk[Ni]) continue; 163 197 Vout[No] += Vin[Ni]; 164 198 Vwt[No] ++; … … 170 204 } 171 205 206 int 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 172 228 /* find the linear astrometric fix between images at this location */ 173 229 int set_linear_terms (Coords *in, Coords *out, int i, int j, int Npix) { … … 177 233 double Xin, Yin, Xout, Yout; 178 234 double Sx2, Sy2, Sxy, SXx, SXy, SYx, SYy; 179 double N, r, d ;235 double N, r, d, phi, theta; 180 236 181 237 Xin = Yin = 0; … … 201 257 202 258 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 } 203 264 if (!RD_to_XY (&Xout, &Yout, r, d, out)) return (FALSE); 204 265
Note:
See TracChangeset
for help on using the changeset viewer.
