IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8386 for trunk/Ohana/src


Ignore:
Timestamp:
Aug 16, 2006, 10:12:55 AM (20 years ago)
Author:
eugene
Message:

updating to new DVO APIs

Location:
trunk/Ohana/src
Files:
1 added
25 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/src/addstar.c

    r8361 r8386  
    104104      exit (2);
    105105    }
     106    dvo_catalog_test (&catalog, TRUE);
    106107
    107108    // Nave_disk == 0 implies an empty catalog file
     
    142143        break;
    143144    }
     145    dvo_catalog_test (&catalog, TRUE);
    144146
    145147    // write out catalog, if appropriate
     
    149151      SetProtect (FALSE);
    150152    }
     153    dvo_catalog_test (&catalog, TRUE);
    151154    dvo_catalog_unlock (&catalog);
    152155    dvo_catalog_free (&catalog);
  • trunk/Ohana/src/delstar/Makefile

    r7393 r8386  
    2828$(SRC)/delete_times.$(ARCH).o     \
    2929$(SRC)/gimages.$(ARCH).o          \
    30 $(SRC)/gcatalog.$(ARCH).o         \
    31 $(SRC)/wcatalog.$(ARCH).o         \
    3230$(SRC)/find_image_db.$(ARCH).o    \
    3331$(SRC)/find_matches.$(ARCH).o     \
  • trunk/Ohana/src/delstar/src/delete_imagefile.c

    r7080 r8386  
    2323
    2424  for (i = 0; i < skylist[0].Nregions; i++) {
     25
    2526    if (VERBOSE) fprintf (stderr, "deleting from %s\n", skylist[0].filename[i]);
    2627    catalog.filename = skylist[0].filename[i];  /* don't free region before catalog! */
    27     switch (lock_catalog (&catalog, LCK_XCLD)) {
    28       case 0:
    29         fprintf (stderr, "ERROR: can't lock file %s\n", catalog.filename);
    30         exit (1);
    31       case 1:
    32         gcatalog (&catalog);
    33         break;
    34       case 2:
    35         if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
    36         unlock_catalog (&catalog);
    37         continue;
    38       default:
    39         fprintf (stderr, "weird lock_catalog exit state\n");
    40         exit (1);
     28    catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
     29    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
     30
     31    // an error exit status here is a significant error
     32    if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "u")) {
     33      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     34      exit (2);
    4135    }
     36    if (!catalog.Nave_disk) {
     37      dvo_catalog_unlock (&catalog);
     38      dvo_catalog_free (&catalog);
     39      continue;
     40    }
     41
    4242    /* pad exposure time by 1 sec to require a valid time */
    4343    /* trate is in 0.1 msec / row  - stop is the latest exposure end time */
     
    4646    stop  = image[0].tzero + trange;
    4747    find_matches (&catalog, image[0].source, start, stop);
    48     wcatalog (&catalog);
    49     unlock_catalog (&catalog);
     48
     49    dvo_catalog_save (&catalog, VERBOSE);
     50    dvo_catalog_unlock (&catalog);
     51    dvo_catalog_free (&catalog);
    5052  }
    5153
  • trunk/Ohana/src/delstar/src/delete_imagename.c

    r7080 r8386  
    3535      if (VERBOSE) fprintf (stderr, "deleting from %s\n", skylist[0].filename[i]);
    3636      catalog.filename = skylist[0].filename[i];  /* don't free region before catalog! */
    37       switch (lock_catalog (&catalog, LCK_XCLD)) {
    38         case 0:
    39           fprintf (stderr, "ERROR: can't lock file %s\n", catalog.filename);
    40           exit (1);
    41         case 1:
    42           gcatalog (&catalog);
    43           break;
    44         case 2:
    45           if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
    46           unlock_catalog (&catalog);
    47           continue;
    48         default:
    49           fprintf (stderr, "weird lock_catalog exit state\n");
    50           exit (1);
     37      catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
     38      catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
     39
     40      // an error exit status here is a significant error
     41      if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "u")) {
     42        fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     43        exit (2);
     44      }
     45      if (!catalog.Nave_disk) {
     46        dvo_catalog_unlock (&catalog);
     47        dvo_catalog_free (&catalog);
     48        continue;
    5149      }
    5250
     
    5755      stop  = image[j].tzero + trange;
    5856      find_matches (&catalog, image[j].source, start, stop);
    59       wcatalog (&catalog);
    60       unlock_catalog (&catalog);
     57
     58      dvo_catalog_save (&catalog, VERBOSE);
     59      dvo_catalog_unlock (&catalog);
     60      dvo_catalog_free (&catalog);
    6161    }
    6262  }
  • trunk/Ohana/src/delstar/src/delete_orphans.c

    r4607 r8386  
    1515  /* find and load catalog file */
    1616  catalog.filename = name;
    17   gcatalog (&catalog);
     17  dvo_catalog_load (&catalog);
    1818  gcatstats (&catalog, &catstats);
    1919
  • trunk/Ohana/src/delstar/src/delete_times.c

    r7080 r8386  
    5555    if (VERBOSE) fprintf (stderr, "deleting from %s\n", skylist[0].filename[i]);
    5656    catalog.filename = skylist[0].filename[i];  /* don't free region before catalog! */
    57     switch (lock_catalog (&catalog, LCK_XCLD)) {
    58       case 0:
    59         fprintf (stderr, "ERROR: can't lock file\n");
    60         exit (1);
    61       case 1:
    62         gcatalog (&catalog);
    63         break;
    64       case 2:
    65         fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
    66         unlock_catalog (&catalog);
    67         continue;
    68       default:
    69         fprintf (stderr, "weird lock_catalog exit state\n");
    70         exit (1);
     57    catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
     58    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
     59
     60    // an error exit status here is a significant error
     61    if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "u")) {
     62      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     63      exit (2);
     64    }
     65    if (!catalog.Nave_disk) {
     66      dvo_catalog_unlock (&catalog);
     67      dvo_catalog_free (&catalog);
     68      continue;
    7169    }
    7270
    7371    find_matches (&catalog, code, START, END);
    74     wcatalog (&catalog);
    75     unlock_catalog (&catalog);
     72    dvo_catalog_save (&catalog, VERBOSE);
     73    dvo_catalog_unlock (&catalog);
     74    dvo_catalog_free (&catalog);
    7675  }
    7776
  • trunk/Ohana/src/libdvo/include/dvo.h

    r8342 r8386  
    280280int dvo_catalog_catformat (char *catformat);
    281281int dvo_catalog_catmode (char *catmode);
     282void dvo_catalog_test (Catalog *catalog, int halt);
    282283
    283284/* catmode-specific APIs */
  • trunk/Ohana/src/libdvo/src/dvo_catalog.c

    r8342 r8386  
    11# include <dvo.h>
    22# define DEBUG 1
     3
     4void dvo_catalog_test (Catalog *catalog, int halt) {
     5
     6  Catalog *subcat;
     7
     8  // fprintf (stderr, "catalog: Naverage = %d, average = %zx\n", catalog[0].Naverage, (size_t) catalog[0].average);
     9  // fprintf (stderr, "catalog: Nmeasure = %d, measure = %zx\n", catalog[0].Nmeasure, (size_t) catalog[0].measure);
     10  // fprintf (stderr, "catalog: Nmissing = %d, missing = %zx\n", catalog[0].Nmissing, (size_t) catalog[0].missing);
     11  // fprintf (stderr, "catalog: Nsecfilt = %d, secfilt = %zx\n", catalog[0].Nsecfilt, (size_t) catalog[0].secfilt);
     12
     13  if (!catalog[0].measure || !catalog[0].secfilt) {
     14    fprintf (stderr, "error: %s\n", catalog[0].filename);
     15    if (halt) abort ();
     16  }
     17
     18  // XXX test that things are correctly initialized
     19  if (catalog[0].catmode != DVO_MODE_SPLIT) return;
     20
     21  subcat = catalog[0].measure_catalog;
     22  if (subcat) {
     23    if (subcat[0].measure_catalog || subcat[0].secfilt_catalog || subcat[0].missing_catalog) {
     24      fprintf (stderr, "error in init\n");
     25      abort ();
     26    }
     27  }
     28  subcat = catalog[0].missing_catalog;
     29  if (subcat) {
     30    if (subcat[0].measure_catalog || subcat[0].secfilt_catalog || subcat[0].missing_catalog) {
     31      fprintf (stderr, "error in init\n");
     32      abort ();
     33    }
     34  }
     35  subcat = catalog[0].secfilt_catalog;
     36  if (subcat) {
     37    if (subcat[0].measure_catalog || subcat[0].secfilt_catalog || subcat[0].missing_catalog) {
     38      fprintf (stderr, "error in init\n");
     39      abort ();
     40    }
     41  }
     42}
    343
    444int dvo_catalog_catformat (char *catformat) {
     
    3575    catalog[0].catflags = 0;
    3676    catalog[0].sorted = 0;
    37 
    38     gfits_init_header (&catalog[0].header);
    39   }
     77  }
     78
     79  gfits_init_header (&catalog[0].header);
    4080
    4181  // the following describe the catalog files on disk
     
    102142  // attempt to unlink an empty file
    103143  fd = fileno (catalog[0].f);
    104   if (fstat (fd, &filestat)) {
     144  if (!fstat (fd, &filestat)) {
    105145    if (filestat.st_size == 0) {
    106146      unlink (catalog[0].filename);
     
    121161// returns FALSE if a catalog could not be opened
    122162// returns TRUE if the catalog was empty
     163enum {DVO_OPEN_NONE, DVO_OPEN_READ, DVO_OPEN_WRITE, DVO_OPEN_UPDATE);
    123164int dvo_catalog_open (Catalog *catalog, SkyRegion *region, int VERBOSE, char *iomode) {
    124165
    125   int Nsecfilt;
    126   int readonly;
    127 
    128   readonly = -1;
    129   if (!strcasecmp (iomode, "r")) readonly = TRUE;
    130   if (!strcasecmp (iomode, "w")) readonly = FALSE;
    131   if (readonly == -1) return (FALSE);
     166  int Nsecfilt, mode;
     167
     168  mode = DVO_OPEN_NONE;
     169  if (!strcasecmp (iomode, "r")) mode = DVO_OPEN_READ;
     170  if (!strcasecmp (iomode, "w")) mode = DVO_OPEN_WRITE;
     171  if (!strcasecmp (iomode, "a")) mode = DVO_OPEN_UPDATE;
     172  if (mode == DVO_OPEN_NONE) return (FALSE);
    132173
    133174  catalog[0].lockmode  = LCK_XCLD;
    134   if (readonly) catalog[0].lockmode  = LCK_SOFT;
     175  if (mode == DVO_OPEN_READ) catalog[0].lockmode  = LCK_SOFT;
    135176
    136177  // XXX make a backup?  always?
     
    161202    break;
    162203  case 2:
    163     if (readonly) return (TRUE);
     204    if (DVO_OPEN_READ || DVO_OPEN_UPDATE) return (TRUE);
    164205    dvo_catalog_create (region, catalog, Nsecfilt); /* fills in new header info */
    165206    if (VERBOSE) fprintf (stderr, "creating new file %s\n", catalog[0].filename);
     
    177218  char measure[80];
    178219
     220  dvo_catalog_init (catalog, FALSE);
     221
    179222  // load the main catalog header, determine characteristics
    180223  if (!gfits_fread_header (catalog[0].f, &catalog[0].header)) {
     
    200243  catalog[0].catformat = DVO_FORMAT_UNDEF;
    201244
    202   catalog[0].average = NULL;
    203   catalog[0].secfilt = NULL;
    204   catalog[0].measure = NULL;
    205   catalog[0].missing = NULL;
    206 
    207245  switch (catalog[0].catmode) {
    208246    case DVO_MODE_RAW:
     
    217255      if (VERBOSE) fprintf (stderr, "reading catalog (mode DVO_MODE_SPLIT)\n");
    218256      dvo_catalog_load_split (catalog, VERBOSE);
     257      dvo_catalog_test (catalog, TRUE);
    219258      break;
    220259    default:
  • trunk/Ohana/src/libdvo/src/dvo_catalog_create.c

    r8342 r8386  
    11# include <dvo.h>
    2 # define DEBUG 1
     2# define DEBUG 0
    33
    44// create a new dvo catalog file (if split, lock extra files as well?)
  • trunk/Ohana/src/libdvo/src/dvo_catalog_split.c

    r8342 r8386  
    6060    gfits_free_header (&header);
    6161  }
     62  dvo_catalog_test (catalog, FALSE);
    6263
    6364  /*** Measure Table ***/
     
    6869  if (catalog[0].catflags & LOAD_MEAS) {
    6970    ALLOCATE (measure, Catalog, 1);
    70     measure[0].measure_catalog = NULL;
    71     measure[0].missing_catalog = NULL;
    72     measure[0].secfilt_catalog = NULL;
     71    dvo_catalog_init (measure, TRUE);
    7372
    7473    /* get split filename from main header (paths relative to cpt file) */
     
    9089    /* matrix should be empty */
    9190    if (!gfits_fread_matrix (measure[0].f, &matrix, &measure[0].header)) {
    92       if (VERBOSE) fprintf (stderr, "can't read primary matrix");
     91      if (VERBOSE) fprintf (stderr, "can't read primary matrix\n");
    9392      return (FALSE);
    9493    }
    9594    /* read Measure table header */
    9695    if (!gfits_fread_header (measure[0].f, &header)) {
    97       if (VERBOSE) fprintf (stderr, "can't read measure PHU header");
     96      if (VERBOSE) fprintf (stderr, "can't read measure PHU header\n");
    9897      return (FALSE);
    9998    }
    10099    /* read Measure table data */
    101100    if (!gfits_fread_ftable_data (measure[0].f, &ftable)) {
    102       if (VERBOSE) fprintf (stderr, "can't read table measure data");
     101      if (VERBOSE) fprintf (stderr, "can't read table measure data\n");
    103102      return (FALSE);
    104103    }
     
    112111    gfits_free_matrix (&matrix);
    113112  }
     113  dvo_catalog_test (catalog, FALSE);
    114114
    115115  /* (Meta Load) */
    116116  if (catalog[0].catflags & LOAD_MEAS_META) {
    117117    ALLOCATE (measure, Catalog, 1);
     118    dvo_catalog_init (measure, TRUE);
    118119
    119120    /* get split filename from main header (paths relative to cpt file) */
     
    142143  }
    143144  catalog[0].measure_catalog = measure;
     145  dvo_catalog_test (catalog, FALSE);
    144146
    145147  /*** Missing Table ***/
     
    148150  if (catalog[0].catflags & LOAD_MISS) {
    149151    ALLOCATE (missing, Catalog, 1);
    150     missing[0].measure_catalog = NULL;
    151     missing[0].missing_catalog = NULL;
    152     missing[0].secfilt_catalog = NULL;
     152    dvo_catalog_init (missing, TRUE);
    153153
    154154    /* get split filename from main header (paths relative to cpt file) */
     
    170170    /* matrix should be empty */
    171171    if (!gfits_fread_matrix (missing[0].f, &matrix, &missing[0].header)) {
    172       if (VERBOSE) fprintf (stderr, "can't read primary matrix");
     172      if (VERBOSE) fprintf (stderr, "can't read primary matrix\n");
    173173      return (FALSE);
    174174    }
    175175    /* read Missing table header */
    176176    if (!gfits_fread_header (missing[0].f, &header)) {
    177       if (VERBOSE) fprintf (stderr, "can't read table missing header");
     177      if (VERBOSE) fprintf (stderr, "can't read table missing header\n");
    178178      return (FALSE);
    179179    }
    180180    /* read Missing table data */
    181181    if (!gfits_fread_ftable_data (missing[0].f, &ftable)) {
    182       if (VERBOSE) fprintf (stderr, "can't read table missing data");
     182      if (VERBOSE) fprintf (stderr, "can't read table missing data\n");
    183183      return (FALSE);
    184184    }
     
    192192  }
    193193  catalog[0].missing_catalog = missing;
     194  dvo_catalog_test (catalog, FALSE);
    194195
    195196  /*** Secfilt Table ***/
     
    198199  if (catalog[0].catflags & LOAD_SECF) {
    199200    ALLOCATE (secfilt, Catalog, 1);
    200     secfilt[0].measure_catalog = NULL;
    201     secfilt[0].missing_catalog = NULL;
    202     secfilt[0].secfilt_catalog = NULL;
     201    dvo_catalog_init (secfilt, TRUE);
    203202
    204203    /* get split filename from main header (paths relative to cpt file) */
     
    220219    /* matrix should be empty */
    221220    if (!gfits_fread_matrix (secfilt[0].f, &matrix, &secfilt[0].header)) {
    222       if (VERBOSE) fprintf (stderr, "can't read primary matrix");
     221      if (VERBOSE) fprintf (stderr, "can't read primary matrix\n");
    223222      return (FALSE);
    224223    }
    225224    /* read secfilt table header */
    226225    if (!gfits_fread_header (secfilt[0].f, &header)) {
    227       if (VERBOSE) fprintf (stderr, "can't read table secfilt header");
     226      if (VERBOSE) fprintf (stderr, "can't read table secfilt header\n");
    228227      return (FALSE);
    229228    }
    230229    /* read secfilt table data */
    231230    if (!gfits_fread_ftable_data (secfilt[0].f, &ftable)) {
    232       if (VERBOSE) fprintf (stderr, "can't read table secfilt data");
     231      if (VERBOSE) fprintf (stderr, "can't read table secfilt data\n");
    233232      return (FALSE);
    234233    }
     
    242241  }
    243242  catalog[0].secfilt_catalog = secfilt;
     243  dvo_catalog_test (catalog, FALSE);
    244244
    245245  /* save the current number so we can do partial updates */
  • trunk/Ohana/src/libdvo/src/skyregion_gsc.c

    r8342 r8386  
    22# define NDECBANDS 24
    33# define NDIV 4
     4# define DEBUG 0
    45
    56static int DecLines[] = {593, 584, 551, 530, 522, 465, 406, 362, 280, 198, 123, 25, 597, 578, 574, 577, 534, 499, 442, 376, 294, 212, 144, 48};
     
    8586  L0.regions[0].childE  =  NDECBANDS;
    8687  strcpy (L0.regions[0].name, "fullsky");
    87   // SkyRegionPrint (&L0.regions[0]);
     88  if (DEBUG) SkyRegionPrint (&L0.regions[0]);
    8889
    8990  /* allocate space for all levels */
     
    9394  ALLOCATE (L3.regions, SkyRegion, 1);
    9495  ALLOCATE (L4.regions, SkyRegion, 1);
     96
     97  // skipLines = 0;
     98  // for (i = 0; i < 16; i++) skipLines += DecLines[i];
     99  // for (i = 16; i < 17; i++) {
    95100
    96101  /* L1 : dec bands */
     
    107112    L1.regions[i].table    = -1;
    108113    strcpy (L1.regions[i].name, DecNames[i]);
    109     // SkyRegionPrint (&L1.regions[i]);
     114    if (DEBUG) SkyRegionPrint (&L1.regions[i]);
    110115
    111116    /* build the L2 regions for this L1 region (based on zones) */
     
    123128    /* subdivide each zone */
    124129    for (j = 0; j < Nzones; j++) {
     130      if (DEBUG) fprintf (stderr, "zone: %d : %f - %f : %f - %f\n", j, zones[j].Rmin, zones[j].Rmax, zones[j].Dmin, zones[j].Dmax);
    125131      SkyTableL2fromZone (&L2, &L3, &L4, band, &zones[j], i);
    126132    }
     
    273279    Dmax = MAX (regions[i].Dmax, Dmax);
    274280    dDec = regions[i].Dmax - regions[i].Dmin;
    275     if (dDec != zones[Nz].dDec) {
     281    if (fabs(dDec - zones[Nz].dDec) > 0.001) {
    276282      /* we've found the end of the current zone */
    277283      zones[Nz].L3end = i;
     
    347353    *p = '/';
    348354    strcpy (L2[0].regions[Nr].name, name);
    349     // SkyRegionPrint (&L2[0].regions[Nr]);
     355    if (DEBUG) SkyRegionPrint (&L2[0].regions[Nr]);
    350356
    351357    /* childS and childE are set in SkyTableL3fromL2 */
     
    383389    L3[0].regions[Nr].childE   =  0;
    384390
    385     // SkyRegionPrint (&L3[0].regions[Nr]);
     391    if (DEBUG) SkyRegionPrint (&L3[0].regions[Nr]);
    386392    /* name is set for the band in SkyRegionForDecBand */
    387393
     
    432438      sprintf (name, "%s.%02d", L3[0].name, Nbox);
    433439      strcpy (L4[0].regions[Nr].name, name);
    434       // SkyRegionPrint (&L4[0].regions[Nr]);
     440      if (DEBUG) SkyRegionPrint (&L4[0].regions[Nr]);
    435441
    436442      Nr ++;
  • trunk/Ohana/src/markrock/src/markrock.c

    r6674 r8386  
    3737
    3838  catalog.filename = argv[1];
    39   switch (lock_catalog (&catalog, LCK_XCLD)) {
    40   case 0:
    41     fprintf (stderr, "ERROR: can't lock file\n");
    42     exit (1);
    43   case 1:
    44     gcatalog (&catalog); /* load from disk */
    45     break;
    46   case 2:
    47     fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
    48     catalog.Naverage = 0;
    49     catalog.Nmeasure = 0;
    50     unlock_catalog (&catalog);
    51     exit (0);
    52   default:
    53     fprintf (stderr, "weird lock_catalog exit state\n");
    54     exit (1);
     39  catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
     40  catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
     41
     42  // an error exit status here is a significant error
     43  if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "a")) {
     44    fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     45    exit (2);
     46  }
     47  if (catalog.Nave_disk) {
     48    dvo_catalog_unlock (&catalog);
     49    dvo_catalog_free (&catalog);
     50    continue;
    5551  }
    5652
     
    6359
    6460  /* rocks2 = find_slow_rocks (&catalog, &catstats, &Nrocks2);  */
     61  dvo_catalog_save (&catalog, VERBOSE);
     62  dvo_catalog_unlock (&catalog);
     63  dvo_catalog_free (&catalog);
    6564
    66   wcatalog (&catalog);
    6765  wrocks (rocks1, Nrocks1);
    68 
    69   unlock_catalog (&catalog);
    7066  /* wrocks (rocks2, Nrocks2); */
    7167
  • trunk/Ohana/src/markstar/src/find_bright_stars.c

    r2490 r8386  
    1515  double dX, dY, dR, MaxDist, MaxDist1, MaxRadius, radius, radius2;
    1616
     17  // put limits on the ref catalog mags
    1718  load_gsc_data (&GSCdata, catstats);
    1819
  • trunk/Ohana/src/markstar/src/find_ghosts.c

    r2490 r8386  
    3232   
    3333    /* find ghost stars */
     34    // put limits on the ref catalog mags
    3435    load_gsc_data_ghost (&GSCdata, region, Nregions, &timage);
    3536
  • trunk/Ohana/src/markstar/src/markstar.c

    r4864 r8386  
    3737
    3838  set_db (&db);
    39   lock_image_db (&db, ImageCat);
     39  dvo_image_lock (&db, ImageCat, 3600.0, LCK_XCLD);
    4040
    41   gcatalog (argv[1], &catalog);
     41  catalog.filename = argv[1];
     42  catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
     43  catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
     44
     45  // an error exit status here is a significant error
     46  if (!dvo_catalog_open (&catalog, NULL, VERBOSE, "a")) {
     47    fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     48    exit (2);
     49  }
     50  if (!catalog.Nave_disk) {
     51    dvo_catalog_unlock (&catalog);
     52    dvo_catalog_free (&catalog);
     53    exit (0);
     54  }
    4255
    4356  gcatstats (&catalog, &catstats);
     
    5366  /* find_ghosts (&catalog, &catstats, argv[1], image, Nimage); */
    5467
    55 
    56   wcatalog (argv[1], &catalog);
     68  dvo_catalog_save (&catalog, VERBOSE);
     69  dvo_catalog_unlock (&catalog);
     70  dvo_catalog_free (&catalog);
    5771
    5872  if (VERBOSE) {
     
    6175             (now.tv_sec - then.tv_sec) + 1e-6*(now.tv_usec - then.tv_usec));
    6276  }
    63   clear_lockfile ();
    6477  fprintf (stderr, "SUCCESS\n");
    6578}
  • trunk/Ohana/src/relphot/Makefile

    r7080 r8386  
    2828$(SRC)/select_images.$(ARCH).o   \
    2929$(SRC)/load_catalogs.$(ARCH).o   \
    30 $(SRC)/gcatalog.$(ARCH).o        \
    3130$(SRC)/bcatalog.$(ARCH).o        \
    3231$(SRC)/GridOps.v2.$(ARCH).o      \
     
    3736$(SRC)/plot_scatter.$(ARCH).o    \
    3837$(SRC)/plotstuff.$(ARCH).o       \
    39 $(SRC)/misc.$(ARCH).o            \
     38$(SRC)/sort.$(ARCH).o            \
    4039$(SRC)/reload_catalogs.$(ARCH).o \
    41 $(SRC)/image-db.$(ARCH).o \
    42 $(SRC)/free_catalogs.$(ARCH).o   \
    4340$(SRC)/setMrelFinal.$(ARCH).o    \
    4441$(SRC)/write_coords.$(ARCH).o    \
    4542$(SRC)/setExclusions.$(ARCH).o   \
    4643$(SRC)/Shutdown.$(ARCH).o        \
    47 $(SRC)/SetSignals.$(ARCH).o      \
    48 $(SRC)/wcatalog.$(ARCH).o
     44$(SRC)/SetSignals.$(ARCH).o     
    4945
    5046OLD = \
  • trunk/Ohana/src/relphot/src/load_catalogs.c

    r8328 r8386  
    88  if (VERBOSE) fprintf (stderr, "loading catalog data\n");
    99
    10   // XXX skip over the empty catalogs? don't add to the list?
    1110  ALLOCATE (catalog, Catalog, skylist[0].Nregions);
    1211
    13   /* load data from each region file, only use bright stars */
    14   // we use LCK_SOFT since we assume the image is locked
     12  // load data from each region file, only use bright stars
    1513  for (i = 0; i < skylist[0].Nregions; i++) {
     14
     15    // set up the basic catalog info
    1616    tcatalog.filename = skylist[0].filename[i];
     17    tcatalog.catformat = dvo_catalog_catformat (CATFORMAT);    // set the default catformat from config data
     18    tcatalog.catmode   = dvo_catalog_catmode (CATMODE);        // set the default catmode from config data
     19    tcatalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_SECF; // don't need to load all data at this point
    1720
    18     tcatalog.catformat = dvo_catalog_format (CATFORMAT);  // set the default catformat from config data
    19     tcatalog.catmode   = dvo_catalog_mode (CATMODE);      // set the default catmode from config data
    20     tcatalog.lockmode  = LCK_SOFT;
    21     dvo_catalog_open (&tcatalog, skylist[0].regions[i], Nsecfilt, "r");
    22 
    23     switch (lock_catalog (&tcatalog, LCK_SOFT)) {
    24     case 0:
    25       fprintf (stderr, "ERROR: can't lock file %s\n", tcatalog.filename);
    26       exit (1);
    27     case 1:
    28       gcatalog (&tcatalog, FALSE); /* load from disk */
    29       break;
    30     case 2:
    31       if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", tcatalog.filename);
    32       tcatalog.Naverage = 0;
    33       tcatalog.Nmeasure = 0;
    34       break;
    35     default:
    36       fprintf (stderr, "weird lock_catalog exit state\n");
     21    if (!dvo_catalog_open (&tcatalog, skylist[0].regions[i], VERBOSE, "r")) {
     22      fprintf (stderr, "ERROR: failure reading catalog %s\n", tcatalog.filename);
    3723      exit (1);
    3824    }
     25    if (VERBOSE && !tcatalog.Nave_disk) fprintf (stderr, "no data in %s, skipping\n", tcatalog.filename);
     26
     27    // select only the brighter stars
    3928    bcatalog (&catalog[i], &tcatalog);
     29    dvo_catalog_unlock (&tcatalog);
     30    dvo_catalog_free (&tcatalog);
    4031  }
    4132
     33  // XXX keep this test?
    4234  Nstar = 0;
    4335  for (i = 0; i < skylist[0].Nregions; i++) {
     
    4941  }
    5042
     43  // XXX consider only returning the populated catalogs
    5144  *Ncatalog = skylist[0].Nregions;
    5245  return (catalog);
    5346}
     47
     48/* this function loads all relevant catalog files for the first pass.  it currently loads the data
     49   read only (SOFT lock) since it assumes the image table has been locked. if we go to the new
     50   addstar locking paradigm, in which the images and catalogs are updated independently, then we may
     51   need to use an XCLD lock here. 
     52*/
  • trunk/Ohana/src/relphot/src/reload_catalogs.c

    r7402 r8386  
    1414    catalog.filename = skylist[0].filename[i];
    1515
    16     // XXX only update existing db tables
     16    // only update existing db tables
    1717    status = stat (catalog.filename, &filestat);
    1818    if ((status == -1) && (errno == ENOENT)) {
     
    2020      continue;
    2121    }
    22     switch (lock_catalog (&catalog, LCK_XCLD)) {
    23       case 0: // file cannot be locked
    24         fprintf (stderr, "ERROR: can't lock file %s\n", catalog.filename);
    25         exit (1);
    26       case 1: // file is now locked
    27         gcatalog (&catalog, TRUE); /* load from disk */
    28         break;
    29       case 2: // file is empty
    30         if (VERBOSE) fprintf (stderr, "no data in file %s, skipping\n", catalog.filename);
    31         unlock_catalog (&catalog);
     22
     23    catalog.catformat = dvo_catalog_catformat (CATFORMAT);    // set the default catformat from config data
     24    catalog.catmode   = dvo_catalog_catmode (CATMODE);        // set the default catmode from config data
     25    catalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
     26
     27    if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) {
     28      fprintf (stderr, "ERROR: failure reading catalog %s\n", catalog.filename);
     29      exit (1);
     30    }
     31    if (VERBOSE && (catalog.Nave_disk == 0)) {
     32        fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
     33        dvo_catalog_unlock (&catalog);
     34        dvo_catalog_free (&catalog);
    3235        continue;
    33       default:
    34         fprintf (stderr, "weird lock_catalog exit state %s\n", catalog.filename);
    35         exit (1);
    3636    }
     37
    3738    initImageBins  (&catalog, 1);
    3839    initMosaicBins (&catalog, 1);
     
    4344
    4445    setMrelFinal (&catalog);
    45     wcatalog (&catalog);
    46     unlock_catalog (&catalog);
     46    dvo_catalog_save (&catalog, VERBOSE);
     47    dvo_catalog_unlock (&catalog);
     48    dvo_catalog_free (&catalog);
    4749
    4850    freeImageBins (1);
  • trunk/Ohana/src/relphot/src/relphot.c

    r7080 r8386  
    8888
    8989  /* at this point, we have correct cal coeffs in the image/mosaic structures */
    90   free_catalogs (catalog, Ncatalog);
     90  for (i = 0; i < Ncatalog; i++) dvo_catalog_free (&catalog[i]);
    9191  freeImageBins (Ncatalog);
    9292  freeMosaicBins (Ncatalog);
Note: See TracChangeset for help on using the changeset viewer.