IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4607


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

bringing delstar up-to-date with addstar

Location:
trunk/Ohana/src/delstar
Files:
7 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/delstar/include/delstar.h

    r4605 r4607  
    1414int    ORPHAN;
    1515int    MISSED;
     16
     17time_t START;
     18time_t END;
     19
     20int    MODE;
     21enum {MODE_IMAGENAME, MODE_IMAGEFILE, MODE_TRANGE, MODE_ORPHAN, MODE_MISSED};
    1622
    1723typedef struct {
  • trunk/Ohana/src/delstar/src/args.c

    r2463 r4607  
    44
    55  fprintf (stderr, "USAGE: delstar (filename) or (start range) or -orphan (region)\n");
     6  fprintf (stderr, "       delstar -trange (start) (range)\n");
     7  fprintf (stderr, "       delstar -orphan (region)\n");
     8  fprintf (stderr, "       delstar -missed (region)\n");
    69  fprintf (stderr, "  optional flags:\n");
    710  fprintf (stderr, "  -v (verbose mode)\n");
     
    1114}
    1215
     16void usage () {
     17  fprintf (stderr, "USAGE: delstar (filename)\n");
     18  fprintf (stderr, "USAGE: delstar -name (imagename)\n");
     19  fprintf (stderr, "USAGE: delstar -trange (start) (range)\n");
     20  fprintf (stderr, "USAGE: delstar -orphan (region)\n");
     21  fprintf (stderr, "USAGE: delstar -missed (region)\n");
     22  exit (2);
     23}
     24
    1325int args (int *argc, char **argv) {
    1426 
    1527
    1628  int N;
    17 
    18   ConfigInit (argc, argv);
    1929
    2030  /* check for help request */
     
    3040  }
    3141
    32   ORPHAN = FALSE;
    33   if ((N = get_argument (*argc, argv, "-orphan"))) {
    34     ORPHAN = TRUE;
     42  MODE = MODE_IMAGEFILE;
     43  if ((N = get_argument (*argc, argv, "-name"))) {
     44    if (MODE != MODE_IMAGEFILE) usage();
     45    MODE = MODE_IMAGENAME;
    3546    remove_argument (N, argc, argv);
    3647  }
    37 
    38   MISSED = FALSE;
    39   if ((N = get_argument (*argc, argv, "-missed"))) {
    40     MISSED = TRUE;
     48  if ((N = get_argument (*argc, argv, "-orphan"))) {
     49    if (MODE != MODE_IMAGEFILE) usage();
     50    MODE = MODE_ORPHAN;
    4151    remove_argument (N, argc, argv);
    4252  }
     53  if ((N = get_argument (*argc, argv, "-missed"))) {
     54    if (MODE != MODE_IMAGEFILE) usage();
     55    MODE = MODE_MISSED;
     56    remove_argument (N, argc, argv);
     57  }
     58  if ((N = get_argument (*argc, argv, "-time"))) {
     59    if (MODE != MODE_IMAGEFILE) usage();
     60    MODE = MODE_TRANGE;
     61    remove_argument (N, argc, argv);
    4362
    44   if ((*argc != 2) && (*argc != 3)) {
    45     fprintf (stderr, "ERROR: Usage: delstar (filename) or (start range) or -orphan (region)\n");
    46     exit (2);
     63    /* tstart */
     64    if (!str_to_time (argv[N], &START)) usage ();
     65    remove_argument (N, argc, argv);
     66
     67    /* interpret second value */
     68    if (str_to_dtime (argv[N], &trange)) {
     69      if (trange < 0) {
     70        END = START;
     71        START = END + trange;
     72      } else {
     73        END = START + trange;
     74      }
     75      remove_argument (Na, argc, argv);
     76      goto goodtime;
     77    }
     78    if (str_to_time (argv[N], &END)) {
     79      if (START > END) {
     80        tmp   = START;
     81        START = END;
     82        END   = START;
     83      }
     84      remove_argument (Na, argc, argv);
     85      goto goodtime;
     86    }
     87    usage ();
     88
     89  goodtime:
     90    fprintf (stderr, "start: %d\n", start);
     91    fprintf (stderr, "end: %d\n", end);
    4792  }
    4893
     94  /* restrict to a single photcode (not compatible with -image) */
     95  PHOTCODE = NULL;
     96  if ((N = get_argument (argc, argv, "-photcode"))) {
     97    remove_argument (N, &argc, argv);
     98    PHOTCODE = GetPhotcodebyName (argv[N]);
     99    remove_argument (N, &argc, argv);
     100  }
     101
     102  if ((MODE == MODE_TIME) && (*argc != 1)) usage ();
     103  if ((MODE != MODE_TIME) && (*argc != 2)) usage ();
     104  return (TRUE);
    49105}
  • trunk/Ohana/src/delstar/src/delete_orphans.c

    r2463 r4607  
    11# include "delstar.h"
    22
    3 delete_orphans (Catalog *catalog) {
     3delete_orphans (char *name) {
    44
    55  int i, j, k, n, m, N, M, found;
     
    1111  Missing *tmpmissing;
    1212  Coords tcoords;
    13 
     13  Catalog catalog;
     14
     15  /* find and load catalog file */
     16  catalog.filename = name;
     17  gcatalog (&catalog);
     18  gcatstats (&catalog, &catstats);
     19
     20  /* find images overlapping catalog */
     21  image = find_images_region (&catstats, &Nimage);
     22  match_images (&catalog, image, Nimage);
    1423
    1524  /** allocate local arrays **/
    16   Nave = catalog[0].Naverage;
    17 
    18   Nmeas = catalog[0].Nmeasure;
     25  Nave = catalog.Naverage;
     26
     27  Nmeas = catalog.Nmeasure;
    1928  ALLOCATE (next, int, Nmeas);
    2029 
    21   Nmiss = catalog[0].Nmissing;
     30  Nmiss = catalog.Nmissing;
    2231  ALLOCATE (next_miss, int, Nmiss);
    2332  ALLOCATE (ave_miss, int, Nmiss);
     
    3948  /* set up references for missing to average */
    4049  for (i = 0; i < Nave; i++) {
    41     for (j = 0; j < catalog[0].average[i].Nn; j++) {
    42       ave_miss[catalog[0].average[i].missing + j] = i;
     50    for (j = 0; j < catalog.average[i].Nn; j++) {
     51      ave_miss[catalog.average[i].missing + j] = i;
    4352    }
    4453  }
    4554  Nmeasfound = 0;
    46   Nsecfilt = catalog[0].Nsecfilt;
     55  Nsecfilt = catalog.Nsecfilt;
    4756
    4857  /* fprintf (stderr, "fixing the measures...\n"); */
    4958  for (i = 0; (i < Nmeas); i++) {
    50     if ((catalog[0].measure[i].t != 0) && (catalog[0].image[i] == -1)) {
     59    if ((catalog.measure[i].t != 0) && (catalog.image[i] == -1)) {
    5160      /* this star is an orphan */
    5261      Nmeasfound ++;
     
    6877     
    6978      /*** fix the corresponding average entry ***/
    70       n = catalog[0].measure[i].averef;
    71       if (catalog[0].average[n].Nm == 0) { /* this should never happen */
     79      n = catalog.measure[i].averef;
     80      if (catalog.average[n].Nm == 0) { /* this should never happen */
    7281        fprintf (stderr, "error? we deleted one too many objects?\n");
    7382        exit (1);
    7483      }
    75       catalog[0].average[n].Nm --;
     84      catalog.average[n].Nm --;
    7685      /* this was only entry in list: will be deleted below.  meanwhile, delete all missing entries*/
    77       if ((catalog[0].average[n].Nm < 1) && (catalog[0].average[n].Nn > 0)) {
    78         m = catalog[0].average[n].missing;
    79         for (j = 0; j < catalog[0].average[n].Nn; j++) {
     86      if ((catalog.average[n].Nm < 1) && (catalog.average[n].Nn > 0)) {
     87        m = catalog.average[n].missing;
     88        for (j = 0; j < catalog.average[n].Nn; j++) {
    8089          M = next_miss[m];
    8190          next_miss[m] = -2;
    8291          m = M;
    8392        }
    84         m = catalog[0].average[n].missing;
     93        m = catalog.average[n].missing;
    8594        /* fix the list links: connect the previous valid link to the next valid link */
    8695        for (j = m; (j >= 0) && (next_miss[j] == -2); j--); /* find previous entry to fix link */
     
    99108      }
    100109      /* this was first entry in list */
    101       if ((catalog[0].average[n].offset == i) && (catalog[0].average[n].Nm > 0)) {
    102         m = catalog[0].average[n].offset;
     110      if ((catalog.average[n].offset == i) && (catalog.average[n].Nm > 0)) {
     111        m = catalog.average[n].offset;
    103112        /* find next valid entry -- notice lack of error checking... */
    104113        for (j = 0; (j < Nmeas) && (next[m+j] == -2); j++);
    105         catalog[0].average[n].offset = m + j;
     114        catalog.average[n].offset = m + j;
    106115      }
    107116
     
    113122  /** find missing in time range of image **/
    114123  for (i = 0; (i < Nmiss); i++) {
    115     if ((next_miss[i] != -2) && (catalog[0].missing[i].t >= start) && (catalog[0].missing[i].t <= end)) {
     124    if ((next_miss[i] != -2) && (catalog.missing[i].t >= start) && (catalog.missing[i].t <= end)) {
    116125      /* this star is in this image */
    117126
     
    135144      found = FALSE;
    136145      for (n = 0; !found && (n < Nave); n++) {
    137         if ((catalog[0].average[n].missing > 0) && (catalog[0].average[n].missing <= i) && (catalog[0].average[n].missing + catalog[0].average[n].Nn > i))
     146        if ((catalog.average[n].missing > 0) && (catalog.average[n].missing <= i) && (catalog.average[n].missing + catalog.average[n].Nn > i))
    138147          found = TRUE;
    139148      }
     
    141150      /*** fix the corresponding average entry ***/
    142151      n = ave_miss[i];
    143       if (catalog[0].average[n].Nn == 0) { /* this should never happen */
     152      if (catalog.average[n].Nn == 0) { /* this should never happen */
    144153        fprintf (stderr, "error? we deleted one too many missing?\n");
    145154        exit (1);
    146155      }
    147       catalog[0].average[n].Nn --;
     156      catalog.average[n].Nn --;
    148157      /* this was first entry in list */
    149       if ((catalog[0].average[n].missing == i) && (catalog[0].average[n].Nn > 0)) {
    150         m = catalog[0].average[n].missing;
     158      if ((catalog.average[n].missing == i) && (catalog.average[n].Nn > 0)) {
     159        m = catalog.average[n].missing;
    151160        for (j = 0; (j < Nmiss) && (next_miss[m+j] == -2); j++);
    152         catalog[0].average[n].missing = m + j;
     161        catalog.average[n].missing = m + j;
    153162      }
    154163
     
    161170  /* this image star matches more than one catalog star */
    162171  if (stars[N].found > -1) {
    163     catalog[0].measure[stars[N].found].flags |= BLEND_IMAGE;
    164     catalog[0].measure[Nmeas].flags |= BLEND_IMAGE;
     172    catalog.measure[stars[N].found].flags |= BLEND_IMAGE;
     173    catalog.measure[Nmeas].flags |= BLEND_IMAGE;
    165174  }
    166175  if (stars[N].found == -2) { /* this image star matches a catalog star on a neighboring catalog */
    167     catalog[0].measure[Nmeas].flags |= BLEND_IMAGE_NEIGHBOR;
     176    catalog.measure[Nmeas].flags |= BLEND_IMAGE_NEIGHBOR;
    168177  }
    169178  if (stars[N].found == -1) { /* this image star matches only this star */
     
    171180  }
    172181  /* this catalog star matches more than one image star */
    173   if (catalog[0].found[n] > -1) {
    174     catalog[0].measure[catalog[0].found[n]].flags |= BLEND_CATALOG;
    175     catalog[0].measure[Nmeas].flags |= BLEND_CATALOG;
     182  if (catalog.found[n] > -1) {
     183    catalog.measure[catalog.found[n]].flags |= BLEND_CATALOG;
     184    catalog.measure[Nmeas].flags |= BLEND_CATALOG;
    176185  } else {
    177     catalog[0].found[n] = Nmeas;
     186    catalog.found[n] = Nmeas;
    178187  }
    179188# endif 
     
    182191  /* fix Average list: delete entries with Nm == 0 */
    183192  for (i = j = 0; (i < Nave) && (j < Nave); i++, j++) {
    184     for (; (j < Nave) && (catalog[0].average[j].Nm == 0); j++);
     193    for (; (j < Nave) && (catalog.average[j].Nm == 0); j++);
    185194    if ((i != j) && (j < Nave)) {
    186       catalog[0].average[i] = catalog[0].average[j];
    187       for (k = 0; k < catalog[0].Nsecfilt; k++) {
    188         catalog[0].secfilt[i*Nsecfilt + k] = catalog[0].secfilt[j*Nsecfilt + k];
     195      catalog.average[i] = catalog.average[j];
     196      for (k = 0; k < catalog.Nsecfilt; k++) {
     197        catalog.secfilt[i*Nsecfilt + k] = catalog.secfilt[j*Nsecfilt + k];
    189198      }
    190199    }
     
    192201  }
    193202  Nave = i;
    194   REALLOCATE (catalog[0].average, Average, Nave);
    195   REALLOCATE (catalog[0].secfilt, SecFilt, MAX (1, Nave*Nsecfilt));
     203  REALLOCATE (catalog.average, Average, Nave);
     204  REALLOCATE (catalog.secfilt, SecFilt, MAX (1, Nave*Nsecfilt));
    196205 
    197206  /* fprintf (stderr, "fixing the measure order...\n"); */
     
    200209  ALLOCATE (tmpmeasure, Measure, Nmeas);
    201210  for (i = 0; i < Nave; i++) {
    202     n = catalog[0].average[i].offset;
    203     catalog[0].average[i].offset = N;
    204     for (k = 0; k < catalog[0].average[i].Nm; k++, N++) {
     211    n = catalog.average[i].offset;
     212    catalog.average[i].offset = N;
     213    for (k = 0; k < catalog.average[i].Nm; k++, N++) {
    205214      if ((n == -1) || (n == -2)) {
    206215        fprintf (stderr, "error: linked list is confused\n");
    207216        exit (1);
    208217      }
    209       tmpmeasure[N] = catalog[0].measure[n];
     218      tmpmeasure[N] = catalog.measure[n];
    210219      tmpmeasure[N].averef = i;
    211220      n = next[n];
     
    213222  }
    214223  Nmeas = N;
    215   free (catalog[0].measure);
    216   catalog[0].measure = tmpmeasure;
    217   REALLOCATE (catalog[0].measure, Measure, Nmeas);
     224  free (catalog.measure);
     225  catalog.measure = tmpmeasure;
     226  REALLOCATE (catalog.measure, Measure, Nmeas);
    218227   
    219228  /* fprintf (stderr, "fixing the mising order...\n"); */
     
    222231  ALLOCATE (tmpmissing, Missing, Nmiss);
    223232  for (i = 0; i < Nave; i++) {
    224     if (catalog[0].average[i].Nn > 0) {
    225       n = catalog[0].average[i].missing;
    226       catalog[0].average[i].missing = N;
    227       for (k = 0; k < catalog[0].average[i].Nn; k++, N++) {
     233    if (catalog.average[i].Nn > 0) {
     234      n = catalog.average[i].missing;
     235      catalog.average[i].missing = N;
     236      for (k = 0; k < catalog.average[i].Nn; k++, N++) {
    228237        if ((n == -1) || (n == -2)) {
    229238          fprintf (stderr, "error: linked list is confused\n");
    230239          exit (1);
    231240        }
    232         tmpmissing[N] = catalog[0].missing[n];
     241        tmpmissing[N] = catalog.missing[n];
    233242        n = next_miss[n];
    234243      }
     
    236245  }
    237246  Nmiss = N;
    238   free (catalog[0].missing);
    239   catalog[0].missing = tmpmissing;
    240   REALLOCATE (catalog[0].missing, Missing, Nmiss);
    241 
    242   catalog[0].Naverage = Nave;
    243   catalog[0].Nmeasure = Nmeas;
    244   catalog[0].Nmissing = Nmiss;
     247  free (catalog.missing);
     248  catalog.missing = tmpmissing;
     249  REALLOCATE (catalog.missing, Missing, Nmiss);
     250
     251  catalog.Naverage = Nave;
     252  catalog.Nmeasure = Nmeas;
     253  catalog.Nmissing = Nmiss;
    245254  if (VERBOSE) fprintf (stderr, "  ending with Nave, Nmeas, Nmiss: %d %d %d\n", Nave, Nmeas, Nmiss);
    246255
    247256}
    248 
  • trunk/Ohana/src/delstar/src/delstar.c

    r2463 r4607  
    11# include "delstar.h"
    2 
    3 /* these variables are needed by Shutdown */
    4 static FILE *f = (FILE *) NULL;
    5 static int Protect = FALSE;
    6 static int Trapped = FALSE;
    7 
    8 /* clean up open / locked ImageCat before shutting down */
    9 int Shutdown () { 
    10   int dbstate;
    11 
    12   Protect = TRUE;
    13   fclearlockfile (ImageCat, f, LCK_HARD, &dbstate);
    14   fprintf (stderr, "ERROR: delstar halted\n");
    15   exit (1);
    16 }
    17 
    18 void TrapSignal (int sig) {
    19     fprintf (stderr, "trapped signal %d, exiting gracefully\n", sig);
    20     if (sig == 11) {
    21       fprintf (stderr, "seg fault\n");
    22       exit (1);
    23     }
    24     if (Protect) {
    25       Trapped = TRUE;
    26       fprintf (stderr, "blocking until protected sections are clear\n");
    27       return;
    28     }
    29     Shutdown ();
    30 }   
    312
    323main (int argc, char **argv) {
    334
    34   int i, j, k, found, Nimage, Nregions, Ntregions, NREGIONS;
    35   int start, end, dbstate;
    36   Image *image, *gimages(), *gtimes(), *find_images();
    37   Catalog catalog;
    38   CatStats catstats;
    39   GSCRegion *region, *tregion, *gregions();
    40  
    415  SetSignals ();
     6  ConfigInit (argc, argv);
    427  args (&argc, argv);
    438
    44   /* lock the image catalog */
    45   f = fsetlockfile (ImageCat, 3600.0, LCK_HARD, &dbstate);
    46   if (f == (FILE *) NULL) {
    47     fprintf (stderr, "ERROR: can't lock image catalog\n");
    48     exit (1);
    49   }
    50   fseek (f, 0, SEEK_SET);
     9  lock_image_db ();
    5110
    5211  /* delete orphaned measurements (no image) from catalog */
    53   if (ORPHAN) {
    54     ALLOCATE (region, GSCRegion, 1);
    55     catalog.filename = argv[1];
    56     gcatalog (&catalog);
    57     gcatstats (&catalog, &catstats);
    58     image = find_images (f, &catstats, &Nimage);
    59     match_images (&catalog, image, Nimage);
    60     delete_orphans (&catalog);
    61     wcatalog (&catalog);
    62     fclearlockfile (ImageCat, f, LCK_HARD, &dbstate);
    63     fprintf (stderr, "SUCCESS\n");
    64     exit (0);
    65   }
    66 
    67   /* delete missed measurements from catalog */
    68   if (MISSED) {
    69     catalog.filename = argv[1];
    70     switch (lock_catalog (&catalog, LCK_XCLD)) {
    71     case 0:
    72       fprintf (stderr, "ERROR: can't lock file\n");
    73       exit (1);
    74     case 1:
    75       gcatalog (&catalog);
     12  switch (MODE) {
     13    case MODE_IMAGEFILE:
     14      delete_imagefile (argv[1]);
    7615      break;
    77     case 2:
    78       fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
    79       catalog.Naverage = 0;
    80       catalog.Nmeasure = 0;
     16    case MODE_IMAGENAME:
     17      delete_imagename (argv[1]);
     18      break;
     19    case MODE_ORPHANS:
     20      delete_orphans (argv[1]);
     21      break;
     22    case MODE_MISSED:
     23      delete_missed (argv[1]);
     24      break;
     25    case MODE_TIME:
     26      delete_time ();
    8127      break;
    8228    default:
    83       fprintf (stderr, "weird lock_catalog exit state\n");
    84       exit (1);
    85     }
    86     delete_missed (&catalog);
    87     wcatalog (&catalog);
    88     fclearlockfile (ImageCat, f, LCK_HARD, &dbstate);
    89     fprintf (stderr, "SUCCESS\n");
    90     exit (0);
    91   }
    92 
    93   /* delete given image from catalogs */
    94   if (argc == 2) {
    95     image = gimages (argv[1]);
    96  
    97     fprintf (stderr, "deleting %s\n", image[0].name);
    98     region = gregions (&image[0], &Nregions);
    99 
    100     for (i = 0; i < Nregions; i++) {
    101       fprintf (stderr, "deleting from %s\n", region[i].filename);
    102       catalog.filename = region[i].filename;  /* don't free region before catalog! */
    103       switch (lock_catalog (&catalog, LCK_SOFT)) {
    104       case 0:
    105         fprintf (stderr, "ERROR: can't lock file\n");
    106         exit (1);
    107       case 1:
    108         gcatalog (&catalog);
    109         break;
    110       case 2:
    111         fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
    112         catalog.Naverage = 0;
    113         catalog.Nmeasure = 0;
    114         break;
    115       default:
    116         fprintf (stderr, "weird lock_catalog exit state\n");
    117         exit (1);
    118       }
    119       find_matches (&catalog, &image[0], 0, 0);
    120       wcatalog (&catalog);
    121     }
    122 
    123     dimages (f, image, 1);
    124     fclearlockfile (ImageCat, f, LCK_HARD, &dbstate);
    125     fprintf (stderr, "SUCCESS\n");
    126     exit (0);
     29      usage ();
    12730  }
    128 
    129   /* delete measurements in time range */
    130   if (argc == 3) {
    131     Nregions = 0;
    132     NREGIONS = 10;
    133     ALLOCATE (region, GSCRegion, NREGIONS);
    134 
    135     /* find image for time range, delete each image */
    136     image = gtimes (f, argv, &Nimage, &start, &end);
    137     for (j = 0; j < Nimage; j++) {
    138       fprintf (stderr, "finding regions for %s\n", image[j].name);
    139       tregion = gregions (&image[j], &Ntregions);
    140       for (i = 0; i < Ntregions; i++) {
    141         found = FALSE;
    142         for (k = 0; (k < Nregions) && !found; k++) {
    143           found = !strcmp (region[k].filename, tregion[i].filename);
    144         }
    145         if (!found) {
    146           strcpy (region[Nregions].filename, tregion[i].filename);
    147           region[Nregions].RA[0] = tregion[i].RA[0];
    148           region[Nregions].RA[1] = tregion[i].RA[1];
    149           region[Nregions].DEC[0] = tregion[i].DEC[0];
    150           region[Nregions].DEC[1] = tregion[i].DEC[1];
    151           Nregions ++;
    152           if (Nregions >= NREGIONS) {
    153             NREGIONS += 10;
    154             REALLOCATE (region, GSCRegion, NREGIONS);
    155           }
    156         }
    157       }
    158     }
    159     for (i = 0; i < Nregions; i++) {
    160       fprintf (stderr, "deleting from %s\n", region[i].filename);
    161       catalog.filename = region[i].filename;  /* don't free region before catalog! */
    162       switch (lock_catalog (&catalog, LCK_SOFT)) {
    163       case 0:
    164         fprintf (stderr, "ERROR: can't lock file\n");
    165         exit (1);
    166       case 1:
    167         gcatalog (&catalog);
    168         break;
    169       case 2:
    170         fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
    171         catalog.Naverage = 0;
    172         catalog.Nmeasure = 0;
    173         break;
    174       default:
    175         fprintf (stderr, "weird lock_catalog exit state\n");
    176         exit (1);
    177       }
    178       find_matches (&catalog, &image[0], start, end);
    179       wcatalog (&catalog);
    180     }
    181     dimages (f, image, Nimage);
    182     fclearlockfile (ImageCat, f, LCK_HARD, &dbstate);
    183     fprintf (stderr, "SUCCESS\n");
    184     exit (0);
    185   }
     31  exit (1);
    18632}
    187 
    188 int SetSignals () {
    189 
    190   int i;
    191 
    192   /* disable almost all signal interrupts */
    193   for (i = 0; i < 36; i++) {
    194     switch (i) {
    195       /* can't redirect this signals */
    196     case SIGKILL:    /* kill -9: cannot be caught or ignored */
    197     case SIGSTOP:    /* SIGSTOP: cannot be caught or ignored */
    198       /* ignore these signals */
    199     case SIGCHLD:    /* child halted: ignore */
    200     case SIGPWR:     /* power failure - why ignore this? */
    201     case SIGWINCH:   /* window resized */
    202     case SIGCONT:    /* continue - maintain this action */
    203     case SIGTSTP:    /* stop signal sent from tty - why ignore? */
    204     case SIGURG:     /* socket signal, ignore this */
    205       break;
    206      
    207     default:
    208       signal (i, TrapSignal);
    209     }
    210   }
    211 
    212 }
  • trunk/Ohana/src/delstar/src/dimages.c

    r2463 r4607  
    11# include "addstar.h"
    22
    3 dimages (FILE *f, Image *image, int Nimages) {
     3int dimages (Image *image, int Nimages) {
    44 
    55  int i, j, Ntimage, ntimage, mode;
     
    99  Image *timage;
    1010  Header header;
     11
     12  /* get image db file pointer */
     13  f = GetDB (&dbstate);
     14  if (dbstate == LCK_EMPTY) {
     15    Shutdown ("database is empty");
     16  }
     17  fseek (f, 0, SEEK_SET);
    1118
    1219  /* use cp to make backup copy */
     
    7077  Fwrite (timage, sizeof(Image), Ntimage, f, "image");
    7178
     79  return (TRUE);
    7280}
     81
     82/* this is kind of silly: we match images in both gimages and dimages
     83 *
     84 */
  • trunk/Ohana/src/delstar/src/gimages.c

    r2463 r4607  
    11# include "delstar.h"
     2
     3/* load information about image from image header */
    24
    35Image *gimages (char *filename) {
  • trunk/Ohana/src/delstar/src/gtimes.c

    r4605 r4607  
    11# include "delstar.h"
    22
    3 Image *gtimes (FILE *f, char **argv, int *NIMAGE, int *START, int *END) {
     3Image *gtimes (int *NIMAGE) {
    44 
    55  int i, npimage, NPIMAGE, ntimage, Ntimage, NTIMAGE, Nimage;
    6   time_t start, end, tstart, tend;
    7   double Ra, Dec, range;
     6  time_t tstart, tend;
     7  double range;
    88  Image *pimage, *timage;
    99  Header header;
     10  FILE *f;
    1011
    11   if (!str_to_time (argv[1], &start)) {
    12     fprintf (stderr, "syntax error\n");
    13     return (FALSE);
     12  /* globals: START, END, PHOTCODE */
     13
     14  /* get image db file pointer */
     15  f = GetDB (&dbstate);
     16  if (dbstate == LCK_EMPTY) {
     17    Shutdown ("database is empty");
    1418  }
    15   if (!str_to_dtime (argv[2], &range)) {
    16     fprintf (stderr, "syntax error\n");
    17     return (FALSE);
    18   }
    19   if (range < 0) {
    20     range = fabs (range);
    21     start -= range;
    22   }
    23   end = start + range;
     19  fseek (f, 0, SEEK_SET);
    2420
    25   fprintf (stderr, "start: %d\n", start);
    26   fprintf (stderr, "end: %d\n", end);
    27 
    28   *START = start;
    29   *END = end;
    30 
    31   /* get image header */
    32   fseek (f, 0, SEEK_SET);
     21  /* read header */
    3322  if (!fits_fread_header (f, &header)) {
    34     fprintf (stderr, "Can't find image catalog: %s\n", ImageCat);
    35     exit (1);
     23    Shutdown ("can't read image catalog %s", ImageCat);
    3624  }
    3725  fseek (f, header.size, SEEK_SET);
     
    4735  ALLOCATE (pimage, Image, NPIMAGE);
    4836
     37  /* add match on photcode */
    4938  for (Ntimage = 0; Ntimage < Nimage; Ntimage += ntimage) {
    5039    ntimage = Fread (timage, sizeof(Image), NTIMAGE, f, "image");
     
    5241      tstart = timage[i].tzero;
    5342      tend = timage[i].tzero + 1e-4*timage[i].trate*timage[i].NY;
    54       if ((tstart <= end) && (tend >= start)) {
     43      if ((tstart <= END) && (tend >= START)) {
    5544        pimage[npimage] = timage[i];
    5645        npimage ++;
     
    6453  free (timage);
    6554
    66   fprintf (stderr, "found the following images:\n");
    67   for (i = 0; i < npimage; i++) {
    68     XY_to_RD (&Ra, &Dec, 0.5*pimage[i].NX, 0.5*pimage[i].NY, &pimage[i].coords);
    69     fprintf (stderr, "%3d %s %8.4f %8.4f %d %d\n", i, pimage[i].name, Ra, Dec,
    70              pimage[i].tzero, pimage[i].nstar);
     55  {
     56    double Ra, Dec;
     57    fprintf (stderr, "found the following images:\n");
     58    for (i = 0; i < npimage; i++) {
     59      XY_to_RD (&Ra, &Dec, 0.5*pimage[i].NX, 0.5*pimage[i].NY, &pimage[i].coords);
     60      fprintf (stderr, "%3d %s %8.4f %8.4f %d %d\n", i, pimage[i].name, Ra, Dec,
     61               pimage[i].tzero, pimage[i].nstar);
     62    }
    7163  }
    7264
Note: See TracChangeset for help on using the changeset viewer.