Changeset 31813 for trunk/psvideophot/src/psvideoLoop.c
- Timestamp:
- Jul 1, 2011, 11:22:48 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/psvideophot/src/psvideoLoop.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psvideophot/src/psvideoLoop.c
r31713 r31813 5 5 #include "psvideophot.h" 6 6 7 // XXX: get these from a recipe8 #define DX 209 #define DY 107 // XXX: derive these from a recipe perhaps basing them on seeing 8 #define DX 10 9 #define DY 5 10 10 #define SKIP 0 11 11 #define EDGE 3 … … 22 22 static double SubSum (psImage *image, double xy[2], double median); 23 23 static void Centering(psImage *image, long edge, double *pSum, double xy[], double median); 24 static psArray *readVideoTable(pmFPAfile *input, psString video_extension_name); 24 25 25 26 bool psvideophotLoop(pmConfig *config, psvideophotOptions *options) … … 90 91 91 92 psString cellName = psMetadataLookupStr(&status, cell->concepts, "CELL.NAME"); 92 psWarning("Found video cell %s %d\n", cellName, view->cell); 93 psLogMsg("psvideophotLoop", 1, "Found video cell %s %d\n", cellName, view->cell); 94 95 // get the position of this cell on the chip 96 int cellX0 = psMetadataLookupS32(&status, cell->concepts, "CELL.X0"); 97 int cellY0 = psMetadataLookupS32(&status, cell->concepts, "CELL.Y0"); 98 int xParity = psMetadataLookupS32(&status, cell->concepts, "CELL.XPARITY"); 99 int yParity = psMetadataLookupS32(&status, cell->concepts, "CELL.YPARITY"); 100 int xBin = psMetadataLookupS32(&status, cell->concepts, "CELL.XBIN"); 101 int yBin = psMetadataLookupS32(&status, cell->concepts, "CELL.YBIN"); 102 103 // avoid errors about unused variables 104 (void) xParity; (void) yParity; (void) cellX0; (void)cellY0; 93 105 94 106 psStats *stats = psStatsAlloc( … … 101 113 ); 102 114 115 // go find the video extension data 116 psString video_extension_name = NULL; 117 psStringAppend(&video_extension_name, "video_table_%s", cellName); 118 psArray *video_table = readVideoTable(input, video_extension_name); 119 if (!video_table) { 120 psError(PS_ERR_UNKNOWN, false, "failed to find video extension:%s", video_extension_name); 121 ESCAPE("invalid image file"); 122 } 123 psMetadataAddArray(cell->analysis, PS_LIST_TAIL, "VIDEO_DATA", 0, "", video_table); 124 125 if (cell->readouts->n != video_table->n) { 126 psError(PS_ERR_UNKNOWN, true, "number of readouts %ld does not match length of video extension: %ld", 127 cell->readouts->n, video_table->n); 128 ESCAPE("invalid data"); 129 } 130 103 131 // process each of the readouts 104 int frame = 0;105 132 pmReadout *readout; // Readout from cell 106 133 while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) { … … 108 135 ESCAPE("load failure for Readout"); 109 136 } 110 if (++frame < SKIP) { 137 int frame = view->readout; 138 if (frame < SKIP - 1) { 111 139 continue; 112 140 } … … 114 142 continue; 115 143 } 144 145 psMetadata *row = video_table->data[frame]; 146 if (!row) { 147 psError(PS_ERR_UNKNOWN, true, "video_table row for frame %d is null", frame); 148 // XXX: rather than fail, should we just skip this frame 149 ESCAPE(" "); 150 } 151 152 // extract the camera's measurements from the video table 153 // We should probably get the column names from a configuration file so that we can 154 // handle any changes more gracefully 155 // Time at which frame was completely received from controller 156 double frame_start = psMetadataLookupF64(&status, row, "frame_start_time"); 157 // Time at which frame was completely received from controller 158 double frame_complete = psMetadataLookupF64(&status, row, "frame_complete_time"); 159 // star centriod, x axis 160 double centroid_x = psMetadataLookupF32(&status, row, "centroid_x"); 161 // star centriod, y axis 162 double centroid_y = psMetadataLookupF64(&status, row, "centroid_y"); 163 // star full width at half maximum 164 double fwhm = psMetadataLookupF64(&status, row, "fwhm"); 165 // star full width at half maximum, x axis 166 double fwhm_x = psMetadataLookupF64(&status, row, "fwhm_x"); 167 // star full width at half maximum, y axis 168 double fwhm_y = psMetadataLookupF64(&status, row, "fwhm_y"); 169 // calculated sky level 170 double sky = psMetadataLookupF64(&status, row, "sky"); 171 // flux from star 172 double flux = psMetadataLookupF64(&status, row, "flux"); 173 // signal to noise ration of video frame 174 double snr = psMetadataLookupF64(&status, row, "snr"); 175 // number of parallel row shits before integration (cleans) 176 double rowpre = psMetadataLookupS32(&status, row, "rowpre"); 177 // number of cols skipped before video readout 178 double cnpix1 = psMetadataLookupS32(&status, row, "cnpix1"); 179 // number of rows skipped before video readout 180 double cnpix2 = psMetadataLookupS32(&status, row, "cnpix2"); 181 182 (void) frame_start; (void) frame_complete; 183 (void) rowpre; (void) cnpix1; (void) cnpix2; (void) fwhm_x; (void) fwhm_y; (void) fwhm; 184 185 double star_chip_x = cellX0 + (centroid_x * xParity); 186 double star_chip_y = cellY0 + (centroid_y * yParity); 187 (void) star_chip_x; (void) star_chip_y; 188 189 // measured position of star in readout coordinates 190 double star_readout_x = (centroid_x - cnpix1) / xBin; 191 double star_readout_y = (centroid_y - cnpix2) / yBin; 192 193 printf("%4d %9.2f %9.2f %9.2f %.1f %.1f %9.6f %6.3f %6.3f %6.3f\n", 194 frame, flux, snr, sky, star_readout_x, star_readout_y, frame_complete - frame_start, 195 fwhm, fwhm_x, fwhm_y); 116 196 117 197 psStatsInit(stats); … … 120 200 psError(PS_ERR_UNKNOWN, false, "unable to generate image stats for cell %d readout %d\n", 121 201 view->cell, view->readout); 202 // XXX: rather than fail, should we just skip this frame 122 203 ESCAPE("failed to generate stats"); 123 204 } … … 131 212 double xy[2]; 132 213 Centering(readout->image, EDGE, &sum, xy, median); 133 double sum2;134 sum2= SubSum(readout->image, xy, median);135 136 printf("%4d %9.2f %9.2f % 8.2f %.1f %.1f %9.2f\n",137 frame, sum, stddev, median, xy[0], xy[1], sum2);214 double ourFlux; 215 ourFlux = SubSum(readout->image, xy, median); 216 217 printf("%4d %9.2f %9.2f %9.2f %.1f %.1f %9.2f\n", 218 frame, ourFlux, ourFlux/stddev, median, xy[0], xy[1], stddev); 138 219 } else { 139 220 printf("%4d %9.2f %9.2f %8.2f\n", … … 141 222 } 142 223 } 224 psLogMsg ("psvideophotLoop", 5, "Done processing video cell"); 143 225 } 144 226 … … 205 287 } 206 288 } 207 xy[0] = edge- 1+sxf/sum;289 xy[0] = edge-2+sxf/sum; 208 290 xy[1] = edge-2+syf/sum; 291 xy[0] = sxf/sum; 292 xy[1] = syf/sum; 209 293 *pSum = sum; 210 294 //printf("%f %f\n", xc, yc); … … 238 322 return(sum); 239 323 } 324 static psArray *readVideoTable(pmFPAfile *input, psString video_extension_name) 325 { 326 if (!psFitsMoveExtName(input->fits, video_extension_name)) { 327 psError(PS_ERR_UNKNOWN, false, "Failed to move to video extension: %s", video_extension_name); 328 return NULL; 329 } 330 331 return psFitsReadTable(input->fits); 332 }
Note:
See TracChangeset
for help on using the changeset viewer.
