IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 23, 2005, 8:55:22 PM (21 years ago)
Author:
eugene
Message:

converted to the libohana/dvo_image I/O routines; improvements in fits_db.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/getstar/src/gimages.c

    r2490 r4864  
    1010  Header header;
    1111 
    12   f = fopen (ImageCat, "r");
    13   if (f == (FILE *) NULL) {
    14     fprintf (stderr, "error opening image cat %s\n", ImageCat);
    15     exit (1);
    16   }
    17 
    18   /* read header */
    19   if (!fits_load_header (f, &header)) {
    20     if (VERBOSE) fprintf (stderr, "ERROR: can't read image catalog %s\n", ImageCat);
    21     exit (1);
    22   }
     12  set_db (&db);
     13  lock_image_db (&db, ImageCat);
     14  if (db[0].dbstate == LCK_EMPTY) Shutdown ("ERROR: No images in catalog %s (1)", db[0].filename);
     15  if (!dvo_image_load (db, VERBOSE, FALSE)) Shutdown ("can't read image catalog %s", db[0].filename);
     16  timage = fits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
     17  unlock_image_db (&db, ImageCat);
    2318
    2419  fits_scan (&header, "ZERO_PT", "%lf", 1, &zeropt);
     
    2621    fprintf (stderr, "ERROR: zero point in image table (%f:%s) inconsistent with zero point in image header (%f:%s)\n",
    2722             zeropt, ImageCat, ZeroPt, filename);
    28     exit (1);
    29   }
    30 
    31   /* advance to data segment */
    32   fseek (f, header.size, SEEK_SET);
    33 
    34   Nimage = 0;
    35   fits_scan (&header, "NIMAGES", "%d", 1, &Nimage);
    36   /* check that file size makes sense */
    37   if (stat (ImageCat, &filestatus) == -1) {
    38     fprintf (stderr, "ERROR: failed to get status of image catalog\n");
    39     exit (1);
    40   }
    41   size = Nimage*sizeof(Image) + header.size;
    42   if (size != filestatus.st_size) {
    43     fprintf (stderr, "ERROR: image catalog has inconsistent size\n");
    44     exit (1);
    45   }
    46 
    47   ALLOCATE (timage, Image, Nimage);
    48   nimage = Fread (timage, sizeof(Image), Nimage, f, "image");
    49   if (nimage != Nimage) {
    50     fprintf (stderr, "error reading images from table\n");
    5123    exit (1);
    5224  }
Note: See TracChangeset for help on using the changeset viewer.