IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 14, 2006, 6:27:39 PM (20 years ago)
Author:
eugene
Message:

updates to the dvo image/catalog APIs

Location:
trunk/Ohana/src/addstar
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/Makefile

    r7780 r8342  
    3535$(SRC)/find_subset.$(ARCH).o \
    3636$(SRC)/fakeimage.$(ARCH).o \
    37 $(SRC)/gcatalog.$(ARCH).o \
    3837$(SRC)/get2mass.$(ARCH).o \
    3938$(SRC)/get2mass_as.$(ARCH).o \
     
    4948$(SRC)/gimages.$(ARCH).o \
    5049$(SRC)/gstars.$(ARCH).o \
    51 $(SRC)/image-db.$(ARCH).o \
    5250$(SRC)/in_image.$(ARCH).o \
    53 $(SRC)/load_pt_catalog.$(ARCH).o \
    5451$(SRC)/load_subpix.$(ARCH).o \
    55 $(SRC)/mkcatalog.$(ARCH).o \
    5652$(SRC)/opening_angle.$(ARCH).o \
    5753$(SRC)/parse_time.$(ARCH).o \
     
    6157$(SRC)/sort_lists.$(ARCH).o \
    6258$(SRC)/update_coords.$(ARCH).o \
    63 $(SRC)/wcatalog.$(ARCH).o \
    6459$(SRC)/Shutdown.$(ARCH).o \
    6560$(SRC)/SkyTableFromTychoIndex.$(ARCH).o \
  • trunk/Ohana/src/addstar/src/addstar.c

    r8328 r8342  
    3030  overlap = NULL;
    3131  set_db (&db);
    32   if (options.update) {
    33     catalog.catflags = LOAD_AVES | LOAD_MEAS_META | LOAD_MISS | LOAD_SECF;
    34   } else {
    35     catalog.catflags = LOAD_AVES | LOAD_MEAS      | LOAD_MISS | LOAD_SECF;
    36   }
    3732
    3833  /* we use the image table to lock db access -- perhaps this is not necessary? */
     34  db.mode = dvo_catalog_catmode (CATMODE);
     35  db.format = dvo_catalog_catformat (CATFORMAT);
    3936  status = dvo_image_lock (&db, ImageCat, 3600.0, LCK_XCLD);
    4037  if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename);
     
    6158
    6259      if (db.dbstate == LCK_EMPTY) {
    63         create_image_db (&db);
     60        dvo_image_create (&db, ZeroPt);
    6461      } else {
    6562        if (!dvo_image_load (&db, VERBOSE, FORCE_READ)) {
     
    9491  for (i = 0; i < skylist[0].Nregions; i++) {
    9592
     93    // set the parameters which guide catalog open/load/create
     94    catalog.catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
     95    catalog.catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
    9696    catalog.filename = skylist[0].filename[i];
    97     catalog.catformat = dvo_catalog_format (CATFORMAT);  // set the default catformat from config data
    98     catalog.catmode   = dvo_catalog_mode (CATMODE);      // set the default catmode from config data
    99     catalog.lockmode  = LCK_XCLD;
    100     dvo_catalog_open (&catalog, skylist[0].regions[i], Nsecfilt, "w");
     97    catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
     98    catalog.catflags = LOAD_AVES | LOAD_MEAS      | LOAD_MISS | LOAD_SECF;
     99    if (options.update) catalog.catflags = LOAD_AVES | LOAD_MEAS_META | LOAD_MISS | LOAD_SECF;
    101100
    102     /* for only_match, skip empty catalogs XXX EAM : this leaves behind empty files */
     101    // an error exit status here is a significant error
     102    if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) {
     103      fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", catalog.filename);
     104      exit (2);
     105    }
     106
     107    // Nave_disk == 0 implies an empty catalog file
     108    // for only_match, skip empty catalogs
    103109    if ((catalog.Nave_disk == 0) && options.only_match) {
    104110      dvo_catalog_unlock (&catalog);
    105       free (catalog.filename);  // can this be done within the dvo_catalog_free function??
    106111      dvo_catalog_free (&catalog);
    107112      continue;
     
    138143    }
    139144
    140     if (Nsubset == 0) {
    141       // XXX remove empty catalogs
    142       unlock_catalog (&catalog);
    143     } else {
     145    // write out catalog, if appropriate
     146    if (Nsubset && !options.only_images) {
    144147      SetProtect (TRUE);
    145       if (!options.only_images) dvo_catalog_save (&catalog);
     148      dvo_catalog_save (&catalog, VERBOSE);
    146149      SetProtect (FALSE);
    147       dvo_catalog_unlock (&catalog);
    148150    }
     151    dvo_catalog_unlock (&catalog);
    149152    dvo_catalog_free (&catalog);
    150     free (catalog.filename); // XXX ????
    151153
    152154    if (options.mode == M_REFCAT) free (stars);
    153155  }
    154156
     157  // XXX is it necessary to lock the image catalog during this entire process?
    155158  if (options.calibrate) { FindCalibration (&image); }
    156159
    157160  if (db.dbstate == LCK_EMPTY) {
    158     create_image_db (&db);
     161    if (VERBOSE) fprintf (stderr, "can't find %s, creating a new one\n", ImageCat);
     162    dvo_image_create (&db, ZeroPt);
    159163  }
    160164 
     
    173177  gettimeofday (&stop, NULL);
    174178  dtime = DTIME (stop, start);
    175   fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for %5d stars, %6d average, %7d measure\n", dtime, Nstars, Naverage, Nmeasure);
     179  fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for %5d stars, %6lld average, %7lld measure\n", dtime, Nstars, Naverage, Nmeasure);
    176180  exit (0);
    177181}
  • trunk/Ohana/src/addstar/src/wcatalog.c

    r8001 r8342  
    55  /* output CATMODE and CATFORMAT are set by mkcatalog
    66     or by mode and format of existing data */
    7 
    8   /* should this be moved into save_catalog?? */
    9   gfits_modify (&catalog[0].header, "SORTED",  "%t", 1, catalog[0].sorted);
    107
    118  /* if partial load, must use update */
     
    2320}
    2421
    25 void free_catalog (Catalog *catalog) {
    26 
    27   /* free, initialize data structures */
    28   if (catalog[0].average != NULL) {
    29     free (catalog[0].average);
    30     catalog[0].Naverage = 0;
    31   }
    32   if (catalog[0].measure != NULL) {
    33     free (catalog[0].measure);
    34     catalog[0].Nmeasure = 0;
    35   }
    36   if (catalog[0].missing != NULL) {
    37     free (catalog[0].missing);
    38     catalog[0].Nmissing = 0;
    39   }
    40   if (catalog[0].secfilt != NULL) {
    41     free (catalog[0].secfilt);
    42     catalog[0].Nsecfilt = 0;
    43   }
    44   gfits_free_header (&catalog[0].header);
    45 }
Note: See TracChangeset for help on using the changeset viewer.