Changeset 15891 for trunk/psastro/src/psastroEnforceChips.c
- Timestamp:
- Dec 22, 2007, 7:42:46 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroEnforceChips.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroEnforceChips.c
r15670 r15891 1 1 # include "psastroInternal.h" 2 # define NONLIN_TOL 0.001 /* tolerance in pixels */ 2 3 3 bool psastroEnforceChips (pmConfig *config, pmFPA *fpa, psMetadata *recipe) { 4 XXX add a function to supply for all entries, as opposed to fixing the poor astrometry ones. 5 bool psastroEnforceChips (pmConfig *config, psMetadata *recipe) { 4 6 5 7 bool status; 6 8 9 bool fixChips = psMetadataLookupBool (&status, config->arguments, "PSASTRO.FIX.CHIPS"); 10 if (!status) { 11 fixChips = psMetadataLookupBool (&status, recipe, "PSASTRO.FIX.CHIPS"); 12 } 13 if (!fixChips) return true; 14 7 15 // identify reference astrometry table 8 16 // if not defined, correction was not requested; skip step 9 pmFPAfile *refAstrom = psMetadataLookupPtr (NULL, config->files, "REF.ASTROM"); 10 if (!refAstrom) return true; 17 pmFPAfile *astrom = psMetadataLookupPtr (NULL, config->files, "PSASTRO.MODEL"); 18 if (!astrom) return true; 19 20 // select the input data sources 21 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT"); 22 if (!input) { 23 psError(PSASTRO_ERR_CONFIG, true, "Can't find input data"); 24 return false; 25 } 26 27 // make sure the astrometry model is loaded 28 // de-activate all files except PSASTRO.MODEL 29 // XXX do I need to supply the input->fpa->concepts to the astrom->fpa->concepts? 30 psFree (astrom->fpa->concepts); 31 astrom->fpa->concepts = psMemIncrRefCounter (input->fpa->concepts); 32 pmFPAfileActivate (config->files, false, NULL); 33 pmFPAfileActivate (config->files, true, "PSASTRO.MODEL"); 11 34 12 35 pmFPAview *view = pmFPAviewAlloc (0); 36 37 // files associated with the science image 38 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 39 psError (PS_ERR_IO, false, "Can't load the astrometry model file"); 40 return false; 41 } 42 43 // loop over all chips, replace input astrometry elements with those from astrom 44 pmChip *obsChip = NULL; 45 while ((obsChip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) { 46 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, obsChip->file_exists, obsChip->process); 47 if (!obsChip->process || !obsChip->file_exists || !obsChip->data_exists) { continue; } 48 49 // set the chip astrometry using the astrom file 50 pmChip *refChip = pmFPAviewThisChip (view, astrom->fpa); 51 52 psFree (obsChip->toFPA); 53 psFree (obsChip->fromFPA); 54 55 // XXX can we do a straight copy? I think so, but we may need to apply a scaling factor based 56 // on the toSky or toTPA values 57 obsChip->toFPA = psMemIncrRefCounter (refChip->toFPA); 58 obsChip->fromFPA = psMemIncrRefCounter (refChip->fromFPA); 59 60 // XXX test to write out adjusted header 61 pmAstromWriteBilevelChip (obsChip->hdu->header, obsChip, NONLIN_TOL); 62 } 63 64 psFree (input->fpa->toSky); 65 psFree (input->fpa->toTPA); 66 psFree (input->fpa->fromTPA); 67 input->fpa->toSky = psMemIncrRefCounter (astrom->fpa->toSky); 68 input->fpa->toTPA = psMemIncrRefCounter (astrom->fpa->toTPA); 69 input->fpa->fromTPA = psMemIncrRefCounter (astrom->fpa->fromTPA); 70 71 psMetadata *updates = psMetadataAlloc(); 72 pmAstromWriteBilevelMosaic (updates, input->fpa, NONLIN_TOL); 73 psMetadataAddMetadata (input->fpa->analysis, PS_LIST_TAIL, "PSASTRO.HEADER", PS_META_REPLACE, "psastro header stats", updates); 74 psFree (updates); 75 76 psFree (view); 77 return true; 78 } 79 80 # if (0) 13 81 14 82 // physical pixel scale in microns per pixel … … 33 101 if (!obsChip->process || !obsChip->file_exists || !obsChip->data_exists) { continue; } 34 102 35 // set the chip astrometry using the refAstrom file36 pmChip *refChip = pmFPAviewThisChip (view, refAstrom->fpa);103 // set the chip astrometry using the astrom file 104 pmChip *refChip = pmFPAviewThisChip (view, astrom->fpa); 37 105 38 106 // bad Astrometry test: ref pixel or angle outside nominal … … 80 148 // XXX for this function to work, I need to: 81 149 // 1 *) define badAstrom (ref pixel too far from nominal?) (ref angle too far off?) 82 // 2) load the refAstrom fpa in the pmFPAfileIO stage150 // 2) load the astrom fpa in the pmFPAfileIO stage 83 151 // 3) allow for this operation to be optional 152 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
