Changeset 15728
- Timestamp:
- Nov 30, 2007, 4:46:27 PM (18 years ago)
- Location:
- branches/eam_branch_20071130/Ohana/src
- Files:
-
- 5 edited
-
dvosplit/src/dvosplit.c (modified) (4 diffs)
-
libdvo/doc/dvo-catalogs.txt (modified) (3 diffs)
-
libdvo/src/dvo_catalog.c (modified) (3 diffs)
-
libdvo/src/dvo_catalog_mef.c (modified) (6 diffs)
-
libdvo/src/dvo_catalog_split.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20071130/Ohana/src/dvosplit/src/dvosplit.c
r15722 r15728 8 8 // the output catalog needs to inherit the SKY_DEPTH of the input catalog. 9 9 // if the CATDIR/SkyTable.fits is not found, assume the HST layout (old default) 10 11 // force the output to have SPLIT mode? 10 12 11 13 // load the sky table for the existing database … … 27 29 // if (current level == out level) skip: no action is needed 28 30 if (skylist[0].regions[i][0].depth >= OUT_DEPTH) continue; 31 // XXX : we need to copy these files to their new names 29 32 33 // change outsky.regions[i].depth for these regions 30 34 outlist = SkyListByPatch (outsky, OUT_DEPTH, skylist[0].regions[i]); 31 35 … … 42 46 43 47 // skip empty input catalogs 44 if (!incatalog.Nave _disk) {48 if (!incatalog.Naves_disk) { 45 49 dvo_catalog_unlock (&incatalog); 46 50 dvo_catalog_free (&incatalog); 47 51 continue; 48 52 } 49 50 outcatalog = SkyTableSubdivide (&incatalog, &Noutcatalog);51 53 52 54 // split out the average entries: … … 67 69 68 70 N = -1; 69 for (n = 0; n < Noutcatalog; n++) {71 for (n = 0; n < outlist[0].Nregions; n++) { 70 72 if (inR < outregions[n].Rmin) continue; 71 73 if (inR > outregions[n].Rmax) continue; -
branches/eam_branch_20071130/Ohana/src/libdvo/doc/dvo-catalogs.txt
r8328 r15728 2 2 // APIs related to the DVO catalogs: 3 3 4 // XXX change name5 // XXX add SORTED test to load6 // XXX add Nsecfilt test? or add an API?7 4 load_catalog (Catalog *catalog, int VERBOSE); 8 // returns9 // 0: failure to lock catalog10 // 1: success: file is locked and opened11 // 2: success: file is locked but empty12 5 13 6 dvo_catalog_lock (Catalog *catalog, int lockmode); … … 20 13 // layout: RAW, MEF, SPLIT 21 14 // mode: READ, WRITE 15 16 // returns 17 // DVO_CAT_OPEN_FAIL: failure to lock catalog 18 // DVO_CAT_OPEN_OK: success: file is locked and opened 19 // DVO_CAT_OPEN_EMPTY: success: file is locked but empty 20 21 the catalog is opened and the data for each of the elements (average, 22 measure, etc) is loaded if requested. Whether or not the data is 23 loaded, the values of catalog.Naves_disk,Naves_off,Naverage are set 24 to match the segment of data loaded. this API always loads either 25 the entire data set, or none. If none, the offset value is set to 26 point at the end of the table. 22 27 23 28 dvo_catalog_save (Catalog *catalog, int VERBOSE); … … 43 48 - open and read an existing catalog / error if missing (can be ignored) 44 49 50 dvo_catalog_open (Catalog *catalog, int mode); 45 51 46 dvo_catalog_open (Catalog *catalog, int mode); 52 dvo_catalog_load_segment_average (Catalog *catalog, int start, int Nrows) 53 54 this function reads in the requested number of rows from the catalog 55 for the Average and SecFilt tables only. It is possible within the 56 DVO framework to examine the average values in slices. 57 58 dvo_catalog_load_segment_measure (Catalog *catalog, int start, int Nrows) 59 60 this function reads in the requested number of rows from the catalog 61 for the Measure table only. It is not guaranteed to be possible to 62 examine the measure values in slices if reference is needed to their 63 average values. 64 65 dvo_catalog_load_segment_missing (Catalog *catalog, int start, int Nrows) 66 67 this function reads in the requested number of rows from the catalog 68 for the Missing table only. It is not guaranteed to be possible to 69 examine the missing values in slices if reference is needed to their 70 average values. -
branches/eam_branch_20071130/Ohana/src/libdvo/src/dvo_catalog.c
r15725 r15728 235 235 if (!status) catalog[0].sorted = TRUE; 236 236 237 // even if the data is sorted on disk, if we only load the MEAS_META, we are238 // treating it as unsorted (eg, append only)239 // XXX deprecate this statement?240 if (catalog[0].catflags & LOAD_MEAS_META) {241 catalog[0].sorted = FALSE;242 }243 244 237 // determine catmode 245 238 if (!gfits_scan (&catalog[0].header, "NAXIS", "%d", 1, &Naxis)) { … … 308 301 309 302 int dvo_catalog_update (Catalog *catalog, char VERBOSE) { 303 304 // even if the data is sorted on disk, if we only load the MEAS_META, we are 305 // treating it as unsorted (eg, append only) 306 // XXX deprecate this statement? 307 XXX: 308 check on this; 309 if (catalog[0].catflags & LOAD_MEAS_META) { 310 catalog[0].sorted = FALSE; 311 } 310 312 311 313 /* update is only valid for catmode SPLIT */ … … 398 400 style : raw, mef, split, mysql 399 401 */ 402 403 int dvo_catalog_load_segment (Catalog *catalog, int VERBOSE, int start, int Nrows) { 404 405 int Naxis, split, status; 406 char measure[80]; 407 408 // catformat determined in dvo_catalog_load_XXX function 409 catalog[0].catformat = DVO_FORMAT_UNDEF; 410 411 switch (catalog[0].catmode) { 412 case DVO_MODE_RAW: 413 if (VERBOSE) fprintf (stderr, "reading catalog (mode DVO_MODE_RAW)\n"); 414 fprintf (stderr, "cannot do this in raw mode\n"); 415 // dvo_catalog_load_segment_raw (catalog, VERBOSE, start, Nrows); 416 break; 417 case DVO_MODE_MEF: 418 if (VERBOSE) fprintf (stderr, "reading catalog (mode DVO_MODE_MEF)\n"); 419 dvo_catalog_load_segment_mef (catalog, VERBOSE, start, Nrows); 420 break; 421 case DVO_MODE_SPLIT: 422 if (VERBOSE) fprintf (stderr, "reading catalog (mode DVO_MODE_SPLIT)\n"); 423 dvo_catalog_load_segment_split (catalog, VERBOSE, start, Nrows); 424 break; 425 default: 426 fprintf (stderr, "error getting catalog mode\n"); 427 exit (2); 428 } 429 return (TRUE); 430 } 431 -
branches/eam_branch_20071130/Ohana/src/libdvo/src/dvo_catalog_mef.c
r15487 r15728 28 28 if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0; 29 29 30 /* save the current number so we can do partial updates */ 31 catalog[0].Naves_disk = Naverage; 32 catalog[0].Nmeas_disk = Nmeasure; 33 catalog[0].Nmiss_disk = Nmissing; 34 catalog[0].Nsecf_disk = Naverage * Nsecfilt; 35 30 36 /** Nsecfilt is unusual: it does not list the number of data items in the table 31 37 instead, the number of items is Nsecfilt * Naverage. **/ 32 38 catalog[0].Nsecfilt = Nsecfilt; 39 40 /* default values, but we will assign these a valid value before we exit (even if empty) */ 41 catalog[0].average = NULL; 42 catalog[0].measure = NULL; 43 catalog[0].missing = NULL; 44 catalog[0].secfilt = NULL; 33 45 34 46 /* validate table mode */ … … 46 58 } 47 59 /* old versions of DVO stored one of the average magnitudes in Average. we save this if needed */ 48 catalog[0].average = FtableToAverage (&ftable, & catalog[0].Naverage, &catalog[0].catformat, &primary);60 catalog[0].average = FtableToAverage (&ftable, &Naverage, &catalog[0].catformat, &primary); 49 61 if (Naverage != catalog[0].Naverage) { 50 fprintf (stderr, "Warning: mismatch between Naverage in PHU and Table headers (%d vs %d)\n", Naverage, catalog[0].Naverage); 51 } 62 fprintf (stderr, "Warning: mismatch between Naverage in PHU and Table headers (%d vs %d)\n", Naverage, catalog[0].Naves_disk); 63 } 64 catalog[0].Naverage = catalog[0].Naves_disk; 65 catalog[0].Naves_off = 0; 52 66 } else { 53 67 Nbytes = gfits_data_size (&header); 54 68 fseek (f, Nbytes, SEEK_CUR); 69 ALLOCATE (catalog[0].average, Average, 1); 70 catalog[0].Naverage = 0; 71 catalog[0].Naves_off = catalog[0].Naves_disk; 55 72 } 56 73 gfits_free_header (&header); … … 72 89 fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers (%d vs %d)\n", Nmeasure, catalog[0].Nmeasure); 73 90 } 91 catalog[0].Nmeasure = catalog[0].Nmeas_disk; 92 catalog[0].Nmeas_off = 0; 74 93 } else { 75 94 Nbytes = gfits_data_size (&header); 76 95 fseek (f, Nbytes, SEEK_CUR); 96 ALLOCATE (catalog[0].measure, Measure, 1); 97 catalog[0].Nmeasure = 0; 98 catalog[0].Nmeas_off = catalog[0].Nmeas_disk; 77 99 } 78 100 … … 93 115 fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers (%d vs %d)\n", Nmissing, catalog[0].Nmissing); 94 116 } 117 catalog[0].Nmissing = catalog[0].Nmiss_disk; 118 catalog[0].Nmiss_off = 0; 95 119 } else { 96 120 Nbytes = gfits_data_size (&header); 97 121 fseek (f, Nbytes, SEEK_CUR); 122 ALLOCATE (catalog[0].missing, Missing, 1); 123 catalog[0].Nmissing = 0; 124 catalog[0].Nmiss_off = catalog[0].Nmiss_disk; 98 125 } 99 126 … … 125 152 Ntmpfilt = catalog[0].Nsecfilt; 126 153 Nsecfilt = catalog[0].Nsecfilt + 1; 127 Ntotal = Nsecfilt * catalog[0].Nave rage;154 Ntotal = Nsecfilt * catalog[0].Naves_disk; 128 155 ALLOCATE (catalog[0].secfilt, SecFilt, Ntotal); 129 for (i = 0; i < catalog[0].Nave rage; i++) {156 for (i = 0; i < catalog[0].Naves_disk; i++) { 130 157 catalog[0].secfilt[i*Nsecfilt + 0] = primary[i]; 131 158 for (j = 0; j < Ntmpfilt; j++) { … … 134 161 } 135 162 catalog[0].Nsecfilt = Nsecfilt; 163 catalog[0].Nsecf_disk = Ntotal; 136 164 free (primary); 137 165 } 138 166 catalog[0].Nsecf_mem = catalog[0].Nsecf_disk; 167 catalog[0].Nsecf_off = 0; 139 168 } else { 140 169 /* no real need to skip the data array here... */ 141 170 Nbytes = gfits_data_size (&header); 142 171 fseek (f, Nbytes, SEEK_CUR); 143 if (primary != NULL) free (primary); 144 } 145 146 /* save the current number so we can do partial updates */ 147 catalog[0].Nave_disk = catalog[0].Naverage; 148 catalog[0].Nmeas_disk = catalog[0].Nmeasure; 149 catalog[0].Nmiss_disk = catalog[0].Nmissing; 172 if (primary != NULL) { 173 free (primary); 174 catalog[0].Nsecfilt ++; 175 catalog[0].Nsecf_disk = catalog[0].Nsecfilt * catalog[0].Naves_disk; 176 } 177 ALLOCATE (catalog[0].secfilt, SecFilt, 1); 178 catalog[0].Nsecf_mem = 0; 179 catalog[0].Nsecf_off = catalog[0].Nsecf_disk; 180 } 150 181 151 182 return (TRUE); -
branches/eam_branch_20071130/Ohana/src/libdvo/src/dvo_catalog_split.c
r15725 r15728 121 121 } 122 122 gfits_free_header (&header); 123 catalog[0].Naverage = Naverage;123 catalog[0].Naverage = catalog[0].Naves_disk; 124 124 catalog[0].Naves_off = 0; 125 125 } else { 126 126 ALLOCATE (catalog[0].average, Average, 1); 127 127 catalog[0].Naverage = 0; 128 catalog[0].Naves_off = Naverage;128 catalog[0].Naves_off = catalog[0].Naves_disk; 129 129 } 130 130 … … 221 221 Ntotal = Nsecfilt * catalog[0].Naves_disk; 222 222 ALLOCATE (catalog[0].secfilt, SecFilt, Ntotal); 223 for (i = 0; i < catalog[0].Nave rage; i++) {223 for (i = 0; i < catalog[0].Naves_disk; i++) { 224 224 catalog[0].secfilt[i*Nsecfilt + 0] = primary[i]; 225 225 for (j = 0; j < Ntmpfilt; j++) { … … 250 250 } 251 251 252 // XXX I either need to always read both average and secfilt at the same time, or 253 // do something sloppy to carry around the primary secfilt values... 252 // I need to always read both average and secfilt at the same time to correctly manage the 253 // primary secfilt values... 254 255 // XXX merge these? use the mode to choose which component? 254 256 255 257 int dvo_catalog_load_segment_split_average (Catalog *catalog, int start, int Nrows) { … … 257 259 // XXX check the open status of the FILE *f? 258 260 261 /*** Average (& SecFilt) Table ***/ 262 if (catalog[0].catflags & LOAD_AVES) { 263 264 /*** load the Average data ***/ 259 265 /* move pointer past header -- must be already read (load_catalog) */ 260 266 fseek (catalog[0].f, catalog[0].header.size, SEEK_SET); … … 290 296 catalog[0].Naves_off = start; 291 297 292 return (TRUE); 293 } 294 295 int dvo_catalog_load_segment_split_measure (Catalog *catalog, int start, int Nrows) { 296 297 // XXX check the open status of the FILE *f? 298 299 Catalog *subcat = catalog[0].measure_catalog; 300 301 /* move pointer past header -- must be already read (load_catalog) */ 302 fseek (subcat[0].f, subcat[0].header.size, SEEK_SET); 303 /* matrix should be empty : XXX should we drop this step and skip the data? */ 304 if (!gfits_fread_matrix (subcat[0].f, &matrix, &subcat[0].header)) { 305 if (VERBOSE) fprintf (stderr, "can't read primary matrix"); 306 return (FALSE); 307 } 308 /* read Measure table header */ 309 if (!gfits_fread_header (subcat[0].f, &header)) { 310 if (VERBOSE) fprintf (stderr, "can't read table measure header"); 311 return (FALSE); 312 } 313 /* read Measure table data : format is irrelevant here */ 314 if (!gfits_fread_vtable_range (subcat[0].f, &vtable, start, Nrows)) { 315 if (VERBOSE) fprintf (stderr, "can't read table measure data"); 316 return (FALSE); 317 } 318 319 /* convert data format to internal : returns number of row read in Nmeasure */ 320 catalog[0].measure = VtableToMeasure (&vtable, &Nmeasure, &catalog[0].catformat); 321 if (Nmeasure != Nrows) { 322 fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers (%d vs %d)\n", Nmeasure, Nrows); 323 } 324 gfits_free_header (&header); 325 gfits_free_matrix (&matrix); 326 catalog[0].Nmeasure = Nmeasure; 327 catalog[0].Nmeas_off = start; 328 return (TRUE); 329 } 330 331 int dvo_catalog_load_segment_split_missing (Catalog *catalog, int start, int Nrows) { 332 333 // XXX check the open status of the FILE *f? 334 335 Catalog *subcat = catalog[0].missing_catalog; 336 337 /* move pointer past header -- must be already read (load_catalog) */ 338 fseek (subcat[0].f, subcat[0].header.size, SEEK_SET); 339 /* matrix should be empty : XXX should we drop this step and skip the data? */ 340 if (!gfits_fread_matrix (subcat[0].f, &matrix, &subcat[0].header)) { 341 if (VERBOSE) fprintf (stderr, "can't read primary matrix"); 342 return (FALSE); 343 } 344 /* read Missing table header */ 345 if (!gfits_fread_header (subcat[0].f, &header)) { 346 if (VERBOSE) fprintf (stderr, "can't read table missing header"); 347 return (FALSE); 348 } 349 /* read Missing table data : format is irrelevant here */ 350 if (!gfits_fread_vtable_range (subcat[0].f, &vtable, start, Nrows)) { 351 if (VERBOSE) fprintf (stderr, "can't read table missing data"); 352 return (FALSE); 353 } 354 355 /* convert data format to internal : returns number of row read in Nmissing */ 356 catalog[0].missing = VtableToMissing (&vtable, &Nmissing, &catalog[0].catformat); 357 if (Nmissing != Nrows) { 358 fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers (%d vs %d)\n", Nmissing, Nrows); 359 } 360 gfits_free_header (&header); 361 gfits_free_matrix (&matrix); 362 catalog[0].Nmissing = Nmissing; 363 catalog[0].Nmiss_off = start; 298 /*** load the secfilt data ***/ 299 Catalog *subcat = catalog[0].secfilt_catalog; 300 301 /* move pointer past header -- must be already read (load_catalog) */ 302 fseek (subcat[0].f, subcat[0].header.size, SEEK_SET); 303 /* matrix should be empty : XXX should we drop this step and skip the data? */ 304 if (!gfits_fread_matrix (subcat[0].f, &matrix, &subcat[0].header)) { 305 if (VERBOSE) fprintf (stderr, "can't read primary matrix"); 306 return (FALSE); 307 } 308 /* read Measure table header */ 309 if (!gfits_fread_header (subcat[0].f, &header)) { 310 if (VERBOSE) fprintf (stderr, "can't read table measure header"); 311 return (FALSE); 312 } 313 /* read Measure table data : format is irrelevant here */ 314 if (!gfits_fread_vtable_range (subcat[0].f, &vtable, start, Nrows)) { 315 if (VERBOSE) fprintf (stderr, "can't read table measure data"); 316 return (FALSE); 317 } 318 319 Nexpect = Nrows * Nsecfilt; 320 catalog[0].secfilt = VtableToSecFilt (&vtable, &Nitems, &catalog[0].catformat); 321 if (Nitems != Nexpect) { 322 fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers (%d vs %d)\n", Nitems, catalog[0].Nsecf_disk); 323 } 324 325 /* if primary is defined, we were supplied with one additional average magnitude from Average 326 we need to interleave these magnitudes with the secfilt entries just loaded */ 327 if (primary != NULL) { 328 int Ntmpfilt, Ntotal, i, j; 329 SecFilt *tmpfilt; 330 tmpfilt = catalog[0].secfilt; 331 Ntmpfilt = catalog[0].Nsecfilt; 332 333 catalog[0].Nsecfilt ++; 334 catalog[0].Nsecf_disk = catalog[0].Nsecfilt * catalog[0].Naves_disk; 335 Nsecfilt = catalog[0].Nsecfilt; 336 337 // the loaded average rows correspond to the loaded secfilt rows 338 // supplement with the loaded primary secfilt data 339 Nexpect = Nrows * Nsecfilt; 340 ALLOCATE (catalog[0].secfilt, SecFilt, Nexpect); 341 for (i = 0; i < Nrows; i++) { 342 catalog[0].secfilt[i*Nsecfilt + 0] = primary[i]; 343 for (j = 0; j < Ntmpfilt; j++) { 344 catalog[0].secfilt[i*Nsecfilt + j + 1] = tmpfilt[i*Ntmpfilt + j]; 345 } 346 } 347 free (primary); 348 } 349 gfits_free_header (&header); 350 gfits_free_matrix (&matrix); 351 catalog[0].Nsecf_mem = Nexpect; 352 catalog[0].Nsecf_off = start * Nsecfilt; 353 354 // CAREFUL: note that Nsecf_disk and Nsecf_off are set to the values if there were no primary data 355 } 356 357 // XXX check the open status of the catalog 358 if (catalog[0].catflags & LOAD_MEAS) { 359 360 Catalog *subcat = catalog[0].measure_catalog; 361 362 /* move pointer past header -- must be already read (load_catalog) */ 363 fseek (subcat[0].f, subcat[0].header.size, SEEK_SET); 364 /* matrix should be empty : XXX should we drop this step and skip the data? */ 365 if (!gfits_fread_matrix (subcat[0].f, &matrix, &subcat[0].header)) { 366 if (VERBOSE) fprintf (stderr, "can't read primary matrix"); 367 return (FALSE); 368 } 369 /* read Measure table header */ 370 if (!gfits_fread_header (subcat[0].f, &header)) { 371 if (VERBOSE) fprintf (stderr, "can't read table measure header"); 372 return (FALSE); 373 } 374 /* read Measure table data : format is irrelevant here */ 375 if (!gfits_fread_vtable_range (subcat[0].f, &vtable, start, Nrows)) { 376 if (VERBOSE) fprintf (stderr, "can't read table measure data"); 377 return (FALSE); 378 } 379 380 /* convert data format to internal : returns number of row read in Nmeasure */ 381 catalog[0].measure = VtableToMeasure (&vtable, &Nmeasure, &catalog[0].catformat); 382 if (Nmeasure != Nrows) { 383 fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers (%d vs %d)\n", Nmeasure, Nrows); 384 } 385 gfits_free_header (&header); 386 gfits_free_matrix (&matrix); 387 catalog[0].Nmeasure = Nmeasure; 388 catalog[0].Nmeas_off = start; 389 } 390 391 // XXX check the open status of the catalog? 392 if (catalog[0].catflags & LOAD_MISS) { 393 394 Catalog *subcat = catalog[0].missing_catalog; 395 396 /* move pointer past header -- must be already read (load_catalog) */ 397 fseek (subcat[0].f, subcat[0].header.size, SEEK_SET); 398 /* matrix should be empty : XXX should we drop this step and skip the data? */ 399 if (!gfits_fread_matrix (subcat[0].f, &matrix, &subcat[0].header)) { 400 if (VERBOSE) fprintf (stderr, "can't read primary matrix"); 401 return (FALSE); 402 } 403 /* read Missing table header */ 404 if (!gfits_fread_header (subcat[0].f, &header)) { 405 if (VERBOSE) fprintf (stderr, "can't read table missing header"); 406 return (FALSE); 407 } 408 /* read Missing table data : format is irrelevant here */ 409 if (!gfits_fread_vtable_range (subcat[0].f, &vtable, start, Nrows)) { 410 if (VERBOSE) fprintf (stderr, "can't read table missing data"); 411 return (FALSE); 412 } 413 414 /* convert data format to internal : returns number of row read in Nmissing */ 415 catalog[0].missing = VtableToMissing (&vtable, &Nmissing, &catalog[0].catformat); 416 if (Nmissing != Nrows) { 417 fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers (%d vs %d)\n", Nmissing, Nrows); 418 } 419 gfits_free_header (&header); 420 gfits_free_matrix (&matrix); 421 catalog[0].Nmissing = Nmissing; 422 catalog[0].Nmiss_off = start; 423 } 364 424 return (TRUE); 365 425 }
Note:
See TracChangeset
for help on using the changeset viewer.
