Changeset 10880 for trunk/psastro/src/psastroMosaicOneChip.c
- Timestamp:
- Jan 2, 2007, 3:26:52 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroMosaicOneChip.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroMosaicOneChip.c
r10830 r10880 1 1 # include "psastro.h" 2 2 3 bool psastroMosaicOneChip (pmChip *chip, pmReadout *readout, psMetadata *recipe, psMetadata *updates, int iteration) { 3 # define REQUIRED_RECIPE_VALUE(VALUE, NAME, TYPE, MESSAGE)\ 4 VALUE = psMetadataLookup##TYPE (&status, recipe, NAME); \ 5 if (!status) { \ 6 psError(PSASTRO_ERR_CONFIG, false, MESSAGE); \ 7 return false; } 8 9 bool psastroMosaicOneChip (pmChip *chip, pmReadout *readout, psMetadata *recipe, psMetadata *updates, bool nonlinear) { 4 10 5 11 bool status; … … 20 26 if (match == NULL) return false; 21 27 22 if ((iteration < 1) || (iteration > 2)) { 23 psError(PSASTRO_ERR_UNKNOWN, false, "invalid iteration number %d\n", iteration); 24 return false; 28 // correct radius to FP units (physical pixel scale in microns per pixel) 29 REQUIRED_RECIPE_VALUE (double pixelScale, "PSASTRO.PIXEL.SCALE", F32, "Failed to lookup pixel scale"); 30 31 // allowed limits for valid solutions 32 REQUIRED_RECIPE_VALUE (float maxError, "PSASTRO.MOSAIC.MAX.ERROR", F32, "failed to find single-chip max allowed error\n"); 33 REQUIRED_RECIPE_VALUE (int minNstar, "PSASTRO.MOSAIC.MIN.NSTAR", S32, "failed to find single-chip min allowed stars\n"); 34 35 // set the order of the per-chip fit (higher order only if nonlinear == true) 36 int order = 1; 37 if (nonlinear) { 38 // select the desired chip order 39 REQUIRED_RECIPE_VALUE (order, "PSASTRO.MOSAIC.CHIP.ORDER", S32, "failed to find mosaic chip-level fit order\n"); 40 41 // modify the order to correspond to the actual number of matched stars: 42 if ((match->n < 11) && (order >= 3)) order = 2; 43 if ((match->n < 7) && (order >= 2)) order = 1; 44 if ((match->n < 4) && (order >= 1)) order = 0; 45 if (order < 1) { 46 psLogMsg ("psastro", 3, "insufficient stars or invalid order: %ld stars", match->n); 47 return false; 48 } 25 49 } 26 50 27 // correct to FP units (physical pixel scale in microns per pixel) 28 double pixelScale = psMetadataLookupF32 (&status, recipe, "PSASTRO.PIXEL.SCALE"); 29 if (!status) { 30 psError(PS_ERR_IO, false, "Failed to lookup pixel scale"); 31 return false; 32 } 33 34 // set the order of the per-chip fit (iteration 1: 1, iteration 2: from recipe) 35 int order = 1; 36 if (iteration == 2) { 37 order = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.ORDER"); 38 if (!status) { 39 psError(PSASTRO_ERR_UNKNOWN, false, "failed to find mosaic chip-level fit order\n"); 40 return false; 41 } 42 } 51 // create output toFPA; set masks appropriate to the Elixir DVO astrometry format 43 52 psFree (chip->toFPA); 44 53 chip->toFPA = psPlaneTransformAlloc (order, order); … … 64 73 } 65 74 66 // allowed limits for valid solutions 67 // XXX have these values depend on the iteration? 68 float maxError = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.MAX.ERROR"); 69 int minNstar = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.MIN.NSTAR"); 75 // toSky converts from FPA & TPA units (microns) to sky units (radians) 76 pmFPA *fpa = chip->parent; 77 float plateScale = 0.5*(fpa->toSky->Xs + fpa->toSky->Ys)*3600.0*PM_DEG_RAD; 70 78 71 // astError is the average 1D scatter in pixels ('results' are in FPA units = microns) 72 // XXX currently using supplied pixel scale: use toFPA->x->coeff[1][0], etc? 73 float astError = 0.5*(results->xStats->clippedStdev + results->yStats->clippedStdev) / pixelScale; 79 // pixError is the average 1D scatter in pixels ('results' are in FPA units = microns) 80 float pixError = 0.5*(results->xStats->clippedStdev + results->yStats->clippedStdev) / pixelScale; 81 82 // astError is the average 1D scatter in arcsec ('results' are in FPA units = microns) 83 float astError = 0.5*(results->xStats->clippedStdev + results->yStats->clippedStdev) * plateScale; 74 84 int astNstar = results->yStats->clippedNvalues; 75 85 … … 77 87 78 88 // XXX should these result in errors or be handled another way? 79 psLogMsg ("psastro", PS_LOG_INFO, "astrometry solution: error: %f , Nstars: %d", astError, astNstar);89 psLogMsg ("psastro", PS_LOG_INFO, "astrometry solution: error: %f arcsec, Nstars: %d", astError, astNstar); 80 90 if (astError > maxError) { 81 91 psLogMsg("psastro", PS_LOG_INFO, "residual error is too large, failed to find a solution: %f > %f", astError, maxError); … … 88 98 89 99 // DVO expects NASTRO = 0 if we fail to find a solution 100 psMetadataAddF32 (updates, PS_LIST_TAIL, "PERROR", PS_META_REPLACE, "astrometry error (pixels)", pixError); 101 psMetadataAddF32 (updates, PS_LIST_TAIL, "CERROR", PS_META_REPLACE, "astrometry error (arcsec)", astError); 90 102 if (validSolution) { 91 psMetadataAdd S32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "", astNstar);92 psMetadataAdd F32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "", astError/sqrt(astNstar));103 psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "astrometry precision (arcsec)", astError/sqrt(astNstar)); 104 psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "number of astrometry stars", astNstar); 93 105 } else { 94 psMetadataAdd S32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "",0);95 psMetadataAdd F32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "", 0.0);106 psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "astrometry precision (arcsec)", 0.0); 107 psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "number of astrometry stars", 0); 96 108 } 97 psMetadataAddF32 (updates, PS_LIST_TAIL, "CERROR", PS_META_REPLACE, "", astError);98 109 psMetadataAddF32 (updates, PS_LIST_TAIL, "EQUINOX", PS_META_REPLACE, "", 2000.0); // XXX this is bogus: should be defined based on equinox of refstars 110 111 // determine fromFPA transformation and apply new transformation to raw & ref stars 112 psastroUpdateChipToFPA (fpa, chip, rawstars, refstars); 99 113 100 114 psFree (fitStats);
Note:
See TracChangeset
for help on using the changeset viewer.
