Changeset 20803
- Timestamp:
- Nov 19, 2008, 3:27:03 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroMosaicOneChip.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroMosaicOneChip.c
r19312 r20803 5 5 if (!status) { \ 6 6 psError(PSASTRO_ERR_CONFIG, false, MESSAGE); \ 7 return false; } 7 return false; } 8 8 9 9 bool psastroMosaicOneChip (pmChip *chip, pmReadout *readout, psMetadata *recipe, psMetadata *updates, int iteration) { … … 29 29 30 30 // correct radius to FP units (physical pixel scale in microns per pixel) 31 REQUIRED_RECIPE_VALUE (double pixelScale, "PSASTRO.PIXEL.SCALE", F32, "Failed to lookup pixel scale"); 31 REQUIRED_RECIPE_VALUE (double pixelScale, "PSASTRO.PIXEL.SCALE", F32, "Failed to lookup pixel scale"); 32 32 33 33 // allowed limits for valid solutions … … 42 42 int order = psMetadataLookupS32 (&status, recipe, orderWord); 43 43 if (!status || (order == -1)) { 44 order = defaultOrder;44 order = defaultOrder; 45 45 } 46 46 47 47 // modify the order to correspond to the actual number of matched stars: 48 if ((match->n < 1 5) && (order >= 3)) order = 2;49 if ((match->n < 1 1) && (order >= 2)) order = 1;50 if ((match->n < 8) && (order >= 1)) order = 0;48 if ((match->n < 17) && (order >= 3)) order = 2; 49 if ((match->n < 13) && (order >= 2)) order = 1; 50 if ((match->n < 9) && (order >= 1)) order = 0; 51 51 if ((match->n < 3) || (order < 0) || (order > 3)) { 52 psLogMsg ("psastro", 3, "insufficient stars (%ld) or invalid order (%d)", match->n, order); 53 return false; 54 } 52 psLogMsg ("psastro", 3, "insufficient stars (%ld) or invalid order (%d)", match->n, order); 53 return false; 54 } 55 55 56 56 psLogMsg ("psastro", PS_LOG_DETAIL, "mosaic fit chip order %d", order); … … 60 60 // coefficients frozen to the current values 61 61 if (order == 0) { 62 // set FIT mask for all higher order terms of the existing solution63 // any existing SET masks will be retained.64 for (int i = 0; i <= chip->toFPA->x->nX; i++) {65 for (int j = 0; j <= chip->toFPA->x->nY; j++) {66 if (i + j > 0) {67 chip->toFPA->x->coeffMask[i][j] |= PS_POLY_MASK_FIT;68 chip->toFPA->y->coeffMask[i][j] |= PS_POLY_MASK_FIT;69 }70 }71 }62 // set FIT mask for all higher order terms of the existing solution 63 // any existing SET masks will be retained. 64 for (int i = 0; i <= chip->toFPA->x->nX; i++) { 65 for (int j = 0; j <= chip->toFPA->x->nY; j++) { 66 if (i + j > 0) { 67 chip->toFPA->x->coeffMask[i][j] |= PS_POLY_MASK_FIT; 68 chip->toFPA->y->coeffMask[i][j] |= PS_POLY_MASK_FIT; 69 } 70 } 71 } 72 72 } else { 73 psFree (chip->toFPA);74 chip->toFPA = psPlaneTransformAlloc (order, order);75 for (int i = 0; i <= chip->toFPA->x->nX; i++) {76 for (int j = 0; j <= chip->toFPA->x->nY; j++) {77 if (i + j > order) {78 chip->toFPA->x->coeffMask[i][j] = PS_POLY_MASK_SET;79 chip->toFPA->y->coeffMask[i][j] = PS_POLY_MASK_SET;80 }81 }82 }73 psFree (chip->toFPA); 74 chip->toFPA = psPlaneTransformAlloc (order, order); 75 for (int i = 0; i <= chip->toFPA->x->nX; i++) { 76 for (int j = 0; j <= chip->toFPA->x->nY; j++) { 77 if (i + j > order) { 78 chip->toFPA->x->coeffMask[i][j] = PS_POLY_MASK_SET; 79 chip->toFPA->y->coeffMask[i][j] = PS_POLY_MASK_SET; 80 } 81 } 82 } 83 83 } 84 84 … … 87 87 psStats *fitStats = NULL; 88 88 // if (order == 0) { 89 // fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);90 // fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA");91 // fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER");89 // fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 90 // fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA"); 91 // fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER"); 92 92 // } else { 93 fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);94 fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA");95 fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER");93 fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 94 fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA"); 95 fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER"); 96 96 // } 97 97 … … 99 99 pmAstromFitResults *results = pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, fitStats); 100 100 if (!results) { 101 psError(PSASTRO_ERR_DATA, false, "failed to perform the matched fit\n");102 return false;101 psError(PSASTRO_ERR_DATA, false, "failed to perform the matched fit\n"); 102 return false; 103 103 } 104 104 … … 124 124 psLogMsg ("psastro", PS_LOG_INFO, "astrometry solution: error: %f arcsec, Nstars: %d", astError, astNstar); 125 125 if ((maxError > 0) && (astError > maxError)) { 126 psLogMsg("psastro", PS_LOG_INFO, "residual error is too large, failed to find a solution: %f > %f", astError, maxError);127 validSolution = false;126 psLogMsg("psastro", PS_LOG_INFO, "residual error is too large, failed to find a solution: %f > %f", astError, maxError); 127 validSolution = false; 128 128 } 129 129 if (astNstar < minNstar) { 130 psLogMsg("psastro", PS_LOG_INFO, "solution uses too few stars: %d < %d", astNstar, minNstar);131 validSolution = false;130 psLogMsg("psastro", PS_LOG_INFO, "solution uses too few stars: %d < %d", astNstar, minNstar); 131 validSolution = false; 132 132 } 133 133 … … 136 136 psMetadataAddF32 (updates, PS_LIST_TAIL, "CERROR", PS_META_REPLACE, "astrometry error (arcsec)", astError); 137 137 if (validSolution) { 138 psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "astrometry precision (arcsec)", astError/sqrt(astNstar));139 psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "number of astrometry stars", astNstar);138 psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "astrometry precision (arcsec)", astError/sqrt(astNstar)); 139 psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "number of astrometry stars", astNstar); 140 140 } else { 141 psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "astrometry precision (arcsec)", 0.0);142 psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "number of astrometry stars", 0);141 psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "astrometry precision (arcsec)", 0.0); 142 psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "number of astrometry stars", 0); 143 143 } 144 144 psMetadataAddF32 (updates, PS_LIST_TAIL, "EQUINOX", PS_META_REPLACE, "", 2000.0); // XXX this is bogus: should be defined based on equinox of refstars … … 147 147 psastroUpdateChipToFPA (fpa, chip, rawstars, refstars); 148 148 149 //plot results 150 psastroVisualPlotMosaicOneChip(rawstars, refstars, match, recipe); 151 149 152 psFree (fitStats); 150 153 psFree (results);
Note:
See TracChangeset
for help on using the changeset viewer.
