Changeset 33656
- Timestamp:
- Apr 1, 2012, 3:08:33 PM (14 years ago)
- Location:
- trunk/Ohana/src/dvosplit
- Files:
-
- 7 edited
-
include/dvosplit.h (modified) (2 diffs)
-
src/ConfigInit.c (modified) (2 diffs)
-
src/args.c (modified) (4 diffs)
-
src/dvosplit.c (modified) (6 diffs)
-
src/open_output_catalogs.c (modified) (2 diffs)
-
src/split_averages.c (modified) (2 diffs)
-
src/split_measures.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/dvosplit/include/dvosplit.h
r27435 r33656 23 23 24 24 int VERBOSE; 25 char CATDIR[256];26 char CATMODE[16]; /* raw, mef, split, mysql */27 char CATFORMAT[16]; /* internal, elixir, loneos, panstarrs */25 char *OUTDIR; 26 char *CATMODE; /* raw, mef, split, mysql */ 27 char *CATFORMAT; /* internal, elixir, loneos, panstarrs */ 28 28 29 29 SkyRegion UserPatch; // used by MODE CAT … … 38 38 int args PROTO((int argc, char **argv)); 39 39 40 Catalog *open_output_catalogs PROTO((SkyList *outlist ));40 Catalog *open_output_catalogs PROTO((SkyList *outlist, int catformat, int catmode)); 41 41 AveLinks *split_averages PROTO((Catalog *incatalog, SkyList *outlist, Catalog *outcatalogs)); 42 42 int split_measures PROTO((Catalog *incatalog, SkyList *outlist, Catalog *outcatalogs, AveLinks *avelinks)); -
trunk/Ohana/src/dvosplit/src/ConfigInit.c
r25757 r33656 5 5 double ZERO_POINT; 6 6 char *config, *file; 7 char CatdirPhotcodeFile[256];8 char MasterPhotcodeFile[256];9 7 10 8 /*** load configuration info ***/ … … 18 16 if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file); 19 17 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...) 30 20 GetConfig (config, "ZERO_PT", "%lf", 0, &ZERO_POINT); 31 21 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 }39 22 40 23 free (config); -
trunk/Ohana/src/dvosplit/src/args.c
r15743 r33656 34 34 } 35 35 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 36 59 /* extra error messages */ 37 60 VERBOSE = FALSE; … … 41 64 } 42 65 43 if (argc == 2) {66 if (argc == 3) { 44 67 if (CONFIRM) { 45 68 fprintf (stderr, "you are splitting the entire sky in one pass\n"); … … 54 77 } 55 78 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"); 57 80 exit (2); 58 81 } … … 61 84 62 85 fprintf (stderr, "USAGE\n"); 63 fprintf (stderr, " dvosplit ( newlevel)\n\n");86 fprintf (stderr, " dvosplit (catdir) (newlevel)\n\n"); 64 87 fprintf (stderr, " optional flags:\n"); 88 fprintf (stderr, " -outdir (outdir) : copy to a new location (does not copy Images.dat)\n"); 65 89 fprintf (stderr, " -region ra ra dec dec : migrate catalogs in specified region\n"); 66 90 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"); 67 93 fprintf (stderr, " -help : this list\n"); 68 94 fprintf (stderr, " -h : this list\n\n"); -
trunk/Ohana/src/dvosplit/src/dvosplit.c
r25757 r33656 1 1 # include "dvosplit.h" 2 2 3 // dvosplit (catdir) (outlevel) [-outdir (outcat)} [-region Rmin Rmax Dmin Dmax] 3 4 // dvosplit (outlevel) [-region Rmin Rmax Dmin Dmax] 5 // (inherites the input catalog's format and mode, unless -set-format or -set-mode are used) 4 6 int main (int argc, char **argv) { 5 7 … … 9 11 Catalog incatalog, *outcatalogs; 10 12 AveLinks *avelinks; 11 char filename[256];13 char *filename, *CATDIR; 12 14 13 15 SetSignals (); … … 15 17 args (argc, argv); 16 18 17 OUT_DEPTH = atoi (argv[1]); 19 CATDIR = strcreate (argv[1]); 20 OUT_DEPTH = atoi (argv[2]); 21 if (!OUTDIR) { 22 OUTDIR = strcreate (CATDIR); 23 } 24 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 // dvosplit can be run locally (no -outdir specified); otherwise, copy Photcode.dat, 34 // Images.dat, SkyTable.fits 35 int LocalCopy = !strcmp (CATDIR, OUTDIR); 36 37 // if not local, save the photcode table (for Nsecfilt and related) 38 if (!LocalCopy) { 39 if (!check_dir_access (OUTDIR, VERBOSE)) { 40 fprintf (stderr, "failed to create output directory %s\n", OUTDIR); 41 exit (1); 42 } 43 snprintf (photcodeFile, 1024, "%s/Photcodes.dat", OUTDIR); 44 if (!SavePhotcodesFITS (photcodeFile)) { 45 fprintf (stderr, "error loading photcode table %s\n", photcodeFile); 46 exit (1); 47 } 48 } 18 49 19 50 // load the sky table for the existing database … … 25 56 26 57 for (i = 0; i < skylist[0].Nregions; i++) { 27 fprintf (stderr, "%s\n", skylist[0].regions[i][0].name);58 if (VERBOSE) fprintf (stderr, "%s\n", skylist[0].regions[i][0].name); 28 59 60 // if !LocalCopy, always copy the file 29 61 // if (current level > out level) skip: cannot currently merge catalogs 30 62 // if (current level == out level) skip: no action is needed 31 if (skylist[0].regions[i][0].depth >= OUT_DEPTH) continue; 63 64 if (skylist[0].regions[i][0].depth > OUT_DEPTH) { 65 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); 66 continue; 67 } 68 69 if (LocalCopy && (skylist[0].regions[i][0].depth == OUT_DEPTH)) continue; 32 70 33 71 // set the parameters which guide catalog open/load/create … … 52 90 outlist = SkyListByPatch (sky, OUT_DEPTH, skylist[0].regions[i]); 53 91 54 outcatalogs = open_output_catalogs (outlist); 92 // Modify the outlist filenames to match the output directory. Note that the 93 // filenames are now owned by the list (and are not freed by SkyListFree) 94 SkyListSetFilenames (outlist, OUTDIR, "cpt"); 95 96 // inherit the input catalog's format and mode (unless overridden) 97 outcatalogs = open_output_catalogs (outlist, incatalog.catformat, incatalog.catmode); 55 98 56 99 avelinks = split_averages (&incatalog, outlist, outcatalogs); … … 75 118 outlist[0].regions[j][0].table = TRUE; 76 119 } 120 121 // free the newly allocated filenames 122 for (j = 0; j < outlist[0].Nregions; j++) { 123 free (outlist[0].filename[j]); 124 } 125 126 // free the rest of the list 127 SkyListFree (outlist); 77 128 } 78 129 79 // save sky table copy 80 sprintf (filename, "%s/SkyTable.fits", CATDIR);130 // save sky table copy (Local or not Local : the depth has changed) 131 filename = SkyTableFilename (OUTDIR); 81 132 check_file_access (filename, TRUE, TRUE, VERBOSE); 82 133 if (!SkyTableSave (sky, filename)) { 83 fprintf (stderr, "ERROR: failed to save sky table for %s\n", CATDIR);134 fprintf (stderr, "ERROR: failed to save sky table for %s\n", OUTDIR); 84 135 exit (1); 136 } 137 138 if (!LocalCopy) { 139 // copy the images table 140 char line[2048]; 141 snprintf (line, 2048, "cp %s/Images.dat %s/Images.dat", CATDIR, OUTDIR); 142 system (line); 85 143 } 86 144 -
trunk/Ohana/src/dvosplit/src/open_output_catalogs.c
r15743 r33656 1 1 # include "dvosplit.h" 2 2 3 Catalog *open_output_catalogs (SkyList *outlist ) {3 Catalog *open_output_catalogs (SkyList *outlist, int catformat, int catmode) { 4 4 5 5 int i; … … 15 15 outcatalogs[i].Nsecfilt = GetPhotcodeNsecfilt (); 16 16 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 19 22 20 23 if (!dvo_catalog_open (&outcatalogs[i], outlist[0].regions[i], VERBOSE, "w")) { -
trunk/Ohana/src/dvosplit/src/split_averages.c
r15746 r33656 26 26 // split out the average & secfilt entries: 27 27 incatalog[0].catflags = LOAD_AVES | LOAD_SECF; 28 Nblocks = incatalog[0].Naves_disk / NROWS; 29 if (incatalog[0].Naves_disk % NROWS) Nblocks ++; 28 29 if (incatalog[0].catmode == DVO_MODE_SPLIT) { 30 Nblocks = incatalog[0].Naves_disk / NROWS; 31 if (incatalog[0].Naves_disk % NROWS) Nblocks ++; 32 } else { 33 Nblocks = 1; 34 } 35 30 36 for (block = 0; block < Nblocks; block++) { 31 37 32 // read up to NROWS at a time 33 dvo_catalog_load_segment (incatalog, VERBOSE, block*NROWS, NROWS); 34 fprintf (stderr, "splitting %s (averages) .. %d of %d\n", incatalog[0].filename, block, Nblocks); 38 if (incatalog[0].catmode == DVO_MODE_SPLIT) { 39 // read up to NROWS at a time 40 dvo_catalog_load_segment (incatalog, VERBOSE, block*NROWS, NROWS); 41 fprintf (stderr, "splitting %s (averages) .. %d of %d\n", incatalog[0].filename, block, Nblocks); 42 } else { 43 dvo_catalog_load (incatalog, VERBOSE); 44 fprintf (stderr, "splitting %s (averages)\n", incatalog[0].filename); 45 } 35 46 36 47 assert (block*NROWS == incatalog[0].Naves_off); … … 84 95 // double check the values of Naverage, Nsecf_mem? 85 96 97 // XXX for output.catformat == MEF, we probably need to skip this stuff and the free below 98 86 99 // write out the new values 87 100 for (cat = 0; cat < outlist[0].Nregions; cat++) { -
trunk/Ohana/src/dvosplit/src/split_measures.c
r15746 r33656 20 20 // split out the measure entries: 21 21 incatalog[0].catflags = LOAD_MEAS; 22 Nblocks = incatalog[0].Nmeas_disk / NROWS; 23 if (incatalog[0].Nmeas_disk % NROWS) Nblocks ++; 22 // if ((incatalog[0].catformat == DVO_FORMAT_ELIXIR) || (incatalog[0].catformat == DVO_FORMAT_LONEOS)) { 23 // // for these two formats, we need the average and secfilt values around until we do the measures... 24 // // XXX I am loading these 2x -- perhaps I can make the API smarter about reloading? 25 // incatalog[0].catflags |= LOAD_AVES | LOAD_SECF; 26 // } 27 28 if (incatalog[0].catmode == DVO_MODE_SPLIT) { 29 Nblocks = incatalog[0].Nmeas_disk / NROWS; 30 if (incatalog[0].Nmeas_disk % NROWS) Nblocks ++; 31 } else { 32 Nblocks = 1; 33 } 34 24 35 for (block = 0; block < Nblocks; block++) { 25 36 26 37 // read up to NROWS at a time 27 dvo_catalog_load_segment (incatalog, VERBOSE, block*NROWS, NROWS); 28 fprintf (stderr, "splitting %s (measures) .. %d of %d\n", incatalog[0].filename, block, Nblocks); 38 if (incatalog[0].catmode == DVO_MODE_SPLIT) { 39 dvo_catalog_load_segment (incatalog, VERBOSE, block*NROWS, NROWS); 40 fprintf (stderr, "splitting %s (measures) .. %d of %d\n", incatalog[0].filename, block, Nblocks); 41 } else { 42 dvo_catalog_load (incatalog, VERBOSE); 43 fprintf (stderr, "splitting %s (measures)\n", incatalog[0].filename); 44 } 29 45 30 46 assert (block*NROWS == incatalog[0].Nmeas_off);
Note:
See TracChangeset
for help on using the changeset viewer.
