- Timestamp:
- Mar 29, 2010, 3:55:49 PM (16 years ago)
- Location:
- branches/eam_branches/20100225
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
psModules/src/objects/pmSourceIO_MatchedRefs.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20100225
- Property svn:mergeinfo changed
-
branches/eam_branches/20100225/psModules/src/objects/pmSourceIO_MatchedRefs.c
r26893 r27517 67 67 68 68 if (!table) { 69 table = psArrayAllocEmpty (0x1000);70 pmFPAview *view = pmFPAviewAlloc (0);69 table = psArrayAllocEmpty (0x1000); 70 pmFPAview *view = pmFPAviewAlloc (0); 71 71 72 // this loop selects the matched stars for all chips73 while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) {74 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);75 if (!chip->process || !chip->file_exists) continue;72 // this loop selects the matched stars for all chips 73 while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) { 74 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 75 if (!chip->process || !chip->file_exists) continue; 76 76 77 char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");77 char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME"); 78 78 79 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {80 psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);81 if (!cell->process || !cell->file_exists) continue;79 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 80 psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 81 if (!cell->process || !cell->file_exists) continue; 82 82 83 // process each of the readouts84 // XXX there can only be one readout per chip, right?85 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {86 if (! readout->data_exists) continue;83 // process each of the readouts 84 // XXX there can only be one readout per chip, right? 85 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) { 86 if (! readout->data_exists) continue; 87 87 88 // select the raw objects for this readout89 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS");90 if (rawstars == NULL) continue;88 // select the raw objects for this readout 89 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS"); 90 if (rawstars == NULL) continue; 91 91 92 // select the raw objects for this readout93 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS");94 if (refstars == NULL) continue;95 psTrace ("psastro", 4, "Trying %ld refstars\n", refstars->n);92 // select the raw objects for this readout 93 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS"); 94 if (refstars == NULL) continue; 95 psTrace ("psastro", 4, "Trying %ld refstars\n", refstars->n); 96 96 97 97 # if (0) 98 // XXX test99 FILE *outfile = fopen ("refstars.dat", "w");100 assert (outfile);101 for (int nn = 0; nn < refstars->n; nn++) {102 pmAstromObj *ref = refstars->data[nn];103 fprintf (outfile, "%lf %lf\n", ref->sky->r*PS_DEG_RAD, ref->sky->d*PS_DEG_RAD);104 }105 fclose (outfile);98 // XXX test 99 FILE *outfile = fopen ("refstars.dat", "w"); 100 assert (outfile); 101 for (int nn = 0; nn < refstars->n; nn++) { 102 pmAstromObj *ref = refstars->data[nn]; 103 fprintf (outfile, "%lf %lf\n", ref->sky->r*PS_DEG_RAD, ref->sky->d*PS_DEG_RAD); 104 } 105 fclose (outfile); 106 106 # endif 107 107 108 psArray *matches = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.MATCH");109 if (matches == NULL) continue;108 psArray *matches = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.MATCH"); 109 if (matches == NULL) continue; 110 110 111 for (int i = 0; i < matches->n; i++) {112 pmAstromMatch *match = matches->data[i];111 for (int i = 0; i < matches->n; i++) { 112 pmAstromMatch *match = matches->data[i]; 113 113 114 pmAstromObj *raw = rawstars->data[match->raw];115 pmAstromObj *ref = refstars->data[match->ref];114 pmAstromObj *raw = rawstars->data[match->raw]; 115 pmAstromObj *ref = refstars->data[match->ref]; 116 116 117 psMetadata *row = psMetadataAlloc ();118 psMetadataAdd (row, PS_LIST_TAIL, "RA", PS_DATA_F64, "right ascension (deg, J2000)", PM_DEG_RAD*ref->sky->r);119 psMetadataAdd (row, PS_LIST_TAIL, "DEC", PS_DATA_F64, "declination (deg, J2000)", PM_DEG_RAD*ref->sky->d);120 psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP", PS_DATA_F32, "x coord on chip", raw->chip->x);121 psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP", PS_DATA_F32, "y coord on chip", raw->chip->y);122 psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP_FIT",PS_DATA_F32, "x fitted coord on chip", ref->chip->x);123 psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP_FIT",PS_DATA_F32, "y fitted coord on chip", ref->chip->y);124 psMetadataAdd (row, PS_LIST_TAIL, "X_FPA", PS_DATA_F32, "x coord on focal plane", raw->FP->x);125 psMetadataAdd (row, PS_LIST_TAIL, "Y_FPA", PS_DATA_F32, "y coord on focal plane", raw->FP->y);126 psMetadataAdd (row, PS_LIST_TAIL, "MAG_INST", PS_DATA_F32, "instrumental magnitude", raw->Mag);127 psMetadataAdd (row, PS_LIST_TAIL, "MAG_REF", PS_DATA_F32, "reference star magnitude", ref->Mag);128 psMetadataAdd (row, PS_LIST_TAIL, "COLOR_REF",PS_DATA_F32, "reference star color", ref->Color);129 psMetadataAdd (row, PS_LIST_TAIL, "CHIP_ID", PS_DATA_STRING, "chip identifier", chipName);130 // XXX need to add the reference color, but this needs getstar / dvo.photcodes for the reference to be refined.117 psMetadata *row = psMetadataAlloc (); 118 psMetadataAdd (row, PS_LIST_TAIL, "RA", PS_DATA_F64, "right ascension (deg, J2000)", PM_DEG_RAD*ref->sky->r); 119 psMetadataAdd (row, PS_LIST_TAIL, "DEC", PS_DATA_F64, "declination (deg, J2000)", PM_DEG_RAD*ref->sky->d); 120 psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP", PS_DATA_F32, "x coord on chip", raw->chip->x); 121 psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP", PS_DATA_F32, "y coord on chip", raw->chip->y); 122 psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP_FIT",PS_DATA_F32, "x fitted coord on chip", ref->chip->x); 123 psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP_FIT",PS_DATA_F32, "y fitted coord on chip", ref->chip->y); 124 psMetadataAdd (row, PS_LIST_TAIL, "X_FPA", PS_DATA_F32, "x coord on focal plane", raw->FP->x); 125 psMetadataAdd (row, PS_LIST_TAIL, "Y_FPA", PS_DATA_F32, "y coord on focal plane", raw->FP->y); 126 psMetadataAdd (row, PS_LIST_TAIL, "MAG_INST", PS_DATA_F32, "instrumental magnitude", raw->Mag); 127 psMetadataAdd (row, PS_LIST_TAIL, "MAG_REF", PS_DATA_F32, "reference star magnitude", ref->Mag); 128 psMetadataAdd (row, PS_LIST_TAIL, "COLOR_REF",PS_DATA_F32, "reference star color", ref->Color); 129 psMetadataAdd (row, PS_LIST_TAIL, "CHIP_ID", PS_DATA_STRING, "chip identifier", chipName); 130 // XXX need to add the reference color, but this needs getstar / dvo.photcodes for the reference to be refined. 131 131 132 psArrayAdd (table, 100, row);133 psFree (row);134 }135 }136 }137 }138 psFree (view);132 psArrayAdd (table, 100, row); 133 psFree (row); 134 } 135 } 136 } 137 } 138 psFree (view); 139 139 140 if (table->n == 0) {141 psFree(table);142 return true;143 }140 if (table->n == 0) { 141 psFree(table); 142 return true; 143 } 144 144 } 145 145 146 146 if (!psFitsWriteTable(fits, NULL, table, "MATCHED_REFS")) { 147 psError( PS_ERR_IO, false, "writing MATCHED_REFS\n");147 psError(psErrorCodeLast(), false, "writing MATCHED_REFS\n"); 148 148 psFree(table); 149 149 return false; … … 165 165 // It is not an error to lack this entry -- psFitsMoveExtNameClean does not raise an error 166 166 if (!psFitsMoveExtNameClean (fits, "MATCHED_REFS")) { 167 psMetadataAddBool (fpa->analysis, PS_LIST_TAIL, "READ.REFMATCH", PS_META_REPLACE, "attempted to read MATCHED_REFS", true);168 return true;167 psMetadataAddBool (fpa->analysis, PS_LIST_TAIL, "READ.REFMATCH", PS_META_REPLACE, "attempted to read MATCHED_REFS", true); 168 return true; 169 169 } 170 170 171 171 // We get the size of the table, and allocate the array of sources first because the table 172 172 // is large and ephemeral --- when the table gets blown away, whatever is allocated after … … 178 178 for (int i = 0; i < numRows; i++) { 179 179 psMetadata *row = psFitsReadTableRow(fits, i); // Table row 180 rows->data[i] = row; 180 if (!row) { 181 psError(psErrorCodeLast(), false, "Unable to read row %d of matched references.", i); 182 psFree(rows); 183 return false; 184 } 185 rows->data[i] = row; 181 186 } 182 187
Note:
See TracChangeset
for help on using the changeset viewer.
