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

Location:
trunk/Ohana/src/relphot
Files:
5 added
6 edited

Legend:

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

    r4805 r4864  
    4242$(SRC)/misc.$(ARCH).o            \
    4343$(SRC)/reload_catalogs.$(ARCH).o \
     44$(SRC)/image-db.$(ARCH).o \
    4445$(SRC)/free_catalogs.$(ARCH).o   \
     46$(SRC)/check_permissions.$(ARCH).o   \
    4547$(SRC)/setMrelFinal.$(ARCH).o    \
    4648$(SRC)/write_coords.$(ARCH).o    \
    4749$(SRC)/setExclusions.$(ARCH).o   \
     50$(SRC)/Shutdown.$(ARCH).o        \
     51$(SRC)/SetSignals.$(ARCH).o      \
    4852$(SRC)/wcatalog.$(ARCH).o
    4953
  • trunk/Ohana/src/relphot/include/relphot.h

    r4828 r4864  
    11# include <ohana.h>
    22# include <dvo.h>
     3# include <signal.h>
    34
    45/* # define GRID_V1 */
     
    118119void          findImages          PROTO((Catalog *catalog, int Ncatalog));
    119120int           findMosaics         PROTO((Catalog *catalog, int Ncatalog));
    120 Image        *find_images         PROTO((GSCRegion *region, int Nregion, int *Nimages, int **LineNum));
     121Image        *find_images         PROTO((FITS_DB *db, GSCRegion *region, int Nregion, int *Nimage, int **LineNum));
     122void set_db (FITS_DB *in);
     123int Shutdown (char *format, ...);
     124void TrapSignal (int sig);
     125void SetProtect (int mode);
     126int SetSignals ();
     127
    121128GSCRegion    *find_regions        PROTO((Image *image, int Nimage, int *Nregions, GSCRegion *fullregion));
    122129void          freeGridBins        PROTO((int Ncatalog));
     
    147154int           liststats           PROTO((double *value, double *dvalue, int N, StatType *stats));
    148155Catalog      *load_catalogs       PROTO((GSCRegion *region, int Nregion, GSCRegion *fullregion));
    149 GSCRegion    *load_images         PROTO((char *seed, int *nregion, GSCRegion *fullregion));
     156GSCRegion    *load_images         PROTO((FITS_DB *db, char *seed, int *nregion, GSCRegion *fullregion));
     157
     158void check_permissions (char *basefile);
     159void lock_image_db (FITS_DB *db, char *filename);
     160void unlock_image_db (FITS_DB *db);
     161void create_image_db (FITS_DB *db);
     162
    150163int           main                PROTO((int argc, char **argv));
    151164void          mark_images         PROTO((Image *image, int Nimage, Image *timage, int Ntimage));
     
    167180int           setExclusions       PROTO((Catalog *catalog, int Ncatalog));
    168181void          setMcal             PROTO((Catalog *catalog, int Poor));
    169 void          setMcalFinal        PROTO((Image *image, int Nimage));
     182void          setMcalFinal        PROTO(());
    170183int           setMcalOutput       PROTO((Catalog *catalog, int Ncatalog));
    171184void          setMgrid            PROTO((Catalog *catalog));
  • trunk/Ohana/src/relphot/src/MosaicOps.c

    r4796 r4864  
    167167}
    168168
    169 void setMcalFinal (Image *image, int Nimage) {
    170 
    171   int i, j, im;
     169void setMcalFinal () {
     170
     171  int i, j, im, Nimage;
     172  Image *image;
    172173
    173174  if (!MOSAICNAME[0]) return;
     175
     176  image = getimages (&Nimage);
    174177
    175178  for (i = 0; i < Nmosaic; i++) {
  • trunk/Ohana/src/relphot/src/find_images.c

    r4796 r4864  
    77   images */
    88
    9 Image *find_images (GSCRegion *region, int Nregion, int *Nimages, int **LineNum) {
    10  
    11   Header header;
     9Image *find_images (FITS_DB *db, GSCRegion *region, int Nregion, int *Nimage, int **LineNum) {
     10 
    1211  Image *timage, *image;
    13   int i, j, k, m, found, nimage, Nimage, NIMAGE;
    14   int status, InRange, ecode;
    15   FILE *f;
     12  int i, j, k, m, found, nimage, Ntimage, NIMAGE;
     13  int InRange, ecode;
    1614  double Xc[5], Yc[5], Xi[5], Yi[5], r, d, dx, dy;
    1715  int *line_number;
     
    2927  strcpy (tcoords.ctype, "RA---TAN");
    3028
    31   /* check if image datafile exists, get header, number of images */
    32   if (!fits_read_header (ImageCat, &header)) {
    33     fprintf (stderr, "ERROR: No images in catalog %s (1)\n", ImageCat);
    34     exit (0);
    35   }
    36   Nimage = 0;
    37   fits_scan (&header, "NIMAGES", "%d", 1, &Nimage);
    38   if (Nimage == 0) {
    39     fprintf (stderr, "ERROR: No images in catalog %s (1)\n", ImageCat);
    40     exit (0);
    41   }
    42 
    43   /* get ready to read data on images */
    44   f = fopen (ImageCat, "r");
    45   if (f == (FILE *) NULL) {
    46     fprintf (stderr, "ERROR: trouble opening Image catalog: %s (2)\n", ImageCat);
    47     exit (0);
    48   }
    49   fseek (f, header.size, SEEK_SET);
    50 
    51   /* load all images */
    52   ALLOCATE (timage, Image, Nimage);
    53   status = Fread (timage, sizeof(Image), Nimage, f, "image");
    54   if (status != Nimage) {
    55     fprintf (stderr, "ERROR: couldn't read images from image catalog: %s\n", ImageCat);
    56     exit (0);
    57   }
     29  timage = fits_table_get_Image (&db[0].ftable, &Ntimage, &db[0].swapped);
    5830
    5931  nimage = 0;
     
    6234  ALLOCATE (line_number, int, NIMAGE);
    6335 
    64   for (i = 0; i < Nimage; i++) {
     36  for (i = 0; i < Ntimage; i++) {
    6537     
    6638    /* select images by photcode */
     
    153125  REALLOCATE (line_number, int, MAX (nimage, 1));
    154126
    155   free (timage);
    156   *Nimages = nimage;
     127  *Nimage  = nimage;
    157128  *LineNum = line_number;
    158   fclose (f);
    159129  return (image);
    160130}
  • trunk/Ohana/src/relphot/src/load_images.c

    r2486 r4864  
    11# include "relphot.h"
    22
    3 static int   Nimage;
    4 static int   *Line;
    5 static Image *image;
    6 
    7 GSCRegion *load_images (char *seed, int *nregion, GSCRegion *fullregion) {
     3GSCRegion *load_images (FITS_DB *db, char *seed, int *nregion, GSCRegion *fullregion) {
    84
    95  GSCRegion *region;
    10   int       Nregion, Ntimage;
    11   Image     *timage;
     6  int        Nregion;
     7  Image     *image;
     8  int       *Line;
     9  int        Nimage;
     10
     11  if (db[0].dbstate == LCK_EMPTY) Shutdown ("ERROR: No images in catalog %s (1)", db[0].filename);
     12
     13  /* read entire db table */
     14  if (!dvo_image_load (db, VERBOSE, FALSE)) Shutdown ("can't read image catalog %s", db[0].filename);
    1215
    1316  region = name_region (seed, &Nregion);
    1417
    1518  /* find images which supplied all measurements */
    16   timage = find_images (region, Nregion, &Ntimage, &Line);
     19  image = find_images (db, region, Nregion, &Nimage, &Line);
    1720  free (Line);
    1821
    1922  /* find all region files which touch images */
    20   region = find_regions (timage, Ntimage, &Nregion, fullregion);
    21   free (timage);
     23  region = find_regions (image, Nimage, &Nregion, fullregion);
     24  free (image);
    2225
    2326  /* find images which supplied all measurements for all regions */
    24   image = find_images (region, Nregion, &Nimage, &Line);
     27  image = find_images (db, region, Nregion, &Nimage, &Line);
    2528  getfullregion (image, Nimage, fullregion);
     29
     30  fits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, Line, Nimage);
    2631
    2732  initImages (image, Nimage);
     
    3035  *nregion = Nregion;
    3136  return (region);
    32 
    3337}
    34 
    35 void wimages () {
    36  
    37   int i, status, mode;
    38   FILE *f;
    39   Header header;
    40 
    41   setMcalFinal (image, Nimage);
    42 
    43   if (!fits_read_header (ImageCat, &header)) {
    44     fprintf (stderr, "ERROR: can't find %s\n", ImageCat);
    45     exit (0);
    46   }
    47  
    48   f = fopen (ImageCat, "r+");
    49   if (f == NULL) {
    50     fprintf (stderr, "ERROR: can't open image catalog file to append: %s\n", ImageCat);
    51     exit (0);
    52   }
    53   mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
    54   chmod (ImageCat, mode);
    55 
    56   if (VERBOSE) fprintf (stderr, "writing out %d images\n", Nimage);
    57   for (i = 0; i < Nimage; i++) {
    58     fseek (f, header.size + Line[i]*sizeof(Image), SEEK_SET);
    59     status = Fwrite (&image[i], sizeof(Image), 1, f, "image");
    60     if (status != 1) {
    61       fprintf (stderr, "ERROR: failure writing image data to catalog %s\n", ImageCat);
    62       exit (0);
    63     }
    64   }
    65 
    66   fclose (f);
    67 }
  • trunk/Ohana/src/relphot/src/relphot.c

    r4796 r4864  
    77  Catalog *catalog;
    88  GSCRegion fullregion, *region;
     9  FITS_DB db;
    910
    1011  /* get configuration info, args */
    1112  initialize (argc, argv);
    1213
     14  set_db (&db);
     15  lock_image_db (&db, ImageCat);
     16
    1317  /* load regions and images based on seed region */
    14   region = load_images (argv[1], &Ncatalog, &fullregion);
     18  region = load_images (&db, argv[1], &Ncatalog, &fullregion);
    1519
    1620  /* load catalog data from region files */
     
    7983  /* load catalog data from region files, update Mrel include all data */
    8084  reload_catalogs (region, Ncatalog, &fullregion);
    81   wimages ();
     85  setMcalFinal ();
     86  dvo_image_update (&db, VERBOSE);
     87  unlock_image_db (&db);
     88
    8289  exit (0);
    8390}
Note: See TracChangeset for help on using the changeset viewer.