Changeset 9732 for trunk/psastro/src/psastroChooseRefstars.c
- Timestamp:
- Oct 24, 2006, 1:58:13 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroChooseRefstars.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroChooseRefstars.c
r9627 r9732 11 11 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, "PSASTRO"); 12 12 if (!recipe) { 13 psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe!\n");14 return false;13 psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe!\n"); 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!\n");21 return false;20 psError(PSASTRO_ERR_CONFIG, true, "Can't find input data!\n"); 21 return false; 22 22 } 23 23 24 float fieldExtra = psMetadataLookupS32 (&status, recipe, "PSASTRO.FIELD.EXTRA"); 24 float fieldExtra = psMetadataLookupS32 (&status, recipe, "PSASTRO.FIELD.EXTRA"); 25 25 if (!status) fieldExtra = 0.0; 26 26 … … 32 32 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 33 33 if (!chip->process || !chip->file_exists) { continue; } 34 35 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {34 35 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 36 36 psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 37 37 if (!cell->process || !cell->file_exists) { continue; } 38 38 39 // process each of the readouts40 // XXX there can only be one readout per chip in astrometry, right?41 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {42 if (! readout->data_exists) { continue; }39 // process each of the readouts 40 // XXX there can only be one readout per chip in astrometry, right? 41 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) { 42 if (! readout->data_exists) { continue; } 43 43 44 // read WCS data from the corresponding header45 pmHDU *hdu = pmFPAviewThisHDU (view, fpa);44 // read WCS data from the corresponding header 45 pmHDU *hdu = pmFPAviewThisHDU (view, fpa); 46 46 47 int Nx = psMetadataLookupS32 (&status, hdu->header, "NAXIS1"); 48 int Ny = psMetadataLookupS32 (&status, hdu->header, "NAXIS2"); 47 int Nx = psMetadataLookupS32 (&status, hdu->header, "NAXIS1"); 48 int Ny = psMetadataLookupS32 (&status, hdu->header, "NAXIS2"); 49 49 50 float minX = -fieldExtra*Nx;51 float maxX = (1+fieldExtra)*Nx;52 float minY = -fieldExtra*Ny;53 float maxY = (1+fieldExtra)*Ny;50 float minX = -fieldExtra*Nx; 51 float maxX = (1+fieldExtra)*Nx; 52 float minY = -fieldExtra*Ny; 53 float maxY = (1+fieldExtra)*Ny; 54 54 55 // the refstars is a subset within range of this chip56 psArray *refstars = psArrayAlloc(100);55 // the refstars is a subset within range of this chip 56 psArray *refstars = psArrayAllocEmpty (100); 57 57 58 // select the reference objects within range of this readout 59 // project the reference objects to this chip 60 for (int i = 0; i < refs->n; i++) { 61 pmAstromObj *ref = pmAstromObjCopy(refs->data[i]); 62 63 // XXX why is this still a private function? 64 p_psProject (ref->TP, ref->sky, fpa->projection); 65 psPlaneDistortApply (ref->FP, fpa->fromTangentPlane, ref->TP, 0.0, 0.0); 66 psPlaneTransformApply (ref->chip, chip->fromFPA, ref->FP); 58 // select the reference objects within range of this readout 59 // project the reference objects to this chip 60 for (int i = 0; i < refs->n; i++) { 61 pmAstromObj *ref = pmAstromObjCopy(refs->data[i]); 67 62 68 // limit the X,Y range of the refs to the selected chip 69 if (ref->chip->x < minX) goto skip; 70 if (ref->chip->x > maxX) goto skip; 71 if (ref->chip->y < minY) goto skip; 72 if (ref->chip->y > maxY) goto skip; 63 // XXX why is this still a private function? 64 p_psProject (ref->TP, ref->sky, fpa->projection); 65 psPlaneDistortApply (ref->FP, fpa->fromTangentPlane, ref->TP, 0.0, 0.0); 66 psPlaneTransformApply (ref->chip, chip->fromFPA, ref->FP); 73 67 74 psArrayAdd (refstars, 100, ref); 75 skip: 76 psFree (ref);77 } 78 psTrace ("psastro", 4, "Added %ld refstars\n", refstars->n);68 // limit the X,Y range of the refs to the selected chip 69 if (ref->chip->x < minX) goto skip; 70 if (ref->chip->x > maxX) goto skip; 71 if (ref->chip->y < minY) goto skip; 72 if (ref->chip->y > maxY) goto skip; 79 73 80 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.REFSTARS", PS_DATA_ARRAY, "astrometry matches", refstars); 81 psFree (refstars); 74 psArrayAdd (refstars, 100, ref); 75 skip: 76 psFree (ref); 77 } 78 psTrace ("psastro", 4, "Added %ld refstars\n", refstars->n); 82 79 83 psastroRefstarSubset (readout); 84 } 85 } 80 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.REFSTARS", PS_DATA_ARRAY, "astrometry matches", refstars); 81 psFree (refstars); 82 83 psastroRefstarSubset (readout); 84 } 85 } 86 86 } 87 87
Note:
See TracChangeset
for help on using the changeset viewer.
