Changeset 8046 for trunk/psastro/src/psastroAstromGuess.c
- Timestamp:
- Aug 1, 2006, 4:15:32 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroAstromGuess.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroAstromGuess.c
r7332 r8046 4 4 // XXX WCS keywords in the headers corresponding to the chips. 5 5 // XXX this function is both converting the header WCS astrometry terms to the fpa terms 6 // and applying the astrometry to the detected objects. 6 // and applying the astrometry to the detected objects. 7 7 bool psastroAstromGuess (pmConfig *config) { 8 8 … … 10 10 bool status = false; 11 11 bool isMosaic = false; 12 double RAmin , RAmax, RAminSky, RAmaxSky;13 double DECmin , DECmax;12 double RAmin = NAN, RAmax = NAN, RAminSky = NAN, RAmaxSky = NAN; 13 double DECmin = NAN, DECmax = NAN; 14 14 15 15 pmChip *chip = NULL; … … 23 23 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, "PSASTRO"); 24 24 if (!recipe) { 25 psErrorStackPrint(stderr, "Can't find PSASTRO recipe!\n");26 exit(EXIT_FAILURE);25 psErrorStackPrint(stderr, "Can't find PSASTRO recipe!\n"); 26 exit(EXIT_FAILURE); 27 27 } 28 28 … … 30 30 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT"); 31 31 if (!input) { 32 psErrorStackPrint(stderr, "Can't find input data!\n");33 exit(EXIT_FAILURE);32 psErrorStackPrint(stderr, "Can't find input data!\n"); 33 exit(EXIT_FAILURE); 34 34 } 35 35 … … 44 44 psTrace (__func__, 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 45 45 if (!chip->process || !chip->file_exists) { continue; } 46 46 47 47 // read WCS data from the corresponding header 48 48 pmHDU *hdu = pmFPAviewThisHDU (view, fpa); 49 49 50 pmAstromReadWCS (fpa, chip, hdu->header, plateScale, isMosaic);51 if (newFPA) {52 newFPA = false;53 RAminSky = fpa->projection->R - M_PI;54 RAmaxSky = fpa->projection->R + M_PI;55 RAmin = RAmax = fpa->projection->R;56 DECmin = DECmax = fpa->projection->D;57 }50 pmAstromReadWCS (fpa, chip, hdu->header, plateScale, isMosaic); 51 if (newFPA) { 52 newFPA = false; 53 RAminSky = fpa->projection->R - M_PI; 54 RAmaxSky = fpa->projection->R + M_PI; 55 RAmin = RAmax = fpa->projection->R; 56 DECmin = DECmax = fpa->projection->D; 57 } 58 58 59 // apply the new WCS guess data to all of the data in the readouts60 // XXX should this go into a different function? this would separate WCS interpretation from application61 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {59 // apply the new WCS guess data to all of the data in the readouts 60 // XXX should this go into a different function? this would separate WCS interpretation from application 61 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 62 62 psTrace (__func__, 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 63 63 if (!cell->process || !cell->file_exists) { continue; } 64 64 65 // process each of the readouts66 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {67 if (! readout->data_exists) { continue; }65 // process each of the readouts 66 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) { 67 if (! readout->data_exists) { continue; } 68 68 69 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS");70 if (rawstars == NULL) { continue; }69 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS"); 70 if (rawstars == NULL) { continue; } 71 71 72 for (int i = 0; i < rawstars->n; i++) { 73 pmAstromObj *raw = rawstars->data[i]; 74 75 psPlaneTransformApply (raw->FP, chip->toFPA, raw->chip); 76 psPlaneDistortApply (raw->TP, fpa->toTangentPlane, raw->FP, 0.0, 0.0); 77 p_psDeproject (raw->sky, raw->TP, fpa->projection); 72 for (int i = 0; i < rawstars->n; i++) { 73 pmAstromObj *raw = rawstars->data[i]; 78 74 79 if (i < 0) { 80 fprintf (stderr, "up: %f,%f -> %f,%f -> %f,%f -> %f,%f\n", 81 raw->chip->x, raw->chip->y, 82 raw->FP->x, raw->FP->y, 83 raw->TP->x, raw->TP->y, 84 raw->sky->r, raw->sky->d); 75 psPlaneTransformApply (raw->FP, chip->toFPA, raw->chip); 76 psPlaneDistortApply (raw->TP, fpa->toTangentPlane, raw->FP, 0.0, 0.0); 77 p_psDeproject (raw->sky, raw->TP, fpa->projection); 85 78 86 psPlane *fp = psPlaneAlloc(); 87 psPlane *tp = psPlaneAlloc(); 88 psPlane *ch = psPlaneAlloc(); 79 if (i < 0) { 80 fprintf (stderr, "up: %f,%f -> %f,%f -> %f,%f -> %f,%f\n", 81 raw->chip->x, raw->chip->y, 82 raw->FP->x, raw->FP->y, 83 raw->TP->x, raw->TP->y, 84 raw->sky->r, raw->sky->d); 89 85 90 p_psProject (tp, raw->sky, fpa->projection);91 psPlaneDistortApply (fp, fpa->fromTangentPlane, tp, 0.0, 0.0);92 psPlaneTransformApply (ch, chip->fromFPA, fp);86 psPlane *fp = psPlaneAlloc(); 87 psPlane *tp = psPlaneAlloc(); 88 psPlane *ch = psPlaneAlloc(); 93 89 94 fprintf (stderr, "dn: %f,%f <- %f,%f <- %f,%f <- %f,%f\n", 95 ch->x, ch->y, 96 fp->x, fp->y, 97 tp->x, tp->y, 98 raw->sky->r, raw->sky->d); 99 } 90 p_psProject (tp, raw->sky, fpa->projection); 91 psPlaneDistortApply (fp, fpa->fromTangentPlane, tp, 0.0, 0.0); 92 psPlaneTransformApply (ch, chip->fromFPA, fp); 100 93 101 // rationalize ra to sky range centered on boresite 102 while (raw->sky->r < RAminSky) raw->sky->r += M_PI; 103 while (raw->sky->r > RAmaxSky) raw->sky->r -= M_PI; 94 fprintf (stderr, "dn: %f,%f <- %f,%f <- %f,%f <- %f,%f\n", 95 ch->x, ch->y, 96 fp->x, fp->y, 97 tp->x, tp->y, 98 raw->sky->r, raw->sky->d); 99 } 104 100 105 RAmin = PS_MIN (raw->sky->r, RAmin); 106 RAmax = PS_MAX (raw->sky->r, RAmax); 101 // rationalize ra to sky range centered on boresite 102 while (raw->sky->r < RAminSky) raw->sky->r += M_PI; 103 while (raw->sky->r > RAmaxSky) raw->sky->r -= M_PI; 107 104 108 DECmin = PS_MIN (raw->sky->d, DECmin); 109 DECmax = PS_MAX (raw->sky->d, DECmax); 110 } 111 } 112 } 105 RAmin = PS_MIN (raw->sky->r, RAmin); 106 RAmax = PS_MAX (raw->sky->r, RAmax); 107 108 DECmin = PS_MIN (raw->sky->d, DECmin); 109 DECmax = PS_MAX (raw->sky->d, DECmax); 110 } 111 } 112 } 113 113 } 114 114 … … 119 119 psMetadataAdd (recipe, PS_LIST_TAIL, "DEC_MIN", PS_DATA_F32 | PS_META_REPLACE, "", DECmin); 120 120 psMetadataAdd (recipe, PS_LIST_TAIL, "DEC_MAX", PS_DATA_F32 | PS_META_REPLACE, "", DECmax); 121 121 122 122 psFree (view); 123 123 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
