IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4680


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

adjust to use match DVO catalog access methods

Location:
trunk/Ohana/src/delstar
Files:
20 edited

Legend:

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

    r4605 r4680  
    1717INCS    =       -I$(INC) -I$(LINC) -I$(XINC)
    1818LIBS    =       -L$(LLIB) -lFITS -lohana -lm
    19 CFLAGS  =       -o $*.$(ARCH).o $(INCS)
     19CFLAGS  =       -o $*.$(ARCH).o $(INCS) -O2
    2020CCFLAGS =       $(INCS) $(LIBS)
    2121
    2222DELSTAR = \
    23 $(SRC)/delstar.$(ARCH).o        $(SRC)/gcatalog.$(ARCH).o       \
    24 $(SRC)/gregions.$(ARCH).o       $(SRC)/gimages.$(ARCH).o        \
    25 $(SRC)/dimages.$(ARCH).o        $(SRC)/gtimes.$(ARCH).o         \
    26 $(SRC)/find_matches.$(ARCH).o   $(SRC)/wcatalog.$(ARCH).o       \
    27 $(SRC)/ConfigInit.$(ARCH).o     $(SRC)/args.$(ARCH).o           \
    28 $(SRC)/aregion.$(ARCH).o        $(SRC)/delete_missed.$(ARCH).o  \
    29 $(SRC)/sort_lists.$(ARCH).o     $(SRC)/parse_time.$(ARCH).o     \
    30 $(SRC)/gcatstats.$(ARCH).o      $(SRC)/find_images.$(ARCH).o    \
    31 $(SRC)/match_images.$(ARCH).o   $(SRC)/delete_orphans.$(ARCH).o \
    32 $(SRC)/convert.$(ARCH).o
     23$(SRC)/delstar.$(ARCH).o          \
     24$(SRC)/SetSignals.$(ARCH).o       \
     25$(SRC)/ConfigInit.$(ARCH).o       \
     26$(SRC)/args.$(ARCH).o             \
     27$(SRC)/image-db.$(ARCH).o         \
     28$(SRC)/delete_imagename.$(ARCH).o \
     29$(SRC)/delete_imagefile.$(ARCH).o \
     30$(SRC)/delete_times.$(ARCH).o     \
     31$(SRC)/gimages.$(ARCH).o          \
     32$(SRC)/gregion_image.$(ARCH).o    \
     33$(SRC)/gregion_patch.$(ARCH).o    \
     34$(SRC)/RegionOps.$(ARCH).o        \
     35$(SRC)/gcatalog.$(ARCH).o         \
     36$(SRC)/wcatalog.$(ARCH).o         \
     37$(SRC)/find_image_db.$(ARCH).o    \
     38$(SRC)/find_matches.$(ARCH).o     \
     39$(SRC)/parse_time.$(ARCH).o       \
     40$(SRC)/convert.$(ARCH).o \
     41$(SRC)/sort_lists.$(ARCH).o \
     42$(SRC)/check_permissions.$(ARCH).o \
     43$(SRC)/dimages.$(ARCH).o         
    3344
    3445OBJ = $(DELSTAR)
     
    6374.c.$(ARCH).o:
    6475        $(CC) $(CFLAGS) -c $<
    65 
    66 
  • trunk/Ohana/src/delstar/include/delstar.h

    r4607 r4680  
    22# include <dvo.h>
    33# include <signal.h>
     4
     5typedef struct {
     6  Coords coords;
     7  float *X, *Y;
     8  int *N;
     9  double RA[2], DEC[2];
     10  double Area, density, spacing;
     11} CatStats;
    412
    513/* global variables set in parameter file */
     
    1523int    MISSED;
    1624
    17 time_t START;
    18 time_t END;
     25time_t    START;
     26time_t    END;
     27PhotCode *PHOTCODE;
    1928
    2029int    MODE;
    21 enum {MODE_IMAGENAME, MODE_IMAGEFILE, MODE_TRANGE, MODE_ORPHAN, MODE_MISSED};
     30enum {MODE_IMAGENAME, MODE_IMAGEFILE, MODE_TIME, MODE_ORPHAN, MODE_MISSED};
    2231
    23 typedef struct {
    24   Coords coords;
    25   float *X, *Y;
    26   int *N;
    27   double RA[2], DEC[2];
    28   double Area, density, spacing;
    29 } CatStats;
     32enum {TIME_NONE, TIME_JD, TIME_MJD, TIME_DATE, TIME_DAYS, TIME_HOURS, TIME_MINUTES, TIME_SECONDS};
    3033
    3134char DateKeyword[64], DateMode[64], UTKeyword[64], MJDKeyword[64], JDKeyword[64];
    3235
    33 /*** values for time formats */
    34 enum {TIME_NONE, TIME_JD, TIME_MJD, TIME_DATE, TIME_DAYS, TIME_HOURS, TIME_MINUTES, TIME_SECONDS};
    35 
    3636/*** conversion functions ***/
    37 int           chk_time              PROTO((char *line));
    38 time_t        date_to_sec           PROTO((char *date));
    39 time_t        jd_to_sec             PROTO((double jd));
    40 time_t        mjd_to_sec            PROTO((double mjd));
    41 char         *sec_to_date           PROTO((time_t second));
    42 double        sec_to_jd             PROTO((time_t second));
    43 double        sec_to_mjd            PROTO((time_t second));
    44 int           str_to_dtime          PROTO((char *line, double *second));
    45 int           str_to_radec          PROTO((double *ra, double *dec, char *str1, char *str2));
    46 int           str_to_time           PROTO((char *line, time_t *second));
     37FILE      *GetDB                  PROTO((int *state));
     38Image     *GetImages              PROTO((int *nimage));
     39GSCRegion *LoadRegions            PROTO((int *nregions));
     40Image     *find_images            PROTO((FILE *f, CatStats *catstats, int *Nimages));
     41int       *find_images_data       PROTO((Image *timage, int *nlist));
     42int       *find_images_name       PROTO((char *filename, int *nlist));
     43int       *find_images_time       PROTO((time_t start, time_t end, PhotCode *code, int *nlist));
     44Image     *gimages                PROTO((char *filename));
     45GSCRegion *gregion_image          PROTO((Image *image, int *Nregions));
     46GSCRegion *gregion_patch          PROTO((GSCRegion *patch, int *nregions));
     47Image     *gtimes                 PROTO((int *NIMAGE));
     48char      *sec_to_date            PROTO((time_t second));
     49void       ConfigInit             PROTO((int *argc, char **argv));
     50int        FindDecBand            PROTO((double dec, double *DEC0, double *DEC1));
     51int        FindRegionByPoint      PROTO((GSCRegion *region, double ra, double dec, GSCRegion *gsc, int Ngsc));
     52int        FindRegionDecBandStart PROTO((GSCRegion *region, int Nregion, double dec));
     53int        FindRegionDecBandStop  PROTO((GSCRegion *region, int Nregion, double dec));
     54int        SetImages              PROTO((Image *new, int Nnew));
     55void       SetProtect             PROTO((int mode));
     56int        SetSignals             PROTO(());
     57int        Shutdown               PROTO((char *format, ...));
     58void       TrapSignal             PROTO((int sig));
     59int        args                   PROTO((int *argc, char **argv));
     60void       check_permissions      PROTO((char *basefile));
     61int        chk_time               PROTO((char *line));
     62time_t     date_to_sec            PROTO((char *date));
     63void       delete_imagefile       PROTO((char *filename));
     64void       delete_imagename       PROTO((char *name));
     65void       delete_times           PROTO(());
     66int        dimages                PROTO((int *imlist, int Nimlist));
     67int        dms_to_ddd             PROTO((double *Value, char *string));
     68int        edge_check             PROTO((double *x1, double *y1, double *x2, double *y2));
     69void       find_matches           PROTO((Catalog *catalog, int photcode, int start, int end));
     70int        gcatalog               PROTO((Catalog *catalog));
     71void       help                   PROTO(());
     72int        hms_to_deg             PROTO((double *h0, double *h1, double *d0, double *d1, char *string));
     73time_t     jd_to_sec              PROTO((double jd));
     74int        load_image_db          PROTO(());
     75void       lock_image_db          PROTO(());
     76void       match_images           PROTO((Catalog *catalog, Image *image, int Nimage));
     77time_t     mjd_to_sec             PROTO((double mjd));
     78double     opening_angle          PROTO((double x1, double y1, double x2, double y2, double x3, double y3));
     79int        parse_time             PROTO((Header *header));
     80int        save_image_db          PROTO(());
     81double     sec_to_jd              PROTO((time_t second));
     82double     sec_to_mjd             PROTO((time_t second));
     83void       sort_lists             PROTO((float *X, float *Y, int *S, int N));
     84void       sort_regions           PROTO((GSCRegion *region, int N));
     85int        str_to_dtime           PROTO((char *line, double *second));
     86int        str_to_radec           PROTO((double *ra, double *dec, char *str1, char *str2));
     87int        str_to_time            PROTO((char *line, time_t *second));
     88void       unlock_image_db        PROTO(());
     89void       usage                  PROTO(());
     90int        wcatalog               PROTO((Catalog *catalog));
  • trunk/Ohana/src/delstar/src/ConfigInit.c

    r2463 r4680  
    11# include "delstar.h"
    22
    3 ConfigInit (int *argc, char **argv) {
     3void ConfigInit (int *argc, char **argv) {
    44
    55  char *config, *file;
  • trunk/Ohana/src/delstar/src/RegionOps.c

    r4611 r4680  
    127127
    128128  /* bracket value of interest */
    129   Nlo = 0; Nhi = Nregion;
     129  Nlo = 0; Nhi = Nregion - 1;
    130130  while (Nhi - Nlo > 10) {
    131131    N = 0.5*(Nlo + Nhi);
     
    161161
    162162  /* bracket value of interest */
    163   Nlo = 0; Nhi = Nregion;
     163  Nlo = 0; Nhi = Nregion - 1;
    164164  while (Nhi - Nlo > 10) {
    165165    N = 0.5*(Nlo + Nhi);
     
    174174
    175175  /* find the last entry < dec */
    176   for (N = Nlo; N < Nhi; N++) {
     176  for (N = Nlo; N <= Nhi; N++) {
    177177    if (region[N].DEC[0] > D1) return (N);
    178178  }
     179  fprintf (stderr, "fail dec band stop: %f: %f  %f, %d - %d, %f %f\n",
     180           dec, D0, D1, Nlo, Nhi, region[Nlo].DEC[0], region[Nlo].DEC[1]);
    179181  return (-1);
    180182  /* this will fail if transition value is not in the data range */
  • trunk/Ohana/src/delstar/src/args.c

    r4607 r4680  
    33void help () {
    44
    5   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");
     5  fprintf (stderr, "USAGE:\n");
     6  fprintf (stderr, "  delstar (filename) or (start range) or -orphan (region)\n");
     7  fprintf (stderr, "  delstar -time (start) (stop/range)\n");
     8  fprintf (stderr, "  delstar -orphan (region)\n");
     9  fprintf (stderr, "  delstar -missed (region)\n\n");
    910  fprintf (stderr, "  optional flags:\n");
    10   fprintf (stderr, "  -v (verbose mode)\n");
     11  fprintf (stderr, "  -v               : verbose mode\n");
     12  fprintf (stderr, "  -photcode (code) : restrict by photcode\n");
    1113  fprintf (stderr, "\n");
    1214  exit (2);
     
    1517
    1618void 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");
     19  fprintf (stderr, "USAGE: delstar (filename) / [optional mode] : -h for help\n");
    2220  exit (2);
    2321}
     
    2523int args (int *argc, char **argv) {
    2624 
    27 
    2825  int N;
     26  double trange;
     27  time_t tmp;
    2928
    3029  /* check for help request */
     
    5857  if ((N = get_argument (*argc, argv, "-time"))) {
    5958    if (MODE != MODE_IMAGEFILE) usage();
    60     MODE = MODE_TRANGE;
     59    MODE = MODE_TIME;
    6160    remove_argument (N, argc, argv);
    6261
    63     /* tstart */
    6462    if (!str_to_time (argv[N], &START)) usage ();
    6563    remove_argument (N, argc, argv);
     
    7371        END = START + trange;
    7472      }
    75       remove_argument (Na, argc, argv);
     73      remove_argument (N, argc, argv);
    7674      goto goodtime;
    7775    }
     
    8280        END   = START;
    8381      }
    84       remove_argument (Na, argc, argv);
     82      remove_argument (N, argc, argv);
    8583      goto goodtime;
    8684    }
    8785    usage ();
    88 
    89   goodtime:
    90     fprintf (stderr, "start: %d\n", start);
    91     fprintf (stderr, "end: %d\n", end);
    9286  }
     87goodtime:
    9388
    9489  /* restrict to a single photcode (not compatible with -image) */
    9590  PHOTCODE = NULL;
    96   if ((N = get_argument (argc, argv, "-photcode"))) {
    97     remove_argument (N, &argc, argv);
     91  if ((N = get_argument (*argc, argv, "-photcode"))) {
     92    remove_argument (N, argc, argv);
    9893    PHOTCODE = GetPhotcodebyName (argv[N]);
    99     remove_argument (N, &argc, argv);
     94    remove_argument (N, argc, argv);
    10095  }
    10196
  • trunk/Ohana/src/delstar/src/convert.c

    r4605 r4680  
    319319}
    320320
     321/**********/
     322int hms_to_deg (double *h0, double *h1, double *d0, double *d1, char *string) {
     323 
     324  int flag_d0, flag_d1, flag_h0, flag_h1;
     325  double tmp;
     326 
     327  *d0 = *h0 = *d1 = *h1 = 0;
     328
     329  flag_h0 = dparse (h0, 1, string);
     330  flag_h1 = dparse (h1, 4, string);
     331  flag_d0 = dparse (d0, 7, string);
     332  flag_d1 = dparse (d1, 9, string);
     333  *h0 *= flag_h0;
     334  *h1 *= flag_h1;
     335  *d0 *= flag_d0;
     336  *d1 *= flag_d1;
     337
     338  dparse (&tmp, 2, string);
     339  *h0 += tmp/60.0;
     340  dparse (&tmp, 3, string);
     341  *h0 += tmp/3600.0;
     342 
     343  dparse (&tmp, 5, string);
     344  *h1 += tmp/60.0;
     345  dparse (&tmp, 6, string);
     346  *h1 += tmp/3600.0;
     347 
     348  dparse (&tmp, 8, string);
     349  *d0 += tmp/60.0;
     350
     351  dparse (&tmp, 10, string);
     352  *d1 += tmp/60.0;
     353
     354  *h0 *= 15*flag_h0;
     355  *h1 *= 15*flag_h1;
     356  *d0 *= flag_d0;
     357  *d1 *= flag_d1;
     358
     359  return (TRUE);
     360}
  • trunk/Ohana/src/delstar/src/delete_imagename.c

    r4607 r4680  
    33void delete_imagename (char *name) {
    44
    5   int i, Nregions;
     5  int i, j, k;
     6  int Nregions, Nimlist, Nimage;
     7  int *imlist;
     8  double trange;
     9  time_t start, stop;
    610  Image *image;
    711  GSCRegion *region;
    812  Catalog catalog;
    913
    10   fprintf (stderr, "this function needs to be debugged\n");
    11   exit (2);
     14  image = GetImages (&Nimage);
    1215
    1316  /* find image in db by name */
    14   image = find_image (filename);
     17  imlist = find_images_name (name, &Nimlist);
     18  if (!Nimlist) Shutdown ("image %s not found in db", name);
    1519 
    16   fprintf (stderr, "deleting %s\n", image[0].name);
    17   region = gregions (image, &Nregions);
     20  for (k = 0; k < Nimlist; k++) {
    1821
    19   for (i = 0; i < Nregions; i++) {
    20     fprintf (stderr, "deleting from %s\n", region[i].filename);
    21     catalog.filename = region[i].filename;  /* don't free region before catalog! */
    22     switch (lock_catalog (&catalog, LCK_SOFT)) {
    23       case 0:
    24         fprintf (stderr, "ERROR: can't lock file\n");
    25         exit (1);
    26       case 1:
    27         gcatalog (&catalog);
    28         break;
    29       case 2:
    30         fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
    31         catalog.Naverage = 0;
    32         catalog.Nmeasure = 0;
    33         break;
    34       default:
    35         fprintf (stderr, "weird lock_catalog exit state\n");
    36         exit (1);
     22    j = imlist[k];
     23    if (VERBOSE) fprintf (stderr, "deleting %s\n", image[j].name);
     24    region = gregion_image (&image[j], &Nregions);
     25
     26    for (i = 0; i < Nregions; i++) {
     27      if (VERBOSE) fprintf (stderr, "deleting from %s\n", region[i].filename);
     28      catalog.filename = region[i].filename;  /* don't free region before catalog! */
     29      switch (lock_catalog (&catalog, LCK_XCLD)) {
     30        case 0:
     31          fprintf (stderr, "ERROR: can't lock file %s\n", catalog.filename);
     32          exit (1);
     33        case 1:
     34          gcatalog (&catalog);
     35          break;
     36        case 2:
     37          if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
     38          unlock_catalog (&catalog);
     39          continue;
     40        default:
     41          fprintf (stderr, "weird lock_catalog exit state\n");
     42          exit (1);
     43      }
     44
     45      /* trate is in 0.1 msec / row  - stop is the latest exposure end time */
     46      /* pad exposure time by 1 sec to require a valid time */
     47      trange = 1e-4*image[j].NY*image[j].trate + image[j].exptime + 1; 
     48      start = image[j].tzero;
     49      stop  = image[j].tzero + trange;
     50      find_matches (&catalog, image[j].source, start, stop);
     51      wcatalog (&catalog);
     52      unlock_catalog (&catalog);
    3753    }
    38     find_matches (&catalog, image);
    39     wcatalog (&catalog);
    4054  }
    4155
    42   dimages (image, 1);
     56  /* delete the identified images */
     57  dimages (imlist, Nimlist);
    4358
    44   /* this probably gets moved inside dimages */
    45   unlock_image_db (ImageCat, f, LCK_HARD, &dbstate);
     59  save_image_db ();
     60  unlock_image_db ();
    4661  fprintf (stderr, "SUCCESS\n");
    4762  exit (0);
  • trunk/Ohana/src/delstar/src/delete_missed.c

    r2463 r4680  
    11# include "delstar.h"
     2
     3/* drop all MISSED values for the given catalog */
    24
    35delete_missed (Catalog *catalog) {
  • 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}
  • trunk/Ohana/src/delstar/src/delstar.c

    r4607 r4680  
    11# include "delstar.h"
    22
    3 main (int argc, char **argv) {
     3int main (int argc, char **argv) {
    44
    55  SetSignals ();
    6   ConfigInit (argc, argv);
     6  ConfigInit (&argc, argv);
    77  args (&argc, argv);
    88
    99  lock_image_db ();
     10  load_image_db ();
    1011
    1112  /* delete orphaned measurements (no image) from catalog */
     
    1718      delete_imagename (argv[1]);
    1819      break;
    19     case MODE_ORPHANS:
    20       delete_orphans (argv[1]);
     20    case MODE_TIME:
     21      delete_times ();
     22      break;
     23    case MODE_ORPHAN:
     24      fprintf (stderr, "delete orphans not available\n");
     25      // delete_orphans (argv[1]);
    2126      break;
    2227    case MODE_MISSED:
    23       delete_missed (argv[1]);
    24       break;
    25     case MODE_TIME:
    26       delete_time ();
     28      fprintf (stderr, "delete missed not available\n");
     29      // delete_missed (argv[1]);
    2730      break;
    2831    default:
  • trunk/Ohana/src/delstar/src/dimages.c

    r4607 r4680  
    1 # include "addstar.h"
     1# include "delstar.h"
    22
    3 int dimages (Image *image, int Nimages) {
     3/* delete images by sequence number */
     4
     5int dimages (int *imlist, int Nimlist) {
    46 
    5   int i, j, Ntimage, ntimage, mode;
    6   int start, end, tstart, tend, status;
    7   char line[256];
    8   struct stat filestat;
    9   Image *timage;
    10   Header header;
     7  int i, j, Nimage;
     8  Image *image;
    119
    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);
     10  image = GetImages (&Nimage);
    1811
    19   /* use cp to make backup copy */
    20   sprintf (line, "cp %s %s~\0", ImageCat, ImageCat);
    21   status = system (line);
    22   if (status) {
    23     fprintf (stderr, "ERROR: unable to create %s~, exiting\n", ImageCat);
    24     Shutdown ();
    25   }
    26   mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
    27   sprintf (line, "%s~\0", ImageCat);
    28   chmod (line, mode);
    29 
    30   /* check if image datafile exists, get header */
    31   fseek (f, 0, SEEK_SET);
    32   if (!fits_fread_header (f, &header)) {
    33     fprintf (stderr, "Can't find image catalog\n");
    34     exit (1);
    35   }
    36   fseek (f, header.size, SEEK_SET);
    37 
    38   fits_scan (&header, "NIMAGES", "%d", 1, &Ntimage);
    39   ALLOCATE (timage, Image, Ntimage);
    40   ntimage = Fread (timage, sizeof(Image), Ntimage, f, "image");
    41   if (Ntimage != ntimage) {
    42     fprintf (stderr, "failed to read in entire image file %s\n", ImageCat);
    43     exit (1);
    44   }
    45 
    46   /* need to delete on basis of both image time & photcode */
    47   /* first, mark the deleted images with a flag (NX = 0) */
    48   for (i = 0; i < Ntimage; i++) {
    49     for (j = 0; j < Nimages; j++) {
    50       tstart = timage[i].tzero;
    51       tend = timage[i].tzero + timage[i].trate * timage[i].NY;
    52       start = image[j].tzero;
    53       end = image[j].tzero + image[j].trate * image[j].NY;
    54       if ((tstart <= end) && (tend >= start) && (timage[i].source == image[j].source)) {
    55         fprintf (stderr, "deleting %s\n", timage[i].name);
    56         timage[i].NX = 0;
    57       }
    58     }
     12  /* first, mark the deleted images with a flag (name = 0) */
     13  for (i = 0; i < Nimlist; i++) {
     14    j = imlist[i];
     15    image[j].name[0] = 0;
     16    /* this puts a restriction on the DB: image name must not be NULL */
    5917  }
    6018
    6119  /* delete the marked images */
    62   for (i = 0, j = 0; j < Ntimage; j++) {
    63     if (timage[j].NX) {
    64       if (i != j) {
    65         timage[i] = timage[j];
    66       }
    67       i++;
     20  for (i = 0, j = 0; j < Nimage; j++) {
     21    if (!image[j].name[0]) continue;
     22    if (i != j) {
     23      image[i] = image[j];
    6824    }
     25    i++;
    6926  }
    70   Ntimage = i;
    71   REALLOCATE (timage, Image, Ntimage);
    72   fits_modify (&header, "NIMAGES", "%d", 1, Ntimage);
     27  Nimage = i;
     28  REALLOCATE (image, Image, Nimage);
    7329
    74   /* should make a backup copy of the ImageCat file */
    75   fseek (f, 0, SEEK_SET);
    76   Fwrite (header.buffer, 1, header.size, f, "char");
    77   Fwrite (timage, sizeof(Image), Ntimage, f, "image");
    78 
     30  SetImages (image, Nimage);
    7931  return (TRUE);
    8032}
    81 
    82 /* this is kind of silly: we match images in both gimages and dimages
    83  *
    84  */
  • trunk/Ohana/src/delstar/src/find_images.c

    r2463 r4680  
    11# include "delstar.h"
    2 double opening_angle ();
    32
    43Image *find_images (FILE *f, CatStats *catstats, int *Nimages) {
     
    133132}
    134133
    135 int edge_check (x1, y1, x2, y2)
    136 double *x1, *y1, *x2, *y2;
    137 {
     134int edge_check (double *x1, double *y1, double *x2, double *y2) {
    138135
    139136  double theta1, theta2;
     
    169166}
    170167
    171 double opening_angle (x1, y1, x2, y2, x3, y3)
    172 double x1, y1, x2, y2, x3, y3;
    173 {
     168double opening_angle (double x1, double y1, double x2, double y2, double x3, double y3) {
    174169
    175170  double dx1, dy1, dx2, dy2, ct, st, theta;
  • trunk/Ohana/src/delstar/src/find_matches.c

    r2463 r4680  
    11# include "delstar.h"
    22
    3 find_matches (Catalog *catalog, Image *image, int start, int end) {
    4 
    5   int i, j, k, n, m, N, M, found;
    6   int *N1, *N2,  *next, *next_miss, *ave_miss, last, last_miss;
    7   int Nave, NAVE, Nmeas, NMEAS, Nmiss, NMISS, Nmatch, photcode;
     3void find_matches (Catalog *catalog, int photcode, int start, int end) {
     4
     5  int i, j, k, n, m, N, M, drop;
     6  int *next, *next_miss, *ave_miss, last, last_miss;
     7  int Nave, Nmeas, Nmiss;
    88  int Nmeasfound, Nsecfilt;
    99  int this, prev;
    10   unsigned int flags;
    1110  Measure *tmpmeasure;
    1211  Missing *tmpmissing;
    13   Coords tcoords;
    1412
    1513  /** allocate local arrays **/
     
    4341    }
    4442  }
    45   photcode = -1;
    46   if ((start == 0) && (end == 0)) {
    47     start = image[0].tzero;
    48     end   = image[0].tzero + 1e-4*image[0].NY*image[0].trate;  /* trate is in 0.1 msec / row */
    49     photcode = image[0].source;
    50   }
    51   if (VERBOSE) fprintf (stderr, "deleting for range %d to %d (photcode %d)\n", start, end, photcode);
     43
     44  if (VERBOSE) fprintf (stderr, "deleting for range %d to %d, photcode %d\n", start, end, photcode);
    5245  Nmeasfound = 0;
    5346  Nsecfilt = catalog[0].Nsecfilt;
    5447
    55   /* fprintf (stderr, "fixing the measures...\n"); */
    56   /** find measure in time range of image **/
     48  if (VERBOSE) fprintf (stderr, "fixing measure...\n");
     49
     50  /** find measure in time range **/
    5751  this = prev = -1;
    5852  for (i = 0; (i < Nmeas); i++) {
    59     if ((i % 10000) == 0) fprintf (stderr, ". ");
    60     if ((catalog[0].measure[i].t >= start) && (catalog[0].measure[i].t <= end) && (photcode == catalog[0].measure[i].source)) {
    61       Nmeasfound ++;
    62       /* this star is in this image */
    63       this = next[i];
    64       next[i] = -2; /* we delete this one */
    65       if (prev != -1) { next[prev] = this; }
     53    if (VERBOSE && !(i % 10000)) fprintf (stderr, ". ");
     54    drop = TRUE;
     55    drop &= (catalog[0].measure[i].t >= start);
     56    drop &= (catalog[0].measure[i].t <= end);
     57    drop &= ((photcode == -1) || (photcode == catalog[0].measure[i].source));
     58    if (!drop) {
     59      prev = i;
     60      continue;
     61    }
     62    Nmeasfound ++;
     63
     64    /* this star is in this image */
     65    this = next[i];
     66    next[i] = -2; /* we delete this one */
     67    if (prev != -1) { next[prev] = this; }
     68
    6669# if (0)
    67       /* why is this section disabled? */
     70    /* why is this section disabled? */
     71    /* fix the list links: connect the previous valid link to the next valid link */
     72    for (j = i; (j >= 0) && (next[j] == -2); j--); /* find previous entry to fix link */
     73    if (j >= 0) { /* if j < 0, there is no previous valid link, ignore this step */
     74      if (next[j] != i) {
     75        fprintf (stderr, "error? (1)  this link seems to have been lost\n");
     76        fprintf (stderr, "j: %d, next[j]: %d, i: %d\n", j, next[j], i);
     77        exit (1);
     78      }
     79      /* find next valid entry to fix link */
     80      for (k = i; (k < Nmeas) && (next[k] == -2); k++);
     81      if (k < Nmeas)
     82        next[j] = k;
     83      else
     84        next[j] = -1;  /* last link in list gets a -1 */
     85    }
     86# endif     
     87
     88    /*** fix the corresponding average entry ***/
     89    n = catalog[0].measure[i].averef;
     90    if (catalog[0].average[n].Nm == 0) { /* this should never happen */
     91      fprintf (stderr, "error? we deleted one too many objects?\n");
     92      exit (1);
     93    }
     94    catalog[0].average[n].Nm --;
     95    /* this was only entry in list: will be deleted below.  meanwhile, delete all missing entries*/
     96    if ((catalog[0].average[n].Nm < 1) && (catalog[0].average[n].Nn > 0)) {
     97      m = catalog[0].average[n].missing;
     98      for (j = 0; j < catalog[0].average[n].Nn; j++) {
     99        M = next_miss[m];
     100        next_miss[m] = -2;
     101        m = M;
     102      }
     103      m = catalog[0].average[n].missing;
    68104      /* fix the list links: connect the previous valid link to the next valid link */
    69       for (j = i; (j >= 0) && (next[j] == -2); j--); /* find previous entry to fix link */
     105      for (j = m; (j >= 0) && (next_miss[j] == -2); j--); /* find previous entry to fix link */
    70106      if (j >= 0) { /* if j < 0, there is no previous valid link, ignore this step */
    71         if (next[j] != i) {
    72           fprintf (stderr, "error? (1)  this link seems to have been lost\n");
    73           fprintf (stderr, "j: %d, next[j]: %d, i: %d\n", j, next[j], i);
    74           exit (1);
    75         }
    76         /* find next valid entry to fix link */
    77         for (k = i; (k < Nmeas) && (next[k] == -2); k++);
    78         if (k < Nmeas)
    79           next[j] = k;
    80         else
    81           next[j] = -1;  /* last link in list gets a -1 */
    82       }
    83 # endif     
    84       /*** fix the corresponding average entry ***/
    85       n = catalog[0].measure[i].averef;
    86       if (catalog[0].average[n].Nm == 0) { /* this should never happen */
    87         fprintf (stderr, "error? we deleted one too many objects?\n");
    88         exit (1);
    89       }
    90       catalog[0].average[n].Nm --;
    91       /* this was only entry in list: will be deleted below.  meanwhile, delete all missing entries*/
    92       if ((catalog[0].average[n].Nm < 1) && (catalog[0].average[n].Nn > 0)) {
    93         m = catalog[0].average[n].missing;
    94         for (j = 0; j < catalog[0].average[n].Nn; j++) {
    95           M = next_miss[m];
    96           next_miss[m] = -2;
    97           m = M;
    98         }
    99         m = catalog[0].average[n].missing;
    100         /* fix the list links: connect the previous valid link to the next valid link */
    101         for (j = m; (j >= 0) && (next_miss[j] == -2); j--); /* find previous entry to fix link */
    102         if (j >= 0) { /* if j < 0, there is no previous valid link, ignore this step */
    103           if (next_miss[j] != m) {
    104             fprintf (stderr, "error? (2) this link seems to have been lost\n");
    105             fprintf (stderr, "j: %d, next_miss[j]: %d, i: %d\n", j, next_miss[j], i);
    106             exit (1);
    107           }
    108           /* find next valid entry to fix link */
    109           for (k = m; (k < Nmiss) && (next_miss[k] == -2); k++);
    110           if (k < Nmiss)
    111             next_miss[j] = k;
    112           else
    113             next_miss[j] = -1;  /* last link in list gets a -1 */
    114         }
    115       }
    116       /* this was first entry in list */
    117       if ((catalog[0].average[n].offset == i) && (catalog[0].average[n].Nm > 0)) {
    118         m = catalog[0].average[n].offset;
    119         /* find next valid entry -- notice lack of error checking... */
    120         for (j = 0; (j < Nmeas) && (next[m+j] == -2); j++);
    121         catalog[0].average[n].offset = m + j;
    122       }
    123     } else {
    124       prev = i;
    125     }
    126   }
    127   fprintf (stderr, "found %d meas to remove\n", Nmeasfound);
    128 
    129   /* fprintf (stderr, "fixing the missing...\n"); */
    130   /** find missing in time range of image **/
    131   for (i = 0; (i < Nmiss); i++) {
    132     if ((next_miss[i] != -2) && (catalog[0].missing[i].t >= start) && (catalog[0].missing[i].t <= end)) {
    133       /* this star is in this image */
    134 
    135       next_miss[i] = -2; /* we delete this one */
    136       /* fix the list links: connect the previous valid link to the next valid link */
    137       for (j = i; (j >= 0) && (next_miss[j] == -2); j--); /* find previous entry to fix link */
    138       if (j >= 0) { /* if j < 0, there is no previous valid link, ignore this step */
    139         if (next_miss[j] != i) {
    140           fprintf (stderr, "error? (3) this link seems to have been lost\n");
     107        if (next_miss[j] != m) {
     108          fprintf (stderr, "error? (2) this link seems to have been lost\n");
    141109          fprintf (stderr, "j: %d, next_miss[j]: %d, i: %d\n", j, next_miss[j], i);
    142110          exit (1);
    143111        }
    144112        /* find next valid entry to fix link */
    145         for (k = i; (k < Nmiss) && (next_miss[k] == -2); k++);
     113        for (k = m; (k < Nmiss) && (next_miss[k] == -2); k++);
    146114        if (k < Nmiss)
    147115          next_miss[j] = k;
     
    149117          next_miss[j] = -1;  /* last link in list gets a -1 */
    150118      }
     119    }
     120    /* this was first entry in list */
     121    if ((catalog[0].average[n].offset == i) && (catalog[0].average[n].Nm > 0)) {
     122      m = catalog[0].average[n].offset;
     123      /* find next valid entry -- notice lack of error checking... */
     124      for (j = 0; (j < Nmeas) && (next[m+j] == -2); j++);
     125      catalog[0].average[n].offset = m + j;
     126    }
     127  }
     128  fprintf (stderr, "found %d meas to remove\n", Nmeasfound);
     129
     130  if (VERBOSE) fprintf (stderr, "fixing missing...");
     131  /** find missing in time range of image **/
     132  for (i = 0; (i < Nmiss); i++) {
     133    if (next_miss[i] == -2) continue;
     134    if (catalog[0].missing[i].t < start) continue;
     135    if (catalog[0].missing[i].t > end) continue;
     136
     137    next_miss[i] = -2; /* we delete this one */
     138    /* fix the list links: connect the previous valid link to the next valid link */
     139    for (j = i; (j >= 0) && (next_miss[j] == -2); j--); /* find previous entry to fix link */
     140    if (j >= 0) { /* if j < 0, there is no previous valid link, ignore this step */
     141      if (next_miss[j] != i) {
     142        fprintf (stderr, "error? (3) this link seems to have been lost\n");
     143        fprintf (stderr, "j: %d, next_miss[j]: %d, i: %d\n", j, next_miss[j], i);
     144        exit (1);
     145      }
     146      /* find next valid entry to fix link */
     147      for (k = i; (k < Nmiss) && (next_miss[k] == -2); k++);
     148      if (k < Nmiss)
     149        next_miss[j] = k;
     150      else
     151        next_miss[j] = -1;  /* last link in list gets a -1 */
     152    }
    151153     
    152       /* find the corresponding avearge entry
    153       found = FALSE;
    154       for (n = 0; !found && (n < Nave); n++) {
    155         if ((catalog[0].average[n].missing > 0) && (catalog[0].average[n].missing <= i) && (catalog[0].average[n].missing + catalog[0].average[n].Nn > i))
    156           found = TRUE;
    157       }
    158       n--; */
    159       /*** fix the corresponding average entry ***/
    160       n = ave_miss[i];
    161       if (catalog[0].average[n].Nn == 0) { /* this should never happen */
    162         fprintf (stderr, "error? we deleted one too many missing?\n");
    163         exit (1);
    164       }
    165       catalog[0].average[n].Nn --;
    166       /* this was first entry in list */
    167       if ((catalog[0].average[n].missing == i) && (catalog[0].average[n].Nn > 0)) {
    168         m = catalog[0].average[n].missing;
    169         for (j = 0; (j < Nmiss) && (next_miss[m+j] == -2); j++);
    170         catalog[0].average[n].missing = m + j;
    171       }
    172 
    173     }
    174   }
    175 
    176   /* currently not worked out, but we will need to delete the references to blended image and cat stars */
    177 # if 0
    178   /*** handle multiple stars */
    179   /* this image star matches more than one catalog star */
    180   if (stars[N].found > -1) {
    181     catalog[0].measure[stars[N].found].flags |= BLEND_IMAGE;
    182     catalog[0].measure[Nmeas].flags |= BLEND_IMAGE;
    183   }
    184   if (stars[N].found == -2) { /* this image star matches a catalog star on a neighboring catalog */
    185     catalog[0].measure[Nmeas].flags |= BLEND_IMAGE_NEIGHBOR;
    186   }
    187   if (stars[N].found == -1) { /* this image star matches only this star */
    188     stars[N].found = Nmeas;  /* save first match, in case coincidences are found */
    189   }
    190   /* this catalog star matches more than one image star */
    191   if (catalog[0].found[n] > -1) {
    192     catalog[0].measure[catalog[0].found[n]].flags |= BLEND_CATALOG;
    193     catalog[0].measure[Nmeas].flags |= BLEND_CATALOG;
    194   } else {
    195     catalog[0].found[n] = Nmeas;
    196   }
    197 # endif 
     154    /*** fix the corresponding average entry ***/
     155    n = ave_miss[i];
     156    if (catalog[0].average[n].Nn == 0) { /* this should never happen */
     157      fprintf (stderr, "error? we deleted one too many missing?\n");
     158      exit (1);
     159    }
     160    catalog[0].average[n].Nn --;
     161    /* this was first entry in list */
     162    if ((catalog[0].average[n].missing == i) && (catalog[0].average[n].Nn > 0)) {
     163      m = catalog[0].average[n].missing;
     164      for (j = 0; (j < Nmiss) && (next_miss[m+j] == -2); j++);
     165      catalog[0].average[n].missing = m + j;
     166    }
     167  }
     168
     169  /* we should delete the references to blended image and cat stars ?? */
     170  /* or drop since we are changing this concept ?? */
    198171
    199172  /* fix Average list: delete entries with Nm == 0 */
     
    266239  free (next_miss);
    267240  free (ave_miss);
    268 
     241  return;
    269242}
    270243
  • trunk/Ohana/src/delstar/src/gimages.c

    r4607 r4680  
    11# include "delstar.h"
    22
    3 /* load information about image from image header */
     3/* load information about image from image header
     4 * this should be the same as addstar/gstars, but it is not...
     5 */
    46
    57Image *gimages (char *filename) {
     
    79  FILE *f;
    810  Header header;
    9   char line[64], photcode[64], *c;
    10   struct tm timeptr;
    11   double tmp, jd;
     11  char photcode[64], *c;
     12  double tmp;
    1213  Image *image;
    13   int Nsec, Nc;
     14  int Nc;
    1415
    1516  ALLOCATE (image, Image, 1);
    1617  /* load header */
    1718  if (!fits_read_header (filename, &header)) {
    18     fprintf (stderr, "ERROR: can't find image file %s\n", filename);
    19     Shutdown ();
     19    Shutdown ("ERROR: can't find image file %s", filename);
    2020  }
    2121
     
    2323  f = fopen (filename, "r");
    2424  if (f == NULL) {
    25     fprintf (stderr, "ERROR: can't find data file %s\n", filename);
    26     Shutdown ();
     25    Shutdown ("ERROR: can't find data file %s", filename);
    2726  }
    2827  fseek (f, header.size, SEEK_SET);
     
    3837  /* get astrometry information */
    3938  if (!GetCoords (&image[0].coords, &header)) {
    40     fprintf (stderr, "ERROR: no astrometric solution in header\n");
    41     Shutdown ();
     39    Shutdown ("ERROR: no astrometric solution in header");
    4240  }
    4341  while (image[0].coords.crval1 < 0) image[0].coords.crval1 += 360.0;
     
    5654  Nc = GetPhotcodeCodebyName (photcode);
    5755  if (!Nc) {
    58     fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", photcode);
    59     Shutdown ();
     56    Shutdown ("ERROR: photcode %s not found in photcode table", photcode);
    6057  }
    6158  image[0].source = Nc;
  • trunk/Ohana/src/delstar/src/gtimes.c

    r4607 r4680  
    5555  {
    5656    double Ra, Dec;
    57     fprintf (stderr, "found the following images:\n");
    58     for (i = 0; i < npimage; i++) {
     57    if (VERBOSE) fprintf (stderr, "found the following images:\n");
     58    for (i = 0; VERBOSE && (i < npimage); i++) {
    5959      XY_to_RD (&Ra, &Dec, 0.5*pimage[i].NX, 0.5*pimage[i].NY, &pimage[i].coords);
    6060      fprintf (stderr, "%3d %s %8.4f %8.4f %d %d\n", i, pimage[i].name, Ra, Dec,
  • trunk/Ohana/src/delstar/src/image-db.c

    r4607 r4680  
    77static int dbstate = LCK_UNLOCK;
    88
     9static Header header;
     10static Image *image = NULL;
     11static int   Nimage;
     12
    913FILE *GetDB (int *state) {
    1014  *state = dbstate;
    1115  return (f);
     16}
     17
     18Image *GetImages (int *nimage) {
     19  *nimage = Nimage;
     20  return (image);
     21}
     22
     23int SetImages (Image *new, int Nnew) {
     24  Nimage = Nnew;
     25  image  =  new;
     26  fits_modify (&header, "NIMAGES", "%d", 1, Nimage);
     27  return (TRUE);
    1228}
    1329
     
    2339  va_start (argp, format);
    2440  vfprintf (stderr, formatplus, argp);
    25   free (formatplus);
    2641  va_end (argp);
    2742
     
    3752  f = fsetlockfile (ImageCat, 3600.0, LOCK, &dbstate);
    3853  if (f == NULL) {
    39     fprintf (stderr, "ERROR: can't lock image catalog\n");
    40     exit (1);
     54    Shutdown ("ERROR: can't lock image catalog");
     55  }
     56  if (dbstate == LCK_EMPTY) {
     57    Shutdown ("ERROR: database is empty");
    4158  }
    4259  fseek (f, 0, SEEK_SET);
    4360}
    4461
    45 void unlock_image_db (Image *image) {
     62int load_image_db () {
     63
     64  int nimage;
     65
     66  /* read header */
     67  fseek (f, 0, SEEK_SET);
     68  if (!fits_fread_header (f, &header)) {
     69    Shutdown ("can't read image catalog %s", ImageCat);
     70  }
     71  fseek (f, header.size, SEEK_SET);
     72
     73  Nimage = 0;
     74  fits_scan (&header, "NIMAGES", "%d", 1, &Nimage);
     75  ALLOCATE (image, Image, Nimage);
     76
     77  nimage = Fread (image, sizeof(Image), Nimage, f, "image");
     78  if (nimage != Nimage) {
     79    Shutdown ("error reading images from db file");
     80  }
     81 
     82  return (TRUE);
     83}
     84
     85int save_image_db () {
     86
     87  int status;
     88  char line[1024];
     89  mode_t mode;
     90
     91  /* use cp to make backup copy */
     92  sprintf (line, "cp %s %s~", ImageCat, ImageCat);
     93  status = system (line);
     94  if (status) {
     95    Shutdown ("ERROR: unable to create %s~, exiting", ImageCat);
     96  }
     97  mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
     98  sprintf (line, "%s~", ImageCat);
     99  chmod (line, mode);
     100
     101  /* update header */
     102  fits_modify (&header, "NIMAGES", "%d", 1, Nimage);
     103
     104  /* write out data to already opened file */
     105  fseek (f, 0, SEEK_SET);
     106  Fwrite (header.buffer, 1, header.size, f, "char");
     107  Fwrite (image, sizeof(Image), Nimage, f, "image");
     108
     109  return (TRUE);
     110}
     111
     112void unlock_image_db () {
    46113
    47114  mode_t mode;
    48 
    49   /* protect wimage from interrupt signals */
    50   if (MODE == M_IMAGE) {
    51     SetProtect (TRUE);
    52     wimage (image);
    53     SetProtect (FALSE);
    54   }
    55115
    56116  fclearlockfile (ImageCat, f, LOCK, &dbstate);
  • trunk/Ohana/src/delstar/src/match_images.c

    r2463 r4680  
    11# include "delstar.h"
    22
    3 match_images (catalog, image, Nimage)
    4 Catalog catalog[];
    5 Image   image[];
    6 int Nimage;
    7 {
     3void match_images (Catalog *catalog, Image *image, int Nimage) {
    84 
    95  int j, k, found;
  • trunk/Ohana/src/delstar/src/parse_time.c

    r3517 r4680  
    11# include "delstar.h"
    22
    3 parse_time (Header *header) {
     3int parse_time (Header *header) {
    44
    55  double jd;
     
    3838  for (Ny = 0, c = strchr (DateMode, 'Y'); c != (char ) NULL; c = strchr (c + 1, 'Y'), Ny++);
    3939  if ((Ny != 2) && (Ny != 4)) {
    40     fprintf (stderr, "error in DATE-MODE format: %s\n", DateMode);
    41     Shutdown ();
     40    Shutdown ("error in DATE-MODE format: %s", DateMode);
    4241  }
    4342  py = strchr (DateMode, 'Y');
     
    4544  pd = strchr (DateMode, 'D');
    4645  if ((py == (char *) NULL) || (pm == (char *) NULL) || (pd == (char *) NULL)) {
    47     fprintf (stderr, "error in DATE-MODE format: %s\n", DateMode);
    48     Shutdown ();
     46    Shutdown ("error in DATE-MODE format: %s", DateMode);
    4947  }
    5048  if ((py > pm) && (py < pd)) {
    51     fprintf (stderr, "error in DATE-MODE format: %s\n", DateMode);
    52     Shutdown ();
     49    Shutdown ("error in DATE-MODE format: %s", DateMode);
    5350  }
    5451  if ((py > pd) && (py < pm)) {
    55     fprintf (stderr, "error in DATE-MODE format: %s\n", DateMode);
    56     Shutdown ();
     52    Shutdown ("error in DATE-MODE format: %s", DateMode);
    5753  }
    5854  mode = 0;
     
    6258  if ((py > pm) && (pm > pd)) { mode = 4; }  /* dd-mm-yyyy */
    6359  if (!mode) {
    64     fprintf (stderr, "error in DATE-MODE format: %s\n", DateMode);
    65     Shutdown ();
     60    Shutdown ("error in DATE-MODE format: %s", DateMode);
    6661  }
    6762
     
    9085  }
    9186  if (Nf != 3) {
    92     fprintf (stderr, "error in date entry (%s) or DATE-MODE format (%s)\n", line, DateMode);
    93     Shutdown ();
     87    Shutdown ("error in date entry (%s) or DATE-MODE format (%s)", line, DateMode);
    9488  }
    9589
  • trunk/Ohana/src/delstar/src/sort_lists.c

    r2463 r4680  
     1# include "delstar.h"
    12
    2 sort_lists (X, Y, S, N)
    3 float *X, *Y;
    4 int *S, N;
    5 {
     3void sort_lists (float *X, float *Y, int *S, int N) {
     4
    65  int l,j,ir,i;
    76  double tX, tY, tS;
     
    1514      tY = Y[l];
    1615      tS = S[l];
    17     }
    18     else {
     16    } else {
    1917      tX = X[ir];
    2018      X[ir] = X[0];
     
    4745  }
    4846}
     47
     48void sort_regions (GSCRegion *region, int N) {
     49
     50  int l,j,ir,i;
     51  GSCRegion tmp;
     52 
     53  l = N >> 1;
     54  ir = N - 1;
     55  for (;;) {
     56    if (l > 0) {
     57      l--;
     58      tmp = region[l];
     59    } else {
     60      tmp = region[ir];
     61      region[ir] = region[0];
     62      if (--ir == 0) {
     63        region[0] = tmp;
     64        return;
     65      }
     66    }
     67    i = l;
     68    j = (l << 1) + 1;
     69    while (j <= ir) {
     70      if (j < ir && region[j].DEC[0] < region[j+1].DEC[0]) j++;
     71      if (tmp.DEC[0] < region[j].DEC[0]) {
     72        region[i] = region[j];
     73        j += (i=j) + 1;
     74      }
     75      else j = ir + 1;
     76    }
     77    region[i] = tmp;
     78  }
     79}
     80
  • trunk/Ohana/src/delstar/src/wcatalog.c

    r2463 r4680  
    11# include "delstar.h"
    22
    3 wcatalog (Catalog *catalog) {
     3int wcatalog (Catalog *catalog) {
    44 
    5   int status;
    6 
    75  /* we'll leave these for now, but they are LONEOS specific */
    86  fits_modify (&catalog[0].header, "MARKSTAR", "%t", 1, FALSE);
     
    3432  }
    3533  fits_free_header (&catalog[0].header);
     34 
     35  return (TRUE);
    3636}
    3737
Note: See TracChangeset for help on using the changeset viewer.