Changeset 27384 for branches/eam_branches/largefiles.20100314/Ohana
- Timestamp:
- Mar 21, 2010, 6:06:42 PM (16 years ago)
- Location:
- branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge
- Files:
-
- 4 added
- 10 edited
-
Makefile (modified) (1 diff)
-
include/dvomerge.h (modified) (4 diffs)
-
src/ConfigInit.c (modified) (3 diffs)
-
src/SkyTablePopulatedRange.c (modified) (3 diffs)
-
src/args.c (modified) (3 diffs)
-
src/build_links.c (modified) (4 diffs)
-
src/dvomerge.c (modified) (1 diff)
-
src/dvomergeCreate.c (added)
-
src/dvomergeUpdate.c (added)
-
src/help.c (added)
-
src/merge_catalogs_new.c (modified) (1 diff)
-
src/merge_catalogs_old.c (modified) (15 diffs)
-
src/psps_ids.c (added)
-
src/usage.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/Makefile
r24745 r27384 22 22 DVOMERGE = \ 23 23 $(SRC)/dvomerge.$(ARCH).o \ 24 $(SRC)/dvomergeUpdate.$(ARCH).o \ 25 $(SRC)/dvomergeCreate.$(ARCH).o \ 24 26 $(SRC)/SetSignals.$(ARCH).o \ 25 27 $(SRC)/ConfigInit.$(ARCH).o \ 26 28 $(SRC)/Shutdown.$(ARCH).o \ 27 $(SRC)/usage.$(ARCH).o \ 29 $(SRC)/help.$(ARCH).o \ 30 $(SRC)/args.$(ARCH).o \ 31 $(SRC)/psps_ids.$(ARCH).o \ 28 32 $(SRC)/SkyTablePopulatedRange.$(ARCH).o \ 29 33 $(SRC)/LoadCatalog.$(ARCH).o \ -
branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/include/dvomerge.h
r27368 r27384 22 22 char CATMODE[16]; /* raw, mef, split, mysql */ 23 23 char CATFORMAT[16]; /* internal, elixir, loneos, panstarrs */ 24 char ImageCat[256]; 24 25 float RADIUS; 25 26 int SKY_DEPTH; … … 28 29 29 30 int main PROTO((int argc, char **argv)); 31 int dvomergeCreate PROTO((int argc, char **argv)); 32 int dvomergeUpdate PROTO((int argc, char **argv)); 30 33 31 34 int ConfigInit PROTO((int *argc, char **argv)); … … 38 41 39 42 void usage PROTO((void)); 40 int SkyTablePopulatedRange PROTO((int *ns, int *ne, SkyTable *sky, int Nstart)); 43 void help PROTO((int argc, char **argv)); 44 int args PROTO((int *argc, char **argv)); 45 46 int SkyTablePopulatedRange PROTO((off_t *ns, off_t *ne, SkyTable *sky, off_t Nstart)); 41 47 42 48 SkyList *SkyTablePopulatedList PROTO((SkyTable *sky)); 43 SkyList *SkyTablePopulatedList_old PROTO((SkyTable *sky, int Ns, int Ne));49 SkyList *SkyTablePopulatedList_old PROTO((SkyTable *sky, off_t Ns, off_t Ne)); 44 50 45 51 int LoadCatalog PROTO((Catalog *catalog, SkyRegion *region, char *filename, char *mode)); … … 48 54 int merge_catalogs_old PROTO((SkyRegion *region, Catalog *output, Catalog *input, double RADIUS)); 49 55 50 int *init_measure_links PROTO((Average *average, int Naverage, Measure *measure, int Nmeasure)); 51 int *init_missing_links PROTO((Average *average, int Naverage, Missing *missing, int Nmissing)); 52 int *build_measure_links PROTO((Average *average, int Naverage, Measure *measure, int Nmeasure)); 53 int add_meas_link PROTO((Average *average, int *next, int Nmeasure, int NMEASURE)); 54 int add_miss_link PROTO((Average *average, int *next, int Nmissing)); 55 Measure *sort_measure PROTO((Average *average, int Naverage, Measure *measure, int Nmeasure, int *next)); 56 Missing *sort_missing PROTO((Average *average, int Naverage, Missing *missing, int Nmissing, int *next_miss)); 56 off_t *init_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure)); 57 off_t *init_missing_links PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing)); 58 off_t *build_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure)); 59 int add_meas_link PROTO((Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE)); 60 int add_miss_link PROTO((Average *average, off_t *next, off_t Nmissing)); 61 Measure *sort_measure PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next)); 62 Missing *sort_missing PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss)); 63 64 uint64_t CreatePSPSDetectionID PROTO((double tobs, int ccdid, int detID)); 65 uint64_t CreatePSPSObjectID PROTO((double ra, double dec)); 66 67 int dvo_image_merge_dbs PROTO((FITS_DB *out, FITS_DB *in)); 68 -
branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/ConfigInit.c
r24750 r27384 4 4 5 5 double ZERO_POINT; 6 char RadiusWord[80]; 6 7 char *config, *file; 7 char CatdirPhotcodeFile[256];8 char MasterPhotcodeFile[256];9 8 10 9 /*** load configuration info ***/ 11 10 file = SelectConfigFile (argc, argv, "ptolemy"); 11 12 12 config = LoadConfigFile (file); 13 13 if (config == (char *) NULL) { … … 18 18 if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file); 19 19 20 GetConfig (config, "PHOTCODE_FILE", "%s", 0, MasterPhotcodeFile); 20 21 21 GetConfig (config, "GSCFILE", "%s", 0, GSCFILE); 22 22 ScanConfig (config, "CATMODE", "%s", 0, CATMODE); 23 23 ScanConfig (config, "CATFORMAT", "%s", 0, CATFORMAT); 24 ScanConfig (config, "RADIUS", "%f", 0, &RADIUS);25 24 GetConfig (config, "SKY_DEPTH", "%d", 0, &SKY_DEPTH); 26 25 if (SKY_DEPTH > 4) { … … 36 35 SetZeroPoint (ZERO_POINT); 37 36 37 /* set the default search radius */ 38 if (!ScanConfig (config, "ADDSTAR_RADIUS", "%s", 0, RadiusWord)) { 39 GetConfig (config, "RADIUS", "%s", 0, RadiusWord); 40 } 41 RADIUS = atof (RadiusWord); 38 42 if (RADIUS < 1e-6) { 39 43 fprintf (stderr, "non-sensical correlation radius %f\n", RADIUS); -
branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/SkyTablePopulatedRange.c
r24745 r27384 1 1 # include "dvomerge.h" 2 2 3 int SkyTablePopulatedRange ( int *ns, int *ne, SkyTable *sky, int Nstart) {3 int SkyTablePopulatedRange (off_t *ns, off_t *ne, SkyTable *sky, off_t Nstart) { 4 4 5 int Ns, Ne;5 off_t Ns, Ne; 6 6 7 7 // given the starting sky region, find the populated range at or below this region … … 26 26 SkyList *SkyTablePopulatedList (SkyTable *sky) { 27 27 28 int i, N, NREGIONS;29 SkyList *list , *subset;28 off_t i, N, NREGIONS; 29 SkyList *list; 30 30 31 31 N = 0; … … 54 54 } 55 55 56 SkyList *SkyTablePopulatedList_old (SkyTable *sky, int Ns, int Ne) {56 SkyList *SkyTablePopulatedList_old (SkyTable *sky, off_t Ns, off_t Ne) { 57 57 58 int i, ns, ne, N, NREGIONS;58 off_t i, ns, ne, N, NREGIONS; 59 59 SkyList *list, *subset; 60 60 -
branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/args.c
r24745 r27384 1 1 # include "dvomerge.h" 2 static void help (void);3 2 4 int args (int argc, char **argv) { 3 /*** check for command line options ***/ 4 int args (int *argc, char **argv) { 5 5 6 int i, N, CONFIRM; 7 8 /* check for help request */ 9 if (get_argument (argc, argv, "-help") || 10 get_argument (argc, argv, "-h")) { 11 help (); 12 } 13 14 /*** check for command line options ***/ 6 int N, CONFIRM; 15 7 16 8 /*** provide additional data ***/ … … 21 13 UserPatch.Dmax = +90; 22 14 CONFIRM = TRUE; 23 if ((N = get_argument ( argc, argv, "-region"))) {24 remove_argument (N, &argc, argv);15 if ((N = get_argument (*argc, argv, "-region"))) { 16 remove_argument (N, argc, argv); 25 17 UserPatch.Rmin = atof (argv[N]); 26 remove_argument (N, &argc, argv);18 remove_argument (N, argc, argv); 27 19 UserPatch.Rmax = atof (argv[N]); 28 remove_argument (N, &argc, argv);20 remove_argument (N, argc, argv); 29 21 UserPatch.Dmin = atof (argv[N]); 30 remove_argument (N, &argc, argv);22 remove_argument (N, argc, argv); 31 23 UserPatch.Dmax = atof (argv[N]); 32 remove_argument (N, &argc, argv);24 remove_argument (N, argc, argv); 33 25 CONFIRM = FALSE; 34 26 } … … 36 28 /* extra error messages */ 37 29 VERBOSE = FALSE; 38 if ((N = get_argument ( argc, argv, "-v"))) {30 if ((N = get_argument (*argc, argv, "-v"))) { 39 31 VERBOSE = TRUE; 40 remove_argument (N, &argc, argv);32 remove_argument (N, argc, argv); 41 33 } 42 34 43 if (argc == 2) { 44 if (CONFIRM) { 45 fprintf (stderr, "you are splitting the entire sky in one pass\n"); 46 fprintf (stderr, "this could be a time consuming operation. type Ctrl-C within 5 seconds to cancel\n"); 47 for (i = 5; i > 0; i--) { 48 fprintf (stderr, "%d.. ", i); 49 usleep (1000000); 50 } 51 fprintf (stderr, "\n"); 52 } 53 return (TRUE); 54 } 55 56 fprintf (stderr, "USAGE: dvosplit (newlevel) [-region (Rmin) (Rmax) (Dmin) (Dmax)]\n"); 57 exit (2); 35 if ((*argc != 6) && (*argc != 4)) usage(); 36 return TRUE; 58 37 } 59 60 static void help () {61 62 fprintf (stderr, "USAGE\n");63 fprintf (stderr, " dvosplit (newlevel)\n\n");64 fprintf (stderr, " optional flags:\n");65 fprintf (stderr, " -region ra ra dec dec : migrate catalogs in specified region\n");66 fprintf (stderr, " -v : verbose mode\n");67 fprintf (stderr, " -help : this list\n");68 fprintf (stderr, " -h : this list\n\n");69 exit (2);70 }71 72 /** addstar modes:73 74 addstar (image.smp) - add cmp/smp image data to db75 addstar -ref (file.dat) (photcode)76 addstar -cat (USNO/2MASS/GSC) -region (ra dec - ra dec)77 78 -replace : ref/cat - replace existing match (photcode/time)79 -match : ref/cat - only add measures to existing averages80 81 ref types:82 ASCII - RA,DEC,M,dM in a table83 84 addstar85 86 **/87 -
branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/build_links.c
r24745 r27384 3 3 /* build the initial links assuming the table is sorted, 4 4 not partial, and has a correct set of average[].measureOffset,Nmeasure values */ 5 int *init_measure_links (Average *average, int Naverage, Measure *measure, int Nmeasure) {6 7 int i, j, N;8 int *next;5 off_t *init_measure_links (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure) { 6 7 off_t i, j, N; 8 off_t *next; 9 9 10 10 N = 0; 11 11 12 ALLOCATE (next, int, Nmeasure);12 ALLOCATE (next, off_t, Nmeasure); 13 13 for (i = 0; i < Naverage; i++, N++) { 14 14 for (j = 0; j < average[i].Nmeasure - 1; j++, N++) { … … 31 31 } 32 32 33 /* average[].measureOffset, average[].Nmeasure are valid within an addstar run */ 34 int add_meas_link (Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE) { 35 36 off_t k, m; 37 38 /* if we have trouble, check validity of next[m] : m < Nmeasure */ 39 m = average[0].measureOffset; 40 41 for (k = 0; k < average[0].Nmeasure - 1; k++) { 42 m = next[m]; 43 if (m >= NMEASURE) { 44 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 45 } 46 } 47 48 /* set up references */ 49 next[Nmeasure] = -1; 50 if (Nmeasure >= NMEASURE) { 51 fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n"); 52 } 53 54 if (m == -1) { 55 average[0].measureOffset = Nmeasure; 56 } else { 57 next[m] = Nmeasure; 58 if (m >= NMEASURE) { 59 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 60 } 61 } 62 63 return (TRUE); 64 } 65 66 Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next) { 67 68 off_t i, k, n, N; 69 Measure *tmpmeasure; 70 71 /* fix order of Measure (memory intensive, but fast) */ 72 N = 0; 73 ALLOCATE (tmpmeasure, Measure, Nmeasure); 74 for (i = 0; i < Naverage; i++) { 75 n = average[i].measureOffset; 76 average[i].measureOffset = N; 77 for (k = 0; k < average[i].Nmeasure; k++, N++) { 78 tmpmeasure[N] = measure[n]; 79 tmpmeasure[N].averef = i; 80 n = next[n]; 81 } 82 } 83 free (measure); 84 return (tmpmeasure); 85 } 86 87 /* construct measure links which are valid FOR THIS LOAD 88 * - if we have a full load, we will get links which can 89 * be used by other programs (eg, relphot, etc) 90 * - if we have a partial load, the links are only valid 91 * for that partial load 92 */ 93 94 off_t *build_measure_links (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure) { 95 96 off_t i, m, k, Nm, averef; 97 off_t *next; 98 99 ALLOCATE (next, off_t, Nmeasure); 100 101 /* reset the Nm, offset values for average */ 102 for (i = 0; i < Naverage; i++) { 103 average[i].measureOffset = -1; 104 average[i].Nmeasure = 0; 105 } 106 107 for (Nm = 0; Nm < Nmeasure; Nm++) { 108 averef = measure[Nm].averef; 109 m = average[averef].measureOffset; 110 next[Nm] = -1; 111 112 if (m == -1) { /* no links yet for source */ 113 average[averef].measureOffset = Nm; 114 average[averef].Nmeasure = 1; 115 continue; 116 } 117 118 for (k = 0; next[m] != -1; k++) { 119 m = next[m]; 120 if (m >= Nmeasure) { 121 fprintf (stderr, "WARNING: m out of bounds (1)\n"); 122 } 123 } 124 125 average[averef].Nmeasure = k + 2; 126 next[m] = Nm; 127 if (m >= Nmeasure) { 128 fprintf (stderr, "WARNING: m out of bounds (2)\n"); 129 } 130 } 131 return (next); 132 } 133 33 134 /* build the initial links assuming the table is sorted */ 34 int *init_missing_links (Average *average, int Naverage, Missing *missing, int Nmissing) {35 36 int i, j, N;37 int *next;135 off_t *init_missing_links (Average *average, off_t Naverage, Missing *missing, off_t Nmissing) { 136 137 off_t i, j, N; 138 off_t *next; 38 139 39 140 N = 0; 40 141 41 ALLOCATE (next, int, Nmissing);142 ALLOCATE (next, off_t, Nmissing); 42 143 for (i = 0; i < Naverage; i++) { 43 144 for (j = 0; j < average[i].Nmissing - 1; j++, N++) { … … 57 158 } 58 159 59 /* average[].measureOffset, average[].Nmeasure are valid within an addstar run */ 60 int add_meas_link (Average *average, int *next, int Nmeasure, int NMEASURE) { 61 62 int k, m; 63 64 /* if we have trouble, check validity of next[m] : m < Nmeasure */ 65 m = average[0].measureOffset; 66 67 for (k = 0; k < average[0].Nmeasure - 1; k++) { 68 m = next[m]; 69 if (m >= NMEASURE) { 70 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 71 } 72 } 73 74 /* set up references */ 75 next[Nmeasure] = -1; 76 if (Nmeasure >= NMEASURE) { 77 fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n"); 78 } 79 80 if (m == -1) { 81 average[0].measureOffset = Nmeasure; 82 } else { 83 next[m] = Nmeasure; 84 if (m >= NMEASURE) { 85 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 86 } 87 } 88 89 return (TRUE); 90 } 91 92 int add_miss_link (Average *average, int *next, int Nmissing) { 93 94 int k, m; 160 int add_miss_link (Average *average, off_t *next, off_t Nmissing) { 161 162 off_t k, m; 95 163 96 164 /* there may be 0 Nmiss; this is not true for Nmeas */ … … 109 177 } 110 178 111 /* construct measure links which are valid FOR THIS LOAD112 * - if we have a full load, we will get links which can113 * be used by other programs (eg, relphot, etc)114 * - if we have a partial load, the links are only valid115 * for that partial load116 */117 118 int *build_measure_links (Average *average, int Naverage, Measure *measure, int Nmeasure) {119 120 int i, m, k, Nm, averef;121 int *next;122 123 ALLOCATE (next, int, Nmeasure);124 125 /* reset the Nm, offset values for average */126 for (i = 0; i < Naverage; i++) {127 average[i].measureOffset = -1;128 average[i].Nmeasure = 0;129 }130 131 for (Nm = 0; Nm < Nmeasure; Nm++) {132 averef = measure[Nm].averef;133 m = average[averef].measureOffset;134 next[Nm] = -1;135 136 if (m == -1) { /* no links yet for source */137 average[averef].measureOffset = Nm;138 average[averef].Nmeasure = 1;139 continue;140 }141 142 for (k = 0; next[m] != -1; k++) {143 m = next[m];144 if (m >= Nmeasure) {145 fprintf (stderr, "WARNING: m out of bounds (1)\n");146 }147 }148 149 average[averef].Nmeasure = k + 2;150 next[m] = Nm;151 if (m >= Nmeasure) {152 fprintf (stderr, "WARNING: m out of bounds (2)\n");153 }154 }155 return (next);156 }157 158 179 /* Missing does not carry enough information to reconstruct the links 159 180 we must always save the missing table, if it exists */ 160 181 161 Measure *sort_measure (Average *average, int Naverage, Measure *measure, int Nmeasure, int *next) { 162 163 int i, k, n, N; 164 Measure *tmpmeasure; 165 166 /* fix order of Measure (memory intensive, but fast) */ 167 N = 0; 168 ALLOCATE (tmpmeasure, Measure, Nmeasure); 169 for (i = 0; i < Naverage; i++) { 170 n = average[i].measureOffset; 171 average[i].measureOffset = N; 172 for (k = 0; k < average[i].Nmeasure; k++, N++) { 173 tmpmeasure[N] = measure[n]; 174 tmpmeasure[N].averef = i; 175 n = next[n]; 176 } 177 } 178 free (measure); 179 return (tmpmeasure); 180 } 181 182 Missing *sort_missing (Average *average, int Naverage, Missing *missing, int Nmissing, int *next) { 183 184 int i, k, n, N; 182 Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next) { 183 184 off_t i, k, n, N; 185 185 Missing *tmpmissing; 186 186 -
branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/dvomerge.c
r25757 r27384 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 help (argc, argv); 7 ConfigInit (&argc, argv); 8 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, FALSE)) { 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, 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, FALSE, SKY_DEPTH_HST, VERBOSE); 43 SkyTableSetFilenames (insky1, input1, "cpt"); 44 45 insky2 = SkyTableLoadOptimal (input2, NULL, NULL, FALSE, 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, TRUE, 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, 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 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 */ -
branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/merge_catalogs_new.c
r27295 r27384 66 66 67 67 if (VERBOSE) { 68 fprintf (stderr, "%d: using %d stars (%d measures) for catalog\n", i, 69 output[0].Naverage, output[0].Nmeasure); 68 fprintf (stderr, "%lld: using %lld stars (%lld measures) for catalog\n", 69 (long long) i, 70 (long long) output[0].Naverage, 71 (long long) output[0].Nmeasure); 70 72 } 71 73 return (TRUE); -
branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/merge_catalogs_old.c
r27295 r27384 1 1 # include "dvomerge.h" 2 # define PSPS_ID TRUE 2 3 3 4 # define IN_REGION(R,D) ( \ … … 119 120 /* negative dX: j is too large */ 120 121 dX = X1[i] - X2[j]; 121 if (dX <= - 2*RADIUS) {122 if (dX <= -1.02*RADIUS) { 122 123 i++; 123 124 continue; 124 125 } 125 126 /* positive dX, i is too large */ 126 if (dX >= 2*RADIUS) {127 if (dX >= 1.02*RADIUS) { 127 128 j++; 128 129 continue; … … 131 132 Jmin = -1; 132 133 Rmin = RADIUS2; 133 for (J = j; (dX > - 2*RADIUS) && (J < Nave); J++) {134 for (J = j; (dX > -1.02*RADIUS) && (J < Nave); J++) { 134 135 /* find closest match for this detection */ 135 136 dX = X1[i] - X2[J]; … … 161 162 } 162 163 163 /** add measurements for this input average object **/164 /** add ALL measurements for this input average object **/ 164 165 for (Nin = 0; Nin < input[0].average[N].Nmeasure; Nin ++) { 165 166 offset = input[0].average[N].measureOffset + Nin; … … 169 170 170 171 // set the new measurements 171 output[0].measure[Nmeas] = input[0].measure[offset];172 output[0].measure[Nmeas] = input[0].measure[offset]; 172 173 173 174 Rin = input[0].average[N].R - input[0].measure[offset].dR / 3600.0; … … 177 178 output[0].measure[Nmeas].dR = 3600.0*(output[0].average[n].R - Rin); // XXX update these based on choice of astromety 178 179 output[0].measure[Nmeas].dD = 3600.0*(output[0].average[n].D - Din); // XXX update these based on choice of astromety 179 output[0].measure[Nmeas].dbFlags = 0; 180 output[0].measure[Nmeas].dbFlags = 0; // XXX why reset these? 180 181 output[0].measure[Nmeas].averef = n; 181 182 output[0].measure[Nmeas].objID = output[0].average[n].objID; 182 183 output[0].measure[Nmeas].catID = output[0].catID; 184 185 // fprintf (stderr, "Nave : %lld, Nmeas : %lld, dR: %f, dD: %f, catID: %d\n", (long long) n, (long long) Nmeas, output[0].measure[Nmeas].dR, output[0].measure[Nmeas].dD, output[0].measure[i].catID); 183 186 184 187 // rationalize dR … … 197 200 output[0].average[n].R, output[0].average[n].D, Rin, Din, 198 201 X1[i], X2[Jmin], Y1[i], Y2[Jmin]); 202 // XXX abort on this? -- this is a bad failure... 199 203 } 200 204 input[0].found[N] = Nmeas; 205 output[0].average[n].Nmeasure ++; 201 206 Nmeas ++; 202 207 } … … 205 210 Nm is recalculated in build_meas_links if loaded table is not sorted */ 206 211 output[0].found[n] = Nmeas; 207 output[0].average[n].Nmeasure ++;208 212 i++; 209 213 } 214 215 # if (0) 216 fprintf (stderr, "--- 1 ---\n"); 217 for (i = 0; i < Nmeas; i++) { 218 fprintf (stderr, "Nave : %d, Nmeas : %lld, dR: %f, dD: %f, catID: %d\n", output[0].measure[i].averef, (long long) i, output[0].measure[i].dR, output[0].measure[i].dD, output[0].measure[i].catID); 219 } 220 # endif 210 221 211 222 /** incorporate unmatched image stars, if this star is in field of this catalog **/ 212 223 /* these new entries are all written out in UPDATE mode */ 213 224 for (i = 0; i < Nstars; i++) { 214 215 N = N1[i];216 if (input[0].found[N] >= 0) continue;217 if (!IN_REGION (input[0].average[N].R, input[0].average[N].D)) continue;218 219 225 /* make sure there is space for next entry */ 220 226 if (Nmeas + input[0].average[N].Nmeasure >= NMEAS) { … … 229 235 } 230 236 237 N = N1[i]; 238 if (input[0].found[N] >= 0) continue; 239 if (!IN_REGION (input[0].average[N].R, input[0].average[N].D)) continue; 240 231 241 output[0].average[Nave].R = input[0].average[N].R; 232 242 output[0].average[Nave].D = input[0].average[N].D; … … 238 248 output[0].average[Nave].Nextend = 0; 239 249 240 output[0].average[Nave].measureOffset = Nmeas;241 output[0].average[Nave].missingOffset = -1;242 output[0].average[Nave].extendOffset = -1;250 output[0].average[Nave].measureOffset = Nmeas; 251 output[0].average[Nave].missingOffset = -1; 252 output[0].average[Nave].extendOffset = -1; 243 253 244 254 output[0].average[Nave].uR = 0; … … 253 263 output[0].average[Nave].Npos = 0; 254 264 255 output[0].average[Nave].objID = objID; 256 output[0].average[Nave].catID = catID; 257 output[0].average[Nave].flags = 0; 265 output[0].average[Nave].objID = objID; // we create objID values in the context of the output db 266 output[0].average[Nave].catID = catID; // we create catID values in the context of the output db 267 output[0].average[Nave].flags = 0; // XXX why reset these? 268 if (PSPS_ID) { 269 output[0].average[Nave].extID = CreatePSPSObjectID(output[0].average[Nave].R, output[0].average[Nave].D); 270 } else { 271 output[0].average[Nave].extID = 0; 272 } 258 273 259 274 objID ++; … … 288 303 Nmeas ++; 289 304 } 305 int Ngroup = input[0].average[N].Nmeasure; 306 for (j = 0; j < Ngroup - 1; j++) { 307 next_meas[Nmeas - Ngroup + j] = Nmeas - Ngroup + j + 1; 308 } 290 309 Nave ++; 291 310 } … … 294 313 REALLOCATE (output[0].measure, Measure, Nmeas); 295 314 296 # define NOSORT TRUE 315 # if (0) 316 fprintf (stderr, "--- 2 ---\n"); 317 for (i = 0; i < Nmeas; i++) { 318 fprintf (stderr, "Nave : %d, Nmeas : %lld, dR: %f, dD: %f, catID: %d\n", output[0].measure[i].averef, (long long) i, output[0].measure[i].dR, output[0].measure[i].dD, output[0].measure[i].catID); 319 } 320 # endif 321 322 # define NOSORT FALSE 297 323 if (NOSORT) { 298 324 output[0].sorted = FALSE; … … 301 327 output[0].measure = sort_measure (output[0].average, Nave, output[0].measure, Nmeas, next_meas); 302 328 } 329 330 # if (0) 331 fprintf (stderr, "--- 3 ---\n"); 332 for (i = 0; i < Nmeas; i++) { 333 fprintf (stderr, "Nave : %d, Nmeas : %lld, dR: %f, dD: %f, catID: %d\n", output[0].measure[i].averef, (long long) i, output[0].measure[i].dR, output[0].measure[i].dD, output[0].measure[i].catID); 334 } 335 # endif 303 336 304 337 /* note stars which have been found in this catalog */ … … 316 349 output[0].Nmeasure = Nmeas; 317 350 output[0].Nsecf_mem = Nave*Nsecfilt; 318 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: % d %d %d, (%d matches)\n", Nstars, Nave, Nmeas,Nmatch);351 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %lld %lld %lld, (%lld matches)\n", (long long) Nstars, (long long) Nave, (long long) Nmeas, (long long) Nmatch); 319 352 320 353 free (next_meas); -
branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/usage.c
r24745 r27384 3 3 void usage (void) { 4 4 fprintf (stderr, "USAGE: dvomerge (input1) and (input2) to (output)\n"); 5 fprintf (stderr, " OR: dvomerge (input) into (output)\n"); 5 6 exit (2); 6 7 }
Note:
See TracChangeset
for help on using the changeset viewer.
