IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 13, 2015, 5:19:12 AM (11 years ago)
Author:
eugene
Message:

adding flags to galphot

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/src/loadgalphot_readstars.c

    r39122 r39125  
    217217    stars[i].found = FALSE;
    218218
     219    dvo_galphot_init (&stars[i].galphot);
     220
    219221    // stars[i].galphot.R = R;
    220222    // stars[i].galphot.D = D;
    … …  
    238240
    239241    // I want to use this flag to set a bit in secfilt.  is that possible?  or maybe galphot.dummy becomes flags
    240     if (!FitChisqMinimum (fit, &stars[i].galphot, &GAL_CHISQ[Nsample*i], &GAL_FLUX[Nsample*i], &GAL_FLUX_ERR[Nsample*i], Nsample, FR_MAJOR_MIN[i], FR_MAJOR_MAX[i], FR_MAJOR_DEL[i], FR_MINOR_MIN[i], FR_MINOR_MAX[i], FR_MINOR_DEL[i])) {
    241       stars[i].flag = TRUE;
    242     }
     242    FitChisqMinimum (fit, &stars[i].galphot, &GAL_CHISQ[Nsample*i], &GAL_FLUX[Nsample*i], &GAL_FLUX_ERR[Nsample*i], Nsample, FR_MAJOR_MIN[i], FR_MAJOR_MAX[i], FR_MAJOR_DEL[i], FR_MINOR_MIN[i], FR_MINOR_MAX[i], FR_MINOR_DEL[i]);
    243243
    244244    // I could either multiply FR_MAJOR_MIN, etc above or the fitted values below
    … …  
    330330  }
    331331
    332   if (Nvalid < 6) goto bad_fit;
     332  if (Nvalid < 6) { galphot->flags |= ID_GALPHOT_TOO_FEW; goto bad_fit; }
    333333
    334334# if (0)
    … …  
    344344  // fit with 3 iterations, 5 sigma clipping (set above after fit2d_init)
    345345  // on failure (for any reason), the stars[i].flag is set to TRUE (XXX bad choice)
    346   if (!fit2d (fit, Xpt, Ypt, chisq, chisqFit, mask, Npts)) goto bad_fit;
     346  if (!fit2d (fit, Xpt, Ypt, chisq, chisqFit, mask, Npts)) { galphot->flags |= ID_GALPHOT_FAIL_FIT; goto bad_fit; }
    347347
    348348  // get X,Y for the chisq min from the fit:
    … …  
    358358  inRange = inRange && (Ymin < MinorMax + MinorDel);
    359359
    360   if (!inRange) goto bad_fit;
     360  if (!inRange) { galphot->flags |= ID_GALPHOT_OUT_OF_RANGE; goto bad_fit; }
    361361
    362362  // chisqMin @ (Xmin,Ymin)
    … …  
    368368  C = -1;
    369369  Q = B*B - 4*A*C;
    370   if (Q < 0.0) goto bad_err;
     370  if (Q < 0.0) { galphot->flags |= ID_GALPHOT_BAD_ERROR; goto bad_err; }
     371  if (A <= 0.0) { galphot->flags |= ID_GALPHOT_BAD_ERROR; goto bad_err; }
    371372 
    372373  float dXmin = (-B + sqrt(Q)) / (2.0 * A);
    … …  
    377378  C = -1;
    378379  Q = B*B - 4*A*C;
    379   if (Q < 0.0) goto bad_err;
     380  if (Q <  0.0) { galphot->flags |= ID_GALPHOT_BAD_ERROR; goto bad_err; }
     381  if (A <= 0.0) { galphot->flags |= ID_GALPHOT_BAD_ERROR; goto bad_err; }
    380382
    381383  float dYmin = (-B + sqrt(Q)) / (2.0 * A);
    … …  
    443445  galphot->majorAxisErr = MajorDel;
    444446  galphot->minorAxisErr = MinorDel;
     447
     448  galphot->mag    = -2.5*log10(flux[iMin]) + ZeroPt; // correct for exptime?
     449  galphot->magErr = sqrt(fluxErr[iMin]) / flux[iMin];
     450  galphot->chisq  = chisqMin;
    445451  return FALSE;
    446452}
Note: See TracChangeset for help on using the changeset viewer.