Changeset 36816
- Timestamp:
- Jun 5, 2014, 4:02:53 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140423/psModules/src
- Files:
-
- 4 edited
-
extras/pmVisual.c (modified) (1 diff)
-
extras/pmVisual.h (modified) (2 diffs)
-
objects/pmPSFtryMakePSF.c (modified) (1 diff)
-
objects/pmSourceVisual.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140423/psModules/src/extras/pmVisual.c
r36623 r36816 162 162 163 163 164 // ask the user to continue or not. give up after 2 seconds. 165 bool pmVisualAskUserOrDump(bool *plotFlag, bool *dumpData) 166 { 167 struct timeval timeout; 168 fd_set fdSet; 169 int status; 170 171 if (dumpData) *dumpData = false; 172 173 char key[10]; 174 if (plotFlag && dumpData) { 175 fprintf (stderr, "[p]ause? [c]ontinue? [s]kip the rest of these plots? [d]ump the data? [a]bort all visual plots? (c) "); 176 } 177 if (plotFlag && !dumpData) { 178 fprintf (stderr, "[p]ause? [c]ontinue? [s]kip the rest of these plots? [a]bort all visual plots? (c) "); 179 } 180 if (!plotFlag && dumpData) { 181 fprintf (stderr, "[p]ause? [c]ontinue? [d]ump the data? [a]bort all visual plots? (c) "); 182 } 183 if (!plotFlag && !dumpData) { 184 fprintf (stderr, "[p]ause? [c]ontinue? [a]bort all visual plots? (c) "); 185 } 186 187 /* Wait up to 1.0 second for a response, then continue */ 188 timeout.tv_sec = 10; 189 timeout.tv_usec = 0; 190 191 FD_ZERO (&fdSet); 192 FD_SET (STDIN_FILENO, &fdSet); 193 194 status = select (1, &fdSet, NULL, NULL, &timeout); 195 if (status <= 0) { 196 fprintf (stderr, "\n"); 197 return true; // if no data, give up 198 } 199 200 while (true) { 201 if (!fgets(key, 8, stdin)) { 202 psWarning("Unable to read option"); 203 } 204 switch (key[0]) { 205 case 's': 206 if (plotFlag) *plotFlag = false; 207 return true; 208 case 'd': 209 if (dumpData) *dumpData = true; 210 return true; 211 case 'a': 212 isVisual = false; 213 return true; 214 case 'c': 215 case '\n': 216 return true; 217 default: 218 break; 219 } 220 221 if (plotFlag && dumpData) { 222 fprintf (stderr, "[p]ause? [c]ontinue? [s]kip the rest of these plots? [d]ump the data? [a]bort all visual plots? (c) "); 223 } 224 if (plotFlag && !dumpData) { 225 fprintf (stderr, "[p]ause? [c]ontinue? [s]kip the rest of these plots? [a]bort all visual plots? (c) "); 226 } 227 if (!plotFlag && dumpData) { 228 fprintf (stderr, "[p]ause? [c]ontinue? [d]ump the data? [a]bort all visual plots? (c) "); 229 } 230 if (!plotFlag && !dumpData) { 231 fprintf (stderr, "[p]ause? [c]ontinue? [a]bort all visual plots? (c) "); 232 } 233 } 234 return true; 235 } 236 164 237 bool pmVisualImStats(psImage *image, double *mean, double *stdev, double *min, double *max) { 165 238 -
branches/eam_branches/ipp-20140423/psModules/src/extras/pmVisual.h
r30623 r36816 52 52 */ 53 53 bool pmVisualAskUser(bool *plotFlag); 54 55 56 /** Ask the user how to proceed. 57 * At the user's request, this will disable diagnostic plotting. 58 * @param plotFlag, set to false if this plot should be disabled in the future 59 * @param dumpData, set to true if user requests a data dump 60 */ 61 bool pmVisualAskUserOrDump(bool *plotFlag, bool *dumpData); 54 62 55 63 … … 138 146 bool pmVisualInitGraph (int kapa, void *section, void *graphdata); 139 147 bool pmVisualAskUser(bool *plotFlag); 148 bool pmVisualAskUserOrDump(bool *plotFlag, bool *dumpData); 140 149 bool pmVisualScaleImage(int kapaFD, psImage *inImage, 141 150 const char *name, int channel, bool clip); -
branches/eam_branches/ipp-20140423/psModules/src/objects/pmPSFtryMakePSF.c
r36623 r36816 220 220 } 221 221 222 // weed out extreme e0 outliers here: find the median and exclude points not in the 223 // range MEDIAN / 5 < e0 < 5 * MEDIAN 224 { 225 psStats *e0stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN); 226 if (psVectorStats (e0stats, e0, NULL, srcMask, 0xff)) { 227 float e0med = e0stats->sampleMedian; 228 229 for (int i = 0; i < sources->n; i++) { 230 // skip any masked sources (failed to fit one of the model steps or get a magnitude) 231 if (srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 232 233 if (e0->data.F32[i] < 0.2*e0med) { 234 srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_OUTLIER; 235 } 236 if (e0->data.F32[i] > 5.0*e0med) { 237 srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_OUTLIER; 238 } 239 } 240 } 241 psFree (e0stats); 242 } 243 222 244 // we run 'clipIter' cycles clipping in each of x and y, with only one iteration each. 223 245 // This way, the parameters masked by one of the fits will be applied to the others -
branches/eam_branches/ipp-20140423/psModules/src/objects/pmSourceVisual.c
r36623 r36816 545 545 psFree (model); 546 546 547 bool dumpData = false; 548 547 549 // pause and wait for user input: 548 550 // continue, save (provide name), ?? 549 pmVisualAskUser(&plotPSF); 551 retry: 552 pmVisualAskUserOrDump(&plotPSF, &dumpData); 553 if (dumpData) { 554 char name[128]; 555 fprintf (stderr, "filename: "); 556 int status = fscanf (stdin, "%127s", name); 557 if (status != 1) { 558 fprintf (stderr, "odd response\n"); 559 goto retry; 560 } 561 562 FILE *f = fopen (name, "w"); 563 if (!f) { 564 fprintf (stderr, "cannot open %s for output\n", name); 565 goto retry; 566 } 567 for (int i = 0; i < x->n; i++) { 568 float vModel = pmTrend2DEval (trend, x->data.F32[i], y->data.F32[i]); 569 fprintf (f, "%f %f %f %f %d\n", x->data.F32[i], y->data.F32[i], param->data.F32[i], vModel, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 570 } 571 fclose (f); 572 goto retry; 573 } 550 574 551 575 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
