IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8630


Ignore:
Timestamp:
Aug 26, 2006, 9:53:48 AM (20 years ago)
Author:
eugene
Message:

updating photdbc to be a more general DVO db copy program

Location:
trunk/Ohana/src/photdbc
Files:
2 added
3 deleted
7 edited

Legend:

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

    r5242 r8630  
    2424$(SRC)/ConfigInit.$(ARCH).o        \
    2525$(SRC)/args.$(ARCH).o              \
     26$(SRC)/copy_images.$(ARCH).o       \
     27$(SRC)/Shutdown.$(ARCH).o          \
     28$(SRC)/make_subcatalog.$(ARCH).o       
     29
     30OLD = \
    2631$(SRC)/liststats.$(ARCH).o         \
    27 $(SRC)/load_images.$(ARCH).o       \
    2832$(SRC)/name_region.$(ARCH).o       \
    2933$(SRC)/find_images.$(ARCH).o       \
     
    3236$(SRC)/load_catalogs.$(ARCH).o     \
    3337$(SRC)/gcatalog.$(ARCH).o          \
    34 $(SRC)/misc.$(ARCH).o              \
    3538$(SRC)/join_stars.$(ARCH).o        \
    3639$(SRC)/unique_measures.$(ARCH).o   \
     
    4043$(SRC)/overlap_funcs.$(ARCH).o     \
    4144$(SRC)/image-db.$(ARCH).o          \
     45$(SRC)/check_permissions.$(ARCH).o \
     46$(SRC)/misc.$(ARCH).o              \
    4247$(SRC)/SetSignals.$(ARCH).o        \
    4348$(SRC)/Shutdown.$(ARCH).o          \
    44 $(SRC)/check_permissions.$(ARCH).o \
    45 $(SRC)/subcatalog.$(ARCH).o        \
    4649$(SRC)/wcatalog.$(ARCH).o
     50
    4751
    4852OBJ = $(SRCLIST)
  • trunk/Ohana/src/photdbc/include/photdbc.h

    r4864 r8630  
    5353double SIGMA_MAX;
    5454int    NMEAS_MIN;
     55double ZERO_POINT;
    5556
     57int ExcludeByInstMag;
     58double INST_MAG_MIN;
     59double INST_MAG_MAX;
     60
     61int ExcludeByMaxMinMag;
     62double MAX_MIN_MAG;
     63
     64SkyRegion REGION;
    5665PhotCodeData photcodes;
    5766
     
    92101void          unique_measures (Catalog *catalog);
    93102void          wcatalog (Catalog *catalog);
    94 Catalog      *subcatalog (Catalog *catalog);
     103int           make_subcatalog (Catalog *subcatalog, Catalog *catalog);
    95104void          check_directory (char *basefile);
    96105
     
    103112void SetProtect (int mode);
    104113int SetSignals ();
     114
     115
     116int copy_images (char *outdir);
  • trunk/Ohana/src/photdbc/src/ConfigInit.c

    r6684 r8630  
    1212void ConfigInit (int *argc, char **argv) {
    1313
    14   double ZERO_POINT, tmp;
    1514  char *config, *file;
    1615
     
    2524  if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file);
    2625
    27   WarnConfig (config, "JOIN_RADIUS",            "%lf", 0, &JOIN_RADIUS);
    28   WarnConfig (config, "UNIQ_RADIUS",            "%lf", 0, &UNIQ_RADIUS);
     26  // WarnConfig (config, "JOIN_RADIUS",            "%lf", 0, &JOIN_RADIUS);
     27  // WarnConfig (config, "UNIQ_RADIUS",            "%lf", 0, &UNIQ_RADIUS);
    2928
    30   WarnConfig (config, "XMIN",                   "%lf", 0, &XMIN);
    31   WarnConfig (config, "XMAX",                   "%lf", 0, &XMAX);
    32   WarnConfig (config, "YMIN",                   "%lf", 0, &YMIN);
    33   WarnConfig (config, "YMAX",                   "%lf", 0, &YMAX);
     29  // WarnConfig (config, "XMIN",                   "%lf", 0, &XMIN);
     30  // WarnConfig (config, "XMAX",                   "%lf", 0, &XMAX);
     31  // WarnConfig (config, "YMIN",                   "%lf", 0, &YMIN);
     32  // WarnConfig (config, "YMAX",                   "%lf", 0, &YMAX);
     33 
     34  // WarnConfig (config, "DMCAL_MIN",              "%lf", 0, &tmp);  DMCAL_MIN = 1000*tmp;
     35  // WarnConfig (config, "MMIN",                   "%lf", 0, &tmp);  MMIN      = 1000*tmp;
     36  // WarnConfig (config, "MMAX",                   "%lf", 0, &tmp);  MMAX      = 1000*tmp;
     37  // WarnConfig (config, "DMSYS",                  "%lf", 0, &tmp);  DMSYS     = SQ(1000*tmp);
     38  // WarnConfig (config, "DMGAIN",                 "%lf", 0, &DMGAIN);
     39  // WarnConfig (config, "CHISQ_MAX",              "%lf", 0, &CHISQ_MAX);
    3440
    35   WarnConfig (config, "RMIN",                   "%lf", 0, &RMIN);
    36   WarnConfig (config, "RMAX",                   "%lf", 0, &RMAX);
    37   WarnConfig (config, "DMIN",                   "%lf", 0, &DMIN);
    38   WarnConfig (config, "DMAX",                   "%lf", 0, &DMAX);
    39 
    40   WarnConfig (config, "DMCAL_MIN",              "%lf", 0, &tmp);  DMCAL_MIN = 1000*tmp;
    41   WarnConfig (config, "MMIN",                   "%lf", 0, &tmp);  MMIN      = 1000*tmp;
    42   WarnConfig (config, "MMAX",                   "%lf", 0, &tmp);  MMAX      = 1000*tmp;
    43   WarnConfig (config, "DMSYS",                  "%lf", 0, &tmp);  DMSYS     = SQ(1000*tmp);
    44   WarnConfig (config, "DMGAIN",                 "%lf", 0, &DMGAIN);
    45   WarnConfig (config, "SIGMA_MAX",              "%lf", 0, &SIGMA_MAX); SIGMA_MAX *= 1000;
    46 
    47   WarnConfig (config, "CHISQ_MAX",              "%lf", 0, &CHISQ_MAX);
    48   WarnConfig (config, "NMEAS_MIN",              "%d",  0, &NMEAS_MIN);
     41  ScanConfig (config, "SIGMA_MAX",              "%lf", 0, &SIGMA_MAX);
     42  ScanConfig (config, "NMEAS_MIN",              "%d",  0, &NMEAS_MIN);
    4943
    5044  WarnConfig (config, "GSCFILE",                "%s",  0, GSCFILE);
     
    7468  free (config);
    7569  free (file);
    76 
    7770}
  • trunk/Ohana/src/photdbc/src/Shutdown.c

    r7080 r8630  
    11# include "photdbc.h"
    2 
    3 static FITS_DB *db;
    4 
    5 void set_db (FITS_DB *in) {
    6   db = in;
    7 }
    82
    93/* clean up open / locked ImageCat before shutting down */
     
    2115  va_end (argp);
    2216
    23   SetProtect (TRUE);
    24   gfits_db_close (db);
    25   fprintf (stderr, "ERROR: addstar halted\n");
     17  fprintf (stderr, "ERROR: photdbc halted\n");
    2618  exit (1);
    2719}
  • trunk/Ohana/src/photdbc/src/args.c

    r4808 r8630  
    1717  }
    1818
     19  ExcludeByInstMag = FALSE;
     20  if ((N = get_argument (argc, argv, "-instmag"))) {
     21    remove_argument (N, &argc, argv);
     22    ExcludeByInstMag = TRUE;
     23    remove_argument (N, &argc, argv);
     24    INST_MAG_MIN = atof(argv[N]);
     25    remove_argument (N, &argc, argv);
     26    INST_MAG_MAX = atof(argv[N]);
     27  }
     28
     29  ExcludeByMaxMinMag = FALSE;
     30  if ((N = get_argument (argc, argv, "-maxminmag"))) {
     31    remove_argument (N, &argc, argv);
     32    ExcludeByMaxMinMag = TRUE;
     33    remove_argument (N, &argc, argv);
     34    MAX_MIN_MAG = atof(argv[N]);
     35  }
     36
     37  /* specify portion of the sky */
     38  REGION.Rmin = 0;
     39  REGION.Rmax = 360;
     40  REGION.Dmin = -90;
     41  REGION.Dmax = +90;
     42  if ((N = get_argument (argc, argv, "-region"))) {
     43    remove_argument (N, &argc, argv);
     44    REGION.Rmin = atof (argv[N]);
     45    remove_argument (N, &argc, argv);
     46    REGION.Rmax = atof (argv[N]);
     47    remove_argument (N, &argc, argv);
     48    REGION.Dmin = atof (argv[N]);
     49    remove_argument (N, &argc, argv);
     50    REGION.Dmax = atof (argv[N]);
     51    remove_argument (N, &argc, argv);
     52
     53    if (REGION.Rmin == REGION.Rmax) {
     54      fprintf (stderr, "ERROR: selected region is ill-defined: Rmin == Rmax\n");
     55      exit (2);
     56    }
     57    if (REGION.Dmin == REGION.Dmax) {
     58      fprintf (stderr, "ERROR: selected region is ill-defined: Dmin == Dmax\n");
     59      exit (2);
     60    }
     61  }
     62
    1963  if (argc != 2) {
    20     fprintf (stderr, "USAGE: photdbc (region)\n");
     64    fprintf (stderr, "USAGE: photdbc (output)\n");
    2165    exit (2);
    2266  }
     67
     68  if ((REGION.Rmin == 0) && (REGION.Rmax == 360) && (REGION.Dmin == -90) && (REGION.Dmax == +90)) {
     69    int i;
     70    fprintf (stderr, "you have requested a copy of the entire sky in one pass\n");
     71    fprintf (stderr, "this could be a time consuming operation.  type Ctrl-C within 5 seconds to cancel\n");
     72    for (i = 5; i > 0; i--) {
     73      fprintf (stderr, "%d.. ", i);
     74      usleep (1000000);
     75    }
     76    fprintf (stderr, "\n");
     77  }
     78
    2379  return (TRUE);
    2480}
    2581
     82/**
     83
     84 this program takes an existing DVO database and makes a copy, applying a number of optional
     85 filters in the process. 
     86
     87 photdbc (output)
     88
     89 allowed filters / restrictions include:
     90
     91 -region ra dec ra dec : limit operation to the specified region
     92 -join                 : join measurements between stars using JOIN_RADIUS
     93 -ccdregion X Y X Y    : only keep detections within the specified detector region
     94                         (can this be limited to specific photcodes? cameras? detectors?)
     95 -photcode_limits code Mmin Mmax : allow multiples of these
     96
     97 SIGMA_MAX
     98 NMEAS_MIN
     99 INST_MAG_MAX
     100 INST_MAG_MIN
     101
     102**/
  • trunk/Ohana/src/photdbc/src/photdbc.c

    r8391 r8630  
    33int main (int argc, char **argv) {
    44
    5   int Nregion, status;
    6   char filename[1024];
    7   Catalog *catalog;
    8   GSCRegion *region;
    9   FITS_DB db;
     5  int i;
     6  char *skyfile;
     7  Catalog incatalog;
     8  Catalog outcatalog;
     9  SkyTable *sky;
     10  SkyList *skylist;
    1011
    1112  /* get configuration info, args, lockfile */
    1213  initialize (argc, argv);
    1314
    14   set_db (&db);
    15   status = dvo_image_lock (&db, ImageCat, 60.0, LCK_XCLD); /* XCLD */
    16   if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename);
    17   if (db.dbstate == LCK_EMPTY) Shutdown ("ERROR: No images in catalog %s (1)", db.filename);
     15  // load and copy the image table
     16  copy_images (argv[1]);
    1817
    19   /* load region and images overlapping region */
    20   region = load_images (&db, argv[1], &Nregion);
     18  // the output catalog needs to inherit the SKY_DEPTH of the input catalog
     19  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, SKY_DEPTH_HST, VERBOSE);
     20  SkyTableSetFilenames (sky, CATDIR, "cpt");
     21  skylist = SkyListByPatch (sky, -1, &REGION);
     22  for (i = 0; i < skylist[0].Nregions; i++) {
    2123
    22   /* load catalog data corresponding to region file */
    23   catalog = load_catalogs (region, Nregion);
     24    // set the parameters which guide catalog open/load/create
     25    incatalog.filename = skylist[0].filename[i];
     26    incatalog.Nsecfilt = GetPhotcodeNsecfilt ();
     27    incatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    2428
    25   /* limit number of measures based on selections */
    26   catalog = subcatalog (catalog);
     29    // an error exit status here is a significant error
     30    if (!dvo_catalog_open (&incatalog, skylist[0].regions[i], VERBOSE, "r")) {
     31      fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", incatalog.filename);
     32      exit (2);
     33    }
     34    // skip empty input catalogs
     35    if (!incatalog.Nave_disk) {
     36      dvo_catalog_unlock (&incatalog);
     37      dvo_catalog_free (&incatalog);
     38      continue;
     39    }
    2740
    28   /* limit number of measures based on selections */
    29   join_stars (catalog);
     41    // create output catalog filename
     42    outcatalog.filename = strsubs (incatalog.filename, CATDIR, argv[1]);
     43    if (outcatalog.filename == NULL) Shutdown ("error with input catalog name");
    3044
    31   unique_measures (catalog);
     45    // define outcatalog open parameters
     46    outcatalog.catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
     47    outcatalog.catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
     48    outcatalog.Nsecfilt  = incatalog.Nsecfilt;                 // inherit from the incatalog
     49    outcatalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
    3250
    33   flag_measures (&db, catalog);
     51    // output catalogs always represent the same skyregions as the input catalogs
     52    if (!dvo_catalog_open (&outcatalog, skylist[0].regions[i], VERBOSE, "w")) {
     53      fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", outcatalog.filename);
     54      exit (2);
     55    }
    3456
    35   get_mags (catalog);
     57    /* limit number of measures based on selections */
     58    make_subcatalog (&outcatalog, &incatalog);
     59       
     60    // XXX add other filters here:
     61    // join_stars (catalog);
     62    // unique_measures (catalog);
     63    // flag_measures (&db, catalog);
     64    // get_mags (catalog);
    3665
    37   // XXX this is all messed up: are we working on more than one region or not??
    38   for (i = 0; i < Nregion; i++) {
    39     // XXX empty catalogs are already unlocked and freed
    40     dvo_catalog_unlock (&catalog[i]);
    41     dvo_catalog_free (&catalog[i]);
     66    dvo_catalog_save (&outcatalog, VERBOSE);
     67    dvo_catalog_unlock (&outcatalog);
     68    dvo_catalog_free (&outcatalog);
     69
     70    dvo_catalog_unlock (&incatalog);
     71    dvo_catalog_free (&incatalog);
    4272  }
    4373
    44   // XXX?????
    45   sprintf (filename, "newdir/%s", argv[1]);
    46   catalog[0].filename = filename;
    47 
    48   check_directory (catalog[0].filename);
    49   if (!dvo_catalog_open (catalog, ...)) {
    50     fprintf (stderr, "can't lock new catalog file %s\n", catalog[0].filename);
    51     exit (1);
    52   }
    53   dvo_catalog_save (catalog);
     74  ALLOCATE (skyfile, char, strlen(argv[1]) + strlen("/SkyTable.fits") + 1);
     75  sprintf (skyfile, "%s/SkyTable.fits", argv[1]);
     76  SkyTableSave (sky, skyfile);
    5477  exit (0);
    5578}
    56 
    57 /** this program is somewhat rough: minimal error checking
    58     -
    59     only one catalog is loaded, corresponding to region file
    60  */
  • trunk/Ohana/src/photdbc/src/unique_measures.c

    r4808 r8630  
    102102}
    103103
     104/*** XXX
     105     this function does not quite do the right thing.  it should remove duplicate measurements
     106     for a single average object.  unique measurements have a unique combination of time and photcode
     107     (IS this true?  only for DET, not for REF...)
     108***/
     109
     110
Note: See TracChangeset for help on using the changeset viewer.