Changeset 24308 for trunk/Ohana
- Timestamp:
- Jun 3, 2009, 9:46:36 AM (17 years ago)
- Location:
- trunk/Ohana/src
- Files:
-
- 14 edited
- 2 copied
-
libdvo/include/dvo.h (modified) (1 diff)
-
relastro (modified) (1 prop)
-
relastro/Makefile (modified) (1 diff)
-
relastro/include/relastro.h (modified) (7 diffs)
-
relastro/src/ConfigInit.c (modified) (2 diffs)
-
relastro/src/FitChip.c (modified) (9 diffs)
-
relastro/src/GetAstromError.c (modified) (1 diff)
-
relastro/src/ImageOps.c (modified) (17 diffs)
-
relastro/src/UpdateObjects.c (modified) (4 diffs)
-
relastro/src/args.c (modified) (1 diff)
-
relastro/src/bcatalog.c (modified) (5 diffs)
-
relastro/src/initialize.c (modified) (2 diffs)
-
relastro/src/load_catalogs.c (modified) (1 diff)
-
relastro/src/relastroVisual.c (copied) (copied from branches/cnb_branches/cnb_branch_20090301/Ohana/src/relastro/src/relastroVisual.c )
-
relastro/src/relastroVisual.h (copied) (copied from branches/cnb_branches/cnb_branch_20090301/Ohana/src/relastro/src/relastroVisual.h )
-
relastro/src/relastro_objects.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libdvo/include/dvo.h
r21508 r24308 108 108 # define ID_MEAS_POOR_ASTROM 0x0010 /* detection is astrometry outlier */ 109 109 # define ID_MEAS_SKIP_ASTROM 0x0020 /* detection was ignored for astrometry measurement */ 110 # define ID_MEAS_U NDEF_1 0x0040 /* unused*/111 # define ID_MEAS_U NDEF_2 0x0080 /* unused*/110 # define ID_MEAS_USED_OBJ 0x0040 /* detection was used during opdate objects */ 111 # define ID_MEAS_USED_CHIP 0x0080 /* detection was used during update chips */ 112 112 # define ID_MEAS_BLEND_MEAS 0x0100 /* detection is within radius of multiple objects */ 113 113 # define ID_MEAS_BLEND_OBJ 0x0200 /* multiple detections within radius of object */ -
trunk/Ohana/src/relastro
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/cnb_branches/cnb_branch_20090301/Ohana/src/relastro merged eligible /branches/pap/Ohana/src/relastro merged eligible /branches/eam_branches/eam_branch_20090303/Ohana/src/relastro 23158-23228 /branches/eam_branches/eam_branch_20090322/Ohana/src/relastro 23482-23529 /branches/pap_magic/Ohana/src/relastro 24120-24173
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/Ohana/src/relastro/Makefile
r17243 r24308 55 55 $(SRC)/relastro_objects.$(ARCH).o \ 56 56 $(SRC)/save_catalogs.$(ARCH).o \ 57 $(SRC)/write_coords.$(ARCH).o 57 $(SRC)/write_coords.$(ARCH).o \ 58 $(SRC)/relastroVisual.$(ARCH).o 58 59 59 60 $(RELASTRO): $(INC)/relastro.h $(KAPA_INCS) -
trunk/Ohana/src/relastro/include/relastro.h
r21508 r24308 44 44 double Ro, dRo; 45 45 double Do, dDo; 46 46 47 47 double uR, duR; 48 48 double uD, duD; … … 63 63 char flags; 64 64 Coords coords; 65 } Mosaic; 65 } Mosaic; 66 66 67 67 typedef struct { … … 87 87 88 88 double SIGMA_LIM; 89 int SRC_MEAS_TOOFEW; //catalog objects wich fewer detections then this are ignored 89 90 double MIN_ERROR; 90 91 … … 119 120 int TimeSelect; 120 121 time_t TSTART, TSTOP; 122 123 int FlagOutlier; 124 int CLIP_THRESH; 121 125 122 126 FitMode FIT_MODE; … … 145 149 int corner_check PROTO((double *x1, double *y1, double *x2, double *y2)); 146 150 void dumpGrid PROTO((void)); 147 void dump_grid PROTO((void)); 151 void dump_grid PROTO((void)); 148 152 int edge_check PROTO((double *x1, double *y1, double *x2, double *y2)); 149 153 void findImages PROTO((Catalog *catalog, int Ncatalog)); … … 220 224 int setMrelOutput PROTO((Catalog *catalog, int Ncatalog, int mark)); 221 225 void set_ZP PROTO((double ZERO)); 222 int setrefcode PROTO((Image *image, int Nimage)); 226 int setrefcode PROTO((Image *image, int Nimage)); 223 227 void skip_measurements PROTO((Catalog *catalog, int pass)); 224 228 void sortA PROTO((double *X, int N)); … … 265 269 int UpdateMeasures (Catalog *catalog, int Ncatalog); 266 270 void fixImageRaw (Catalog *catalog, int Ncatalog, int im); 271 void FlagOutliers(Catalog *catalog); 272 int MeasFilterTest(Measure *measure); 267 273 268 274 int sun_ecliptic (double jd, double *lambda, double *beta, double *epsilon); -
trunk/Ohana/src/relastro/src/ConfigInit.c
r17207 r24308 20 20 21 21 GetConfig (config, "RELASTRO_SIGMA_LIM", "%lf", 0, &SIGMA_LIM); 22 GetConfig (config, "RELASTRO_SRC_MEAS_TOOFEW", "%d", 0, &SRC_MEAS_TOOFEW); 22 23 23 24 // XXX these are used in relphot to identify poor stars / images -- define … … 55 56 fprintf (stderr, "directory %s does not exist, giving up\n", CATDIR); 56 57 exit (1); 57 } 58 } 58 59 59 60 /* update master photcode table if not defined */ -
trunk/Ohana/src/relastro/src/FitChip.c
r17209 r24308 1 1 # include "relastro.h" 2 # include "relastroVisual.h" 2 3 3 4 // XXX make these user parameters … … 5 6 # define FIT_CHIP_NITER 3 6 7 # define FIT_CHIP_NSIGMA 3.0 8 7 9 8 10 // XXX we should test if the fit is sufficiently constrained across the chip, or if the … … 22 24 23 25 ALLOCATE (values, double, Nmatch); 24 25 26 for (Niter = 0; Niter < FIT_CHIP_NITER; Niter ++) { 26 27 … … 28 29 for (i = Nscatter = 0; i < Nmatch; i++) { 29 30 if (raw[i].mask) continue; 30 if ( raw[i].dMag > FIT_CHIP_MAX_ERROR) continue;31 if (isnan(raw[i].dMag) || raw[i].dMag > FIT_CHIP_MAX_ERROR) continue; 31 32 32 33 dL = raw[i].L - ref[i].L; 33 34 dM = raw[i].M - ref[i].M; 34 35 dR = hypot (dL, dM); 35 36 36 37 values[Nscatter] = dR; 37 38 Nscatter++; … … 41 42 dsort (values, Nscatter); 42 43 dRmax = FIT_CHIP_NSIGMA*values[(int)(0.40*Nscatter)]; 44 relastroVisualPlotScatter(values, dRmax, Nscatter); 45 relastroVisualPlotRawRef(raw, ref, dRmax, Nmatch); 43 46 44 47 // fit the requested order polynomial … … 50 53 // generate the fit matches 51 54 for (i = 0; i < Nmatch; i++) { 52 if (raw[i].mask) continue; 55 if (raw[i].mask) { 56 continue; 57 } 58 if (isnan(raw[i].dMag) || raw[i].dMag > FIT_CHIP_MAX_ERROR) { 59 continue; 60 } 53 61 54 62 // only keep objects within dRmax … … 57 65 dR = hypot (dL, dM); 58 66 if (dR > dRmax) continue; 59 67 60 68 fit_add (fit, raw[i].X, raw[i].Y, ref[i].L, ref[i].M, raw[i].dPos); 61 69 } … … 66 74 case 0: 67 75 case 1: 68 skip = (fit[0].Npts < 8);69 break;76 skip = (fit[0].Npts < 8); 77 break; 70 78 case 2: 71 skip = (fit[0].Npts < 11);72 break;79 skip = (fit[0].Npts < 11); 80 break; 73 81 case 3: 74 skip = (fit[0].Npts < 15);75 break;82 skip = (fit[0].Npts < 15); 83 break; 76 84 default: 77 fprintf (stderr, "invalid chip order %d\n", coords[0].Npolyterms);78 abort ();85 fprintf (stderr, "invalid chip order %d\n", coords[0].Npolyterms); 86 abort (); 79 87 } 80 88 if (skip) { … … 95 103 XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, coords); 96 104 } 105 97 106 } 98 107 -
trunk/Ohana/src/relastro/src/GetAstromError.c
r16810 r24308 30 30 31 31 dPtotal = sqrt(SQ(dPsys) + AS*SQ(dPobs) + MS*SQ(dM)); 32 33 //XXX dXccd, dYccd are now working correctly 34 //dPtotal = AS * dPobs; 35 32 36 dPtotal = MAX (dPtotal, MIN_ERROR); 33 37 -
trunk/Ohana/src/relastro/src/ImageOps.c
r17243 r24308 1 1 # include "relastro.h" 2 #define TESTING 2 3 3 4 static unsigned int *start; … … 91 92 for (i = 0; VERBOSE && (i < Nimage); i++) { 92 93 name = GetPhotcodeNamebyCode (image[i].photcode); 93 fprintf (stderr, "image %d has %d measures (%s, %s)\n", i, Nlist[i], 94 ohana_sec_to_date(image[i].tzero), name);95 } 94 fprintf (stderr, "image %d has %d measures (%s, %s)\n", i, Nlist[i], 95 ohana_sec_to_date(image[i].tzero), name); 96 } 96 97 } 97 98 … … 101 102 int i; 102 103 Measure *measure; 103 104 104 105 measure = &catalog[cat].measure[meas]; 105 106 … … 110 111 if (measure[0].t < start[i]) continue; 111 112 if (measure[0].t > stop[i]) continue; 112 113 113 114 // index for (catalog, measure) -> image 114 115 bin[cat][meas] = i; … … 125 126 REALLOCATE (clist[i], int, NLIST[i]); 126 127 REALLOCATE (mlist[i], int, NLIST[i]); 127 } 128 } 128 129 return; 129 130 } … … 157 158 158 159 plot_defaults (&graphdata); 159 graphdata.ymin = PlotdMmin; 160 graphdata.ymin = PlotdMmin; 160 161 graphdata.ymax = PlotdMmax; 161 162 plot_list (&graphdata, xlist, Mlist, Nimage, "airmass vs Mcal", "airmass.png"); … … 163 164 plot_list (&graphdata, Mlist, dlist, Nimage, "Mcal vs dMcal", NULL); 164 165 165 # define NBIN 20 0166 # define NBIN 20 166 167 REALLOCATE (xlist, double, NBIN); 167 168 REALLOCATE (Mlist, double, NBIN); … … 191 192 int i, m, c, n; 192 193 double X, Y, L, M, P, Q, R, D, dR, dD; 193 194 194 195 Mosaic *mosaic; 195 196 Coords *moscoords, *imcoords; 196 197 197 198 moscoords = NULL; 198 199 mosaic = getMosaicForImage (im); … … 224 225 dR = 3600.0*(catalog[c].average[n].R - R); 225 226 dD = 3600.0*(catalog[c].average[n].D - D); 226 227 227 228 if (fabs(catalog[c].measure[m].dR - dR) > 10.0) { 228 229 // XXXXX running into this still for last megacam exposure: wrong mosaic? … … 249 250 catalog[c].measure[m].dR = 3600.0*(catalog[c].average[n].R - R); 250 251 } 251 } 252 } 252 253 return; 253 254 } … … 259 260 260 261 int i, m, c, n; 261 262 262 263 Mosaic *mosaic; 263 264 Coords *moscoords; 264 265 StarData *raw; 265 266 266 267 ALLOCATE (raw, StarData, Nlist[im]); 267 268 … … 271 272 mosaic = getMosaicForImage (im); 272 273 if (mosaic == NULL) { 273 fprintf (stderr, "mosaic not found for image %s\n", image[im].name);274 exit (1);274 fprintf (stderr, "mosaic not found for image %s\n", image[im].name); 275 exit (1); 275 276 } 276 277 moscoords = &mosaic[0].coords; … … 284 285 raw[i].X = catalog[c].measure[m].Xccd; 285 286 raw[i].Y = catalog[c].measure[m].Yccd; 286 287 287 288 raw[i].Mag = catalog[c].measure[m].M; 288 289 raw[i].dMag = catalog[c].measure[m].dM; … … 292 293 293 294 // an object with only one detection provides no information about the image calibration 295 //XXX this is already taken care of in bcatalog 294 296 raw[i].mask = FALSE; 295 if (catalog[c].average[n].Nmeasure < 2) { 296 raw[i].mask = TRUE; 297 } 297 int mask = FALSE; 298 if (catalog[c].average[n].Nmeasure <= SRC_MEAS_TOOFEW) { 299 mask = TRUE; 300 } 301 if (!finite(catalog[c].measure[m].dR) || !finite(catalog[c].measure[m].dD)) { 302 mask = TRUE; 303 } 304 305 raw[i].mask = mask; 306 298 307 299 308 switch (mode) { 300 309 case MODE_SIMPLE: 301 /* note that for a Simple image, L,M = P,Q */302 XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, &image[im].coords);303 raw[i].P = raw[i].L;304 raw[i].Q = raw[i].M;305 LM_to_RD (&raw[i].R, &raw[i].D, raw[i].P, raw[i].Q, &image[im].coords);306 break;310 /* note that for a Simple image, L,M = P,Q */ 311 XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, &image[im].coords); 312 raw[i].P = raw[i].L; 313 raw[i].Q = raw[i].M; 314 LM_to_RD (&raw[i].R, &raw[i].D, raw[i].P, raw[i].Q, &image[im].coords); 315 break; 307 316 case MODE_MOSAIC: 308 XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, &image[im].coords);309 XY_to_LM (&raw[i].P, &raw[i].Q, raw[i].L, raw[i].M, moscoords);310 LM_to_RD (&raw[i].R, &raw[i].D, raw[i].P, raw[i].Q, moscoords);311 break;317 XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, &image[im].coords); 318 XY_to_LM (&raw[i].P, &raw[i].Q, raw[i].L, raw[i].M, moscoords); 319 LM_to_RD (&raw[i].R, &raw[i].D, raw[i].P, raw[i].Q, moscoords); 320 break; 312 321 default: 313 322 fprintf (stderr, "error: invalid mode in getImageRaw"); 314 323 abort (); 315 324 } 316 } 325 } 317 326 318 327 *Nstars = Nlist[im]; … … 330 339 Coords *moscoords; 331 340 StarData *ref; 332 341 333 342 ALLOCATE (ref, StarData, Nlist[im]); 334 343 … … 352 361 ref[i].R = catalog[c].average[n].R; 353 362 ref[i].D = catalog[c].average[n].D; 354 363 355 364 ref[i].Mag = catalog[c].measure[m].M; 356 365 ref[i].dMag = catalog[c].measure[m].dM; … … 373 382 break; 374 383 default: 375 fprintf (stderr, "invalid case");376 abort();377 } 378 } 379 384 fprintf (stderr, "invalid case"); 385 abort(); 386 } 387 } 388 380 389 *Nstars = Nlist[im]; 381 390 return (ref); 382 391 } 392 393 /** lifted from relphot/StarOps.clean_measures */ 394 void FlagOutliers2D(Catalog *catalog); 395 396 void FlagOutliers (Catalog *catalog) { 397 // XXX FlagOutliers is just using FlagOutliers2D 398 FlagOutliers2D(catalog); 399 return; 400 401 int i, j, k, m, N, Ndel, Nave, Nmax, TOOFEW, Nsecfilt; 402 double Ns, theta, x, y; 403 double *R, *D, *dR, *dD; 404 StatType statsR, statsD; 405 406 Nsecfilt = GetPhotcodeNsecfilt(); 407 assert(catalog[0].Nsecfilt == Nsecfilt); 408 409 if (VERBOSE) fprintf (stderr, "marking poor measures\n"); 410 Nmax = 0; 411 for (i = 0; i < catalog[0].Naverage; i++) { 412 Nmax = MAX (Nmax, catalog[0].average[i].Nmeasure); 413 } 414 415 ALLOCATE (R, double, Nmax); 416 ALLOCATE (D, double, Nmax); 417 ALLOCATE (dR, double, Nmax); 418 ALLOCATE (dD, double, Nmax); 419 420 /* it makes no sense to mark 3-sigma outliers with <5 measurements */ 421 TOOFEW = MAX (5, SRC_MEAS_TOOFEW); 422 423 Ns = CLIP_THRESH; 424 Ndel = Nave = 0; 425 426 /* loop over each object in the catalog */ 427 for (j = 0; j < catalog[0].Naverage; j++) { 428 429 /* accumulate list of valid measurements */ 430 m = catalog[0].average[j].measureOffset; 431 N = 0; 432 for (k = 0; k < catalog[0].average[j].Nmeasure; k++, m++) { 433 434 // skip measurements based on user selected criteria 435 if (!MeasFilterTest(&catalog[0].measure[m])) continue; 436 R[N] = catalog[0].measure[m].dR; 437 D[N] = catalog[0].measure[m].dD; 438 dR[N] = GetAstromError( &catalog[0].measure[m], ERROR_MODE_RA); 439 dD[N] = GetAstromError( &catalog[0].measure[m], ERROR_MODE_DEC); 440 if (isnan(R[N]) || isnan(D[N])) continue; 441 N++; 442 } 443 if (N <= TOOFEW) continue; 444 445 /* 3-sigma clip based on stats of inner 50% */ 446 initstats ("MEAN"); 447 liststats (R, dR, N, &statsR); 448 liststats (D, dD, N, &statsD); 449 450 statsR.sigma = MAX (MIN_ERROR, statsR.sigma); 451 statsD.sigma = MAX (MIN_ERROR, statsD.sigma); 452 453 /* compare per-object distance to this standard deviation, and flag outliers*/ 454 m = catalog[0].average[j].measureOffset; 455 N = 0; 456 for (k = 0; k < catalog[0].average[j].Nmeasure; k++, m++) { 457 //reset flag on each invocation 458 catalog[0].measure[m].dbFlags &= ~ID_MEAS_POOR_ASTROM; 459 460 // skip measurements based on user selected criteria 461 if (!MeasFilterTest(&catalog[0].measure[m])) continue; 462 463 x = catalog[0].measure[m].dR - statsR.median; 464 y = catalog[0].measure[m].dD - statsD.median; 465 theta = atan2(y,x); 466 if ((x*x + y*y) > (SQR(statsR.sigma * Ns * cos(theta)) + 467 SQR(statsD.sigma * Ns * sin(theta)))) { 468 catalog[0].measure[m].dbFlags |= ID_MEAS_POOR_ASTROM; 469 Ndel++; 470 } 471 N++; 472 Nave ++; 473 } 474 475 //examine results 476 relastroVisualPlotOutliers(catalog, catalog[0].average[j].measureOffset, 477 catalog[0].average[j].Nmeasure, 478 statsR, statsD, Ns); 479 } 480 481 if (VERBOSE) fprintf (stderr, "%d measures marked poor, %d total\n", Ndel, Nave); 482 free (R); 483 free(dR); 484 free(D); 485 free(dD); 486 } 487 488 489 /** an alternative outlier rejection scheme */ 490 void FlagOutliers2D (Catalog *catalog) { 491 492 int i, j, k, m, N, Ndel, Nave, Nmax, TOOFEW, Nsecfilt; 493 double *index; 494 double Ns, theta, x, y; 495 double *R, *D, *dR, *dD, *d2; 496 StatType statsR, statsD; 497 498 Nsecfilt = GetPhotcodeNsecfilt(); 499 assert(catalog[0].Nsecfilt == Nsecfilt); 500 501 if (VERBOSE) fprintf (stderr, "marking poor measures\n"); 502 Nmax = 0; 503 for (i = 0; i < catalog[0].Naverage; i++) { 504 Nmax = MAX (Nmax, catalog[0].average[i].Nmeasure); 505 } 506 507 ALLOCATE (R, double, Nmax); 508 ALLOCATE (D, double, Nmax); 509 ALLOCATE (dR, double, Nmax); 510 ALLOCATE (dD, double, Nmax); 511 ALLOCATE (d2, double, Nmax); 512 ALLOCATE (index, double, Nmax); 513 514 /* it makes no sense to mark 3-sigma outliers with <5 measurements */ 515 TOOFEW = MAX (5, SRC_MEAS_TOOFEW); 516 517 Ns = CLIP_THRESH; 518 Ndel = Nave = 0; 519 520 /* loop over each object in the catalog */ 521 for (j = 0; j < catalog[0].Naverage; j++) { 522 523 /* accumulate list of valid measurements */ 524 m = catalog[0].average[j].measureOffset; 525 N = 0; 526 527 for (k = 0; k < catalog[0].average[j].Nmeasure; k++, m++) { 528 529 //reset flag on each invocation 530 catalog[0].measure[m].dbFlags &= ~ID_MEAS_POOR_ASTROM; 531 532 // skip measurements based on user selected criteria 533 if (!MeasFilterTest(&catalog[0].measure[m])) continue; 534 R[N] = catalog[0].measure[m].dR; 535 D[N] = catalog[0].measure[m].dD; 536 dR[N] = GetAstromError( &catalog[0].measure[m], ERROR_MODE_RA); 537 dD[N] = GetAstromError( &catalog[0].measure[m], ERROR_MODE_DEC); 538 if (isnan(R[N]) || isnan(D[N])) continue; 539 N++; 540 } 541 if (N <= TOOFEW) continue; 542 543 /* calculate mean of all points*/ 544 initstats ("MEAN"); 545 liststats (R, dR, N, &statsR); 546 liststats (D, dD, N, &statsD); 547 statsR.sigma = MAX (MIN_ERROR, statsR.sigma); 548 statsD.sigma = MAX (MIN_ERROR, statsD.sigma); 549 550 /* calculate deviations of all points*/ 551 m = catalog[0].average[j].measureOffset; 552 N = 0; 553 for (k = 0; k < catalog[0].average[j].Nmeasure; k++, m++) { 554 //skip bad measurements 555 if (!MeasFilterTest(&catalog[0].measure[m])) continue; 556 x = catalog[0].measure[m].dR - statsR.median; 557 y = catalog[0].measure[m].dD - statsD.median; 558 theta = atan2(y,x); 559 d2[N] = (x*x + y*y) / (SQR(statsR.sigma * Ns * cos(theta)) + 560 SQR(statsD.sigma * Ns * sin(theta))); 561 index[N] = m; 562 N++; 563 } 564 565 // sort d2 566 dsortpair(d2, index, N); 567 N = (N/2 > (N-1)) ? N/2 : N-1; 568 569 // recalculate image center, sigma based on closest 50% of points 570 for(k = 0; k < N; k++) { 571 int ind = (int) index[k]; 572 R[k] = catalog[0].measure[ind].dR; 573 D[k] = catalog[0].measure[ind].dD; 574 dR[k] = GetAstromError( &catalog[0].measure[ind], ERROR_MODE_RA); 575 dD[k] = GetAstromError( &catalog[0].measure[ind], ERROR_MODE_DEC); 576 } 577 liststats (R, dR, N, &statsR); 578 liststats (D, dD, N, &statsD); 579 statsR.sigma = MAX (MIN_ERROR, statsR.sigma); 580 statsD.sigma = MAX (MIN_ERROR, statsD.sigma); 581 582 // use these new statistics to flag outliers 583 m = catalog[0].average[j].measureOffset; 584 N = 0; 585 for (k = 0; k < catalog[0].average[j].Nmeasure; k++, m++) { 586 //skip bad measurements 587 if (!MeasFilterTest(&catalog[0].measure[m])) continue; 588 x = catalog[0].measure[m].dR - statsR.median; 589 y = catalog[0].measure[m].dD - statsD.median; 590 theta = atan2(y,x); 591 d2[N] = (x*x + y*y) / (SQR(statsR.sigma * Ns * cos(theta)) + 592 SQR(statsD.sigma * Ns * sin(theta))); 593 if ((d2[N]) > 1) { 594 catalog[0].measure[m].dbFlags |= ID_MEAS_POOR_ASTROM; 595 Ndel ++; 596 } 597 N++; 598 Nave++; 599 } //done rejecting outliers 600 601 //examine results 602 relastroVisualPlotOutliers(catalog, catalog[0].average[j].measureOffset, 603 catalog[0].average[j].Nmeasure, 604 statsR, statsD, Ns); 605 606 } //done looping over objects 607 608 if (VERBOSE) fprintf (stderr, "%d measures marked poor, %d total\n", Ndel, Nave); 609 free (R); 610 free(dR); 611 free(D); 612 free(dD); 613 free(d2); 614 free(index); 615 } 616 617 618 619 /** Determine whether a measurement should be included in the analysis, based on supplied filter criteria */ 620 int MeasFilterTest(Measure *measure) { 621 int found, k; 622 long mask; 623 PhotCode *code; 624 float mag; 625 626 if (!finite(measure[0].dR) || !finite(measure[0].dD)) return FALSE; 627 if (!finite(measure[0].M)) return FALSE; //XXX is this necessary for all relastro tasks? 628 629 /* select measurements by photcode, or equiv photcode, if specified */ 630 if (NphotcodesKeep > 0) { 631 found = FALSE; 632 for (k = 0; (k < NphotcodesKeep) && !found; k++) { 633 if (photcodesKeep[k][0].code == measure[0].photcode) found = TRUE; 634 if (photcodesKeep[k][0].code == GetPhotcodeEquivCodebyCode(measure[0].photcode)) found = TRUE; 635 } 636 if (!found) return FALSE; 637 } 638 639 if (NphotcodesSkip > 0) { 640 found = FALSE; 641 for (k = 0; (k < NphotcodesSkip) && !found; k++) { 642 if (photcodesSkip[k][0].code == measure[0].photcode) found = TRUE; 643 if (photcodesSkip[k][0].code == GetPhotcodeEquivCodebyCode(measure[0].photcode)) found = TRUE; 644 } 645 if (found) return FALSE; 646 } 647 648 /* select measurements by time */ 649 if (TimeSelect) { 650 if (measure[0].t < TSTART) return FALSE; 651 if (measure[0].t > TSTOP) return FALSE; 652 } 653 654 /* select measurements by quality */ 655 if (PhotFlagSelect) { 656 if (PhotFlagBad) { 657 mask = PhotFlagBad; 658 } else { 659 code = GetPhotcodebyCode (measure[0].photcode); 660 mask = code[0].astromBadMask; 661 } 662 if (mask & measure[0].photFlags) return FALSE; 663 } 664 665 /* select measurements by measurement error */ 666 if ((SIGMA_LIM > 0) && (measure[0].dM > SIGMA_LIM)) return FALSE; 667 668 /* select measurements by mag limit */ 669 if (ImagSelect) { 670 mag = PhotInst (measure); 671 if (mag < ImagMin || mag > ImagMax) return FALSE; 672 } 673 674 return TRUE; 675 } -
trunk/Ohana/src/relastro/src/UpdateObjects.c
r23595 r24308 97 97 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 98 98 99 //exclude measurements which have non-finite astrometry 100 if (!finite(catalog[i].measure[m].dR) || !finite(catalog[i].measure[m].dD)) continue; 99 //does the measurement pass the supplied filtering constraints? 100 if (!MeasFilterTest(&catalog[i].measure[m])) { 101 catalog[i].measure[m].dbFlags &= ~ID_MEAS_USED_OBJ; 102 continue; 103 } 104 105 //outlier rejection 106 if (FlagOutlier && (catalog[i].measure[m].dbFlags & ID_MEAS_POOR_ASTROM)) { 107 catalog[i].measure[m].dbFlags &= ~ID_MEAS_USED_OBJ; 108 continue; 109 } 101 110 102 111 // exclude measurements by previous outlier detection … … 109 118 # endif 110 119 111 /* exclude measurements by quality */ 112 if (PhotFlagSelect) { 113 if (PhotFlagBad) { 114 mask = PhotFlagBad; 115 } else { 116 code = GetPhotcodebyCode (catalog[i].measure[m].photcode); 117 mask = code[0].astromBadMask; 118 } 119 if (mask & catalog[i].measure[m].photFlags) { 120 catalog[i].measure[m].dbFlags |= ID_MEAS_SKIP_ASTROM; 121 continue; 122 } 123 } 124 125 /* exclude measurements by mag limit */ 126 if (ImagSelect) { 127 mag = PhotInst (&catalog[i].measure[m]); 128 if (mag < ImagMin) { 129 catalog[i].measure[m].dbFlags |= ID_MEAS_SKIP_ASTROM; 130 continue; 131 } 132 if (mag > ImagMax) { 133 catalog[i].measure[m].dbFlags |= ID_MEAS_SKIP_ASTROM; 134 continue; 135 } 136 } 137 138 /* select or exclude measurements by photcode, or equiv photcode, if specified */ 139 if (NphotcodesKeep > 0) { 140 found = FALSE; 141 for (kp = 0; (kp < NphotcodesKeep) && !found; kp++) { 142 if (photcodesKeep[kp][0].code == catalog[i].measure[m].photcode) found = TRUE; 143 if (photcodesKeep[kp][0].code == GetPhotcodeEquivCodebyCode(catalog[i].measure[m].photcode)) found = TRUE; 144 } 145 if (!found) continue; 146 } 147 if (NphotcodesSkip > 0) { 148 found = FALSE; 149 for (kp = 0; (kp < NphotcodesSkip) && !found; kp++) { 150 if (photcodesSkip[kp][0].code == catalog[i].measure[m].photcode) found = TRUE; 151 if (photcodesSkip[kp][0].code == GetPhotcodeEquivCodebyCode(catalog[i].measure[m].photcode)) found = TRUE; 152 } 153 if (found) continue; 154 } 120 catalog[i].measure[m].dbFlags |= ID_MEAS_USED_OBJ; 155 121 156 122 R[N] = getMeanR (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); … … 179 145 180 146 // too few measurements for average position (require 2 values) 181 if (N < 2) {147 if (N < SRC_MEAS_TOOFEW) { 182 148 // XXX need to define PHOTOM and ASTROM object flags 183 // catalog[i].average[j].code|= ID_STAR_FEW;184 continue;149 catalog[i].average[j].flags |= ID_STAR_FEW; 150 if (N < 2) continue; 185 151 } 186 152 … … 276 242 } 277 243 244 //make sure that the fit succeeded 245 assert(finite(fit.Ro) && finite(fit.Do) && 246 finite(fit.dRo) && finite(fit.dDo) && 247 finite(fit.uR) && finite(fit.uD) && 248 finite(fit.duR) && finite(fit.duD) && 249 finite(fit.p) && finite(fit.dp)); 250 278 251 // the measure fields must be updated before the average fields 279 252 m = catalog[i].average[j].measureOffset; -
trunk/Ohana/src/relastro/src/args.c
r17205 r24308 40 40 FIT_TARGET = TARGET_MOSAICS; 41 41 } 42 43 FlagOutlier = FALSE; 44 if ((N = get_argument (argc, argv, "-clip"))) { 45 remove_argument (N, &argc, argv); 46 CLIP_THRESH = atof (argv[N]); 47 remove_argument (N, &argc, argv); 48 FlagOutlier = TRUE; 49 } 50 42 51 if (FIT_TARGET == TARGET_NONE) usage(); 43 52 -
trunk/Ohana/src/relastro/src/bcatalog.c
r21508 r24308 2 2 3 3 int bcatalog (Catalog *subcatalog, Catalog *catalog) { 4 4 5 5 int i, j, k, offset, found; 6 6 int NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm, Nsecfilt; … … 23 23 /* exclude stars not in range or with too few measurements */ 24 24 for (i = 0; i < catalog[0].Naverage; i++) { 25 if (catalog[0].average[i].Nmeasure < 2) continue; 26 25 if (catalog[0].average[i].Nmeasure <= SRC_MEAS_TOOFEW) { 26 continue; 27 } 28 27 29 /* start with all stars good */ 28 30 subcatalog[0].average[Naverage] = catalog[0].average[i]; … … 44 46 45 47 offset = catalog[0].average[i].measureOffset + j; 46 47 /* select measurements by photcode, or equiv photcode, if specified */ 48 if (NphotcodesKeep > 0) { 49 found = FALSE; 50 for (k = 0; (k < NphotcodesKeep) && !found; k++) { 51 if (photcodesKeep[k][0].code == catalog[0].measure[offset].photcode) found = TRUE; 52 if (photcodesKeep[k][0].code == GetPhotcodeEquivCodebyCode(catalog[0].measure[offset].photcode)) found = TRUE; 53 } 54 if (!found) continue; 55 } 56 if (NphotcodesSkip > 0) { 57 found = FALSE; 58 for (k = 0; (k < NphotcodesSkip) && !found; k++) { 59 if (photcodesSkip[k][0].code == catalog[0].measure[offset].photcode) found = TRUE; 60 if (photcodesSkip[k][0].code == GetPhotcodeEquivCodebyCode(catalog[0].measure[offset].photcode)) found = TRUE; 61 } 62 if (found) continue; 48 49 //filter objects based on user supplied criteria 50 if (!MeasFilterTest(&catalog[0].measure[offset])) { 51 catalog[0].measure[offset].dbFlags &= ~ID_MEAS_USED_CHIP; 52 continue; 63 53 } 64 54 65 / * select measurements by time */66 if ( TimeSelect) {67 if (catalog[0].measure[offset].t < TSTART) continue;68 if (catalog[0].measure[offset].t > TSTOP)continue;55 //filter out outliers 56 if (FlagOutlier && (catalog[0].measure[offset].dbFlags & ID_MEAS_POOR_ASTROM)) { 57 catalog[0].measure[offset].dbFlags &= ~ID_MEAS_USED_CHIP; 58 continue; 69 59 } 70 71 /* select measurements by quality */ 72 // XXX FIX THIS!! 73 // if (DophotSelect && (catalog[0].measure[offset].dophot != DophotValue)) continue; 74 75 /* select measurements by quality */ 76 if (PhotFlagSelect) { 77 if (PhotFlagBad) { 78 mask = PhotFlagBad; 79 } else { 80 code = GetPhotcodebyCode (catalog[0].measure[offset].photcode); 81 mask = code[0].astromBadMask; 82 } 83 if (mask & catalog[0].measure[offset].photFlags) continue; 84 } 85 86 /* select measurements by measurement error */ 87 if ((SIGMA_LIM > 0) && (catalog[0].measure[offset].dM > SIGMA_LIM)) continue; 88 89 /* select measurements by mag limit */ 90 if (ImagSelect) { 91 mag = PhotInst (&catalog[0].measure[offset]); 92 if (mag < ImagMin) continue; 93 if (mag > ImagMax) continue; 94 } 60 catalog[0].measure[offset].dbFlags |= ID_MEAS_USED_CHIP; 95 61 96 62 // re-assess on each run of relastro if a measurement should be used … … 110 76 subcatalog[0].measure[Nmeasure] = catalog[0].measure[offset]; 111 77 subcatalog[0].measure[Nmeasure].averef = Naverage; 112 if (RESET) { 113 subcatalog[0].measure[Nmeasure].dbFlags &= ~ID_MEAS_POOR_ASTROM;114 subcatalog[0].measure[Nmeasure].dbFlags &= ~ID_MEAS_AREA;78 if (RESET) { 79 subcatalog[0].measure[Nmeasure].dbFlags &= ~ID_MEAS_POOR_ASTROM; 80 subcatalog[0].measure[Nmeasure].dbFlags &= ~ID_MEAS_AREA; 115 81 } 82 116 83 Nmeasure ++; 117 84 Nm ++; 118 85 if (Nmeasure == NMEASURE) { 119 NMEASURE += 1000;120 REALLOCATE (subcatalog[0].measure, Measure, NMEASURE);86 NMEASURE += 1000; 87 REALLOCATE (subcatalog[0].measure, Measure, NMEASURE); 121 88 } 122 89 } … … 139 106 140 107 if (VERBOSE) { 141 fprintf (stderr, "%d: using %d stars (%d measures) for catalog\n", i, 142 subcatalog[0].Naverage, subcatalog[0].Nmeasure);108 fprintf (stderr, "%d: using %d stars (%d measures) for catalog\n", i, 109 subcatalog[0].Naverage, subcatalog[0].Nmeasure); 143 110 } 144 111 return (TRUE); -
trunk/Ohana/src/relastro/src/initialize.c
r17213 r24308 25 25 fprintf (stderr, "codename: %s\n", codename); 26 26 if ((photcodesKeep[NphotcodesKeep] = GetPhotcodebyName (codename)) == NULL) { 27 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename);28 exit (1);27 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename); 28 exit (1); 29 29 } 30 30 NphotcodesKeep ++; … … 46 46 fprintf (stderr, "codename: %s\n", codename); 47 47 if ((photcodesSkip[NphotcodesSkip] = GetPhotcodebyName (codename)) == NULL) { 48 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename);49 exit (1);48 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename); 49 exit (1); 50 50 } 51 51 NphotcodesSkip ++; -
trunk/Ohana/src/relastro/src/load_catalogs.c
r21508 r24308 29 29 } 30 30 if (VERBOSE && !pcatalog[0].Naves_disk) fprintf (stderr, "no data in %s, skipping\n", pcatalog[0].filename); 31 32 //outlier rejection 33 if (FlagOutlier) { 34 FlagOutliers(&tcatalog); 35 } 31 36 32 37 // select only the brighter stars -
trunk/Ohana/src/relastro/src/relastro_objects.c
r21508 r24308 8 8 SkyList *skylist = NULL; 9 9 Catalog catalog; 10 10 11 11 12 // load the current sky table (layout of all SkyRegions) … … 37 38 } 38 39 40 if (FlagOutlier) { 41 FlagOutliers(&catalog); 42 } 43 39 44 // XXX consider what gets reset (only ASTROM flags) 40 45 if (RESET) {
Note:
See TracChangeset
for help on using the changeset viewer.
