IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8342


Ignore:
Timestamp:
Aug 14, 2006, 6:27:39 PM (20 years ago)
Author:
eugene
Message:

updates to the dvo image/catalog APIs

Location:
trunk/Ohana
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/doc/dvotools.txt

    r7689 r8342  
    44photometric and astrometric calibrations needed by Pan-STARRS, ie the
    55AP Survey.
     6
     7dvo DB manipulations:
     8
     9  - create a subset of a database (restrict by magnitude limits, time,
     10    region, etc)
     11  - re-organize the table structure using a new SkyTable file
     12  - remove the automatic extension of the secfilt table; make a mode to
     13    add a new secondary filter
     14
     15dvo DB organization mods:
     16
     17  - drop the primary photcodes and put all primaries in the 'secfilt' table
     18  - construct a FITS table for the photcodes
     19  - tables for the camera and filter data which is currently in the config
     20  - tools to update the photcode table
    621
    722addstar : need a few additional new variations on the addstar concept
  • trunk/Ohana/src/addstar/Makefile

    r7780 r8342  
    3535$(SRC)/find_subset.$(ARCH).o \
    3636$(SRC)/fakeimage.$(ARCH).o \
    37 $(SRC)/gcatalog.$(ARCH).o \
    3837$(SRC)/get2mass.$(ARCH).o \
    3938$(SRC)/get2mass_as.$(ARCH).o \
     
    4948$(SRC)/gimages.$(ARCH).o \
    5049$(SRC)/gstars.$(ARCH).o \
    51 $(SRC)/image-db.$(ARCH).o \
    5250$(SRC)/in_image.$(ARCH).o \
    53 $(SRC)/load_pt_catalog.$(ARCH).o \
    5451$(SRC)/load_subpix.$(ARCH).o \
    55 $(SRC)/mkcatalog.$(ARCH).o \
    5652$(SRC)/opening_angle.$(ARCH).o \
    5753$(SRC)/parse_time.$(ARCH).o \
     
    6157$(SRC)/sort_lists.$(ARCH).o \
    6258$(SRC)/update_coords.$(ARCH).o \
    63 $(SRC)/wcatalog.$(ARCH).o \
    6459$(SRC)/Shutdown.$(ARCH).o \
    6560$(SRC)/SkyTableFromTychoIndex.$(ARCH).o \
  • trunk/Ohana/src/addstar/src/addstar.c

    r8328 r8342  
    3030  overlap = NULL;
    3131  set_db (&db);
    32   if (options.update) {
    33     catalog.catflags = LOAD_AVES | LOAD_MEAS_META | LOAD_MISS | LOAD_SECF;
    34   } else {
    35     catalog.catflags = LOAD_AVES | LOAD_MEAS      | LOAD_MISS | LOAD_SECF;
    36   }
    3732
    3833  /* we use the image table to lock db access -- perhaps this is not necessary? */
     34  db.mode = dvo_catalog_catmode (CATMODE);
     35  db.format = dvo_catalog_catformat (CATFORMAT);
    3936  status = dvo_image_lock (&db, ImageCat, 3600.0, LCK_XCLD);
    4037  if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename);
     
    6158
    6259      if (db.dbstate == LCK_EMPTY) {
    63         create_image_db (&db);
     60        dvo_image_create (&db, ZeroPt);
    6461      } else {
    6562        if (!dvo_image_load (&db, VERBOSE, FORCE_READ)) {
     
    9491  for (i = 0; i < skylist[0].Nregions; i++) {
    9592
     93    // set the parameters which guide catalog open/load/create
     94    catalog.catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
     95    catalog.catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
    9696    catalog.filename = skylist[0].filename[i];
    97     catalog.catformat = dvo_catalog_format (CATFORMAT);  // set the default catformat from config data
    98     catalog.catmode   = dvo_catalog_mode (CATMODE);      // set the default catmode from config data
    99     catalog.lockmode  = LCK_XCLD;
    100     dvo_catalog_open (&catalog, skylist[0].regions[i], Nsecfilt, "w");
     97    catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
     98    catalog.catflags = LOAD_AVES | LOAD_MEAS      | LOAD_MISS | LOAD_SECF;
     99    if (options.update) catalog.catflags = LOAD_AVES | LOAD_MEAS_META | LOAD_MISS | LOAD_SECF;
    101100
    102     /* for only_match, skip empty catalogs XXX EAM : this leaves behind empty files */
     101    // an error exit status here is a significant error
     102    if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) {
     103      fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", catalog.filename);
     104      exit (2);
     105    }
     106
     107    // Nave_disk == 0 implies an empty catalog file
     108    // for only_match, skip empty catalogs
    103109    if ((catalog.Nave_disk == 0) && options.only_match) {
    104110      dvo_catalog_unlock (&catalog);
    105       free (catalog.filename);  // can this be done within the dvo_catalog_free function??
    106111      dvo_catalog_free (&catalog);
    107112      continue;
     
    138143    }
    139144
    140     if (Nsubset == 0) {
    141       // XXX remove empty catalogs
    142       unlock_catalog (&catalog);
    143     } else {
     145    // write out catalog, if appropriate
     146    if (Nsubset && !options.only_images) {
    144147      SetProtect (TRUE);
    145       if (!options.only_images) dvo_catalog_save (&catalog);
     148      dvo_catalog_save (&catalog, VERBOSE);
    146149      SetProtect (FALSE);
    147       dvo_catalog_unlock (&catalog);
    148150    }
     151    dvo_catalog_unlock (&catalog);
    149152    dvo_catalog_free (&catalog);
    150     free (catalog.filename); // XXX ????
    151153
    152154    if (options.mode == M_REFCAT) free (stars);
    153155  }
    154156
     157  // XXX is it necessary to lock the image catalog during this entire process?
    155158  if (options.calibrate) { FindCalibration (&image); }
    156159
    157160  if (db.dbstate == LCK_EMPTY) {
    158     create_image_db (&db);
     161    if (VERBOSE) fprintf (stderr, "can't find %s, creating a new one\n", ImageCat);
     162    dvo_image_create (&db, ZeroPt);
    159163  }
    160164 
     
    173177  gettimeofday (&stop, NULL);
    174178  dtime = DTIME (stop, start);
    175   fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for %5d stars, %6d average, %7d measure\n", dtime, Nstars, Naverage, Nmeasure);
     179  fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for %5d stars, %6lld average, %7lld measure\n", dtime, Nstars, Naverage, Nmeasure);
    176180  exit (0);
    177181}
  • trunk/Ohana/src/addstar/src/wcatalog.c

    r8001 r8342  
    55  /* output CATMODE and CATFORMAT are set by mkcatalog
    66     or by mode and format of existing data */
    7 
    8   /* should this be moved into save_catalog?? */
    9   gfits_modify (&catalog[0].header, "SORTED",  "%t", 1, catalog[0].sorted);
    107
    118  /* if partial load, must use update */
     
    2320}
    2421
    25 void free_catalog (Catalog *catalog) {
    26 
    27   /* free, initialize data structures */
    28   if (catalog[0].average != NULL) {
    29     free (catalog[0].average);
    30     catalog[0].Naverage = 0;
    31   }
    32   if (catalog[0].measure != NULL) {
    33     free (catalog[0].measure);
    34     catalog[0].Nmeasure = 0;
    35   }
    36   if (catalog[0].missing != NULL) {
    37     free (catalog[0].missing);
    38     catalog[0].Nmissing = 0;
    39   }
    40   if (catalog[0].secfilt != NULL) {
    41     free (catalog[0].secfilt);
    42     catalog[0].Nsecfilt = 0;
    43   }
    44   gfits_free_header (&catalog[0].header);
    45 }
  • trunk/Ohana/src/libdvo/Makefile

    r8295 r8342  
    3737$(SRC)/dvo_catalog_mef.$(ARCH).o       \
    3838$(SRC)/dvo_catalog_split.$(ARCH).o     \
     39$(SRC)/dvo_catalog_create.$(ARCH).o    \
    3940$(SRC)/dvo_convert.$(ARCH).o           \
    4041$(SRC)/dvo_convert_elixir.$(ARCH).o    \
  • trunk/Ohana/src/libdvo/include/dvo.h

    r8328 r8342  
    268268
    269269/** dvo_catalog APIs */
    270 void dvo_catalog_init (Catalog *catalog);
    271 void dvo_catalog_create (SkyRegion *region, Catalog *catalog, int Nsecfilt, char *catformat, char *catmode);
     270void dvo_catalog_init (Catalog *catalog, int complete);
     271void dvo_catalog_create (SkyRegion *region, Catalog *catalog, int Nsecfilt);
     272void dvo_catalog_free (Catalog *catalog);
     273int dvo_catalog_check (Catalog *catalog, int Nsecfilt, int extend);
    272274int dvo_catalog_lock (Catalog *catalog, int lockmode);
    273275int dvo_catalog_unlock (Catalog *catalog);
    274276int dvo_catalog_load (Catalog *catalog, int VERBOSE);
     277int dvo_catalog_open (Catalog *catalog, SkyRegion *region, int VERBOSE, char *iomode);
    275278int dvo_catalog_save (Catalog *catalog, char VERBOSE);
    276279int dvo_catalog_update (Catalog *catalog, char VERBOSE);
     280int dvo_catalog_catformat (char *catformat);
     281int dvo_catalog_catmode (char *catmode);
    277282
    278283/* catmode-specific APIs */
     
    333338int dvo_image_save_raw (FITS_DB *db, int VERBOSE);
    334339int dvo_image_addrows (FITS_DB *db, Image *new, int Nnew);
     340void dvo_image_create (FITS_DB *db, double ZeroPoint);
    335341
    336342int FtableToImage (FTable *ftable, Header *theader, int *format);
  • trunk/Ohana/src/libdvo/src/dvo_catalog.c

    r8328 r8342  
    1 # include <ohana.h>
    21# include <dvo.h>
    32# define DEBUG 1
    43
    5 void dvo_catalog_init (Catalog *catalog) {
    6 
    7   catalog[0].f = NULL;
    8   catalog[0].filename = NULL;
    9 
    10   gfits_init_header (&catalog[0].header);
    11 
     4int dvo_catalog_catformat (char *catformat) {
     5 
     6  /* set the specified CATFORMAT */
     7  if (!strcasecmp (catformat, "INTERNAL"))  return (DVO_FORMAT_INTERNAL);
     8  if (!strcasecmp (catformat, "LONEOS"))    return (DVO_FORMAT_LONEOS);
     9  if (!strcasecmp (catformat, "ELIXIR"))    return (DVO_FORMAT_ELIXIR);
     10  if (!strcasecmp (catformat, "PANSTARRS")) return (DVO_FORMAT_PANSTARRS);
     11  if (!strcasecmp (catformat, "PMTEST"))    return (DVO_FORMAT_PMTEST);
     12  return (DVO_FORMAT_UNDEF);
     13}
     14
     15int dvo_catalog_catmode (char *catmode) {
     16
     17  /* set the specified CATMODE */
     18  if (!strcasecmp (catmode, "RAW"))   return (DVO_MODE_RAW);
     19  if (!strcasecmp (catmode, "MEF"))   return (DVO_MODE_MEF);
     20  if (!strcasecmp (catmode, "SPLIT")) return (DVO_MODE_SPLIT);
     21  return (DVO_MODE_UNDEF);
     22}
     23
     24// init all data, or just catalog data
     25void dvo_catalog_init (Catalog *catalog, int complete) {
     26
     27  // the following are used to guide open/create/load
     28  if (complete) {
     29    catalog[0].f = NULL;
     30    catalog[0].filename = NULL;
     31
     32    catalog[0].lockmode = 0;
     33    catalog[0].catmode  = 0;
     34    catalog[0].catformat = 0;
     35    catalog[0].catflags = 0;
     36    catalog[0].sorted = 0;
     37
     38    gfits_init_header (&catalog[0].header);
     39  }
     40
     41  // the following describe the catalog files on disk
    1242  catalog[0].average = NULL;
    1343  catalog[0].measure = NULL;
     
    3060  catalog[0].secfilt_catalog = NULL;
    3161
    32   /* extra catalog information */
    33   catalog[0].lockmode = 0;
    34   catalog[0].catmode  = 0;
    35   catalog[0].catformat = 0;
    36   catalog[0].catflags = 0;
    37   catalog[0].sorted = 0;
    38  
    3962  /* pointers for data manipulation */
    4063  catalog[0].found = NULL;
     
    7194int dvo_catalog_unlock (Catalog *catalog) {
    7295
    73   int dbstate;
     96  int fd, dbstate;
     97  struct stat filestat;
    7498
    7599  if (catalog[0].f == (FILE *) NULL) return (2);
    76100  // fprintf (stderr, "unlocking: %s\n", catalog[0].filename);
     101
     102  // attempt to unlink an empty file
     103  fd = fileno (catalog[0].f);
     104  if (fstat (fd, &filestat)) {
     105    if (filestat.st_size == 0) {
     106      unlink (catalog[0].filename);
     107    }
     108  }
     109
    77110  fclearlockfile (catalog[0].filename, catalog[0].f, catalog[0].lockmode, &dbstate);
    78111
     
    85118}
    86119
    87 int dvo_catalog_open (Catalog *catalog, int NSECFILT, int VERBOSE, int MODE) {
    88 
     120// open an existing catalog file or or create a new one as needed (iomode == "w")
     121// returns FALSE if a catalog could not be opened
     122// returns TRUE if the catalog was empty
     123int dvo_catalog_open (Catalog *catalog, SkyRegion *region, int VERBOSE, char *iomode) {
     124
     125  int Nsecfilt;
     126  int readonly;
     127
     128  readonly = -1;
     129  if (!strcasecmp (iomode, "r")) readonly = TRUE;
     130  if (!strcasecmp (iomode, "w")) readonly = FALSE;
     131  if (readonly == -1) return (FALSE);
     132
     133  catalog[0].lockmode  = LCK_XCLD;
     134  if (readonly) catalog[0].lockmode  = LCK_SOFT;
     135
     136  // XXX make a backup?  always?
    89137  if (!check_file_access (catalog[0].filename, TRUE, VERBOSE)) {
    90     if (VERBOSE) fprintf (stderr, "no permission to access %f\n", catalog[0].filename);
     138    if (VERBOSE) fprintf (stderr, "no permission to access %s\n", catalog[0].filename);
    91139    return (FALSE);
    92140  }
     
    94142  if (VERBOSE) fprintf (stderr, "adding to %s\n", catalog[0].filename);
    95143   
     144  // save the expected Nsecfilt value for testing
     145  Nsecfilt = catalog[0].Nsecfilt;
     146
    96147  switch (dvo_catalog_lock (catalog, catalog[0].lockmode)) {
    97148  case 0:
     
    110161    break;
    111162  case 2:
    112     if (MODE == DVO_READ_ONLY) return (FALSE);
    113     dvo_catalog_create (region, catalog, NSECFILT); /* fills in new header info */
     163    if (readonly) return (TRUE);
     164    dvo_catalog_create (region, catalog, Nsecfilt); /* fills in new header info */
    114165    if (VERBOSE) fprintf (stderr, "creating new file %s\n", catalog[0].filename);
    115166    break;
     
    118169}
    119170
     171// load an existing dvo_catalog currenly, the catmode information is carried per
     172// catalog.  the user-set value of catmode will set the output mode for new
     173// tables an old table will keep its mode.
    120174int dvo_catalog_load (Catalog *catalog, int VERBOSE) {
    121175 
    122   int Naxis, split;
     176  int Naxis, split, status;
    123177  char measure[80];
    124178
    125   /** we will have to check catmode for MYSQL before reading from the file **/
    126 
    127   gfits_fread_header (catalog[0].f, &catalog[0].header);
     179  // load the main catalog header, determine characteristics
     180  if (!gfits_fread_header (catalog[0].f, &catalog[0].header)) {
     181    if (VERBOSE) fprintf (stderr, "failure to read main catalog header\n");
     182    return (FALSE);
     183  }
     184  // check if the table has been sorted or not
     185  status = gfits_scan (&catalog[0].header, "SORTED", "%t", 1, &catalog[0].sorted);
     186  if (!status) catalog[0].sorted = TRUE;
     187
     188  // determine catmode
    128189  if (!gfits_scan (&catalog[0].header, "NAXIS", "%d", 1, &Naxis)) {
    129190    if (VERBOSE) fprintf (stderr, "can't determine catalog db mode\n");
    130191    return (FALSE);
    131192  }
     193  catalog[0].catmode = DVO_MODE_MEF;
    132194  split = gfits_scan (&catalog[0].header, "MEASURE", "%s", 1, measure);
    133 
    134   /* currenly, the catmode information is carried per table.
    135      the user-set value of catmode will set the output mode for new tables
    136      an old table will keep its mode
    137   */
    138 
    139   /* check if the table has been sorted or not */
    140   status = gfits_scan (&catalog[0].header, "SORTED", "%t", 1, &catalog[0].sorted);
    141   if (!status) catalog[0].sorted = TRUE;
    142 
    143   catalog[0].catmode = DVO_MODE_MEF;
    144   catalog[0].catformat = DVO_FORMAT_UNDEF;
    145195  if (split) catalog[0].catmode = DVO_MODE_SPLIT;
    146196  if (Naxis == 2) catalog[0].catmode = DVO_MODE_RAW;
    147197  /* don't use Naxis == 2 and split mode! */
     198
     199  // catformat determined in dvo_catalog_load_XXX function
     200  catalog[0].catformat = DVO_FORMAT_UNDEF;
    148201
    149202  catalog[0].average = NULL;
     
    172225}
    173226
     227// write out the data, unlink if empty?
    174228int dvo_catalog_save (Catalog *catalog, char VERBOSE) {
     229
     230  // set the 'sorted' header keyword
     231  gfits_modify (&catalog[0].header, "SORTED",  "%t", 1, catalog[0].sorted);
     232
     233  if (catalog[0].Nmeas_off != 0) {
     234    if (!dvo_catalog_update (catalog, VERBOSE)) {
     235      return (FALSE);
     236    }
     237    return (TRUE);
     238  }
    175239
    176240  switch (catalog[0].catmode) {
     
    210274      break;
    211275    default:
     276      fprintf (stderr, "failure updating catalog\n");
    212277      fprintf (stderr, "invalid catalog mode\n");
    213278      exit (2);
     
    222287
    223288  if (catalog[0].Nsecfilt == Nsecfilt) return (TRUE);
    224 
    225289  if (catalog[0].Nsecfilt > Nsecfilt) return (FALSE);
    226 
    227290  if ((catalog[0].Nsecfilt < Nsecfilt) && !extend) return (FALSE);
    228291
    229292  if ((catalog[0].Nsecfilt < Nsecfilt) && extend) {
    230 
    231293    Nextra = Nsecfilt - catalog[0].Nsecfilt;
    232294    insec = catalog[0].secfilt;
     
    251313}
    252314
     315void dvo_catalog_free (Catalog *catalog) {
     316
     317  /* free, initialize data structures */
     318  if (catalog[0].average != NULL) {
     319    free (catalog[0].average);
     320    catalog[0].Naverage = 0;
     321  }
     322  if (catalog[0].measure != NULL) {
     323    free (catalog[0].measure);
     324    catalog[0].Nmeasure = 0;
     325  }
     326  if (catalog[0].missing != NULL) {
     327    free (catalog[0].missing);
     328    catalog[0].Nmissing = 0;
     329  }
     330  if (catalog[0].secfilt != NULL) {
     331    free (catalog[0].secfilt);
     332    catalog[0].Nsecfilt = 0;
     333  }
     334  gfits_free_header (&catalog[0].header);
     335  // free (catalog[0].filename);
     336}
     337
    253338/*
    254339  mode   : items to read (LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF)
  • trunk/Ohana/src/libdvo/src/dvo_catalog_create.c

    r8328 r8342  
    1 # include <ohana.h>
    21# include <dvo.h>
    32# define DEBUG 1
    43
    54// create a new dvo catalog file (if split, lock extra files as well?)
    6 void dvo_catalog_create (SkyRegion *region, Catalog *catalog, int Nsecfilt, char *catformat, char *catmode) {
     5// catalog internals which must be set:
     6// catalog[0].filename
     7// catalog[0].catmode
     8// catalog[0].catformat (used by dvo_catalog_save)
     9// catalog[0].lockmode
     10void dvo_catalog_create (SkyRegion *region, Catalog *catalog, int Nsecfilt) {
    711
    8   int length, status;
     12  int length;
    913  char *path, *root, *file, *line;
    1014  time_t now;
     
    1216  if (DEBUG) fprintf (stderr, "new catalog file: %s\n", catalog[0].filename);
    1317
    14   dvo_catalog_init (catalog);
    15 
    16   /* set the recommended CATFORMAT */
    17   catalog[0].catformat = DVO_FORMAT_UNDEF;
    18   if (!strcasecmp (catformat, "INTERNAL"))  catalog[0].catformat = DVO_FORMAT_INTERNAL;
    19   if (!strcasecmp (catformat, "LONEOS"))    catalog[0].catformat = DVO_FORMAT_LONEOS;
    20   if (!strcasecmp (catformat, "ELIXIR"))    catalog[0].catformat = DVO_FORMAT_ELIXIR;
    21   if (!strcasecmp (catformat, "PANSTARRS")) catalog[0].catformat = DVO_FORMAT_PANSTARRS;
    22   if (!strcasecmp (catformat, "PMTEST"))    catalog[0].catformat = DVO_FORMAT_PMTEST;
    23   if (catalog[0].catformat == DVO_FORMAT_UNDEF) {
    24     fprintf (stderr, "invalid output catalog format\n");
    25     exit (1);
    26   }
    27 
    28   /* set the recommended CATMODE */
    29   catalog[0].catmode = DVO_MODE_UNDEF;
    30   if (!strcasecmp (catmode, "RAW"))   catalog[0].catmode = DVO_MODE_RAW;
    31   if (!strcasecmp (catmode, "MEF"))   catalog[0].catmode = DVO_MODE_MEF;
    32   if (!strcasecmp (catmode, "SPLIT")) catalog[0].catmode = DVO_MODE_SPLIT;
    33   if (catalog[0].catmode == DVO_MODE_UNDEF) {
    34     fprintf (stderr, "invalid output catalog mode\n");
    35     exit (1);
    36   }
     18  // init the data values, not the internals listed above
     19  dvo_catalog_init (catalog, FALSE);
    3720
    3821  /* for RAW mode, make header a fake image */
     
    5235    /* define measure catalog file */
    5336    ALLOCATE (catalog[0].measure_catalog, Catalog, 1);
    54     dvo_catalog_init (catalog[0].measure_catalog);
     37    dvo_catalog_init (catalog[0].measure_catalog, TRUE);
    5538
    5639    /* create basic data for measure catalog file */
     
    6447    /* define missing catalog file */
    6548    ALLOCATE (catalog[0].missing_catalog, Catalog, 1);
    66     dvo_catalog_init (catalog[0].missing_catalog);
     49    dvo_catalog_init (catalog[0].missing_catalog, TRUE);
    6750
    6851    /* create basic data for missing catalog file */
     
    7659    /* define secfilt catalog file */
    7760    ALLOCATE (catalog[0].secfilt_catalog, Catalog, 1);
    78     dvo_catalog_init (catalog[0].secfilt_catalog);
     61    dvo_catalog_init (catalog[0].secfilt_catalog, TRUE);
    7962
    8063    /* create basic data for secfilt catalog file */
     
    9073    // lock the additional split files
    9174    // XXX clear residual locks if we fail
    92     if (lock_catalog (catalog[0].measure_catalog, catalog[0].lockmode) != 2) {
     75    if (dvo_catalog_lock (catalog[0].measure_catalog, catalog[0].lockmode) != 2) {
    9376      fprintf (stderr, "error with file lock\n");
    9477      exit (2);
    9578    }
    96     if (lock_catalog (catalog[0].missing_catalog, catalog[0].lockmode) != 2) {
     79    if (dvo_catalog_lock (catalog[0].missing_catalog, catalog[0].lockmode) != 2) {
    9780      fprintf (stderr, "error with file lock\n");
    9881      exit (2);
    9982    }
    100     if (lock_catalog (catalog[0].secfilt_catalog, catalog[0].lockmode) != 2) {
     83    if (dvo_catalog_lock (catalog[0].secfilt_catalog, catalog[0].lockmode) != 2) {
    10184      fprintf (stderr, "error with file lock\n");
    10285      exit (2);
  • trunk/Ohana/src/libdvo/src/dvo_catalog_split.c

    r8328 r8342  
    7878
    7979    /* lock & open catalog file */
    80     if (lock_catalog (measure, catalog[0].lockmode) != 1) {
     80    if (dvo_catalog_lock (measure, catalog[0].lockmode) != 1) {
    8181      fprintf (stderr, "cannot access measure file %s\n", measure[0].filename);
    8282      exit (2);
     
    123123
    124124    /* lock & open catalog file */
    125     if (lock_catalog (measure, catalog[0].lockmode) != 1) {
     125    if (dvo_catalog_lock (measure, catalog[0].lockmode) != 1) {
    126126      fprintf (stderr, "cannot access measure file %s\n", measure[0].filename);
    127127      exit (2);
     
    158158
    159159    /* lock & open catalog file */
    160     if (lock_catalog (missing, catalog[0].lockmode) != 1) {
     160    if (dvo_catalog_lock (missing, catalog[0].lockmode) != 1) {
    161161      fprintf (stderr, "cannot access missing file %s\n", missing[0].filename);
    162162      exit (2);
     
    208208
    209209    /* lock & open catalog file */
    210     if (lock_catalog (secfilt, catalog[0].lockmode) != 1) {
     210    if (dvo_catalog_lock (secfilt, catalog[0].lockmode) != 1) {
    211211      fprintf (stderr, "cannot access secfilt file %s\n", secfilt[0].filename);
    212212      exit (2);
  • trunk/Ohana/src/libdvo/src/dvo_image.c

    r7080 r8342  
    148148  return (TRUE);
    149149}
     150
     151void dvo_image_create (FITS_DB *db, double ZeroPoint) {
     152
     153  /* create new header */
     154  gfits_init_header (&db[0].header);
     155
     156  /* check the mode */
     157  switch (db[0].mode) {
     158    case DVO_MODE_RAW:
     159      /* make header a fake image */
     160      db[0].header.bitpix   = 16;
     161      db[0].header.Naxes    = 2;
     162      db[0].header.Naxis[0] = 1;
     163      db[0].header.Naxis[1] = 1;
     164      gfits_create_header (&db[0].header);
     165      break;
     166    case DVO_MODE_MEF:
     167    case DVO_MODE_SPLIT:
     168      db[0].header.extend   = TRUE;
     169      gfits_create_header (&db[0].header);
     170      db[0].mode = DVO_MODE_MEF;
     171      break;
     172    default:
     173      fprintf (stderr, "invalid output catalog mode\n");
     174      exit (1);
     175  }
     176
     177  /* check the format */
     178  if (db[0].format == DVO_FORMAT_UNDEF) {
     179    fprintf (stderr, "invalid output catalog format\n");
     180    exit (1);
     181  }
     182
     183  gfits_create_matrix (&db[0].header, &db[0].matrix);
     184  gfits_table_set_Image (&db[0].ftable, NULL, 0);
     185
     186  gfits_modify (&db[0].header, "NIMAGES", "%d", 1, 0);
     187  gfits_modify (&db[0].header, "ZERO_PT", "%lf", 1, ZeroPoint);
     188
     189  if (db[0].format == DVO_FORMAT_INTERNAL)  gfits_modify (&db[0].header, "FORMAT", "%s", 1, "INTERNAL");
     190  if (db[0].format == DVO_FORMAT_LONEOS)    gfits_modify (&db[0].header, "FORMAT", "%s", 1, "LONEOS");
     191  if (db[0].format == DVO_FORMAT_ELIXIR)    gfits_modify (&db[0].header, "FORMAT", "%s", 1, "ELIXIR");
     192  if (db[0].format == DVO_FORMAT_PANSTARRS) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PANSTARRS");
     193  if (db[0].format == DVO_FORMAT_PMTEST)    gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PMTEST");
     194 
     195  return;
     196}
  • trunk/Ohana/src/libdvo/src/skyregion_gsc.c

    r8328 r8342  
    4141
    4242  int i, j, skipLines, Nzones;
    43   char temp[80], name[80];
    4443
    4544  Header theader;
    4645  FTable ftable;
    4746  SkyTable *skytable;
    48   SkyRegion *regions;
    4947  SkyTable *band;
    5048  SkyTable L0, L1, L2, L3, L4;
     
    202200void SkyTableSort (SkyTable *table) {
    203201
    204   int i, j, k, l, ir, N;
     202  int i, j, l, ir, N;
    205203  SkyRegion *regions;
    206204  SkyRegion tempregion;
     
    251249 
    252250  float Dmin, Dmax, dDec;
    253   int i, Nz, NZ, Ndiv, Nregions;
     251  int i, Nz, NZ, Nregions;
    254252  SkyRegion *regions;
    255253  SkyRegionZone *zones;
Note: See TracChangeset for help on using the changeset viewer.