IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34576


Ignore:
Timestamp:
Oct 25, 2012, 10:20:24 AM (14 years ago)
Author:
eugene
Message:

fix problems with ChisqPos and object flags for relastro

Location:
trunk/Ohana/src/relastro
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relastro/include/relastro.h

    r33963 r34576  
    271271void          initstats           PROTO((char *mode));
    272272int           liststats           PROTO((double *value, double *dvalue, int N, StatType *stats));
     273int           liststats_pos       PROTO((double *value, double *dvalue, int N, StatType *stats, int XVERB));
    273274Catalog      *load_catalogs       PROTO((SkyList *skylist, int *Ncatalog, int subselect, int hostID, char *hostpath));
    274275int           load_images         PROTO((FITS_DB *db, SkyList *skylist));
  • trunk/Ohana/src/relastro/src/UpdateObjects.c

    r34465 r34576  
    103103      mode = FIT_MODE;
    104104
     105      // XVERB |= (catalog[i].averge[j].objID == 0xc90) && (catalog[i].average[j].catID == 0x2a1e);
     106      XVERB |= (catalog[i].average[j].objID == OBJ_ID_SRC) && (catalog[i].average[j].catID == CAT_ID_SRC);
     107      XVERB |= (catalog[i].average[j].objID == OBJ_ID_DST) && (catalog[i].average[j].catID == CAT_ID_DST);
     108
    105109      // find the basic properties of the detections for this object (Tmin, Tmax, Tmean)
    106110      for (k = 0; k < catalog[i].average[j].Nmeasure; k++) {
     111
     112        if (XVERB) {
     113          char *date = ohana_sec_to_date (measure[k].t);
     114          fprintf (stderr, OFF_T_FMT" %f %f %s : 0x%08x : 0x%08x\n",  k, measure[k].dR, measure[k].dD, date, measure[k].dbFlags, measureBig[k].dbFlags);
     115          free (date);
     116        }
    107117
    108118        // does the measurement pass the supplied filtering constraints?
     
    138148        if (isnan(dX[N])) {
    139149          measure[k].dbFlags &= ~ID_MEAS_USED_OBJ;
     150          if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; }
    140151          continue;
    141152        }
    142153        if (isnan(dY[N])) {
    143154          measure[k].dbFlags &= ~ID_MEAS_USED_OBJ;
     155          if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; }
    144156          continue;
    145157        }
     
    207219      coords.crval1 = R[0];
    208220      coords.crval2 = D[0];
    209 
    210       // XVERB |= (catalog[i].averge[j].objID == 0xc90) && (catalog[i].average[j].catID == 0x2a1e);
    211       XVERB |= (catalog[i].average[j].objID == OBJ_ID_SRC) && (catalog[i].average[j].catID == CAT_ID_SRC);
    212       XVERB |= (catalog[i].average[j].objID == OBJ_ID_DST) && (catalog[i].average[j].catID == CAT_ID_DST);
    213221
    214222      // to judge the quality of the PM and PAR fits, we need to fit all three models and compare Chisq
     
    266274      // fit the average model
    267275      if ((mode == FIT_AVERAGE) || (mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) {
    268         liststats (R, dR, N, &statsR); // WARNING: this function modifies R (do not use after here)
    269         liststats (D, dD, N, &statsD); // WARNING: this function modifies D (do not use after here)
     276        liststats_pos (R, dR, N, &statsR, XVERB); // WARNING: this function modifies R (do not use after here)
     277        liststats_pos (D, dD, N, &statsD, XVERB); // WARNING: this function modifies D (do not use after here)
    270278
    271279        fitAve.Ro = statsR.mean;
     
    275283        fitAve.dDo = 3600.0*statsD.sigma;
    276284
    277         fitAve.chisq = 0.5*(statsR.chisq + statsD.chisq);
     285        fitAve.chisq = 0.5 * (statsR.chisq + statsD.chisq);
    278286        fitAve.Nfit = N;
    279287
     
    358366      catalog[i].average[j].Trange = (Trange * 86400 * 365.26);
    359367      catalog[i].average[j].Npos = fit.Nfit;
    360       if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f) pm=(%f %f)\n",
     368      if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f) pm=(%f %f) chisq=(%f, %f, %f)\n",
    361369                          catalog[i].average[j].R,
    362370                          catalog[i].average[j].D,
     
    365373                          3600*(catalog[i].average[j].D - fit.Do),
    366374                          catalog[i].average[j].uR,
    367                           catalog[i].average[j].uD);
    368 
     375                          catalog[i].average[j].uD,
     376                          fitAve.chisq, fitPM.chisq, fitPAR.chisq);
    369377    }
    370378
  • trunk/Ohana/src/relastro/src/liststats.c

    r34429 r34576  
    148148}
    149149
     150int liststats_pos (double *value, double *dvalue, int N, StatType *stats, int XVERB) {
     151 
     152  int i, ks, ke, Nm;
     153  double Mo, dMo, M, dM, X2, dS, *chi;
     154
     155  ke = ks = dMo = 0;
     156
     157  stats[0].Nmeas = N;
     158  stats[0].mean  = 0;
     159  stats[0].sigma = 0;
     160  stats[0].error = 0;
     161  stats[0].chisq = 0;
     162  if (N < 1) return (FALSE);
     163
     164  dsortpair (value, dvalue, N);
     165  if (N % 2) {
     166    stats[0].median = value[(int)(0.5*N)];
     167  } else {
     168    stats[0].median = 0.5*(value[N/2] + value[N/2 - 1]);
     169  }
     170  stats[0].min    = value[0];
     171  stats[0].max    = value[N-1];
     172
     173  switch (statmode) {
     174  case M_MEDIAN:
     175    ks = 0;
     176    ke = N;
     177    Mo = stats[0].median;
     178    Nm = N;
     179    goto chisq;
     180    break;
     181  case M_MEAN:
     182  case M_WTMEAN:
     183    ks = 0;
     184    ke = N;
     185    break;
     186  case M_INNER_MEAN:
     187  case M_INNER_WTMEAN:
     188  case M_CHI_INNER_MEAN:
     189  case M_CHI_INNER_WTMEAN:
     190    ks = 0.25*N + 0.50;
     191    ke = 0.75*N + 0.25;
     192    if (N <= 3) {
     193      ks = 0;
     194      ke = N;
     195    }
     196    break;
     197  case M_INNER_80_MEAN:
     198  case M_INNER_80_WTMEAN:
     199  case M_CHI_INNER_80_MEAN:
     200  case M_CHI_INNER_80_WTMEAN:
     201    ks = 0.1*N + 0.1;
     202    ke = 0.8*N + 0.1;
     203    if (N <= 10) {
     204      ks = 0;
     205      ke = N;
     206    }
     207    break;
     208  }   
     209
     210  if ((statmode == M_CHI_INNER_MEAN) ||
     211      (statmode == M_CHI_INNER_WTMEAN) ||
     212      (statmode == M_CHI_INNER_80_MEAN) ||
     213      (statmode == M_CHI_INNER_80_WTMEAN)) {
     214    ALLOCATE (chi, double, N);
     215    for (i = 0; i < N; i++) {
     216      chi[i] = (value[i] - stats[0].median) / dvalue[i];
     217    }
     218    dsortthree (chi, value, dvalue, N);
     219    free (chi);
     220  }
     221
     222  /* calculating the per-star offset based on the weighted average */
     223  M = dM = Nm = 0;
     224  if ((statmode == M_WTMEAN) ||
     225      (statmode == M_INNER_WTMEAN) ||
     226      (statmode == M_INNER_80_WTMEAN) ||
     227      (statmode == M_CHI_INNER_WTMEAN) ||
     228      (statmode == M_CHI_INNER_80_WTMEAN)) {
     229    for (i = ks; i < ke; i++) {
     230      M   += value[i] / SQ (dvalue[i]);
     231      dM  += 1.0 / SQ (dvalue[i]);
     232      Nm  ++; 
     233    }   
     234    Mo = M / dM;
     235    dMo = sqrt (1.0 / dM);
     236  } else {
     237    for (i = ks; i < ke; i++) {
     238      M   += value[i];
     239      dM  += SQ (dvalue[i]);
     240      Nm  ++; 
     241    }   
     242    Mo = M / (double) Nm;
     243    dMo = sqrt (dM / (double) Nm);
     244  }
     245
     246 chisq:
     247  /* find sigma and chisq */
     248  X2 = dS = 0;
     249  for (i = ks; i < ke; i++) {
     250    M  = SQ (value[i] - Mo);
     251    dM = SQ (dvalue[i]);
     252    X2 += M / dM;
     253    dS += M;
     254    if (XVERB) fprintf (stderr, "chisq contrib : %f : %f : %f : %f : %f\n", Mo, 3600.0*(value[i] - Mo), 3600.0*dvalue[i], (value[i] - Mo) / dvalue[i], X2);
     255  }
     256  X2 = X2 / (Nm - 1);
     257  dS = sqrt (dS / Nm);
     258
     259  stats[0].mean  = Mo;
     260  stats[0].Nmeas = Nm;
     261  stats[0].chisq = X2;
     262  stats[0].sigma = dS;
     263  stats[0].error = dMo;
     264
     265  return (TRUE);
     266}
     267
  • trunk/Ohana/src/relastro/src/relastro_objects.c

    r34429 r34576  
    132132
    133133    char command[1024];
    134     snprintf (command, 1024, "relastro_client -update-objects -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f",
    135               table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
     134    snprintf (command, 1024, "relastro_client -update-objects -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s",
     135              table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE);
    136136
    137137    char tmpline[1024];
Note: See TracChangeset for help on using the changeset viewer.