Changeset 10513
- Timestamp:
- Dec 6, 2006, 2:49:49 PM (20 years ago)
- Location:
- trunk/psastro/src
- Files:
-
- 3 edited
-
psastro.h (modified) (1 diff)
-
psastroChipAstrom.c (modified) (1 diff)
-
psastroWCS.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastro.h
r10438 r10513 43 43 44 44 bool pmAstromReadWCS (pmFPA *fpa, pmChip *chip, psMetadata *header, double plateScale, bool isMosaic); 45 bool pmAstromWriteWCS (psPlaneTransform *toFPA, psP rojection *toSky, psMetadata *header, double plateScale);45 bool pmAstromWriteWCS (psPlaneTransform *toFPA, psPlaneDistort *toTPA, psProjection *toSky, psMetadata *header, double plateScale); 46 46 psPlaneDistort *psPlaneDistortIdentity (); 47 bool psPlaneDistortIsIdentity (psPlaneDistort *distort); 47 48 48 49 psArray *psastroLoadRefstars (pmConfig *config); -
trunk/psastro/src/psastroChipAstrom.c
r10438 r10513 55 55 return false; 56 56 } 57 pmAstromWriteWCS (chip->toFPA, fpa->to Sky, updates, plateScale);57 pmAstromWriteWCS (chip->toFPA, fpa->toTangentPlane, fpa->toSky, updates, plateScale); 58 58 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.HEADER", PS_DATA_METADATA, "psastro header stats", updates); 59 59 psFree (updates); -
trunk/psastro/src/psastroWCS.c
r9643 r10513 208 208 // convert toFPA / toSky components to traditional WCS 209 209 // plateScale is nominal physical scale on tangent plane (microns / arcsecond) 210 bool pmAstromWriteWCS (psPlaneTransform *toFPA, psProjection *toSky, psMetadata *header, double plateScale) { 210 // this requires toTP to be the identity transformation 211 bool pmAstromWriteWCS (psPlaneTransform *toFPA, psPlaneDistort *toTPA, psProjection *toSky, psMetadata *header, double plateScale) { 212 213 // techinically, we can have a plate scale here (toTPA:dx,dy != 1) 214 if (!psPlaneDistortIsIdentity (toTPA)) psAbort ("psastro", "invalid TPA transformation"); 211 215 212 216 switch (toSky->type) { … … 232 236 } 233 237 234 // XXX not really right: needs to deal with non-identity toTP coeffs 238 # if (0) 239 // XXX not really right: needs to deal with non-identity to coeffs 235 240 // XXX actually, totally wrong. fix the conversions 236 241 // XXX need to handle the plateScale 242 243 // solve for CDELT1,2: 244 cdelt1 = toSky->Xs*DEG_RAD*toTPA->x->coeff[1][0][0][0]; 245 cdelt2 = toSky->Ys*DEG_RAD*toTPA->y->coeff[0][1][0][0]; 246 247 // L,M = toFPA(X,Y) 248 // solve for CRPIX1,2 (Xo,Yo) : L,M(Xo,Yo) = 0,0 249 // linear solution for Xo,Yo: 250 R = (xsum[1][0]*ysum[0][1] - xsum[0][1]*ysum[1][0]); 251 Xo = det*(ysum[0][0]*xsum[0][1] - xsum[0][0]*ysum[0][1]); 252 Yo = det*(xsum[0][0]*ysum[1][0] - ysum[0][0]*xsum[1][0]); 253 254 if ( 255 # endif 256 237 257 psMetadataAddF32 (header, PS_LIST_TAIL, "CRVAL1", PS_META_REPLACE, "", toSky->R*DEG_RAD); 238 258 psMetadataAddF32 (header, PS_LIST_TAIL, "CRVAL2", PS_META_REPLACE, "", toSky->D*DEG_RAD); … … 362 382 } 363 383 364 // XXX for the moment, we mimic the limited Elixir mosastro orders384 // construct a psPlaneDistort which is the identify transformation 365 385 psPlaneDistort *psPlaneDistortIdentity (int order) { 366 386 … … 376 396 for (int j = 0; j <= order; j++) { 377 397 if (i + j > order) { 378 distort->x->mask [ 1][1][0][0] = 1;379 distort->y->mask [ 1][1][0][0] = 1;398 distort->x->mask [i][j][0][0] = 1; 399 distort->y->mask [i][j][0][0] = 1; 380 400 } 381 401 } … … 386 406 return distort; 387 407 } 408 409 // check that the given psPlaneDistort is the identity 410 bool psPlaneDistortIsIdentity (psPlaneDistort *distort) { 411 412 int order; 413 bool status; 414 415 // we currently only support up to 3rd order polynomials 416 if (distort->x->nX < 1) return false; 417 if (distort->x->nY < 1) return false; 418 if (distort->y->nX < 1) return false; 419 if (distort->y->nY < 1) return false; 420 421 if (distort->x->nX > 3) return false; 422 if (distort->x->nY > 3) return false; 423 if (distort->y->nX > 3) return false; 424 if (distort->y->nY > 3) return false; 425 426 if (distort->x->nZ > 0) return false; 427 if (distort->x->nT > 0) return false; 428 if (distort->y->nZ > 0) return false; 429 if (distort->y->nT > 0) return false; 430 431 if (distort->x->nX != distort->x->nY) return false; 432 if (distort->y->nX != distort->y->nY) return false; 433 434 status = true; 435 order = distort->x->nX; 436 for (int i = 0; i <= order; i++) { 437 for (int j = 0; j <= order; j++) { 438 if (i + j > order) { 439 // high-order cross terms must be masked (eg, x^3 y^2) 440 status &= !distort->x->mask[i][j][0][0]; 441 } else { 442 if (i + j != 1) { 443 // non-linear and off-diagonal terms must be 0 (eg, x^2, x y) 444 status &= (distort->x->coeff[i][j][0][0] == 0.0); 445 } else { 446 // linear, diagonal terms must be 1.0 447 status &= (distort->x->coeff[i][j][0][0] == 1.0); 448 } 449 } 450 } 451 } 452 453 order = distort->y->nX; 454 for (int i = 0; i <= order; i++) { 455 for (int j = 0; j <= order; j++) { 456 if (i + j > order) { 457 // high-order cross terms must be masked (eg, x^3 y^2) 458 status &= !distort->y->mask[i][j][0][0]; 459 } else { 460 if (i + j != 1) { 461 // non-linear and off-diagonal terms must be 0 (eg, x^2, x y) 462 status &= (distort->y->coeff[i][j][0][0] == 0.0); 463 } else { 464 // linear, diagonal terms must be 1.0 465 status &= (distort->y->coeff[i][j][0][0] == 1.0); 466 } 467 } 468 } 469 } 470 return status; 471 }
Note:
See TracChangeset
for help on using the changeset viewer.
