IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31260


Ignore:
Timestamp:
Apr 10, 2011, 12:14:54 PM (15 years ago)
Author:
eugene
Message:

generate mosaic/measure links with image IDs not times; add some time stamps

Location:
branches/eam_branches/ipp-20110404/Ohana/src/relphot
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110404/Ohana/src/relphot/include/relphot.h

    r31258 r31260  
    227227void relphot_help (int argc, char **argv);
    228228
     229off_t getImageByID (off_t ID);
     230
    229231int rationalize_mosaics ();
    230232int LimitDensityCatalog (Catalog *subcatalog, Catalog *catalog);
  • branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/MosaicOps.c

    r31258 r31260  
    99static off_t   **imlist; /* mosaic -> image[] */
    1010static off_t   **bin;    /* catalog, measure -> mosaic */
     11
     12// list of mosaics associated with an image
     13static off_t   *mosimage;
    1114
    1215// list of mosaic associated with each image 
     
    3336  ALLOCATE (NIMLIST, off_t,   NMOSAIC);
    3437
     38  ALLOCATE (mosimage, off_t, Nimage); // mosaic to which image belongs
     39
    3540  /* a 'mosaic' in relphot is (unlike relastro) a virtual concept: there is no
    3641   * entry in the image table that represents this mosaic.  Instead, it is an
     
    4045  /* generate list of unique mosaics */
    4146  for (i = 0; i < Nimage; i++) {
     47    mosimage[i] = -1;
    4248
    4349    /* select valid mosaic images by photcode */
     
    5662      if (start > mosaic[j].stop)  continue;
    5763      found = TRUE;
     64
     65      // add reference from image to mosaic
     66      mosimage[i] = j;
    5867
    5968      /* add image to mosaic image list */
     
    8493    imlist[Nmosaic][0] = i;
    8594
     95    // add reference from image to mosaic
     96    mosimage[i] = Nmosaic;
     97   
    8698    Nmosaic ++;
    8799    if (Nmosaic == NMOSAIC) {
     
    269281}
    270282
     283# if 1
     284// # if USE_IMAGE_ID
     285
     286void matchMosaics (Catalog *catalog, off_t meas, int cat) {
     287
     288  off_t idx, ID, mosID;
     289  Measure *measure;
     290
     291  measure = &catalog[cat].measure[meas];
     292
     293  ID = measure[0].imageID;
     294  idx = getImageByID (ID);
     295  if (idx == -1) {
     296    if (VERBOSE2) fprintf (stderr, "missed measurement "OFF_T_FMT", %d\n", meas, cat);
     297  }
     298
     299  mosID = mosimage[idx];
     300  if (mosID < 0) {
     301    Image *image = getimage(idx);
     302    fprintf (stderr, "unmatched image %s\n", image[0].name);
     303    return;
     304  }
     305
     306  // test to check we got the right match:
     307  {
     308    Image *image = getimage(idx);
     309    unsigned int imageStart = image[0].tzero - MAX(0.01*image[0].trate*image[0].NY, 1);
     310    if (imageStart != mosaic[mosID].start) {
     311      fprintf (stderr, "error in image to mosaic match\n");
     312      abort();
     313    }
     314  }
     315
     316  bin[cat][meas] = mosID;
     317
     318  clist[mosID][Nlist[mosID]] = cat;
     319  mlist[mosID][Nlist[mosID]] = meas;
     320  Nlist[mosID] ++;
     321   
     322  if (Nlist[mosID] == NLIST[mosID]) {
     323    NLIST[mosID] += 100;
     324    REALLOCATE (clist[mosID], int,   NLIST[mosID]);
     325    REALLOCATE (mlist[mosID], off_t, NLIST[mosID]);
     326  }     
     327  return;
     328}
     329
     330# else // USE_IMAGE_ID
     331
    271332void matchMosaics (Catalog *catalog, off_t meas, int cat) {
    272333
     
    287348      setGridMeasure (meas, cat, X, Y);
    288349    }
    289 # endif
     350# endif // GRID_V1
    290351
    291352    bin[cat][meas] = i;
     
    303364  }
    304365  // if we miss a measurement, it might be a REF type of value
    305   // fprintf (stderr, "missed measurement\n");
     366  if (VERBOSE2) fprintf (stderr, "missed measurement "OFF_T_FMT", %d\n", meas, cat);
    306367  return;
    307368}
     369# endif // USE_IMAGE_ID
    308370
    309371float getMmos (off_t meas, int cat) {
  • branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/reload_catalogs.c

    r15743 r31260  
    11# include "relphot.h"
     2
     3# define TIMESTAMP(TIME) \
     4    gettimeofday (&stop, (void *) NULL);        \
     5    dtime = DTIME (stop, start);                \
     6    TIME += dtime;                              \
     7    gettimeofday (&start, (void *) NULL);
    28
    39void reload_catalogs (SkyList *skylist) {
     
    814  Catalog catalog;
    915
     16  struct timeval start, stop;
     17  double dtime, time1, time2, time3, time4, time5, time6, time7;
     18
    1019  if (VERBOSE) fprintf (stderr, "re-loading catalog data\n");
    1120
    1221  /* load data from each region file */
    1322  for (i = 0; i < skylist[0].Nregions; i++) {
     23    gettimeofday (&start, (void *) NULL);
    1424    catalog.filename = skylist[0].filename[i];
    1525
     
    2030      continue;
    2131    }
     32    TIMESTAMP(time1);
    2233
    2334    catalog.catformat = dvo_catalog_catformat (CATFORMAT);    // set the default catformat from config data
     
    3647        continue;
    3748    }
     49    TIMESTAMP(time2);
    3850
    3951    initImageBins  (&catalog, 1);
    4052    initMosaicBins (&catalog, 1);
    4153    initGridBins   (&catalog, 1);
     54    TIMESTAMP(time3);
    4255
    4356    findImages (&catalog, 1);
    4457    findMosaics (&catalog, 1);
     58    TIMESTAMP(time4);
    4559
    4660    setMrelFinal (&catalog);
     61    TIMESTAMP(time5);
     62
    4763    dvo_catalog_save (&catalog, VERBOSE);
    4864    dvo_catalog_unlock (&catalog);
    4965    dvo_catalog_free (&catalog);
     66    TIMESTAMP(time6);
    5067
    5168    freeImageBins (1);
    5269    freeMosaicBins (1);
    5370    freeGridBins (1);
     71    TIMESTAMP(time7);
    5472  }
     73
     74  fprintf (stderr, "time1 %f : find catalog\n", time1);
     75  fprintf (stderr, "time2 %f : load catalog\n", time2);
     76  fprintf (stderr, "time3 %f : init imbins\n",  time3);
     77  fprintf (stderr, "time4 %f : find images\n",  time4);
     78  fprintf (stderr, "time5 %f : set Mrel\n",     time5);
     79  fprintf (stderr, "time6 %f : save catalog\n", time6);
     80  fprintf (stderr, "time7 %f : free catalog\n", time7);
    5581}
  • branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/relphot.c

    r31258 r31260  
    4747    if (!dvo_image_load (&db, VERBOSE, FALSE)) Shutdown ("can't read image catalog %s", db.filename);
    4848  }
    49   MARKTIME("load image data: %f sec\n", dtime);
     49  MARKTIME("-- load image data: %f sec\n", dtime);
    5050
    5151  /* load regions and images based on specified sky patch */
     
    5454  // XXX this is fairly lame: argv[1] is photcode if UserPatchSelect is true
    5555  skylist = load_images (&db, argv[1], &UserPatch, UserPatchSelect);
    56   MARKTIME("load images: %f sec\n", dtime);
     56  MARKTIME("-- load images: %f sec\n", dtime);
    5757
    5858  /* unlock, if we can (else, unlocked below) */
     
    6161  /* load catalog data from region files */
    6262  catalog = load_catalogs (skylist, &Ncatalog);
    63   MARKTIME("load catalog data: %f sec\n", dtime);
     63  MARKTIME("-- load catalog data: %f sec\n", dtime);
    6464 
    6565  /* add in a loop over the catalogs calling dvo_catalog_chipcoords */
     
    6767  /* match measurements with images, mosaics */
    6868  initImageBins  (catalog, Ncatalog);
    69   MARKTIME("make image bins: %f sec\n", dtime);
     69  MARKTIME("-- make image bins: %f sec\n", dtime);
    7070
    7171  initMosaicBins (catalog, Ncatalog);
     
    7474
    7575  findImages (catalog, Ncatalog);
    76   MARKTIME("set up image indexes: %f sec\n", dtime);
     76  MARKTIME("-- set up image indexes: %f sec\n", dtime);
    7777
    7878  findMosaics (catalog, Ncatalog);  /* also sets Grid values */
    79   MARKTIME("set up mosaic indexes: %f sec\n", dtime);
     79  MARKTIME("-- set up mosaic indexes: %f sec\n", dtime);
    8080
    8181  SAVEPLOT = FALSE;
     
    152152    // if ((i == 4) || (i == 8) || (i == 12) || (i == 16)) clean_images ();
    153153    global_stats (catalog, Ncatalog);
     154    MARKTIME("-- finished loop %d: %f sec\n", i, dtime);
    154155  }
    155156
     
    169170  setMcal  (catalog, TRUE);
    170171  setMmos  (catalog, TRUE);
     172  MARKTIME("-- finalize Mcal values: %f sec\n", dtime);
    171173
    172174  /* at this point, we have correct cal coeffs in the image/mosaic structures */
     
    178180  /* load catalog data from region files, update Mrel include all data */
    179181  reload_catalogs (skylist);
     182  MARKTIME("-- updated all catalogs: %f sec\n", dtime);
     183
    180184  setMcalFinal ();
    181 
    182185  reload_images (&db);
    183186 
Note: See TracChangeset for help on using the changeset viewer.