IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36808


Ignore:
Timestamp:
Jun 3, 2014, 8:04:22 AM (12 years ago)
Author:
eugene
Message:

add refColor tracking to image and average

Location:
branches/eam_branches/ipp-20140423/Ohana/src/relastro
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140423/Ohana/src/relastro/include/relastro.h

    r36796 r36808  
    8383  double L, M;  /* Focal Plane   - pixels  */
    8484  double X, Y;  /* Chip Coords   - pixels  */
    85   double Mag;
    86   double dMag;
    87   double dPos;
     85  float Mag;
     86  float Color;
     87  float dMag;
     88  float dPos;
    8889  int mask;
    8990  int Nmeas;
     
    216217char          WHERE_A[10000],          WHERE_B[10000];
    217218SkyRegionSelection SELECTION;
     219
     220char         *DCR_COLOR_POS,    *DCR_COLOR_NEG;
     221PhotCode     *DCR_PHOTCODE_POS, *DCR_PHOTCODE_NEG;
     222int           DCR_NSEC_POS,      DCR_NSEC_NEG;
    218223
    219224int ImagSelect;
     
    526531int ImageTableSave (char *filename, Image *images, off_t Nimages);
    527532int select_mosaics_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage);
     533
     534float getColor (off_t meas, int cat);
  • branches/eam_branches/ipp-20140423/Ohana/src/relastro/src/BrightCatalog.c

    r35105 r36808  
    167167    GET_COLUMN(measureOffset,  "OFF_MEASURE", int);
    168168    GET_COLUMN(missingOffset,  "OFF_MISSING", int);
    169     GET_COLUMN(extendOffset,   "OFF_EXTEND",  int);
     169    GET_COLUMN(refColor,   "REF_COLOR",  float);
    170170    GET_COLUMN(flags,          "FLAGS",       int);
    171171    GET_COLUMN(photFlagsUpper, "PHOTFLAGS_U", int);
     
    202202      average[i].measureOffset   = measureOffset[i]   ;
    203203      average[i].missingOffset   = missingOffset[i]   ;
    204       average[i].extendOffset    = extendOffset[i]    ; 
     204      average[i].refColor    = refColor[i]    ; 
    205205      average[i].flags           = flags[i]           ;
    206206      average[i].photFlagsUpper  = photFlagsUpper[i]  ;
     
    234234    free (measureOffset);
    235235    free (missingOffset);
    236     free (extendOffset);
     236    free (refColor);
    237237    free (flags);
    238238    free (photFlagsUpper);
     
    510510    int      *measureOffset ; ALLOCATE (measureOffset , int     , catalog->Naverage);
    511511    int      *missingOffset ; ALLOCATE (missingOffset , int     , catalog->Naverage);
    512     int      *extendOffset  ; ALLOCATE (extendOffset  , int     , catalog->Naverage);
     512    float    *refColor      ; ALLOCATE (refColor  , float     , catalog->Naverage);
    513513    int      *flags         ; ALLOCATE (flags         , int     , catalog->Naverage);
    514514    int      *photFlagsUpper; ALLOCATE (photFlagsUpper, int     , catalog->Naverage);
     
    543543      measureOffset[i]   = average[i].measureOffset   ;
    544544      missingOffset[i]   = average[i].missingOffset   ;
    545       extendOffset[i]    = average[i].extendOffset    ; 
     545      refColor[i]    = average[i].refColor    ; 
    546546      flags[i]           = average[i].flags           ;
    547547      photFlagsUpper[i]  = average[i].photFlagsUpper  ;
     
    575575    gfits_set_bintable_column (&theader, &ftable, "OFF_MEASURE", measureOffset,   catalog->Naverage);
    576576    gfits_set_bintable_column (&theader, &ftable, "OFF_MISSING", missingOffset,   catalog->Naverage);
    577     gfits_set_bintable_column (&theader, &ftable, "OFF_EXTEND",  extendOffset,    catalog->Naverage);
     577    gfits_set_bintable_column (&theader, &ftable, "REF_COLOR",  refColor,    catalog->Naverage);
    578578    gfits_set_bintable_column (&theader, &ftable, "FLAGS",       flags,           catalog->Naverage);
    579579    gfits_set_bintable_column (&theader, &ftable, "PHOTFLAGS_U", photFlagsUpper,  catalog->Naverage);
     
    605605    free (measureOffset);
    606606    free (missingOffset);
    607     free (extendOffset);
     607    free (refColor);
    608608    free (flags);
    609609    free (photFlagsUpper);
  • branches/eam_branches/ipp-20140423/Ohana/src/relastro/src/FitChip.c

    r36769 r36808  
    44int FitChip (StarData *raw, StarData *ref, int Nmatch, Image *image) {
    55
    6   int i, NstatFull, Nstat, Niter;
     6  int i, NstatFull, Nstat, Niter, Nkeep;
    77  float dLsig, dMsig, dRsig;
    88  float dLsigFull, dMsigFull, dRsigFull;
     
    2424
    2525    // measure the scatter distribution (use only the bright end detections)
     26    Nkeep = 0;
    2627    for (i = 0; i < Nmatch; i++) {
    2728      if (raw[i].mask) continue;
     
    4243        continue;
    4344      }
    44     }
     45      Nkeep ++;
     46    }
     47
     48    // I'm rejecting some points from the fit above; I count the remainders and actually
     49    // use that count to set order_use below
    4550
    4651    // figures to assess the fitting process:
     
    5055    relastroVisualPlotChipFit(raw, ref, dRmax, Nmatch);
    5156
    52     // set the maximum order for the polynomial (based on number of stars)
     57    // set the maximum order for the polynomial (based on number of stars kept above)
    5358    int order_use = 0;
    54     if (Nmatch >  5) order_use = 1; // 4 stars per polynomial term (per dimension)
    55     if (Nmatch > 30) order_use = 2; // 5 stars per polynomial term (per dimension)
    56     if (Nmatch > 60) order_use = 3; // 6 stars per polynomial term (per dimension)
     59    if (Nkeep >  5) order_use = 1; // 4 stars per polynomial term (per dimension)
     60    if (Nkeep > 30) order_use = 2; // 5 stars per polynomial term (per dimension)
     61    if (Nkeep > 60) order_use = 3; // 6 stars per polynomial term (per dimension)
    5762    if (order_use < 1) {
    58       if (VERBOSE2) fprintf (stderr, "insufficient measurements (%d) for linear fit\n", Nmatch);
     63      if (VERBOSE2) fprintf (stderr, "insufficient measurements (%d) for linear fit\n", Nkeep);
    5964      image[0].flags |= ID_IMAGE_ASTROM_FEW;
    6065      return FALSE;
    6166    }
    6267    image[0].coords.Npolyterms = order_use;
    63 
    64 # if (0)
    65     if (CHIPORDER > 0) {
    66       int Ndof_min = 3;
    67       int order_max = 0.5*(sqrt(4*Nmatch - 4*Ndof_min + 1) - 3);
    68       int order_use = MIN (CHIPORDER, order_max);
    69       if (order_use < 1) {
    70         if (VERBOSE2) fprintf (stderr, "insufficient measurements (%d) for linear fit\n", Nmatch);
    71         image[0].flags |= ID_IMAGE_ASTROM_FEW;
    72         return FALSE;
    73       }
    74       image[0].coords.Npolyterms = order_use;
    75     }
    76 # endif
    7768
    7869    if (fit) fit_free (fit);
     
    8475      fit_add (fit, raw[i].X, raw[i].Y, ref[i].L, ref[i].M, raw[i].dPos);
    8576    }
    86 
    87 # if (0)
    88     // check if the fit has enough data points for the polynomial order
    89     skip = FALSE;
    90     switch (image[0].coords.Npolyterms) {
    91       case 0:
    92       case 1:
    93         skip = (fit[0].Npts < 8);
    94         break;
    95       case 2:
    96         skip = (fit[0].Npts < 11);
    97         break;
    98       case 3:
    99         skip = (fit[0].Npts < 15);
    100         break;
    101       default:
    102         fprintf (stderr, "invalid chip order %d\n", image[0].coords.Npolyterms);
    103         skip = TRUE;
    104     }
    105     if (skip) {
    106       if (VERBOSE2) fprintf (stderr, "insufficient measurements (%d) for requested order (%d)\n", fit[0].Npts, image[0].coords.Npolyterms);
    107       fit_free (fit);
    108       image[0].flags |= ID_IMAGE_ASTROM_FEW;
    109       return FALSE;
    110     }
    111 # endif
    11277
    11378    // measure the fit, update the coords & object coordinates
     
    147112  }
    148113
     114  int Ncolor = 0;
     115  float *colorList = NULL;
     116  ALLOCATE (colorList, float, Nmatch);
     117
     118  for (i = 0; i < Nmatch; i++) {
     119    if (!raw[i].mask) continue;
     120    if (!isnan(ref[i].Color)) {
     121      colorList[Ncolor] = ref[i].Color;
     122      Ncolor ++;
     123    }
     124  }
     125  fsort (colorList, Ncolor);
     126  float colorMedian = (Ncolor > 0) ? colorList[(int)(0.5*Ncolor)] : NAN;
     127  image[0].refColor = colorMedian;
     128  free (colorList);
     129
    149130  GetScatterRawRef(&dLsigFull, &dMsigFull, &dRsigFull, &NstatFull, raw, ref, Nmatch, SIGMA_LIM);
    150131  GetScatterRawRef(&dLsig,     &dMsig,     &dRsig,     &Nstat,     raw, ref, Nmatch, IMFIT_SYS_SIGMA_LIM);
     
    164145  image[0].dYpixSys = dMsig;
    165146  image[0].nFitAstrom = fit[0].Npts;
     147
     148  // fprintf (stderr, "%s %6.3f %4d %4d\n", image[0].name, image[0].refColor, Ncolor, image[0].nFitAstrom);
    166149
    167150  if (fit) fit_free (fit);
  • branches/eam_branches/ipp-20140423/Ohana/src/relastro/src/ImageOps.c

    r36800 r36808  
    333333*/
    334334
     335float getColor (off_t meas, int cat) {
     336
     337  off_t i;
     338
     339  i = MeasureToImage[cat][meas];
     340  if (i == -1) return (NAN);
     341  return (image[i].refColor);
     342}
     343
    335344void plot_images () {
    336345
     
    738747  StarData *ref;
    739748
     749  int Nsecfilt = GetPhotcodeNsecfilt();
     750
    740751  mosaic = NULL;
    741752  moscoords = NULL;
     
    765776    ref[i].dMag = measure[0].dM;
    766777    ref[i].dPos = GetAstromErrorTiny (&measure[0], ERROR_MODE_POS);
     778
     779    if ((DCR_NSEC_POS >= 0) && (DCR_NSEC_NEG >= -1)) {
     780      ref[i].Color = catalog[c].secfilt[n*Nsecfilt + DCR_NSEC_POS].M - catalog[c].secfilt[n*Nsecfilt + DCR_NSEC_NEG].M;
     781    }
    767782
    768783    ref[i].mask = FALSE;
  • branches/eam_branches/ipp-20140423/Ohana/src/relastro/src/UpdateObjects.c

    r36800 r36808  
    1010static double *T;
    1111static double *dT;
     12static double *C;
    1213
    1314void initObjectData (Catalog *catalog, int Ncatalog) {
     
    3637  ALLOCATE (pX, double, MAX (1, Nmax));
    3738  ALLOCATE (pY, double, MAX (1, Nmax));
     39
     40  ALLOCATE (C, double, MAX (1, Nmax));
    3841
    3942
     
    5457  free (pX);
    5558  free (pY);
     59
     60  free (C);
    5661
    5762
     
    6166
    6267  off_t j, k, m;
    63   int i, N, Nsecfilt, mode, result, status, XVERB;
     68  int i, N, Nc, Nsecfilt, mode, result, status, XVERB;
    6469  StatType statsR, statsD;
    6570  Coords coords;
     
    116121      }
    117122
     123      Nc = 0;
    118124      N = 0;
    119125      m = catalog[i].average[j].measureOffset;
     
    222228        dD[N] = dY[N] / 3600.0;
    223229
     230        float color = getColor (m+k, i);
     231        if (!isnan(color)) {
     232          C[Nc] = color;
     233          Nc++;
     234        }
     235
    224236        N++;
    225237      }
     
    341353        Nave ++;
    342354      }
     355
     356      dsort (C, Nc);
     357      float colorMedian = (Nc > 0) ? C[(int)(0.5*Nc)] : NAN;
     358      catalog[i].average[j].refColor = colorMedian;
    343359
    344360      /* choose the result based on the chisq values */
  • branches/eam_branches/ipp-20140423/Ohana/src/relastro/src/args.c

    r36800 r36808  
    292292    remove_argument (N, &argc, argv);
    293293    TimeSelect = TRUE;
     294  }
     295
     296  DCR_COLOR_POS = NULL;
     297  DCR_COLOR_NEG = NULL;
     298  if ((N = get_argument (argc, argv, "-dcr-color"))) {
     299    remove_argument (N, &argc, argv);
     300    DCR_COLOR_POS = strcreate(argv[N]);
     301    remove_argument (N, &argc, argv);
     302    DCR_COLOR_NEG = strcreate(argv[N]);
     303    remove_argument (N, &argc, argv);
    294304  }
    295305
  • branches/eam_branches/ipp-20140423/Ohana/src/relastro/src/initialize.c

    r36746 r36808  
    77
    88  if (RELASTRO_OP == OP_MERGE_SOURCE) return;
     9
     10  if (DCR_COLOR_POS)  fprintf (stderr, "DCR_COLOR_POS:  %s\n", DCR_COLOR_POS);
     11  if (DCR_COLOR_NEG)  fprintf (stderr, "DCR_COLOR_NEG:  %s\n", DCR_COLOR_NEG);
    912
    1013  if (PHOTCODE_KEEP_LIST)  fprintf (stderr, "PHOTCODE_KEEP_LIST:  %s\n", PHOTCODE_KEEP_LIST);
     
    1922  photcodesGroupA = ParsePhotcodeList (PHOTCODE_A_LIST,     &NphotcodesGroupA, TRUE);
    2023  photcodesGroupB = ParsePhotcodeList (PHOTCODE_B_LIST,     &NphotcodesGroupB, TRUE);
     24
     25  DCR_NSEC_POS = DCR_NSEC_NEG = -1;
     26  if (DCR_COLOR_POS) {
     27    DCR_PHOTCODE_POS = GetPhotcodebyName (DCR_COLOR_POS);
     28    if (!DCR_PHOTCODE_POS) {
     29      fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", DCR_COLOR_POS);
     30      exit (1);
     31    }
     32    DCR_NSEC_POS = GetPhotcodeNsec (DCR_PHOTCODE_POS[0].code);
     33  }
     34  if (DCR_COLOR_NEG) {
     35    DCR_PHOTCODE_NEG = GetPhotcodebyName (DCR_COLOR_NEG);
     36    if (!DCR_PHOTCODE_NEG) {
     37      fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", DCR_COLOR_NEG);
     38      exit (1);
     39    }
     40    DCR_NSEC_NEG = GetPhotcodeNsec (DCR_PHOTCODE_NEG[0].code);
     41  }
    2142
    2243  initstats (STATMODE);
Note: See TracChangeset for help on using the changeset viewer.