Changeset 34356
- Timestamp:
- Aug 25, 2012, 11:45:32 AM (14 years ago)
- Location:
- branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src
- Files:
-
- 1 added
- 2 edited
-
dvomergeHistory.c (added)
-
dvomergeImageIDs.c (modified) (2 diffs)
-
dvomergeUpdate_catalogs.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvomergeImageIDs.c
r33963 r34356 21 21 return TRUE; 22 22 } 23 // this operation reads the PHU header (inDB.header) 23 24 if (!dvo_image_load (&inDB, VERBOSE, TRUE)) { 24 25 Shutdown ("can't read input image catalog %s", inDB.filename); 25 26 } 27 28 // read the header for the database ID? 29 char *indbID = dvomergeHistoryReadID (&inDB); 30 if (!indbID) { 31 Shutdown ("this database is missing a DVO database ID; please generate one before merging\n"); 32 } 26 33 27 34 /*** load output/Images.dat ***/ … … 41 48 } 42 49 50 dmhImage *history = dmhImageRead (&outDB); 51 if (!history) { 52 Shutdown ("error reading history for output database\n"); 53 } 54 43 55 // convert database table to internal structure & add to output image db 44 56 dvo_image_merge_dbs(IDmap, &outDB, &inDB); 45 57 dvo_image_unlock (&inDB); // unlock input 58 59 // add the new image db to merge history 60 // (updates header as well as history structure 61 if (!dmhImageAdd (&outDB, history, indbID)) { 62 Shutdown ("error reading history for output database\n"); 63 } 64 65 // XXX I need to pass the history structure back out somehow... 46 66 47 67 SetProtect (TRUE); -
branches/eam_branches/ipp-20120805/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
r34260 r34356 31 31 outlist = SkyListByBounds (outsky, -1, inlist[0].regions[i][0].Rmin + dPos, inlist[0].regions[i][0].Rmax - dPos, inlist[0].regions[i][0].Dmin + dPos, inlist[0].regions[i][0].Dmax - dPos); 32 32 33 // there may be more than one output region for a given input region. are any of these output regions relevant to this machine? 33 OutputStatus *outstat = OutputStatusInit (outlist->Nregions); 34 35 // there may be more than one output region for a given input region. 36 // are any of these output regions relevant to this machine? 34 37 int found = FALSE; 35 38 for (j = 0; !found && (j < outlist[0].Nregions); j++) { 36 found = (found || HostTableTestHost(outlist[0].regions[j], HOST_ID)); 39 outstat[j].valid = HostTableTestHost(outlist[0].regions[j], HOST_ID); 40 found = (found || outstat[j].valid); 37 41 } 38 42 39 43 // skip this input table for if no output files are on this machine 40 44 if (!found) { 45 OutputStatusFree (outstat, outlist->Nregions); 41 46 SkyListFree (outlist); 42 47 continue; 43 48 } 44 49 45 // get the stats on this input file (for comparison with the output headers) 46 struct stat instats; 47 int stat_result = stat (inlist[0].filename[i], &instats); 48 if (stat_result) { 49 if (errno == ENOENT) continue; 50 fprintf (stderr, "cannot read stats on input file %s\n", inlist[0].filename[i]); 51 perror ("stats error message:"); 52 exit (2); 53 } 54 55 // instats.st_size & instats.st_mtime 56 57 // check if any of the output files have NOT yet received data from this input file 58 50 // get stats for history check 51 dmhObjectStats *inStats = dmhObjectStatsRead (inlist[0].filename[i]); 52 53 // Check if any of the output files have NOT yet received data from this input file 54 // If none have been missed, we can skip the input file completely 59 55 int missed = FALSE; 60 for (j = 0; !missed && (j < outlist[0].Nregions); j++) {61 if (! HostTableTestHost(outlist[0].regions[j], HOST_ID)) continue;56 for (j = 0; j < outlist[0].Nregions; j++) { 57 if (!outstat[j].valid) continue; 62 58 63 59 // set the parameters which guide catalog open/load/create … … 65 61 snprintf (hostfile, DVO_MAX_PATH, "%s/%s.cpt", HOSTDIR, outlist[0].regions[j]->name); 66 62 char *filename = HOST_ID ? hostfile : outlist[0].filename[j]; 67 68 // get the stats on this input file (for comparison with the output headers) 69 struct stat outstats; 70 stat_result = stat (filename, &outstats); 71 if (stat_result) { 72 if (errno == ENOENT) { 73 missed = TRUE; 74 break; 75 } 76 fprintf (stderr, "cannot read stats on output file %s\n", filename); 77 perror ("stats error message:"); 78 exit (2); 79 } 80 81 FILE *fout = fopen (filename, "r"); 82 if (!fout) { 83 fprintf (stderr, "problem opening output file to read header %s\n", filename); 84 perror ("stats error message:"); 85 exit (2); 86 } 87 88 Header outheader; 89 if (!gfits_fread_header (fout, &outheader)) { 90 fprintf (stderr, "problem reading header for output file %s\n", filename); 91 exit (2); 92 } 93 94 fclose (fout); 95 96 // XXX note that we are hardwired to v 2 97 // check the header of output catalog for an existing merge 98 long long last_size; 99 char last_moddate[80]; 100 gfits_scan (&outheader, "LMRG_SZ2", "%lld", 1, &last_size); 101 gfits_scan (&outheader, "LMRG_DT2", "%s", 1, last_moddate); 102 103 time_t last_mod = ohana_date_to_sec (last_moddate); 104 105 if (last_size != instats.st_size) { 106 missed = TRUE; 107 break; 108 } 109 110 if (last_mod != instats.st_mtime) { 111 missed = TRUE; 112 break; 113 } 63 outstat[j].filename = strcreate (filename); 64 65 outstat[j].history = dmhObjectRead (outstat[j].filename); 66 67 outstat[j].missed = dmhObjectCheck (outstat[j].history, inStats); 68 missed = (missed || outstat[j].missed); 114 69 } 115 70 if (!missed) { 116 71 fprintf (stderr, "skipping %s, already merged\n", inlist[0].filename[i]); 72 OutputStatusFree (outstat, outlist->Nregions); 73 dmhObjectStatsFree (inStats); 74 SkyListFree (outlist); 117 75 continue; 118 76 } … … 125 83 dvo_catalog_unlock (&incatalog); 126 84 dvo_catalog_free (&incatalog); 85 OutputStatusFree (outstat, outlist->Nregions); 86 dmhObjectStatsFree (inStats); 127 87 SkyListFree (outlist); 128 88 continue; 129 89 } 130 131 char *moddate = ohana_sec_to_date (instats.st_mtime);132 90 133 91 // merge input into the appropriate output tables 134 92 for (j = 0; j < outlist[0].Nregions; j++) { 135 93 // skip tables for which the output files are not on this machine 136 if (!HostTableTestHost(outlist[0].regions[j], HOST_ID)) continue; 94 if (!outstat[j].valid) continue; 95 96 // skip if we have already done the merge 97 if (!outstat[j].missed) continue; 137 98 138 99 if (VERBOSE) fprintf (stderr, "output : %s\n", outlist[0].regions[j][0].name); 139 100 140 // set the parameters which guide catalog open/load/create 141 char hostfile[DVO_MAX_PATH]; 142 snprintf (hostfile, DVO_MAX_PATH, "%s/%s.cpt", HOSTDIR, outlist[0].regions[j]->name); 143 outcatalog.filename = HOST_ID ? hostfile : outlist[0].filename[j]; 101 // the real filename 102 outcatalog.filename = outstat[j].filename; 144 103 145 104 // load input catalog … … 151 110 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 152 111 153 # if (0) 154 // get the LMRG data from the previous pass 155 long long last_size; 156 char last_moddate[80]; 157 int status_size = gfits_scan (&outcatalog.header, "LMRG_SZ", "%lld", 1, &last_size); 158 int status_date = gfits_scan (&outcatalog.header, "LMRG_DT", "%s", 1, last_moddate); 159 160 // save the LMRG data from the previous pass 161 if (status_size && status_date) { 162 gfits_modify (&outcatalog.header, "LMRG_SZ1", "%lld", 1, (long long) last_size); 163 gfits_modify (&outcatalog.header, "LMRG_DT1", "%s", 1, last_moddate); 164 } 165 166 // update header of output catalog 167 gfits_modify (&outcatalog.header, "LMRG_SZ", "%lld", 1, (long long) instats.st_size); 168 gfits_modify (&outcatalog.header, "LMRG_DT", "%s", 1, moddate); 169 # endif 170 171 // update header of output catalog 172 // XXX note that we are hardwired to v 2 173 gfits_modify (&outcatalog.header, "LMRG_SZ2", "%lld", 1, (long long) instats.st_size); 174 gfits_modify (&outcatalog.header, "LMRG_DT2", "%s", 1, moddate); 112 dmhObjectAdd (outstat[j].history, &outcatalog.header, inStats); 175 113 176 114 if (!dvo_catalog_backup (&outcatalog, TRUE)) { … … 196 134 fprintf (stderr, "merged %s into %s\n", inlist[0].regions[i][0].name, outlist[0].regions[j][0].name); 197 135 } 136 137 OutputStatusFree (outstat, outlist->Nregions); 198 138 SkyListFree (outlist); 199 free (moddate);139 dmhObjectStatsFree (inStats); 200 140 201 141 dvo_catalog_unlock (&incatalog);
Note:
See TracChangeset
for help on using the changeset viewer.
