IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39517 for trunk


Ignore:
Timestamp:
Apr 6, 2016, 4:56:18 PM (10 years ago)
Author:
eugene
Message:

apply Mflat to measurements in loop; add stack repair

Location:
trunk/Ohana/src/relphot
Files:
6 edited

Legend:

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

    r39513 r39517  
    639639int GetStackSeq (Image *image, double Rstk, double Dstk, unsigned short photcode, float X, float Y);
    640640void sort_by_ra (double *R, double *D, int *I, int *S, int N);
     641
     642void RepairWarpMeasuresOpenLogfile ();
     643void RepairWarpMeasuresCloseLogfile ();
  • trunk/Ohana/src/relphot/src/RepairWarpMeasures.c

    r39514 r39517  
    11# include "relphot.h"
     2
     3FILE *logfile = NULL;
     4
     5void RepairWarpMeasuresOpenLogfile () {
     6
     7  char name[DVO_MAX_PATH];
     8  snprintf (name, DVO_MAX_PATH, "%s/repair.warp.log", HOSTDIR);
     9  logfile = fopen (name, "w");
     10  if (!logfile) fprintf (stderr, "failed to open repair warp logfile %s\n", name);
     11}
     12
     13void RepairWarpMeasuresCloseLogfile () {
     14  if (!logfile) return;
     15  fclose (logfile);
     16}
    217
    318// XXX need to load_images first and generate some lookup tables
     
    5166        }
    5267        // the old imageID was wrong.  replace with the new one:
     68        if (logfile) fprintf (logfile, "fix stack %10.6f %10.6f %5d %6.1f %6.1f 0x%08x %d -> %d\n", average->R, average->D, measure->photcode, measure->Xccd, measure->Yccd, measure->detID, measure->imageID, image[im].imageID);
    5369        measure->imageID = image[im].imageID;
    5470      } else {
     
    7490          }
    7591          // the old imageID was wrong.  replace with the new one:
     92          if (logfile) fprintf (logfile, "fix stack %10.6f %10.6f %5d %6.1f %6.1f 0x%08x %d -> %d\n", average->R, average->D, measure->photcode, measure->Xccd, measure->Yccd, measure->detID, measure->imageID, image[im].imageID);
    7693          measure->imageID = image[im].imageID;
    7794        }
  • trunk/Ohana/src/relphot/src/relphot_objects.c

    r39513 r39517  
    1515
    1616  Catalog catalog;
     17
     18  INITTIME;
    1719
    1820  // XXX need to decide how to determine PARALLEL mode...
     
    3234  if (db.dbstate == LCK_EMPTY) Shutdown ("ERROR: No images in catalog %s (1)", db.filename);
    3335  if (!dvo_image_load (&db, VERBOSE, FALSE)) Shutdown ("can't read image catalog %s", db.filename);
     36  MARKTIME("read image table: %f sec\n", dtime);
    3437  // the raw FITS data is freed by dvo_image_load, leaving only the Image structure data
    3538
    3639  /* load regions and images based on specified sky patch (default depth) */
    3740  load_images (&db, skylist, &UserPatch, TRUE);
     41  MARKTIME("loaded images: %f sec\n", dtime);
    3842
    3943  // load the ZP corrections here
     
    4246  if (REPAIR_WARPS) {
    4347    FindWarpGroups ();
     48    MARKTIME("setup warp groups: %f sec\n", dtime);
    4449    MakeStackIndex ();
     50    MARKTIME("setup stack index: %f sec\n", dtime);
     51    RepairWarpMeasuresOpenLogfile ();
    4552  }
    4653
     
    129136      free_tiny_values(&catalog);
    130137      dvo_catalog_free (&catalog);
     138      freeImageBins (1, FALSE);
     139      freeMosaicBins (1, FALSE);
     140      freeGridBins (1);
    131141      continue;
    132142    }
     
    159169  }
    160170
    161   if (REPAIR_WARPS) FreeWarpGroups ();
     171  if (REPAIR_WARPS) {
     172    FreeWarpGroups ();
     173    FreeStackGroups ();
     174    RepairWarpMeasuresCloseLogfile ();
     175  }
    162176
    163177  gfits_db_free (&db);
  • trunk/Ohana/src/relphot/src/select_images.c

    r39511 r39517  
    271271    }
    272272  }
    273   MARKTIME("finish image selection: %f sec\n", dtime);
     273  MARKTIME("\nfinish image selection: %f sec\n", dtime);
    274274
    275275  if (VERBOSE) fprintf (stderr, "found "OFF_T_FMT" images\n", nimage);
  • trunk/Ohana/src/relphot/src/setMrelCatalog.c

    r39464 r39517  
    205205
    206206    // ** Choose the calibration (depends on the mode : do I have an image reference or not?)
    207     float Mcal = 0, Mmos = 0, Mgrid = 0;
     207    float Mcal = 0.0, Mmos = 0.0, Mgrid = 0.0, Mflat = 0.0;
    208208    off_t meas = measureOffset + k;
    209209    if (getImageEntry (meas, cat) < 0) {
     
    215215    } else {
    216216      // getMcal_alt returns image[].Mcal modified by flatcorr(image.photom_map_id,x,y)
     217      // NOTE: getMcal_alt does not include measure.Mflat
    217218      Mcal  = getMcal_alt (meas, cat, flatcorr, measureT[k].Xccd, measureT[k].Yccd);
    218219      if (isnan(Mcal))  SKIP_THIS_MEAS(Ncal);
     
    221222      Mgrid = getMgrid (meas, cat);
    222223      if (isnan(Mgrid)) SKIP_THIS_MEAS(Ngrid);
     224      Mflat = isnan (measureT[k].Mflat) ? 0.0 : measureT[k].Mflat;
    223225    }
    224226
     
    244246      if (CHECK_VALID_MAG(Map, dMap)) {
    245247        int Nap = results->aperData[Nsec].Nlist;
    246         results->aperData[Nsec].flxlist[Nap] = Map - Mcal - Mmos - Mgrid;
     248        results->aperData[Nsec].flxlist[Nap] = Map + Mflat - Mcal - Mmos - Mgrid;
    247249        results->aperData[Nsec].errlist[Nap] = dMap;
    248250        results->aperData[Nsec].wgtlist[Nap] = useUbercalWeight ? UBERCAL_WEIGHT : 1.0;
     
    259261      if (CHECK_VALID_MAG(Mkron, dMkron)) {
    260262        int Nkron = results->kronData[Nsec].Nlist;
    261         results->kronData[Nsec].flxlist[Nkron] = Mkron - Mcal - Mmos - Mgrid;
     263        results->kronData[Nsec].flxlist[Nkron] = Mkron + Mflat - Mcal - Mmos - Mgrid;
    262264        results->kronData[Nsec].errlist[Nkron] = dMkron;
    263265        results->kronData[Nsec].wgtlist[Nkron] = isUbercal ? UBERCAL_WEIGHT : 1.0;
     
    272274    if (CHECK_VALID_MAG(Mpsf, dMpsf)) {
    273275      int Npsf = results->psfData[Nsec].Nlist;
    274       results->psfData[Nsec].flxlist[Npsf] = Mpsf - Mcal - Mmos - Mgrid;
     276      results->psfData[Nsec].flxlist[Npsf] = Mpsf + Mflat - Mcal - Mmos - Mgrid;
    275277      results->psfData[Nsec].errlist[Npsf] = dMpsf;
    276278      results->psfData[Nsec].wgtlist[Npsf] = isUbercal ? UBERCAL_WEIGHT : 1.0;
  • trunk/Ohana/src/relphot/src/setMrelFinal.c

    r39464 r39517  
    104104  ALLOCATE (catalog[0].measureRank, char, catalog[0].Nmeasure);
    105105  setMeasureRank (catalog);
    106   setMrelOutput (catalog, 1, flatcorr);
    107   if (!simpleAverage) setMcalOutput (catalog, 1, flatcorr);
     106  setMrelOutput (catalog, 1, flatcorr); // sets the values secfilt.M = <measure.M + measure.Mflat - image.Mcal>
     107  setMcalOutput (catalog, 1, flatcorr); // sets measure.Mcal = image.Mcal
    108108
    109109  /* clear ID_OBJ_POOR, ID_OBJ_FEW values before writing ??? */
Note: See TracChangeset for help on using the changeset viewer.