IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 20, 2010, 12:05:07 PM (16 years ago)
Author:
eugene
Message:

optimizations for dvomerge and relastro; complete checks of db I/O success; fix overloaded image flags

Location:
trunk/Ohana
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

    • Property svn:mergeinfo deleted
  • trunk/Ohana/src/dvomerge/src/dvomergeUpdate.c

    r28857 r29001  
    66  off_t i, j, Ns, Ne;
    77  SkyTable *outsky, *insky;
    8   SkyList *inlist;
     8  SkyList *outlist, *inlist;
    99  Catalog incatalog, outcatalog;
    1010  char filename[256], *input, *output;
     
    7070  SkyTableSetFilenames (insky, input, "cpt");
    7171
     72  // XXX apply this...generate the subset matching the user-selected region
     73  inlist = SkyListByPatch (insky, -1, &UserPatch);
     74
    7275  // generate an output table populated at the desired depth
    7376  outsky = SkyTableLoadOptimal (output, NULL, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
     
    7982  // loop over the populatable output tables; check for data in input in the corresponding regions
    8083
    81   SkyTablePopulatedRange (&Ns, &Ne, insky, 0);
    82   depth = insky[0].regions[Ns].depth;
     84  SkyListPopulatedRange (&Ns, &Ne, inlist, 0);
     85  depth = inlist[0].regions[Ns][0].depth;
    8386 
    84   // loop over the populatable output regions
    85   for (i = 0; i < outsky[0].Nregions; i++) {
    86     if (!outsky[0].regions[i].table) continue;
    87     if (VERBOSE) fprintf (stderr, "output: %s\n", outsky[0].regions[i].name);
     87  // loop over the populated input regions
     88  for (i = 0; i < inlist[0].Nregions; i++) {
     89    if (!inlist[0].regions[i][0].table) continue;
     90    if (VERBOSE) fprintf (stderr, "input: %s\n", inlist[0].regions[i][0].name);
    8891
    89     SetPhotcodeTable(outputPhotcodes);
     92    SetPhotcodeTable(inputPhotcodes);
    9093    // load / create output catalog (if catalog does not exist, it will be created)
    91     LoadCatalog (&outcatalog, &outsky[0].regions[i], outsky[0].filename[i], "w");
     94    LoadCatalog (&incatalog, &inlist[0].regions[i][0], inlist[0].filename[i], "r");
     95    // skip empty input catalogs
     96    if (!incatalog.Naves_disk) {
     97        dvo_catalog_unlock (&incatalog);
     98        dvo_catalog_free (&incatalog);
     99        continue;
     100    }
    92101
    93102    // combine only tables at equal or larger depth
     
    97106    // compare to a slightly reduced footprint
    98107    float dPos = 2.0/3600.0;
    99     inlist = SkyListByBounds (insky, depth, outsky[0].regions[i].Rmin + dPos, outsky[0].regions[i].Rmax - dPos, outsky[0].regions[i].Dmin + dPos, outsky[0].regions[i].Dmax - dPos);
    100     for (j = 0; j < inlist[0].Nregions; j++) {
    101       if (VERBOSE) fprintf (stderr, "input : %s\n", inlist[0].regions[j][0].name);
     108    outlist = SkyListByBounds (outsky, depth, inlist[0].regions[i][0].Rmin + dPos, inlist[0].regions[i][0].Rmax - dPos, inlist[0].regions[i][0].Dmin + dPos, inlist[0].regions[i][0].Dmax - dPos);
     109    for (j = 0; j < outlist[0].Nregions; j++) {
     110      if (VERBOSE) fprintf (stderr, "output : %s\n", outlist[0].regions[j][0].name);
    102111
    103112      // load input catalog
    104       SetPhotcodeTable(inputPhotcodes);
    105       LoadCatalog (&incatalog, inlist[0].regions[j], inlist[0].filename[j], "r");
     113      SetPhotcodeTable(outputPhotcodes);
     114      LoadCatalog (&outcatalog, outlist[0].regions[j], outlist[0].filename[j], "w");
    106115
    107       // skip empty input catalogs
    108       if (!incatalog.Naves_disk) {
    109         dvo_catalog_unlock (&incatalog);
    110         dvo_catalog_free (&incatalog);
    111         continue;
    112       }
    113116      dvo_update_image_IDs (&IDmap, &incatalog);
    114       merge_catalogs_old (&outsky[0].regions[i], &outcatalog, &incatalog, RADIUS, secfiltMap);
    115       dvo_catalog_unlock (&incatalog);
    116       dvo_catalog_free (&incatalog);
     117      merge_catalogs_old (&outsky[0].regions[j], &outcatalog, &incatalog, RADIUS, secfiltMap);
    117118
    118       fprintf (stderr, "merged %s into %s\n", outsky[0].regions[i].name, inlist[0].regions[j][0].name);
     119      outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
     120
     121      // if we receive a signal which would cause us to exit, wait until the full catalog is written
     122      SetProtect (TRUE);
     123      dvo_catalog_save (&outcatalog, VERBOSE);
     124      SetProtect (FALSE);
     125
     126      dvo_catalog_unlock (&outcatalog);
     127      dvo_catalog_free (&outcatalog);
     128
     129      fprintf (stderr, "merged %s into %s\n", inlist[0].regions[i][0].name, outlist[0].regions[j][0].name);
    119130    }
    120     SkyListFree (inlist);
     131    SkyListFree (outlist);
    121132
    122     outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
    123     dvo_catalog_save (&outcatalog, VERBOSE);
    124     dvo_catalog_unlock (&outcatalog);
    125     dvo_catalog_free (&outcatalog);
     133    dvo_catalog_unlock (&incatalog);
     134    dvo_catalog_free (&incatalog);
    126135  }
    127136
     
    153162  // load the image table
    154163  if (inDB.dbstate == LCK_EMPTY) {
    155     Shutdown ("can't find input image catalog %s", inDB.filename);
     164    // Shutdown ("can't find input image catalog %s", inDB.filename);
     165    IDmap->Nmap = 0;
     166    return TRUE;
    156167  }
    157168  if (!dvo_image_load (&inDB, VERBOSE, TRUE)) {
Note: See TracChangeset for help on using the changeset viewer.