- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/Ohana
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/Ohana merged eligible /branches/eam_branches/Ohana.20100407 27635-27772 /branches/pap_delete/Ohana 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simtest_nebulous_branches/Ohana/src/dvomerge/src/dvomerge.c
r24750 r27840 1 1 # include "dvomerge.h" 2 2 3 // dvomerge (catdir.in1) and (catdir.in2) to (catdir.output) [-region Rmin Rmax Dmin Dmax] [4 // merge sources from (catdir.from) into (catdir.to)5 3 int main (int argc, char **argv) { 6 4 7 int i, j, Ns, Ne, depth1, depth2; 8 SkyTable *outsky, *insky1, *insky2; 9 SkyList *inlist; 10 Catalog incatalog, outcatalog; 11 char filename[256], *input1, *input2, *output; 5 SetSignals (); 6 dvomerge_help (argc, argv); 7 ConfigInit (&argc, argv); 8 dvomerge_args (&argc, argv); 12 9 13 SetSignals (); 14 ConfigInit (&argc, argv); 15 16 if (argc != 6) usage(); 17 if (strcasecmp (argv[2], "and")) usage(); 18 if (strcasecmp (argv[4], "to")) usage(); 19 20 input1 = argv[1]; 21 input2 = argv[3]; 22 output = argv[5]; 23 24 // the first input define the photcode table & db layout 25 sprintf (filename, "%s/Photcodes.dat", input1); 26 if (!LoadPhotcodes (filename, NULL)) { 27 fprintf (stderr, "error loading photcode table %s\n", filename); 28 exit (1); 29 } 30 // save the photcodes in the output catdir 31 sprintf (filename, "%s/Photcodes.dat", output); 32 if (!check_file_access (filename, TRUE, TRUE)) { 33 fprintf (stderr, "error creating output catdir %s\n", output); 34 exit (1); 35 } 36 if (!SavePhotcodesFITS (filename)) { 37 fprintf (stderr, "error saving photcode table %s\n", filename); 38 exit (1); 39 } 40 41 // load the sky table for the existing database 42 insky1 = SkyTableLoadOptimal (input1, NULL, NULL, SKY_DEPTH_HST, VERBOSE); 43 SkyTableSetFilenames (insky1, input1, "cpt"); 44 45 insky2 = SkyTableLoadOptimal (input2, NULL, NULL, SKY_DEPTH_HST, VERBOSE); 46 SkyTableSetFilenames (insky2, input2, "cpt"); 47 48 // generate an output table populated at the desired depth 49 outsky = SkyTableLoadOptimal (output, NULL, GSCFILE, SKY_DEPTH, VERBOSE); 50 SkyTableSetFilenames (outsky, output, "cpt"); 51 52 // loop over the populatable output tables; check for data in input1 and/or input2 53 // in the corresponding regions 54 55 SkyTablePopulatedRange (&Ns, &Ne, insky1, 0); 56 depth1 = insky1[0].regions[Ns].depth; 57 58 SkyTablePopulatedRange (&Ns, &Ne, insky2, 0); 59 depth2 = insky2[0].regions[Ns].depth; 60 61 // loop over the populatable output regions 62 for (i = 0; i < outsky[0].Nregions; i++) { 63 if (!outsky[0].regions[i].table) continue; 64 fprintf (stderr, "output: %s\n", outsky[0].regions[i].name); 65 66 // load / create output catalog 67 LoadCatalog (&outcatalog, &outsky[0].regions[i], outsky[0].filename[i], "w"); 68 69 // combine only tables at equal or larger depth 70 71 // load in all of the tables from input1 for this region 72 inlist = SkyListByBounds (insky1, depth1, outsky[0].regions[i].Rmin, outsky[0].regions[i].Rmax, outsky[0].regions[i].Dmin, outsky[0].regions[i].Dmax); 73 for (j = 0; j < inlist[0].Nregions; j++) { 74 fprintf (stderr, "input 1: %s\n", inlist[0].regions[j][0].name); 75 76 // load input catalog (1) 77 LoadCatalog (&incatalog, inlist[0].regions[j], inlist[0].filename[j], "r"); 78 79 // skip empty input catalogs 80 if (!incatalog.Naves_disk) { 81 dvo_catalog_unlock (&incatalog); 82 dvo_catalog_free (&incatalog); 83 continue; 84 } 85 merge_catalogs_new (&outsky[0].regions[i], &outcatalog, &incatalog); 86 dvo_catalog_unlock (&incatalog); 87 dvo_catalog_free (&incatalog); 88 } 89 SkyListFree (inlist); 90 91 // load in all of the tables from input2 for this region 92 inlist = SkyListByBounds (insky2, depth2, outsky[0].regions[i].Rmin, outsky[0].regions[i].Rmax, outsky[0].regions[i].Dmin, outsky[0].regions[i].Dmax); 93 for (j = 0; j < inlist[0].Nregions; j++) { 94 fprintf (stderr, "input 2: %s\n", inlist[0].regions[j][0].name); 95 96 // load input catalog (1) 97 LoadCatalog (&incatalog, inlist[0].regions[j], inlist[0].filename[j], "r"); 98 99 // skip empty input catalogs 100 if (!incatalog.Naves_disk) { 101 dvo_catalog_unlock (&incatalog); 102 dvo_catalog_free (&incatalog); 103 continue; 104 } 105 merge_catalogs_old (&outsky[0].regions[i], &outcatalog, &incatalog, RADIUS); 106 dvo_catalog_unlock (&incatalog); 107 dvo_catalog_free (&incatalog); 108 } 109 SkyListFree (inlist); 110 111 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 112 dvo_catalog_save (&outcatalog, VERBOSE); 113 dvo_catalog_unlock (&outcatalog); 114 dvo_catalog_free (&outcatalog); 115 } 116 117 // save the output sky table copy 118 sprintf (filename, "%s/SkyTable.fits", output); 119 check_file_access (filename, TRUE, VERBOSE); 120 if (!SkyTableSave (outsky, filename)) { 121 fprintf (stderr, "ERROR: failed to save sky table for %s\n", output); 122 exit (1); 123 } 124 125 exit (0); 10 if (argc == 6) dvomergeCreate (argc, argv); 11 if (argc == 4) dvomergeUpdate (argc, argv); 12 dvomerge_usage(); 13 exit (2); // cannot reach here. 126 14 } 127 15 128 /* 16 /* we have two possible modes of operation: 129 17 130 for the upgrade of the synth database, at a minimum I need to use an output format that uses 131 doubles for the astrometry. Optionally I should merge in the 2MASS photometry measurements, since that 132 would be quite useful for comparison. 18 Create : dvomerge (in1) and (in2) to (out) -- create a new db from two input dbs 19 Update : dvomerge (in) into (out) -- merge a new db into an existing db 133 20 134 generality questions: 135 * optional 136 137 138 139 */ 140 21 */
Note:
See TracChangeset
for help on using the changeset viewer.
