Changeset 10830
- Timestamp:
- Dec 24, 2006, 3:56:53 PM (19 years ago)
- Location:
- trunk/psastro/src
- Files:
-
- 2 added
- 10 edited
-
Makefile.am (modified) (3 diffs)
-
psastro.h (modified) (1 diff)
-
psastroAstromGuess.c (modified) (7 diffs)
-
psastroChooseRefstars.c (modified) (1 diff)
-
psastroMosaicAstrom.c (modified) (3 diffs)
-
psastroMosaicChipAstrom.c (modified) (3 diffs)
-
psastroMosaicGradients.c (added)
-
psastroMosaicOneChip.c (added)
-
psastroMosaicSetAstrom.c (modified) (2 diffs)
-
psastroMosaicSetMatch.c (modified) (3 diffs)
-
psastroOneChip.c (modified) (2 diffs)
-
psastroUtils.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/Makefile.am
r10716 r10830 12 12 13 13 libpsastro_la_SOURCES = \ 14 psastroArguments.c \ 14 psastroArguments.c \ 15 psastroErrorCodes.c \ 16 psastroVersion.c \ 15 17 psastroCleanup.c \ 16 18 psastroParseCamera.c \ … … 18 20 psastroDataSave.c \ 19 21 psastroAstromGuess.c \ 20 psastroLoadRefstars.c \21 psastroChooseRefstars.c \22 psastroLoadRefstars.c \ 23 psastroChooseRefstars.c \ 22 24 psastroConvert.c \ 23 25 psastroChipAstrom.c \ … … 28 30 psastroRefstarSubset.c \ 29 31 psastroMosaicAstrom.c \ 30 psastroMosaicG etGrads.c\32 psastroMosaicGradients.c \ 31 33 psastroMosaicChipAstrom.c \ 34 psastroMosaicOneChip.c \ 32 35 psastroMosaicSetAstrom.c \ 33 psastroMosaicSetMatch.c \ 34 psastroMosaicHeaders.c \ 35 psastroMosaicRescaleChips.c \ 36 psastroErrorCodes.c \ 37 psastroVersion.c 36 psastroMosaicSetMatch.c 38 37 39 38 include_HEADERS = \ -
trunk/psastro/src/psastro.h
r10716 r10830 56 56 57 57 // mosaic fitting functions 58 psArray *psastroMosaicGetGrads (pmFPA *fpa, psMetadata *recipe); 58 psArray *psastroMosaicGradients (pmFPA *fpa, psMetadata *recipe); 59 bool psastroMosaicCommonScale (pmFPA *fpa, psMetadata *recipe); 59 60 bool psastroMosaicAstrom (pmConfig *config, psArray *refs); 60 bool psastroMosaicChipAstrom (pmFPA *fpa, psMetadata *recipe );61 bool psastroMosaicSetMatch (pmFPA *fpa, psMetadata *recipe );61 bool psastroMosaicChipAstrom (pmFPA *fpa, psMetadata *recipe, int iteration); 62 bool psastroMosaicSetMatch (pmFPA *fpa, psMetadata *recipe, int iteration); 62 63 bool psastroMosaicSetAstrom (pmFPA *fpa); 63 64 bool psastroMosaicHeaders (pmConfig *config); 64 65 bool psastroMosaicRescaleChips (pmFPA *fpa); 65 66 bool pmAstromWriteBilevelChip (psPlaneTransform *toFPA, psMetadata *header, double plateScale); 67 psMetadata *pmAstromWriteBilevelMosaic (psProjection *toSky, psPlaneDistort *toTP, double plateScale); 66 bool psastroMosaicOneChip (pmChip *chip, pmReadout *readout, psMetadata *recipe, psMetadata *updates, int iteration); 68 67 69 68 // Return version strings. 70 69 psString psastroVersion(void); 71 70 psString psastroVersionLong(void); 71 -
trunk/psastro/src/psastroAstromGuess.c
r10784 r10830 11 11 bool newFPA = true; 12 12 bool status = false; 13 bool isMosaic = false;14 13 double RAmin = NAN; 15 14 double RAmax = NAN; … … 25 24 DECmin = DECmax = -90; 26 25 RAmin = RAmax = RAminSky = RAmaxSky = 0; 27 28 // is this a mosaic astrometry analysis?29 psMetadataLookupStr (&isMosaic, config->arguments, "MOSASTRO");30 26 31 27 // select the current recipe … … 43 39 } 44 40 45 double plateScale = psMetadataLookupF32 (&status, recipe, "PSASTRO.PLATE.SCALE"); 46 if (!status) plateScale = 1.0; 47 plateScale = 1.0; 41 // physical pixel scale in microns per pixel 42 double pixelScale = psMetadataLookupF32 (&status, recipe, "PSASTRO.PIXEL.SCALE"); 43 if (!status) { 44 psError(PS_ERR_IO, false, "Failed to lookup pixel scale"); 45 return false; 46 } 48 47 49 48 pmFPAview *view = pmFPAviewAlloc (0); … … 57 56 pmHDU *hdu = pmFPAviewThisHDU (view, fpa); 58 57 59 pmAstromReadWCS (fpa, chip, hdu->header, p lateScale, isMosaic);58 pmAstromReadWCS (fpa, chip, hdu->header, pixelScale); 60 59 if (newFPA) { 61 60 newFPA = false; … … 69 68 70 69 // apply the new WCS guess data to all of the data in the readouts 71 // XXX should this go into a different function? this would separate WCS interpretation from application72 70 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 73 71 psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); … … 85 83 86 84 psPlaneTransformApply (raw->FP, chip->toFPA, raw->chip); 87 psPlane DistortApply (raw->TP, fpa->toTPA, raw->FP, 0.0, 0.0);85 psPlaneTransformApply (raw->TP, fpa->toTPA, raw->FP); 88 86 psDeproject (raw->sky, raw->TP, fpa->toSky); 89 87 … … 100 98 101 99 psProject (tp, raw->sky, fpa->toSky); 102 psPlane DistortApply (fp, fpa->fromTPA, tp, 0.0, 0.0);100 psPlaneTransformApply (fp, fpa->fromTPA, tp); 103 101 psPlaneTransformApply (ch, chip->fromFPA, fp); 104 102 -
trunk/psastro/src/psastroChooseRefstars.c
r10785 r10830 62 62 63 63 psProject (ref->TP, ref->sky, fpa->toSky); 64 psPlane DistortApply (ref->FP, fpa->fromTPA, ref->TP, 0.0, 0.0);64 psPlaneTransformApply (ref->FP, fpa->fromTPA, ref->TP); 65 65 psPlaneTransformApply (ref->chip, chip->fromFPA, ref->FP); 66 66 -
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 */ -
trunk/psastro/src/psastroMosaicChipAstrom.c
r9574 r10830 1 1 # include "psastro.h" 2 # define NONLIN_TOL 0.001 /* tolerance in pixels */ 2 3 3 bool psastroMosaicChipAstrom (pmFPA *fpa, psMetadata *recipe ) {4 bool psastroMosaicChipAstrom (pmFPA *fpa, psMetadata *recipe, int iteration) { 4 5 5 6 pmChip *chip = NULL; … … 22 23 if (! readout->data_exists) { continue; } 23 24 24 // select the raw objects for this readout 25 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS"); 26 if (rawstars == NULL) { continue; } 25 // save WCS and analysis metadata in update header 26 psMetadata *updates = psMetadataAlloc(); 27 27 28 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS"); 29 if (refstars == NULL) { continue; } 28 psastroMosaicOneChip (chip, readout, recipe, updates, iteration); 30 29 31 psArray *match = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.MATCH"); 32 if (match == NULL) { continue; } 33 34 // need to pass in an update header, sent in from above 35 pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, recipe, NULL); 30 pmAstromWriteBilevelChip (updates, chip, NONLIN_TOL); 31 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.HEADER", PS_DATA_METADATA, "psastro header stats", updates); 32 psFree (updates); 36 33 } 37 34 } … … 39 36 return true; 40 37 } 38 39 /* the iteration value may be 1 or 2. 40 */ -
trunk/psastro/src/psastroMosaicSetAstrom.c
r10613 r10830 30 30 31 31 psPlaneTransformApply (raw->FP, chip->toFPA, raw->chip); 32 psPlane DistortApply (raw->TP, fpa->toTPA, raw->FP, 0.0, 0.0);32 psPlaneTransformApply (raw->TP, fpa->toTPA, raw->FP); 33 33 psDeproject (raw->sky, raw->TP, fpa->toSky); 34 34 } … … 41 41 42 42 psProject (ref->TP, ref->sky, fpa->toSky); 43 psPlane DistortApply (ref->FP, fpa->fromTPA, ref->TP, 0.0, 0.0);43 psPlaneTransformApply (ref->FP, fpa->fromTPA, ref->TP); 44 44 psPlaneTransformApply (ref->chip, chip->fromFPA, ref->FP); 45 45 } -
trunk/psastro/src/psastroMosaicSetMatch.c
r9574 r10830 1 1 # include "psastro.h" 2 2 3 bool psastroMosaicSetMatch (pmFPA *fpa, psMetadata *recipe ) {3 bool psastroMosaicSetMatch (pmFPA *fpa, psMetadata *recipe, int iteration) { 4 4 5 5 pmChip *chip = NULL; … … 7 7 pmReadout *readout = NULL; 8 8 pmFPAview *view = pmFPAviewAlloc (0); 9 10 FILE *f; 11 char name[128]; 9 char radiusWord[64]; 12 10 13 11 FILE *g1 = fopen ("raw.ps.dat", "w"); 14 12 FILE *g2 = fopen ("ref.ps.dat", "w"); 13 14 // use small radius to match stars (assume starting astrometry is good) 15 bool status = false; 16 sprintf (radiusWord, "PSASTRO.MOSAIC.RADIUS.N%d", iteration); 17 double RADIUS = psMetadataLookupF32 (&status, recipe, radiusWord); 18 if (!status) { 19 psError(PS_ERR_IO, false, "Failed to lookup matching radius: %s", radiusWord); 20 return NULL; 21 } 15 22 16 23 // this loop selects the matched stars for all chips … … 37 44 psTrace ("psastro", 4, "Trying %ld refstars\n", refstars->n); 38 45 39 // use small radius to match stars (assume starting astrometry is good) 40 // XXX should this take a (double radius)? 41 psArray *matches = pmAstromRadiusMatchChip (rawstars, refstars, recipe); 46 psArray *matches = pmAstromRadiusMatchChip (rawstars, refstars, RADIUS); 42 47 psTrace ("psastro", 4, "Matched %ld refstars\n", matches->n); 43 44 sprintf (name, "raw.%02d.dat", view->chip);45 f = fopen (name, "w");46 for (int i = 0; i < rawstars->n; i++) {47 pmAstromObj *raw = rawstars->data[i];48 fprintf (f, "%f %f %f %f %f %f\n", raw->chip->x, raw->chip->y, raw->FP->x, raw->FP->y, raw->sky->r, raw->sky->d);49 }50 fclose (f);51 52 sprintf (name, "ref.%02d.dat", view->chip);53 f = fopen (name, "w");54 for (int i = 0; i < refstars->n; i++) {55 pmAstromObj *ref = refstars->data[i];56 fprintf (f, "%f %f %f %f %f %f\n", ref->chip->x, ref->chip->y, ref->FP->x, ref->FP->y, ref->sky->r, ref->sky->d);57 }58 fclose (f);59 48 60 49 for (int i = 0; i < matches->n; i++) { -
trunk/psastro/src/psastroOneChip.c
r10789 r10830 25 25 psastroUpdateChipToFPA (fpa, chip, rawstars, refstars); 26 26 27 // supplied radius is in pixels 28 double RADIUS = psMetadataLookupF32 (&status, recipe, "PSASTRO.MATCH.RADIUS"); 29 if (!status) { 30 psError(PS_ERR_IO, false, "Failed to lookup matching radius"); 31 return false; 32 } 33 34 // correct to FP units (physical pixel scale in microns per pixel) 35 double pixelScale = psMetadataLookupF32 (&status, recipe, "PSASTRO.PIXEL.SCALE"); 36 if (!status) { 37 psError(PS_ERR_IO, false, "Failed to lookup pixel scale"); 38 return false; 39 } 40 RADIUS *= pixelScale; 41 27 42 // use small radius to match stars 28 psArray *match = pmAstromRadiusMatch (rawstars, refstars, recipe);43 psArray *match = pmAstromRadiusMatchFP (rawstars, refstars, RADIUS); 29 44 if (stats == NULL) { 30 45 psError(PSASTRO_ERR_UNKNOWN, false, "failed to find radius-matched sources\n"); … … 32 47 } 33 48 34 int nX = psMetadataLookupS32 (&status, recipe, "PSASTRO.CHIP.NX"); 35 if (!status) nX = 1; 36 37 int nY = psMetadataLookupS32 (&status, recipe, "PSASTRO.CHIP.NY"); 38 if (!status) nY = 1; 39 40 psPlaneTransform *toFPAout = psPlaneTransformAlloc (nX, nY); 41 42 // improved fit for astrometric terms 43 if (!pmAstromMatchFit (toFPAout, rawstars, refstars, match, recipe, updates)) { 44 psError(PSASTRO_ERR_DATA, false, "failed to find a valid fitted match solution\n"); 49 // create the output fit model 50 int order = psMetadataLookupS32 (&status, recipe, "PSASTRO.CHIP.ORDER"); 51 if (!status) { 52 psError(PSASTRO_ERR_UNKNOWN, false, "failed to find single-chip fit order\n"); 45 53 return false; 46 54 } 47 55 psFree (chip->toFPA); 48 chip->toFPA = toFPAout; 56 chip->toFPA = psPlaneTransformAlloc (order, order); 57 for (int i = 0; i <= chip->toFPA->x->nX; i++) { 58 for (int j = 0; j <= chip->toFPA->x->nY; j++) { 59 if (i + j > order) { 60 chip->toFPA->x->mask[i][j] = 1; 61 chip->toFPA->y->mask[i][j] = 1; 62 } 63 } 64 } 49 65 50 // write results 66 // XXX allow statitic to be set by the user 67 psStats *fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 68 fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.CHIP.NSIGMA"); 69 fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.CHIP.NITER"); 70 71 // improved fit for astrometric terms 72 pmAstromFitResults *results = pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, fitStats); 73 if (!results) { 74 psError(PSASTRO_ERR_DATA, false, "failed to perform the matched fit\n"); 75 return false; 76 } 77 78 // allowed limits for valid solutions 79 float maxError = psMetadataLookupF32 (&status, recipe, "PSASTRO.MAX.ERROR"); 80 int minNstar = psMetadataLookupS32 (&status, recipe, "PSASTRO.MIN.NSTAR"); 81 82 // astError is the average 1D scatter in pixels ('results' are in FPA units = microns) 83 float astError = 0.5*(results->xStats->clippedStdev + results->yStats->clippedStdev) / pixelScale; 84 int astNstar = results->yStats->clippedNvalues; 85 86 bool validSolution = true; 87 88 // XXX should these result in errors or be handled another way? 89 psLogMsg ("psastro", PS_LOG_INFO, "astrometry solution: error: %f, Nstars: %d", astError, astNstar); 90 if (astError > maxError) { 91 psLogMsg("psastro", PS_LOG_INFO, "residual error is too large, failed to find a solution: %f > %f", astError, maxError); 92 validSolution = false; 93 } 94 if (astNstar < minNstar) { 95 psLogMsg("psastro", PS_LOG_INFO, "solution uses too few stars: %d < %d", astNstar, minNstar); 96 validSolution = false; 97 } 98 99 // DVO expects NASTRO = 0 if we fail to find a solution 100 if (validSolution) { 101 psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "", astNstar); 102 psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "", astError/sqrt(astNstar)); 103 } else { 104 psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "", 0); 105 psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "", 0.0); 106 } 107 psMetadataAddF32 (updates, PS_LIST_TAIL, "CERROR", PS_META_REPLACE, "", astError); 108 psMetadataAddF32 (updates, PS_LIST_TAIL, "EQUINOX", PS_META_REPLACE, "", 2000.0); // XXX this is bogus: should be defined based on equinox of refstars 109 110 // write results 51 111 psastroUpdateChipToFPA (fpa, chip, rawstars, refstars); 52 112 53 113 psFree (match); 54 114 psFree (stats); 115 psFree (results); 116 psFree (fitStats); 55 117 psFree (gridStats); 56 118 return true; -
trunk/psastro/src/psastroUtils.c
r10613 r10830 1 1 # include "psastro.h" 2 2 # define RENORM 0 3 4 // fix this to look up the value in the chip concepts 5 static double getChipPixelScale (pmChip *chip) { 6 return 10.0; 7 } 8 9 // I have an FPA structure with multiple chips. we have loaded or measured astrometry for each 10 // chip with independent pixel/degree scaling values. These will naturally compensate locally 11 // somewhat for the telescope distortion. to measure the telescope distortion, we need to 12 // force the chips to have the same pixel scale and measure the difference from that solution. 13 // Convert an FPA with disparate pixel scales to a common pixel scale (perhaps depending on the 14 // chip -- eg, TC3) 15 16 bool psastroMosaicCommonScale (pmFPA *fpa, psMetadata *recipe) { 17 18 // options : use the MIN or MAX chip as global reference or supplied pixel scales 19 // (microns/pixel), which may depend on the chip 20 21 float pixelScaleUse, pixelScale1, pixelScale2, pixelScale; 22 23 char *option = psMetadataLookupStr (NULL, recipe, "PSASTRO.COMMON.SCALE.OPTION"); 24 if (option == NULL) { 25 psError(PSASTRO_ERR_DATA, false, "no choice set for common scale option\n"); 26 return false; 27 } 28 29 bool useExternal = true; 30 31 // find the min or max scale chip 32 if (!strcasecmp (option, "MIN") || !strcasecmp (option, "MAX")) { 33 34 bool useMax = !strcasecmp (option, "MAX"); 35 pixelScaleUse = (useMax) ? FLT_MIN : FLT_MAX; 36 37 for (int i = 0; i < fpa->chips->n; i++) { 38 pmChip *chip = fpa->chips->data[i]; 39 40 pixelScale1 = hypot (chip->toFPA->x->coeff[1][0], chip->toFPA->x->coeff[0][1]); 41 pixelScale2 = hypot (chip->toFPA->y->coeff[1][0], chip->toFPA->y->coeff[0][1]); 42 pixelScale = 0.5*(pixelScale1 + pixelScale2); 43 44 pixelScaleUse = (useMax) ? PS_MAX (pixelScale, pixelScaleUse) : PS_MIN (pixelScale, pixelScaleUse); 45 } 46 useExternal = false; 47 } 48 49 // rescale each chip by the reference scale 50 for (int i = 0; i < fpa->chips->n; i++) { 51 pmChip *chip = fpa->chips->data[i]; 52 53 psPlaneTransform *toFPA = chip->toFPA; 54 psPlaneTransform *fromFPA = chip->fromFPA; 55 56 pixelScale1 = hypot (toFPA->x->coeff[1][0], toFPA->x->coeff[0][1]); 57 pixelScale2 = hypot (toFPA->y->coeff[1][0], toFPA->y->coeff[0][1]); 58 59 if (useExternal) { 60 pixelScaleUse = getChipPixelScale (chip); 61 } 62 63 for (int i = 0; i <= toFPA->x->nX; i++) { 64 for (int j = 0; j <= toFPA->x->nX; j++) { 65 toFPA->x->coeff[i][j] *= pixelScaleUse/pixelScale1; 66 toFPA->y->coeff[i][j] *= pixelScaleUse/pixelScale2; 67 fromFPA->x->coeff[i][j] *= pixelScale1/pixelScaleUse; 68 fromFPA->y->coeff[i][j] *= pixelScale2/pixelScaleUse; 69 } 70 } 71 72 } 73 return true; 74 } 3 75 4 76 bool psastroUpdateChipToFPA (pmFPA *fpa, pmChip *chip, psArray *rawstars, psArray *refstars) { … … 13 85 14 86 psPlaneTransformApply (raw->FP, chip->toFPA, raw->chip); 15 psPlane DistortApply (raw->TP, fpa->toTPA, raw->FP, 0.0, 0.0);87 psPlaneTransformApply (raw->TP, fpa->toTPA, raw->FP); 16 88 psDeproject (raw->sky, raw->TP, fpa->toSky); 17 89 }
Note:
See TracChangeset
for help on using the changeset viewer.
