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:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

    • Property svn:mergeinfo deleted
  • trunk/Ohana/src/dvomerge/Makefile

    r27583 r29001  
    2020dvomerge     : $(BIN)/dvoconvert.$(ARCH)
    2121
    22 all: dvomerge dvoconvert
     22all: dvomerge dvoconvert dvosecfilt
    2323
    2424DVOMERGE = \
     
    5858$(BIN)/dvoconvert.$(ARCH) : $(DVOCONVERT)
    5959
    60 INSTALL = dvomerge dvoconvert
     60DVOSECFILT = \
     61$(SRC)/dvosecfilt.$(ARCH).o \
     62$(SRC)/SetSignals.$(ARCH).o \
     63$(SRC)/ConfigInit.$(ARCH).o \
     64$(SRC)/Shutdown.$(ARCH).o \
     65$(SRC)/help.$(ARCH).o \
     66$(SRC)/args.$(ARCH).o
     67
     68$(DVOSECFILT)  : $(INC)/dvomerge.h
     69
     70$(BIN)/dvosecfilt.$(ARCH) : $(DVOSECFILT)
     71
     72INSTALL = dvomerge dvoconvert dvosecfilt
    6173
    6274# dependancy rules for binary code #########################
  • trunk/Ohana/src/dvomerge/include/dvomerge.h

    r28855 r29001  
    5555int        dvoconvert_args        PROTO((int *argc, char **argv));
    5656
     57void       dvosecfilt_usage       PROTO((void));
     58void       dvosecfilt_help        PROTO((int argc, char **argv));
     59int        dvosecfilt_args        PROTO((int *argc, char **argv));
     60
    5761int        SkyTablePopulatedRange PROTO((off_t *ns, off_t *ne, SkyTable *sky, off_t Nstart));
     62int        SkyListPopulatedRange  PROTO((off_t *ns, off_t *ne, SkyList *sky, off_t Nstart));
    5863
    5964SkyList   *SkyTablePopulatedList  PROTO((SkyTable *sky));
  • trunk/Ohana/src/dvomerge/src/SkyTablePopulatedRange.c

    r27435 r29001  
    1212    Ns = sky[0].regions[Nstart].childS;
    1313    Ne = sky[0].regions[Nstart].childE;
     14    if (Ns == 0) {
     15      fprintf (stderr, "no populated tables at an appropriate depth\n");
     16      exit (1);
     17    }
     18    Nstart = Ns;
     19  }
     20
     21  *ns = Ns;
     22  *ne = Ne;
     23  return (TRUE);
     24}
     25
     26int SkyListPopulatedRange (off_t *ns, off_t *ne, SkyList *sky, off_t Nstart) {
     27
     28  off_t Ns, Ne;
     29
     30  // given the starting sky region, find the populated range at or below this region
     31
     32  Ns = Nstart;
     33  Ne = Nstart + 1;
     34  while (!sky[0].regions[Nstart][0].table) {
     35    Ns = sky[0].regions[Nstart][0].childS;
     36    Ne = sky[0].regions[Nstart][0].childE;
    1437    if (Ns == 0) {
    1538      fprintf (stderr, "no populated tables at an appropriate depth\n");
  • trunk/Ohana/src/dvomerge/src/args.c

    r28855 r29001  
    1515    remove_argument (N, argc, argv);
    1616    ALTERNATE_PHOTCODE_FILE = strdup(argv[N]);
     17    remove_argument (N, argc, argv);
     18  }
     19
     20  /*** provide additional data ***/
     21  /* restrict to a portion of the sky? */
     22  UserPatch.Rmin = 0;
     23  UserPatch.Rmax= 360;
     24  UserPatch.Dmin = -90;
     25  UserPatch.Dmax = +90;
     26  if ((N = get_argument (*argc, argv, "-region"))) {
     27    remove_argument (N, argc, argv);
     28    UserPatch.Rmin = atof (argv[N]);
     29    remove_argument (N, argc, argv);
     30    UserPatch.Rmax = atof (argv[N]);
     31    remove_argument (N, argc, argv);
     32    UserPatch.Dmin = atof (argv[N]);
     33    remove_argument (N, argc, argv);
     34    UserPatch.Dmax = atof (argv[N]);
    1735    remove_argument (N, argc, argv);
    1836  }
     
    3755  return TRUE;
    3856}
     57
     58/*** check for command line options ***/
     59int dvosecfilt_args (int *argc, char **argv) {
     60 
     61  int N;
     62
     63  /* extra error messages */
     64  VERBOSE = FALSE;
     65  if ((N = get_argument (*argc, argv, "-v"))) {
     66    VERBOSE = TRUE;
     67    remove_argument (N, argc, argv);
     68  }
     69
     70  if (*argc != 3) dvosecfilt_usage();
     71  return TRUE;
     72}
  • trunk/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c

    r28354 r29001  
    1313 
    1414  images = gfits_table_get_Image (&in[0].ftable, &Nimages, &in[0].swapped);
     15  if (!images) {
     16    fprintf (stderr, "ERROR: failed to read images\n");
     17    exit (2);
     18  }
     19
    1520  ALLOCATE (IDmap->old, off_t, Nimages);
    1621  ALLOCATE (IDmap->new, off_t, Nimages);
     
    5964
    6065  off_t Nlo, Nhi, N;
     66
     67  if (!IDmap->Nmap) return 0;
    6168
    6269  // find the a close entry below desired ID
  • trunk/Ohana/src/dvomerge/src/dvoconvert.c

    r28855 r29001  
    148148  // convert the raw image table to Image type (byteswap if needed)
    149149  images = gfits_table_get_Image (&inDB.ftable, &Nimages, &inDB.swapped);
     150  if (!images) {
     151    fprintf (stderr, "ERROR: failed to read images\n");
     152    exit (2);
     153  }
    150154
    151155  // update additional metadata
  • 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)) {
  • trunk/Ohana/src/dvomerge/src/dvoverify.c

    r28268 r29001  
    154154  // convert the raw image table to Image type (byteswap if needed)
    155155  images = gfits_table_get_Image (&inDB.ftable, &Nimages, &inDB.swapped);
     156  if (!images) {
     157    fprintf (stderr, "ERROR: failed to read images\n");
     158    exit (2);
     159  }
    156160
    157161  // update additional metadata
  • trunk/Ohana/src/dvomerge/src/help.c

    r27583 r29001  
    44  fprintf (stderr, "USAGE: dvomerge (input1) and (input2) to (output)\n");
    55  fprintf (stderr, "   OR: dvomerge (input) into (output)\n");
     6  fprintf (stderr, "   [-region Rmin Rmax Dmin Dmax]\n");
    67  exit (2);
    78}
     
    1011
    1112  fprintf (stderr, "USAGE: dvoconvert (input) to (output)\n");
     13
     14  exit (2);
     15}
     16
     17void dvosecfilt_usage(void) {
     18
     19  fprintf (stderr, "USAGE: dvosecfilt (input) -photcodes (photcodes.txt)\n");
    1220
    1321  exit (2);
     
    5765}
    5866
     67void dvosecfilt_help (int argc, char **argv) {
     68
     69  /* check for help request */
     70  if (get_argument (argc, argv, "-help")) goto show_help;
     71  if (get_argument (argc, argv, "-h"))    goto show_help;
     72  return;
     73
     74show_help:
     75
     76  fprintf (stderr, "USAGE\n");
     77  fprintf (stderr, "  dvosecfilt (input) (Nsecfilt)\n\n");
     78
     79  fprintf (stderr, "  change number of secfilt entries in photcode table (updates secfilt tables only)\n");
     80 
     81  fprintf (stderr, "  optional flags:\n");
     82  fprintf (stderr, "  -v                          : verbose mode\n");
     83  fprintf (stderr, "  -help                       : this list\n");
     84  fprintf (stderr, "  -h                          : this list\n\n");
     85  exit (2);
     86}
     87
Note: See TracChangeset for help on using the changeset viewer.