IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33214


Ignore:
Timestamp:
Feb 8, 2012, 7:28:41 AM (14 years ago)
Author:
eugene
Message:

major cleanups: a new output directory may be specified (or split files stay in local catdir); format and mode are inherited from input (override with -set-format and -set-mode options)

Location:
branches/eam_branches/ipp-20111122/Ohana/src/dvosplit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/dvosplit/include/dvosplit.h

    r27435 r33214  
    2323
    2424int    VERBOSE;
    25 char   CATDIR[256];
    26 char   CATMODE[16];    /* raw, mef, split, mysql */
    27 char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
     25char  *OUTDIR;
     26char  *CATMODE;    /* raw, mef, split, mysql */
     27char  *CATFORMAT;  /* internal, elixir, loneos, panstarrs */
    2828
    2929SkyRegion UserPatch;  // used by MODE CAT
     
    3838int        args                   PROTO((int argc, char **argv));
    3939
    40 Catalog   *open_output_catalogs   PROTO((SkyList *outlist));
     40Catalog   *open_output_catalogs   PROTO((SkyList *outlist, int catformat, int catmode));
    4141AveLinks  *split_averages         PROTO((Catalog *incatalog, SkyList *outlist, Catalog *outcatalogs));
    4242int        split_measures         PROTO((Catalog *incatalog, SkyList *outlist, Catalog *outcatalogs, AveLinks *avelinks));
  • branches/eam_branches/ipp-20111122/Ohana/src/dvosplit/src/ConfigInit.c

    r25757 r33214  
    55  double ZERO_POINT;
    66  char *config, *file;
    7   char CatdirPhotcodeFile[256];
    8   char MasterPhotcodeFile[256];
    97
    108  /*** load configuration info ***/
     
    1816  if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file);
    1917
    20   GetConfig (config, "CATDIR",                  "%s",  0, CATDIR);
    21   GetConfig (config, "PHOTCODE_FILE",           "%s",  0, MasterPhotcodeFile);
    22 
    23   ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
    24   ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
    25 
    26   /* default mode, format, if not specified */
    27   if (*CATMODE == 0) strcpy (CATMODE, "RAW");
    28   if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
    29 
     18  // XXX this really needs to be deprecated.  It is always 25.0, and should just be hard-wired
     19  // (the purpose of this value is now completely pointless...)
    3020  GetConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);
    3121  SetZeroPoint (ZERO_POINT);
    32 
    33   /* XXX this does not yet write out the master photcode table */
    34   sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    35   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    36     fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    37     exit (1);
    38   }
    3922
    4023  free (config);
  • branches/eam_branches/ipp-20111122/Ohana/src/dvosplit/src/args.c

    r15743 r33214  
    3434  }
    3535
     36  OUTDIR = NULL;
     37  if ((N = get_argument (argc, argv, "-outdir"))) {
     38    remove_argument (N, &argc, argv);
     39    OUTDIR = strcreate (argv[N]);
     40    remove_argument (N, &argc, argv);
     41  }
     42
     43  // override input catalog format (PS1_V1, PS1_REF, etc)
     44  CATFORMAT = NULL;
     45  if ((N = get_argument (argc, argv, "-set-format"))) {
     46    remove_argument (N, &argc, argv);
     47    CATFORMAT = strcreate (argv[N]);
     48    remove_argument (N, &argc, argv);
     49  }
     50
     51  // override input catalog mode (raw, mef, split, mysql)
     52  CATMODE = NULL;
     53  if ((N = get_argument (argc, argv, "-set-mode"))) {
     54    remove_argument (N, &argc, argv);
     55    CATMODE = strcreate (argv[N]);
     56    remove_argument (N, &argc, argv);
     57  }
     58
    3659  /* extra error messages */
    3760  VERBOSE = FALSE;
     
    4164  }
    4265
    43   if (argc == 2) {
     66  if (argc == 3) {
    4467    if (CONFIRM) {
    4568      fprintf (stderr, "you are splitting the entire sky in one pass\n");
     
    5477  }
    5578
    56   fprintf (stderr, "USAGE: dvosplit (newlevel) [-region (Rmin) (Rmax) (Dmin) (Dmax)]\n");
     79  fprintf (stderr, "USAGE: dvosplit (catdir) (newlevel) [-outdir outdir] [-region (Rmin) (Rmax) (Dmin) (Dmax)]\n");
    5780  exit (2);
    5881}
     
    6184
    6285  fprintf (stderr, "USAGE\n");
    63   fprintf (stderr, "  dvosplit (newlevel)\n\n");
     86  fprintf (stderr, "  dvosplit (catdir) (newlevel)\n\n");
    6487  fprintf (stderr, "  optional flags:\n");
     88  fprintf (stderr, "  -outdir (outdir)            : copy to a new location (does not copy Images.dat)\n");
    6589  fprintf (stderr, "  -region ra ra dec dec       : migrate catalogs in specified region\n");
    6690  fprintf (stderr, "  -v                          : verbose mode\n");
     91  fprintf (stderr, "  -set-format (format)        : set format of output catalog (or inherit from input)\n");
     92  fprintf (stderr, "  -set-mode (mode)            : set mode of output catalog (or inherit from input)\n");
    6793  fprintf (stderr, "  -help                       : this list\n");
    6894  fprintf (stderr, "  -h                          : this list\n\n");
  • branches/eam_branches/ipp-20111122/Ohana/src/dvosplit/src/dvosplit.c

    r33204 r33214  
    11# include "dvosplit.h"
    22
    3 // XXX : go to this : dvosplit (catdir) (outlevel) [-region Rmin Rmax Dmin Dmax]
     3// dvosplit (catdir) (outlevel) [-outdir (outcat)} [-region Rmin Rmax Dmin Dmax]
    44// dvosplit (outlevel) [-region Rmin Rmax Dmin Dmax]
     5// (inherites the input catalog's format and mode, unless -set-format or -set-mode are used)
    56int main (int argc, char **argv) {
    67
     
    1011  Catalog incatalog, *outcatalogs;
    1112  AveLinks *avelinks;
    12   char filename[256];
     13  char *filename, *CATDIR;
    1314
    1415  SetSignals ();
     
    1617  args (argc, argv);
    1718
    18   // XXX : OUTCAT = strcreate (argv[1]);
    19   // XXX : OUT_DEPTH = atoi (argv[2]);
     19  CATDIR = strcreate (argv[1]);
     20  OUT_DEPTH = atoi (argv[2]);
     21  if (!OUTDIR) {
     22    OUTDIR = strcreate (CATDIR);
     23  }
    2024
    21   OUT_DEPTH = atoi (argv[1]);
     25  // load the photcode table (for Nsecfilt and related)
     26  char photcodeFile[1024];
     27  snprintf (photcodeFile, 1024, "%s/Photcodes.dat", CATDIR);
     28  if (!LoadPhotcodes (photcodeFile, NULL, FALSE)) {
     29    fprintf (stderr, "error loading photcode table %s\n", photcodeFile);
     30    exit (1);
     31  }
     32
     33  // XXX should strip off any trailing slashes
     34  int LocalCopy = !strcmp (CATDIR, OUTDIR);
     35
     36  // if not local, save the photcode table (for Nsecfilt and related)
     37  if (!LocalCopy) {
     38    if (!check_dir_access (OUTDIR, VERBOSE)) {
     39      fprintf (stderr, "failed to create output directory %s\n", OUTDIR);
     40      exit (1);
     41    }
     42    snprintf (photcodeFile, 1024, "%s/Photcodes.dat", OUTDIR);
     43    if (!SavePhotcodesFITS (photcodeFile)) {
     44      fprintf (stderr, "error loading photcode table %s\n", photcodeFile);
     45      exit (1);
     46    }
     47  }
    2248
    2349  // load the sky table for the existing database
     
    2955 
    3056  for (i = 0; i < skylist[0].Nregions; i++) {
    31     fprintf (stderr, "%s\n", skylist[0].regions[i][0].name);
     57    if (VERBOSE) fprintf (stderr, "%s\n", skylist[0].regions[i][0].name);
    3258
     59    // if !LocalCopy, always copy the file
    3360    // if (current level >  out level) skip: cannot currently merge catalogs
    3461    // if (current level == out level) skip: no action is needed
    35     // XXX if outdir != indir, copy the tables across
    36     if (skylist[0].regions[i][0].depth >= OUT_DEPTH) continue;
     62
     63    if (skylist[0].regions[i][0].depth > OUT_DEPTH) {
     64      if (VERBOSE) fprintf (stderr, "WARNING, cannot merge deeper catalog %s (%d vs %d)\n", skylist[0].regions[i][0].name, skylist[0].regions[i][0].depth, OUT_DEPTH);
     65      continue;
     66    }
     67
     68    if (LocalCopy && (skylist[0].regions[i][0].depth == OUT_DEPTH)) continue;
    3769
    3870    // set the parameters which guide catalog open/load/create
    3971    incatalog.filename = skylist[0].filename[i];
    4072    incatalog.Nsecfilt = GetPhotcodeNsecfilt ();
    41     incatalog.catflags = LOAD_NONE;
     73    incatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF | LOAD_MISS;
    4274
    4375    // an error exit status here is a significant error
     
    5688    // change sky.regions[i].depth for these regions
    5789    outlist = SkyListByPatch (sky, OUT_DEPTH, skylist[0].regions[i]);
    58     // XXX update the filenames for outlist given the new outdir
    5990
    60     outcatalogs = open_output_catalogs (outlist);
     91    // Modify the outlist filenames to match the output directory.  Note that the
     92    // filenames are now owned by the list (and are not freed by SkyListFree)
     93    SkyListSetFilenames (outlist, OUTDIR, "cpt");
     94
     95    // inherit the input catalog's format and mode (unless overridden)
     96    outcatalogs = open_output_catalogs (outlist, incatalog.catformat, incatalog.catmode);
    6197
    6298    avelinks = split_averages (&incatalog, outlist, outcatalogs);
     
    81117      outlist[0].regions[j][0].table = TRUE;
    82118    }
     119
     120    // free the newly allocated filenames
     121    for (j = 0; j < outlist[0].Nregions; j++) {
     122      free (outlist[0].filename[j]);
     123    }
     124
     125    // free the rest of the list
     126    SkyListFree (outlist);
    83127  }
    84128
    85129  // save sky table copy
    86   sprintf (filename, "%s/SkyTable.fits", CATDIR);
     130  filename = SkyTableFilename (OUTDIR);
    87131  check_file_access (filename, TRUE, TRUE, VERBOSE);
    88132  if (!SkyTableSave (sky, filename)) {
    89     fprintf (stderr, "ERROR: failed to save sky table for %s\n", CATDIR);
     133    fprintf (stderr, "ERROR: failed to save sky table for %s\n", OUTDIR);
    90134    exit (1);
    91135  }
  • branches/eam_branches/ipp-20111122/Ohana/src/dvosplit/src/open_output_catalogs.c

    r15743 r33214  
    11# include "dvosplit.h"
    22
    3 Catalog *open_output_catalogs (SkyList *outlist) {
     3Catalog *open_output_catalogs (SkyList *outlist, int catformat, int catmode) {
    44
    55  int i;
     
    1515    outcatalogs[i].Nsecfilt  = GetPhotcodeNsecfilt ();
    1616    outcatalogs[i].catflags  = LOAD_NONE;
    17     outcatalogs[i].catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
    18     outcatalogs[i].catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
     17    outcatalogs[i].catformat = CATFORMAT ? dvo_catalog_catformat (CATFORMAT) : catformat;  // set the default catformat from config data
     18    outcatalogs[i].catmode   = CATMODE   ? dvo_catalog_catmode (CATMODE)     : catmode;    // set the default catmode from config data
     19
     20    // the user options -set-format and -set-mode assign values to the globals CATFORMAT
     21    // and CATMODE (in args.c); otherwise the values from the input catalogs are inherited
    1922
    2023    if (!dvo_catalog_open (&outcatalogs[i], outlist[0].regions[i], VERBOSE, "w")) {
Note: See TracChangeset for help on using the changeset viewer.