Changeset 10830 for trunk/psastro/src/psastroMosaicAstrom.c
- Timestamp:
- Dec 24, 2006, 3:56:53 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroMosaicAstrom.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroMosaicAstrom.c
r10815 r10830 1 1 # include "psastro.h" 2 # define NONLIN_TOL 0.001 /* tolerance in pixels */ 2 3 4 // XXX require this fpa to have multiple chip extensions and a PHU? 3 5 bool psastroMosaicAstrom (pmConfig *config, psArray *refs) { 4 6 5 7 bool status; 6 psArray *grad s = NULL;8 psArray *gradients = NULL; 7 9 8 10 // select the current recipe … … 20 22 } 21 23 22 int order = psMetadataLookupF32 (&status, recipe, "PSASTRO.DISTORTION.ORDER");23 if (!status) order = 3.0;24 25 24 pmFPA *fpa = input->fpa; 26 25 27 psastroMosaicSetMatch (fpa, recipe); 26 // XXX before we do object matches, we need to fix failed chips 27 // compare chips with supplied mosaic model 28 // adjust significant outliers to match model 28 29 29 // XXX no input distortion model yet; existing fpa distortion is identity: replace it 30 // XXX make this a test if these are NULL; the load step can NULL them if nothing is loaded 31 // XXX if we have an input distortion model, the gradient is measuring the error rel to that model 32 // XXX how does this couple to the individual chip fits? 30 // given the existing per-chip astrometry, determine matches between raw and ref stars 31 psastroMosaicSetMatch (fpa, recipe, 0); 32 33 // fitted chips will follow the local plate-scale, hiding the distortion 34 // modify the chip->toFPA scaling to match knowledge about pixel scale 35 psastroMosaicCommonScale (fpa, recipe); 36 37 gradients = psastroMosaicGradients (fpa, recipe); 38 39 // allocate mosaic-level polynomial transformation and set masks needed by DVO 40 int order = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.ORDER"); 41 if (!status) { 42 psError(PSASTRO_ERR_UNKNOWN, false, "failed to find single-chip fit order\n"); 43 return false; 44 } 33 45 psFree (fpa->toTPA); 34 psFree (fpa->fromTPA); 35 fpa->toTPA = psPlaneDistortIdentity (order); 36 fpa->fromTPA = psPlaneDistortIdentity (order); 46 fpa->toTPA = psPlaneTransformAlloc (order, order); 47 for (int i = 0; i <= fpa->toTPA->x->nX; i++) { 48 for (int j = 0; j <= fpa->toTPA->x->nY; j++) { 49 if (i + j > order) { 50 fpa->toTPA->x->mask[i][j] = 1; 51 fpa->toTPA->y->mask[i][j] = 1; 52 } 53 } 54 } 37 55 38 grads = psastroMosaicGetGrads (fpa, recipe); 39 40 // fit the measured gradients with the telescope distortion model (3rd order polynomial) 41 pmAstromFitDistortion (fpa, grads, recipe); 42 psastroMosaicRescaleChips (fpa); 56 // fit the measured gradients with the telescope distortion model (polynomial order based on toTPA) 57 pmAstromFitDistortion (fpa, gradients, recipe); 58 psFree (gradients); 43 59 44 60 // apply the new distortion terms up and down 45 61 // re-perform the match with a slightly tighter circle 62 // XXX modify match radius 63 // XXX set chip.order to 1 46 64 psastroMosaicSetAstrom (fpa); 47 psastroMosaicSetMatch (fpa, recipe); 65 psastroMosaicSetMatch (fpa, recipe, 1); 66 psastroMosaicChipAstrom (fpa, recipe, 1); 48 67 49 // fit the chips with linear fits 50 // re-match 51 psastroMosaicChipAstrom (fpa, recipe); 52 psastroMosaicSetMatch (fpa, recipe); 68 // do a second pass on the distortion with improved chip positions and rotations 69 // XXX do we need to iterate with this step until the distortions don't change? 70 psastroMosaicCommonScale (fpa, recipe); 71 gradients = psastroMosaicGradients (fpa, recipe); 72 pmAstromFitDistortion (fpa, gradients, recipe); 73 psFree (gradients); 74 75 // now fit the chips under the common distortion with higher-order terms 76 // XXX modify match radius 77 // XXX set chip.order to NORDER 78 psastroMosaicSetAstrom (fpa); 79 psastroMosaicSetMatch (fpa, recipe, 2); 80 psastroMosaicChipAstrom (fpa, recipe, 2); 53 81 54 // re-fit the chips with higher-order fits 55 // re-match 56 psastroMosaicChipAstrom (fpa, recipe); 57 psastroMosaicSetMatch (fpa, recipe); 82 // save WCS and analysis metadata in update header 83 // XXX need to add global summary statistics 84 psMetadata *updates = psMetadataAlloc(); 85 pmAstromWriteBilevelMosaic (updates, fpa, NONLIN_TOL); 86 psMetadataAdd (fpa->analysis, PS_LIST_TAIL, "PSASTRO.HEADER", PS_DATA_METADATA, "psastro header stats", updates); 87 psFree (updates); 58 88 59 // re-fit the chips with higher-order fits 60 psastroMosaicChipAstrom (fpa, recipe); 61 psastroMosaicHeaders (config); 89 // update the headers based on the results 90 // psastroMosaicHeaders (config); 62 91 63 92 return true; … … 65 94 66 95 /* coordinate frame hierachy 67 pixels (on a given readout)68 cell69 chip70 FP (focal plane)71 TP (tangent plane)72 sky (ra, dec)73 */96 * pixels (on a given readout) 97 * cell 98 * chip 99 * FP (focal plane) 100 * TP (tangent plane) 101 * sky (ra, dec) 102 */
Note:
See TracChangeset
for help on using the changeset viewer.
