IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37198


Ignore:
Timestamp:
Aug 7, 2014, 6:20:06 AM (12 years ago)
Author:
eugene
Message:

more careful calculation of mag vs flux; add catID to output

Location:
branches/eam_branches/ipp-20140717/Ohana/src/dvopsps
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140717/Ohana/src/dvopsps/include/dvopsps.h

    r37176 r37198  
    1414  unsigned int ippDetectID;
    1515  int imageID;
     16  int catID;
    1617  double ra;
    1718  double dec;
  • branches/eam_branches/ipp-20140717/Ohana/src/dvopsps/src/DetectionOps.c

    r37176 r37198  
    5151  GET_COLUMN(ippDetectID , "ippDetectID", int);
    5252  GET_COLUMN(imageID     , "imageID",     int);
     53  GET_COLUMN(catID       , "catID",       int);
    5354  GET_COLUMN(ra          , "ra",          double); // XXX signed vs unsigned?
    5455  GET_COLUMN(dec         , "dec",         double);
     
    7677    detections[i].ippDetectID  = ippDetectID[i];
    7778    detections[i].imageID      = imageID[i];   
     79    detections[i].catID        = catID[i];   
    7880    detections[i].ra           = ra[i];         
    7981    detections[i].dec          = dec[i];       
     
    99101  free (ippDetectID);
    100102  free (imageID    );
     103  free (catID      );
    101104  free (ra         );
    102105  free (dec        );
     
    166169  gfits_define_bintable_column (&theader, "J", "ippDetectID", NULL, NULL, 1.0, FT_BZERO_INT32);
    167170  gfits_define_bintable_column (&theader, "J", "imageID",     NULL, NULL, 1.0, FT_BZERO_INT32);
     171  gfits_define_bintable_column (&theader, "J", "catID",       NULL, NULL, 1.0, FT_BZERO_INT32);
    168172  gfits_define_bintable_column (&theader, "D", "ra",          NULL, NULL, 1.0, 0.0);
    169173  gfits_define_bintable_column (&theader, "D", "dec",         NULL, NULL, 1.0, 0.0);
     
    191195  uint32_t   *ippDetectID ; ALLOCATE (ippDetectID ,  uint32_t, Ndetections);
    192196   int32_t   *imageID     ; ALLOCATE (imageID     ,   int32_t, Ndetections);
     197   int32_t   *catID       ; ALLOCATE (catID       ,   int32_t, Ndetections);
    193198  double     *ra          ; ALLOCATE (ra          ,  double,   Ndetections);
    194199  double     *dec         ; ALLOCATE (dec         ,  double,   Ndetections);
     
    214219    ippDetectID[i] = detections[i].ippDetectID ;
    215220    imageID[i]     = detections[i].imageID     ;
     221    catID[i]       = detections[i].catID       ;
    216222    ra[i]          = detections[i].ra          ;
    217223    dec[i]         = detections[i].dec         ;
     
    237243  gfits_set_bintable_column (&theader, &ftable, "ippDetectID", ippDetectID , Ndetections);
    238244  gfits_set_bintable_column (&theader, &ftable, "imageID",     imageID     , Ndetections);
     245  gfits_set_bintable_column (&theader, &ftable, "catID",       catID       , Ndetections);
    239246  gfits_set_bintable_column (&theader, &ftable, "ra",          ra          , Ndetections);
    240247  gfits_set_bintable_column (&theader, &ftable, "dec",         dec         , Ndetections);
     
    258265  free (ippDetectID );
    259266  free (imageID     );
     267  free (catID       );
    260268  free (ra          );
    261269  free (dec         );
  • branches/eam_branches/ipp-20140717/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c

    r37176 r37198  
    66Detections *detections = NULL;
    77
     8static float ZeroPoint = 25.0;
     9
    810int init_detections () {
    911  NDETECTIONS = 1000;
     
    1517
    1618  off_t i, j;
     19
     20  ZeroPoint = GetZeroPoint();
    1721
    1822  int missingID = 0;
     
    9195
    9296  off_t found = 0;
     97
     98  ZeroPoint = GetZeroPoint();
    9399
    94100  INITTIME;
     
    179185  }
    180186
    181   PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (objID, detectID, ippObjID, ippDetectID, imageID, ");
    182   PrintIOBuffer (buffer, "ra, dec_, raErr, decErr, zp, telluricExt, airmass, expTime, Mpsf, dMpsf, Mkron, dMkron, Map, dMap, flags) VALUES \n");
     187  PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (objID, detectID, ippObjID, ippDetectID, imageID, catID, ");
     188  PrintIOBuffer (buffer, "ra, dec_, raErr, decErr, zp, telluricExt, airmass, expTime, ");
     189  PrintIOBuffer (buffer, "Mpsf, dMpsf, Mkron, dMkron, Map, dMap, flags) VALUES \n");
    183190
    184191  return TRUE;
     
    231238  PrintIOBuffer (buffer,  "%u,  ", detection->ippDetectID); // ippDetectID
    232239  PrintIOBuffer (buffer,  "%d,  ", detection->imageID);     // imageID
     240  PrintIOBuffer (buffer,  "%d,  ", detection->catID);       // DVO Catalog ID
    233241
    234242  PRINT_FLOAT(buffer, detection->ra,          "%.8f, ");
     
    252260}
    253261
     262float getMagFromValueOrFlux (float flux, float mag, float zp) {
     263
     264  // first, if mag is finite, use mag:
     265  if (isfinite(mag)) {
     266    return (zp + mag - ZeroPoint);
     267  }
     268
     269  if (isfinite(flux) && (flux > 0.0)) {
     270    fprintf (stderr, "how did we get here?\n");
     271    return (zp - 2.5*log10(flux));
     272  }
     273
     274  if (isfinite(flux) && (flux <= 0.0)) {
     275    return (NAN);
     276  }
     277  return (NAN);
     278}
     279
     280float getdMagFromValueOrFlux (float flux, float dflux, float dmag) {
     281
     282  // first, if mag is finite, use mag:
     283  if (isfinite(dmag)) {
     284    return (dmag);
     285  }
     286
     287  if (isfinite(flux) && isfinite(dflux)) {
     288    return (dflux / fabs(flux));
     289  }
     290  return (NAN);
     291}
     292
    254293int assign_detection_values (Detections *detection, Measure *measure, Average *average) {
    255294
     
    266305  detection->objID        = average->extID;   // objID
    267306  detection->detectID     = measure->extID;   // detectID
    268   detection->ippObjID     = ippObjID;          // ippObID
     307  detection->ippObjID     = ippObjID;         // ippObjID
    269308  detection->ippDetectID  = measure->detID;   // ippDetectID
    270309  detection->imageID      = measure->imageID; // imageID
     310  detection->catID        = measure->catID;   // catID
    271311
    272312  detection->ra           = measure->R;    // ra
     
    281321
    282322  // XXX clean this up with dvo_photcode_ops calls:
    283   detection->Mpsf   = (measure->FluxPSF  > 0.0) ? zp - 2.5*log10(measure->FluxPSF)  : NAN;
    284   detection->Mkron  = (measure->FluxKron > 0.0) ? zp - 2.5*log10(measure->FluxKron) : NAN;
    285   detection->Map    = (measure->FluxAp   > 0.0) ? zp - 2.5*log10(measure->FluxAp)   : NAN;
    286 
    287   detection->dMpsf  = (measure->FluxPSF  > 0.0) ? measure->dFluxPSF / measure->FluxPSF : NAN;
    288   detection->dMkron = (measure->FluxKron > 0.0) ? measure->dFluxKron/ measure->FluxKron: NAN;
    289   detection->dMap   = (measure->FluxAp   > 0.0) ? measure->dFluxAp  / measure->FluxAp  : NAN;
     323  // if (isfinite(measure->FluxPSF) && (measure->FluxPSF < 0.0))
     324  detection->Mpsf  = getMagFromValueOrFlux (measure->FluxPSF,  measure->M,     zp);
     325  detection->Mkron = getMagFromValueOrFlux (measure->FluxKron, measure->Mkron, zp);
     326  detection->Map   = getMagFromValueOrFlux (measure->FluxAp,   measure->Map,   zp);
     327
     328  detection->dMpsf  = getdMagFromValueOrFlux (measure->FluxPSF,  measure->dFluxPSF,  measure->dM);
     329  detection->dMkron = getdMagFromValueOrFlux (measure->FluxKron, measure->dFluxKron, measure->dMkron);
     330  detection->dMap   = getdMagFromValueOrFlux (measure->FluxAp,   measure->dFluxAp,   measure->dMap);
    290331
    291332  detection->flags  = measure->dbFlags;  // flags
Note: See TracChangeset for help on using the changeset viewer.