Changeset 15743 for trunk/Ohana/src/dvosplit
- Timestamp:
- Dec 5, 2007, 3:29:29 PM (19 years ago)
- Location:
- trunk/Ohana/src/dvosplit
- Files:
-
- 11 added
- 1 edited
-
Makefile (added)
-
include (added)
-
include/dvosplit.h (added)
-
src/ConfigInit.c (added)
-
src/SetSignals.c (added)
-
src/Shutdown.c (added)
-
src/args.c (added)
-
src/dvosplit.c (modified) (5 diffs)
-
src/open_output_catalogs.c (added)
-
src/split_averages.c (added)
-
src/split_measures.c (added)
-
src/split_missings.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/dvosplit/src/dvosplit.c
r15722 r15743 1 1 # include "dvosplit.h" 2 # define NROWS 100000 /* ~10MB per row for measures */3 2 3 // dvosplit (outlevel) [-region Rmin Rmax Dmin Dmax] 4 4 int main (int argc, char **argv) { 5 5 6 // USAGE: dvosplit (outlevel) [-region RA RA DEC DEC] 6 int i, j, OUT_DEPTH; 7 SkyTable *sky; 8 SkyList *skylist, *outlist; 9 Catalog incatalog, *outcatalogs; 10 AveLinks *avelinks; 11 char filename[256]; 7 12 8 // the output catalog needs to inherit the SKY_DEPTH of the input catalog. 9 // if the CATDIR/SkyTable.fits is not found, assume the HST layout (old default) 13 SetSignals (); 14 ConfigInit (&argc, argv); 15 args (argc, argv); 16 17 OUT_DEPTH = atoi (argv[1]); 10 18 11 19 // load the sky table for the existing database … … 13 21 SkyTableSetFilenames (sky, CATDIR, "cpt"); 14 22 15 // XXX I should just be copying the input sky and setting the output names on that16 // load the sky table for the existing database, generate output names17 outsky = SkyTableLoadOptimal (CATDIR, NULL, NULL, SKY_DEPTH_HST, VERBOSE);18 SkyTableSetFilenames (outsky, OUTDIR, "cpt");19 20 23 // get the list of populated regions 21 skylist = SkyListByPatch (sky, -1, & REGION);24 skylist = SkyListByPatch (sky, -1, &UserPatch); 22 25 23 26 for (i = 0; i < skylist[0].Nregions; i++) { … … 27 30 // if (current level == out level) skip: no action is needed 28 31 if (skylist[0].regions[i][0].depth >= OUT_DEPTH) continue; 29 30 outlist = SkyListByPatch (outsky, OUT_DEPTH, skylist[0].regions[i]);31 32 32 33 // set the parameters which guide catalog open/load/create … … 42 43 43 44 // skip empty input catalogs 44 if (!incatalog.Nave _disk) {45 if (!incatalog.Naves_disk) { 45 46 dvo_catalog_unlock (&incatalog); 46 47 dvo_catalog_free (&incatalog); … … 48 49 } 49 50 50 outcatalog = SkyTableSubdivide (&incatalog, &Noutcatalog); 51 // change sky.regions[i].depth for these regions 52 outlist = SkyListByPatch (sky, OUT_DEPTH, skylist[0].regions[i]); 51 53 52 // split out the average entries: 53 incatalog.catflags = LOAD_AVES; 54 Nblocks = incatalog.Nave_disk / NROWS; 55 for (j = 0; j < Nblocks; j++) { 54 outcatalogs = open_output_catalogs (outlist); 56 55 57 // read up to NROWS at a time 58 dvo_catalog_load_segment (&incatalog, VERBOSE, j*NROWS, NROWS); 56 avelinks = split_averages (&incatalog, outlist, outcatalogs); 59 57 60 for (k = 0; k < incatalog.Naverage; k++) { 61 averef = j*NROWS + k; 62 63 inR = incatalog.average[k].R; 64 inD = incatalog.average[k].D; 58 split_measures (&incatalog, outlist, outcatalogs, avelinks); 65 59 66 // which of the outcatalogs contains this coordinate? 60 // XXX missing entries have to be reconstructed if they are desired 61 // split_missings (&incatalog, outlist, outcatalogs, avelinks); 67 62 68 N = -1; 69 for (n = 0; n < Noutcatalog; n++) { 70 if (inR < outregions[n].Rmin) continue; 71 if (inR > outregions[n].Rmax) continue; 72 if (inD < outregions[n].Dmin) continue; 73 if (inD > outregions[n].Dmax) continue; 74 Ncat = n; 75 break; 76 } 77 if (Ncat == -1) continue; 63 dvo_catalog_unlock (&incatalog); 78 64 79 // XXX this probably needs to be Nave_disk so we can have partial saves 80 Nout = outcatalog[Ncat].Naverage; 81 outref[averef] = Nout; 82 outcat[averef] = Ncat; 83 84 outcatalog[Ncat].average[Nout] = incatalog.average[k]; 85 outcatalog[Ncat].Naverage++; 86 } 87 88 for (n = 0; n < Noutcatalog; n++) { 89 dvo_catalog_save_segment (&outcatalog[Ncat], VERBOSE, outcatalog[Ncat].Nave_disk, outcatalog[Ncat].Naverage); 90 } 65 for (j = 0; j < outlist[0].Nregions; j++) { 66 dvo_catalog_unlock (&outcatalogs[j]); 91 67 } 92 68 93 // split out the measure entries: 94 incatalog.catflags = LOAD_MEAS; 95 Nblocks = incatalog.Nmeas_disk / NROWS; 96 for (j = 0; j < Nblocks; j++) { 97 98 // read up to NROWS at a time 99 dvo_catalog_load_segment (&incatalog, VERBOSE, j*NROWS, NROWS); 100 101 for (k = 0; k < incatalog.Nmeasure; k++) { 102 103 averef = incatalog.measure[k].averef; 104 Ncat = outcat[averef]; 105 106 Nout = outcatalog[Ncat].Nmeasure; 107 outcatalog[Ncat].measure[Nout] = incatalog.measure[k]; 108 outcatalog[Ncat].measure[Nout].averef = outref[averef]; 109 outcatalog[Ncat].Nmeasure++; 110 } 111 112 for (n = 0; n < Noutcatalog; n++) { 113 dvo_catalog_save_segment (&outcatalog[N], VERBOSE, outcatalog[N].Nmeas_disk, outcatalog[N].Nmeasure); 114 } 69 // adjust depth 70 skylist[0].regions[i][0].table = FALSE; 71 for (j = 0; j < outlist[0].Nregions; j++) { 72 outlist[0].regions[j][0].table = TRUE; 115 73 } 116 74 117 // split out the secfilt entries: 118 incatalog.catflags = LOAD_SECF; 119 Nblocks = incatalog.Nsecfilt_disk / NROWS; 120 for (j = 0; j < Nblocks; j++) { 75 } 121 76 122 // read up to NROWS at a time 123 dvo_catalog_load_segment (&incatalog, VERBOSE, j*NROWS, NROWS); 77 // save sky table copy 78 sprintf (filename, "%s/SkyTable.fits", CATDIR); 79 check_file_access (filename, FALSE, VERBOSE); 80 if (!SkyTableSave (sky, filename)) { 81 fprintf (stderr, "ERROR: failed to save sky table for %s\n", CATDIR); 82 exit (1); 83 } 124 84 125 for (k = 0; k < incatalog.Naverage; k++) { 126 127 averef = j*NROWS + k; 128 Ncat = outcat[averef]; 129 Nout = outref[averef] * Nsecfilt; 130 131 for (n = 0; n < Nsecfilt; n++) { 132 outcatalog[Ncat].secfilt[Nout + n] = incatalog.measure[k*Nsecfilt + n]; 133 } 134 } 135 136 for (n = 0; n < Noutcatalog; n++) { 137 dvo_catalog_save_segment (&outcatalog[N], VERBOSE, outcatalog[N].Nmeas_disk, outcatalog[N].Nmeasure); 138 } 139 } 140 85 exit (0); 86 }
Note:
See TracChangeset
for help on using the changeset viewer.
