IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 30, 2005, 9:14:00 AM (21 years ago)
Author:
eugene
Message:

adjust to use match DVO catalog access methods

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/delstar/src/delete_times.c

    r4607 r4680  
    33void delete_times () {
    44
    5     Nregions = 0;
    6     NREGIONS = 10;
    7     ALLOCATE (region, GSCRegion, NREGIONS);
     5  int i, j, k, n;
     6  int Nimage, Nimlist, found, code;
     7  int Ntregions, Nregions, NREGIONS;
     8  int *imlist;
     9  GSCRegion *region, *tregion;
     10  Image *image;
     11  Catalog catalog;
    812
    9     /* find image for time range, delete each image */
    10     image = gtimes (&Nimage);
    11     for (j = 0; j < Nimage; j++) {
    12       fprintf (stderr, "finding regions for %s\n", image[j].name);
    13       tregion = gregions (&image[j], &Ntregions);
    14       for (i = 0; i < Ntregions; i++) {
    15         found = FALSE;
    16         for (k = 0; (k < Nregions) && !found; k++) {
    17           found = !strcmp (region[k].filename, tregion[i].filename);
    18         }
    19         if (!found) {
    20           strcpy (region[Nregions].filename, tregion[i].filename);
    21           region[Nregions].RA[0] = tregion[i].RA[0];
    22           region[Nregions].RA[1] = tregion[i].RA[1];
    23           region[Nregions].DEC[0] = tregion[i].DEC[0];
    24           region[Nregions].DEC[1] = tregion[i].DEC[1];
    25           Nregions ++;
    26           if (Nregions >= NREGIONS) {
    27             NREGIONS += 10;
    28             REALLOCATE (region, GSCRegion, NREGIONS);
    29           }
     13  code = (PHOTCODE == NULL) ? -1 : PHOTCODE[0].code;
     14
     15  Nregions = 0;
     16  NREGIONS = 10;
     17  ALLOCATE (region, GSCRegion, NREGIONS);
     18
     19  image = GetImages (&Nimage);
     20
     21  /* find images for time range, delete each image */
     22  imlist = find_images_time (START, END, PHOTCODE, &Nimlist);
     23
     24  /* find all overlapping regions */
     25  for (n = 0; n < Nimlist; n++) {
     26    j = imlist[n];
     27    if (VERBOSE) fprintf (stderr, "finding regions for %s\n", image[j].name);
     28
     29    tregion = gregion_image (&image[j], &Ntregions);
     30    for (i = 0; i < Ntregions; i++) {
     31      found = FALSE;
     32      for (k = 0; (k < Nregions) && !found; k++) {
     33        found = !strcmp (region[k].filename, tregion[i].filename);
     34      }
     35      if (!found) {
     36        strcpy (region[Nregions].filename, tregion[i].filename);
     37        region[Nregions].RA[0] = tregion[i].RA[0];
     38        region[Nregions].RA[1] = tregion[i].RA[1];
     39        region[Nregions].DEC[0] = tregion[i].DEC[0];
     40        region[Nregions].DEC[1] = tregion[i].DEC[1];
     41        Nregions ++;
     42        if (Nregions >= NREGIONS) {
     43          NREGIONS += 10;
     44          REALLOCATE (region, GSCRegion, NREGIONS);
    3045        }
    3146      }
    3247    }
    33     for (i = 0; i < Nregions; i++) {
    34       fprintf (stderr, "deleting from %s\n", region[i].filename);
    35       catalog.filename = region[i].filename;  /* don't free region before catalog! */
    36       switch (lock_catalog (&catalog, LCK_SOFT)) {
     48    free (tregion);
     49  }
     50
     51  /* delete from all identified regions */
     52  for (i = 0; i < Nregions; i++) {
     53    if (VERBOSE) fprintf (stderr, "deleting from %s\n", region[i].filename);
     54    catalog.filename = region[i].filename;  /* don't free region before catalog! */
     55    switch (lock_catalog (&catalog, LCK_XCLD)) {
    3756      case 0:
    3857        fprintf (stderr, "ERROR: can't lock file\n");
     
    4362      case 2:
    4463        fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
    45         catalog.Naverage = 0;
    46         catalog.Nmeasure = 0;
    47         break;
     64        unlock_catalog (&catalog);
     65        continue;
    4866      default:
    4967        fprintf (stderr, "weird lock_catalog exit state\n");
    5068        exit (1);
    51       }
    52       find_matches (&catalog, &image[0], start, end);
    53       wcatalog (&catalog);
    5469    }
    55     dimages (image, Nimage);
    56     fprintf (stderr, "SUCCESS\n");
    57     exit (0);
     70
     71    find_matches (&catalog, code, START, END);
     72    wcatalog (&catalog);
     73    unlock_catalog (&catalog);
     74  }
     75
     76  /* delete the identified images */
     77  dimages (imlist, Nimlist);
     78
     79  save_image_db ();
     80  unlock_image_db ();
     81  fprintf (stderr, "SUCCESS\n");
     82  exit (0);
    5883}
Note: See TracChangeset for help on using the changeset viewer.