Changeset 18476
- Timestamp:
- Jul 11, 2008, 10:01:25 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroChipAstrom.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroChipAstrom.c
r17108 r18476 11 11 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSASTRO_RECIPE); 12 12 if (!recipe) { 13 psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe");14 return false;13 psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe"); 14 return false; 15 15 } 16 16 … … 18 18 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT"); 19 19 if (!input) { 20 psError(PSASTRO_ERR_CONFIG, true, "Can't find input data");21 return false;20 psError(PSASTRO_ERR_CONFIG, true, "Can't find input data"); 21 return false; 22 22 } 23 23 … … 25 25 pmFPA *fpa = input->fpa; 26 26 27 int numGoodChips = 0; // Number of chips for which astrometry succeeds 28 27 29 while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) { 28 30 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 29 31 if (!chip->process || !chip->file_exists) { continue; } 30 31 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 32 33 int numGoodCells = 0; // Number of cells for which astrometry succeeds 34 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 32 35 psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 33 36 if (!cell->process || !cell->file_exists) { continue; } 34 if (!chip->fromFPA) { continue; }37 if (!chip->fromFPA) { continue; } 35 38 36 // process each of the readouts 37 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) { 38 if (! readout->data_exists) { continue; } 39 // process each of the readouts 40 int numGoodRO = 0; // Number of readouts for which astrometry succeeds 41 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) { 42 if (! readout->data_exists) { continue; } 39 43 40 // select the raw objects for this readout41 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS");42 if (rawstars == NULL) { continue; }44 // select the raw objects for this readout 45 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS"); 46 if (rawstars == NULL) { continue; } 43 47 44 // select the raw objects for this readout45 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS");46 if (refstars == NULL) { continue; }48 // select the raw objects for this readout 49 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS"); 50 if (refstars == NULL) { continue; } 47 51 48 // the absolute minimum number of stars is 4 (for order = 1)49 if ((rawstars->n < 4) || (refstars->n < 4)) {50 readout->data_exists = false;51 psLogMsg ("psastro", 3, "insufficient rawstars (%ld) or refstars (%ld)", 52 rawstars->n, refstars->n);53 continue;54 } 52 // the absolute minimum number of stars is 4 (for order = 1) 53 if ((rawstars->n < 4) || (refstars->n < 4)) { 54 readout->data_exists = false; 55 psLogMsg ("psastro", 3, "insufficient rawstars (%ld) or refstars (%ld)", 56 rawstars->n, refstars->n); 57 continue; 58 } 55 59 56 // save WCS and analysis metadata in update header57 psMetadata *updates = psMetadataAlloc();60 // save WCS and analysis metadata in update header 61 psMetadata *updates = psMetadataAlloc(); 58 62 59 // XXX update the header with info to reflect the failure60 if (!psastroOneChipGrid (fpa, chip, refstars, rawstars, recipe, updates)) {61 readout->data_exists = false;62 psLogMsg ("psastro", 3, "failed to find a solution\n");63 psFree (updates);64 continue;65 }66 // XXX update the header with info to reflect the failure67 if (!psastroOneChipFit (fpa, chip, refstars, rawstars, recipe, updates)) {68 readout->data_exists = false;69 psLogMsg ("psastro", 3, "failed to find a solution\n");70 psFree (updates);71 continue;72 }63 // XXX update the header with info to reflect the failure 64 if (!psastroOneChipGrid (fpa, chip, refstars, rawstars, recipe, updates)) { 65 readout->data_exists = false; 66 psLogMsg ("psastro", 3, "failed to find a solution\n"); 67 psFree (updates); 68 continue; 69 } 70 // XXX update the header with info to reflect the failure 71 if (!psastroOneChipFit (fpa, chip, refstars, rawstars, recipe, updates)) { 72 readout->data_exists = false; 73 psLogMsg ("psastro", 3, "failed to find a solution\n"); 74 psFree (updates); 75 continue; 76 } 73 77 74 // write the elapsed time here; this will be updated in psastroMosaicAstrometry, if called 75 psMetadataAddF32 (updates, PS_LIST_TAIL, "DT_ASTR", PS_META_REPLACE, "elapsed psastro time", psTimerMark ("psastroAnalysis")); 78 numGoodRO++; 76 79 77 pmAstromWriteWCS (updates, fpa, chip, NONLIN_TOL); 78 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.HEADER", PS_DATA_METADATA, "psastro header stats", updates); 79 psFree (updates); 80 // write the elapsed time here; this will be updated in psastroMosaicAstrometry, if called 81 psMetadataAddF32 (updates, PS_LIST_TAIL, "DT_ASTR", PS_META_REPLACE, "elapsed psastro time", psTimerMark ("psastroAnalysis")); 80 82 81 if (psTraceGetLevel("psastro.dump") > 0) { 83 pmAstromWriteWCS (updates, fpa, chip, NONLIN_TOL); 84 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.HEADER", PS_DATA_METADATA, "psastro header stats", updates); 85 psFree (updates); 82 86 83 char *filename = NULL; 84 char *chipname = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME"); 87 if (psTraceGetLevel("psastro.dump") > 0) { 85 88 86 psStringAppend (&filename, "rawstars.ch.%s.dat", chipname); 87 psastroDumpStars (rawstars, filename); 88 psFree (filename); 89 filename = NULL; 89 char *filename = NULL; 90 char *chipname = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME"); 90 91 91 psStringAppend (&filename, "refstars.ch.%s.dat", chipname); 92 psastroDumpStars (refstars, filename); 93 psFree (filename); 94 filename = NULL; 95 } 96 } 97 } 92 psStringAppend (&filename, "rawstars.ch.%s.dat", chipname); 93 psastroDumpStars (rawstars, filename); 94 psFree (filename); 95 filename = NULL; 96 97 psStringAppend (&filename, "refstars.ch.%s.dat", chipname); 98 psastroDumpStars (refstars, filename); 99 psFree (filename); 100 filename = NULL; 101 } 102 } 103 if (numGoodRO > 0) { 104 numGoodCell++; 105 } 106 } 107 if (numGoodCell > 0) { 108 numGoodChip++; 109 } 110 } 111 112 if (fpa->chips->n == 1 && numGoodChip == 0) { 113 psError(PSASTRO_ERR_UNKNOWN, false, "Failed to fit single chip."); 114 return false; 98 115 } 99 116 … … 102 119 # if (0) 103 120 if (!psastroFixChipsTest (config, recipe)) { 104 psError(PSASTRO_ERR_UNKNOWN, false, "failed to align problematic chips");105 return false;121 psError(PSASTRO_ERR_UNKNOWN, false, "failed to align problematic chips"); 122 return false; 106 123 } 107 124 # endif 108 125 109 126 if (!psastroFixChips (config, recipe)) { 110 psError(PSASTRO_ERR_UNKNOWN, false, "failed to align problematic chips");111 return false;127 psError(PSASTRO_ERR_UNKNOWN, false, "failed to align problematic chips"); 128 return false; 112 129 } 113 130
Note:
See TracChangeset
for help on using the changeset viewer.
