Changeset 27840 for branches/simtest_nebulous_branches/extsrc/gpcsw/gpcsrc/fits/burntool/persistio.c
- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
extsrc/gpcsw/gpcsrc/fits/burntool/persistio.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/extsrc/gpcsw/gpcsrc/fits/burntool/persistio.c
r23924 r27840 16 16 /****************************************************************/ 17 17 /* persist_read(): Read all the persistence trails from a file */ 18 STATIC int persist_read(CELL *cell, const char *infile )18 STATIC int persist_read(CELL *cell, const char *infile, int apply) 19 19 { 20 20 int i, k, nbox=0; … … 38 38 while(fgets(line, 1024, fp) != NULL) { 39 39 if(line[0] == '#') continue; 40 sscanf(line, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %lf %d %d %d ",40 sscanf(line, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %lf %d %d %d %d", 41 41 &boxbuf[nbox].cell, &boxbuf[nbox].time, 42 42 &boxbuf[nbox].cx, &boxbuf[nbox].cy, … … 50 50 &boxbuf[nbox].func, &boxbuf[nbox].up, 51 51 &boxbuf[nbox].slope, &boxbuf[nbox].nfit, 52 &boxbuf[nbox].sxfit, &boxbuf[nbox].exfit); 53 if(boxbuf[nbox].nfit <= 0) continue; 54 boxbuf[nbox].zero = (double *)calloc(boxbuf[nbox].nfit, sizeof(double)); 55 boxbuf[nbox].xfit = (int *)calloc(boxbuf[nbox].nfit, sizeof(int)); 56 boxbuf[nbox].yfit = (int *)calloc(boxbuf[nbox].nfit, sizeof(int)); 57 for(i=0; i<boxbuf[nbox].nfit; i++) { 58 if(fgets(line, 1024, fp) == NULL) { 59 fprintf(stderr, "\rerror: short read of burn lines\n"); 60 return(-1); 61 } 62 sscanf(line, "%d %d %lf\n", &boxbuf[nbox].xfit[i], 63 &boxbuf[nbox].yfit[i], &boxbuf[nbox].zero[i]); 64 } 65 boxbuf[nbox].fiterr = 0; 52 &boxbuf[nbox].sxfit, &boxbuf[nbox].exfit, 53 &boxbuf[nbox].fiterr); 54 if(boxbuf[nbox].nfit > 0) { 55 boxbuf[nbox].zero = (double *)calloc(boxbuf[nbox].nfit, sizeof(double)); 56 boxbuf[nbox].xfit = (int *)calloc(boxbuf[nbox].nfit, sizeof(int)); 57 boxbuf[nbox].yfit = (int *)calloc(boxbuf[nbox].nfit, sizeof(int)); 58 if(boxbuf[nbox].zero == NULL || 59 boxbuf[nbox].xfit == NULL || 60 boxbuf[nbox].yfit == NULL) { 61 fprintf(stderr, "\rerror: failed to alloc boxbuf\n"); 62 exit(-673); 63 } 64 65 for(i=0; i<boxbuf[nbox].nfit; i++) { 66 if(fgets(line, 1024, fp) == NULL) { 67 fprintf(stderr, "\rerror: short read of burn lines\n"); 68 return(-1); 69 } 70 sscanf(line, "%d %d %lf\n", &boxbuf[nbox].xfit[i], 71 &boxbuf[nbox].yfit[i], &boxbuf[nbox].zero[i]); 72 } 73 } 74 // 100203 JT: fiterr now saved and read, refit if not just an "apply" 75 if(!apply) boxbuf[nbox].fiterr = 0; 66 76 /* Augment counts */ 67 77 k = boxbuf[nbox].cell; … … 84 94 for(k=0; k<MAXCELL; k++) { 85 95 if( (i=cell[k].npersist) > 0) { 86 cell[k].persist = (OBJBOX *)calloc(i, sizeof(OBJBOX)); 96 if( (cell[k].persist = (OBJBOX *)calloc(i, sizeof(OBJBOX))) == NULL) { 97 fprintf(stderr, "\rerror: failed to alloc cell persist buffer\n"); 98 exit(-674); 99 } 87 100 cell[k].npersist = 0; 88 101 } … … 147 160 for(kp=0; kp<n; kp++) { 148 161 k = boxid[kp]; 149 zk = box[k].zero[box[k].nfit/2]; 162 zk = 0.0; 163 if(box[k].nfit > 0) zk = box[k].zero[box[k].nfit/2]; 150 164 for(jp=kp+1; jp<n; jp++) { 151 165 j = boxid[jp]; 152 zj = box[j].zero[box[j].nfit/2]; 166 zj = 0.0; 167 if(box[j].nfit > 0) zj = box[j].zero[box[j].nfit/2]; 153 168 if(ABS(yctr[jp]-yctr[kp]) > DIFFERENT_STREAK) { 154 169 /* Trim back the feebler streak */ … … 238 253 /* First: patched up persists */ 239 254 for(k=0; k<cell[j].npersist; k++) { 240 if(cell[j].persist[k].fiterr) continue; 241 if(cell[j].persist[k].nfit <= 0) continue; 242 fprintf(fp, "%3d %7d %3d %3d %5d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %1d %1d %9.6f %3d %3d %3d\n", 255 256 /* Retire old burns */ 257 if(cell[j].time - cell[j].persist[k].time > EXPIRE_TRAIL_TIME) 258 continue; 259 260 if(PERSIST_RETAIN) { 261 /* Keep fits which have a dubious slope */ 262 if(cell[j].persist[k].fiterr != FIT_SLOPE_ERROR) { 263 if(cell[j].persist[k].fiterr) continue; 264 if(cell[j].persist[k].nfit <= 0) continue; 265 } 266 } else { 267 if(cell[j].persist[k].fiterr) continue; 268 if(cell[j].persist[k].nfit <= 0) continue; 269 } 270 fprintf(fp, "%3d %7d %3d %3d %5d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %1d %1d %9.6f %3d %3d %3d %d\n", 243 271 j, cell[j].persist[k].time, 244 272 cell[j].persist[k].cx, cell[j].persist[k].cy, … … 252 280 cell[j].persist[k].func, cell[j].persist[k].up, 253 281 cell[j].persist[k].slope, cell[j].persist[k].nfit, 254 cell[j].persist[k].sxfit, cell[j].persist[k].exfit); 282 cell[j].persist[k].sxfit, cell[j].persist[k].exfit, 283 cell[j].persist[k].fiterr); 255 284 for(i=0; i<cell[j].persist[k].nfit; i++) { 256 285 fprintf(fp, "%3d %3d %8.4f\n", cell[j].persist[k].xfit[i], … … 262 291 for(k=0; k<cell[j].nburn; k++) { 263 292 if(!cell[j].burn[k].burned) continue; 264 if(cell[j].burn[k].fiterr && 265 cell[j].burn[k].fiterr != FIT_TOP_ERROR) continue; 266 if(cell[j].burn[k].nfit <= 0) continue; 293 if(PERSIST_RETAIN) { 294 /* Keep fits which have a dubious slope */ 295 if(cell[j].burn[k].fiterr != FIT_SLOPE_ERROR) { 296 if(cell[j].burn[k].fiterr && 297 cell[j].burn[k].fiterr != FIT_TOP_ERROR) continue; 298 if(cell[j].burn[k].nfit <= 0) continue; 299 } 300 } else { 301 if(cell[j].burn[k].fiterr && 302 cell[j].burn[k].fiterr != FIT_TOP_ERROR) continue; 303 if(cell[j].burn[k].nfit <= 0) continue; 304 } 267 305 268 306 i = (cell[j].burn[k].ex - cell[j].burn[k].sx + 1) / 2; 269 fprintf(fp, "%3d %7d %3d %3d %5d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %1d %1d %9.6f %3d %3d %3d \n",307 fprintf(fp, "%3d %7d %3d %3d %5d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %1d %1d %9.6f %3d %3d %3d %d\n", 270 308 j, cell[j].burn[k].time, 271 309 cell[j].burn[k].cx, cell[j].burn[k].cy, … … 279 317 cell[j].burn[k].func, cell[j].burn[k].up, 280 318 cell[j].burn[k].slope, cell[j].burn[k].nfit, 281 cell[j].burn[k].sxfit, cell[j].burn[k].exfit); 319 cell[j].burn[k].sxfit, cell[j].burn[k].exfit, 320 cell[j].burn[k].fiterr); 282 321 for(i=0; i<cell[j].burn[k].nfit; i++) { 283 322 fprintf(fp, "%3d %3d %8.4f\n", cell[j].burn[k].xfit[i],
Note:
See TracChangeset
for help on using the changeset viewer.
