Changeset 33214
- Timestamp:
- Feb 8, 2012, 7:28:41 AM (14 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src/dvosplit
- Files:
-
- 5 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)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/dvosplit/include/dvosplit.h
r27435 r33214 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)); -
branches/eam_branches/ipp-20111122/Ohana/src/dvosplit/src/ConfigInit.c
r25757 r33214 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); -
branches/eam_branches/ipp-20111122/Ohana/src/dvosplit/src/args.c
r15743 r33214 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"); -
branches/eam_branches/ipp-20111122/Ohana/src/dvosplit/src/dvosplit.c
r33204 r33214 1 1 # include "dvosplit.h" 2 2 3 // XXX : go to this : dvosplit (catdir) (outlevel)[-region Rmin Rmax Dmin Dmax]3 // dvosplit (catdir) (outlevel) [-outdir (outcat)} [-region Rmin Rmax Dmin Dmax] 4 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) 5 6 int main (int argc, char **argv) { 6 7 … … 10 11 Catalog incatalog, *outcatalogs; 11 12 AveLinks *avelinks; 12 char filename[256];13 char *filename, *CATDIR; 13 14 14 15 SetSignals (); … … 16 17 args (argc, argv); 17 18 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 } 20 24 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 } 22 48 23 49 // load the sky table for the existing database … … 29 55 30 56 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); 32 58 59 // if !LocalCopy, always copy the file 33 60 // if (current level > out level) skip: cannot currently merge catalogs 34 61 // 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; 37 69 38 70 // set the parameters which guide catalog open/load/create 39 71 incatalog.filename = skylist[0].filename[i]; 40 72 incatalog.Nsecfilt = GetPhotcodeNsecfilt (); 41 incatalog.catflags = LOAD_ NONE;73 incatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF | LOAD_MISS; 42 74 43 75 // an error exit status here is a significant error … … 56 88 // change sky.regions[i].depth for these regions 57 89 outlist = SkyListByPatch (sky, OUT_DEPTH, skylist[0].regions[i]); 58 // XXX update the filenames for outlist given the new outdir59 90 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); 61 97 62 98 avelinks = split_averages (&incatalog, outlist, outcatalogs); … … 81 117 outlist[0].regions[j][0].table = TRUE; 82 118 } 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); 83 127 } 84 128 85 129 // save sky table copy 86 sprintf (filename, "%s/SkyTable.fits", CATDIR);130 filename = SkyTableFilename (OUTDIR); 87 131 check_file_access (filename, TRUE, TRUE, VERBOSE); 88 132 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); 90 134 exit (1); 91 135 } -
branches/eam_branches/ipp-20111122/Ohana/src/dvosplit/src/open_output_catalogs.c
r15743 r33214 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")) {
Note:
See TracChangeset
for help on using the changeset viewer.
