Changeset 8386 for trunk/Ohana/src/libdvo
- Timestamp:
- Aug 16, 2006, 10:12:55 AM (20 years ago)
- Location:
- trunk/Ohana/src/libdvo
- Files:
-
- 5 edited
-
include/dvo.h (modified) (1 diff)
-
src/dvo_catalog.c (modified) (8 diffs)
-
src/dvo_catalog_create.c (modified) (1 diff)
-
src/dvo_catalog_split.c (modified) (11 diffs)
-
src/skyregion_gsc.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libdvo/include/dvo.h
r8342 r8386 280 280 int dvo_catalog_catformat (char *catformat); 281 281 int dvo_catalog_catmode (char *catmode); 282 void dvo_catalog_test (Catalog *catalog, int halt); 282 283 283 284 /* catmode-specific APIs */ -
trunk/Ohana/src/libdvo/src/dvo_catalog.c
r8342 r8386 1 1 # include <dvo.h> 2 2 # define DEBUG 1 3 4 void dvo_catalog_test (Catalog *catalog, int halt) { 5 6 Catalog *subcat; 7 8 // fprintf (stderr, "catalog: Naverage = %d, average = %zx\n", catalog[0].Naverage, (size_t) catalog[0].average); 9 // fprintf (stderr, "catalog: Nmeasure = %d, measure = %zx\n", catalog[0].Nmeasure, (size_t) catalog[0].measure); 10 // fprintf (stderr, "catalog: Nmissing = %d, missing = %zx\n", catalog[0].Nmissing, (size_t) catalog[0].missing); 11 // fprintf (stderr, "catalog: Nsecfilt = %d, secfilt = %zx\n", catalog[0].Nsecfilt, (size_t) catalog[0].secfilt); 12 13 if (!catalog[0].measure || !catalog[0].secfilt) { 14 fprintf (stderr, "error: %s\n", catalog[0].filename); 15 if (halt) abort (); 16 } 17 18 // XXX test that things are correctly initialized 19 if (catalog[0].catmode != DVO_MODE_SPLIT) return; 20 21 subcat = catalog[0].measure_catalog; 22 if (subcat) { 23 if (subcat[0].measure_catalog || subcat[0].secfilt_catalog || subcat[0].missing_catalog) { 24 fprintf (stderr, "error in init\n"); 25 abort (); 26 } 27 } 28 subcat = catalog[0].missing_catalog; 29 if (subcat) { 30 if (subcat[0].measure_catalog || subcat[0].secfilt_catalog || subcat[0].missing_catalog) { 31 fprintf (stderr, "error in init\n"); 32 abort (); 33 } 34 } 35 subcat = catalog[0].secfilt_catalog; 36 if (subcat) { 37 if (subcat[0].measure_catalog || subcat[0].secfilt_catalog || subcat[0].missing_catalog) { 38 fprintf (stderr, "error in init\n"); 39 abort (); 40 } 41 } 42 } 3 43 4 44 int dvo_catalog_catformat (char *catformat) { … … 35 75 catalog[0].catflags = 0; 36 76 catalog[0].sorted = 0; 37 38 gfits_init_header (&catalog[0].header); 39 }77 } 78 79 gfits_init_header (&catalog[0].header); 40 80 41 81 // the following describe the catalog files on disk … … 102 142 // attempt to unlink an empty file 103 143 fd = fileno (catalog[0].f); 104 if ( fstat (fd, &filestat)) {144 if (!fstat (fd, &filestat)) { 105 145 if (filestat.st_size == 0) { 106 146 unlink (catalog[0].filename); … … 121 161 // returns FALSE if a catalog could not be opened 122 162 // returns TRUE if the catalog was empty 163 enum {DVO_OPEN_NONE, DVO_OPEN_READ, DVO_OPEN_WRITE, DVO_OPEN_UPDATE); 123 164 int dvo_catalog_open (Catalog *catalog, SkyRegion *region, int VERBOSE, char *iomode) { 124 165 125 int Nsecfilt ;126 int readonly; 127 128 readonly = -1;129 if (!strcasecmp (iomode, " r")) readonly = TRUE;130 if (!strcasecmp (iomode, " w")) readonly = FALSE;131 if ( readonly == -1) return (FALSE);166 int Nsecfilt, mode; 167 168 mode = DVO_OPEN_NONE; 169 if (!strcasecmp (iomode, "r")) mode = DVO_OPEN_READ; 170 if (!strcasecmp (iomode, "w")) mode = DVO_OPEN_WRITE; 171 if (!strcasecmp (iomode, "a")) mode = DVO_OPEN_UPDATE; 172 if (mode == DVO_OPEN_NONE) return (FALSE); 132 173 133 174 catalog[0].lockmode = LCK_XCLD; 134 if ( readonly) catalog[0].lockmode = LCK_SOFT;175 if (mode == DVO_OPEN_READ) catalog[0].lockmode = LCK_SOFT; 135 176 136 177 // XXX make a backup? always? … … 161 202 break; 162 203 case 2: 163 if ( readonly) return (TRUE);204 if (DVO_OPEN_READ || DVO_OPEN_UPDATE) return (TRUE); 164 205 dvo_catalog_create (region, catalog, Nsecfilt); /* fills in new header info */ 165 206 if (VERBOSE) fprintf (stderr, "creating new file %s\n", catalog[0].filename); … … 177 218 char measure[80]; 178 219 220 dvo_catalog_init (catalog, FALSE); 221 179 222 // load the main catalog header, determine characteristics 180 223 if (!gfits_fread_header (catalog[0].f, &catalog[0].header)) { … … 200 243 catalog[0].catformat = DVO_FORMAT_UNDEF; 201 244 202 catalog[0].average = NULL;203 catalog[0].secfilt = NULL;204 catalog[0].measure = NULL;205 catalog[0].missing = NULL;206 207 245 switch (catalog[0].catmode) { 208 246 case DVO_MODE_RAW: … … 217 255 if (VERBOSE) fprintf (stderr, "reading catalog (mode DVO_MODE_SPLIT)\n"); 218 256 dvo_catalog_load_split (catalog, VERBOSE); 257 dvo_catalog_test (catalog, TRUE); 219 258 break; 220 259 default: -
trunk/Ohana/src/libdvo/src/dvo_catalog_create.c
r8342 r8386 1 1 # include <dvo.h> 2 # define DEBUG 12 # define DEBUG 0 3 3 4 4 // create a new dvo catalog file (if split, lock extra files as well?) -
trunk/Ohana/src/libdvo/src/dvo_catalog_split.c
r8342 r8386 60 60 gfits_free_header (&header); 61 61 } 62 dvo_catalog_test (catalog, FALSE); 62 63 63 64 /*** Measure Table ***/ … … 68 69 if (catalog[0].catflags & LOAD_MEAS) { 69 70 ALLOCATE (measure, Catalog, 1); 70 measure[0].measure_catalog = NULL; 71 measure[0].missing_catalog = NULL; 72 measure[0].secfilt_catalog = NULL; 71 dvo_catalog_init (measure, TRUE); 73 72 74 73 /* get split filename from main header (paths relative to cpt file) */ … … 90 89 /* matrix should be empty */ 91 90 if (!gfits_fread_matrix (measure[0].f, &matrix, &measure[0].header)) { 92 if (VERBOSE) fprintf (stderr, "can't read primary matrix ");91 if (VERBOSE) fprintf (stderr, "can't read primary matrix\n"); 93 92 return (FALSE); 94 93 } 95 94 /* read Measure table header */ 96 95 if (!gfits_fread_header (measure[0].f, &header)) { 97 if (VERBOSE) fprintf (stderr, "can't read measure PHU header ");96 if (VERBOSE) fprintf (stderr, "can't read measure PHU header\n"); 98 97 return (FALSE); 99 98 } 100 99 /* read Measure table data */ 101 100 if (!gfits_fread_ftable_data (measure[0].f, &ftable)) { 102 if (VERBOSE) fprintf (stderr, "can't read table measure data ");101 if (VERBOSE) fprintf (stderr, "can't read table measure data\n"); 103 102 return (FALSE); 104 103 } … … 112 111 gfits_free_matrix (&matrix); 113 112 } 113 dvo_catalog_test (catalog, FALSE); 114 114 115 115 /* (Meta Load) */ 116 116 if (catalog[0].catflags & LOAD_MEAS_META) { 117 117 ALLOCATE (measure, Catalog, 1); 118 dvo_catalog_init (measure, TRUE); 118 119 119 120 /* get split filename from main header (paths relative to cpt file) */ … … 142 143 } 143 144 catalog[0].measure_catalog = measure; 145 dvo_catalog_test (catalog, FALSE); 144 146 145 147 /*** Missing Table ***/ … … 148 150 if (catalog[0].catflags & LOAD_MISS) { 149 151 ALLOCATE (missing, Catalog, 1); 150 missing[0].measure_catalog = NULL; 151 missing[0].missing_catalog = NULL; 152 missing[0].secfilt_catalog = NULL; 152 dvo_catalog_init (missing, TRUE); 153 153 154 154 /* get split filename from main header (paths relative to cpt file) */ … … 170 170 /* matrix should be empty */ 171 171 if (!gfits_fread_matrix (missing[0].f, &matrix, &missing[0].header)) { 172 if (VERBOSE) fprintf (stderr, "can't read primary matrix ");172 if (VERBOSE) fprintf (stderr, "can't read primary matrix\n"); 173 173 return (FALSE); 174 174 } 175 175 /* read Missing table header */ 176 176 if (!gfits_fread_header (missing[0].f, &header)) { 177 if (VERBOSE) fprintf (stderr, "can't read table missing header ");177 if (VERBOSE) fprintf (stderr, "can't read table missing header\n"); 178 178 return (FALSE); 179 179 } 180 180 /* read Missing table data */ 181 181 if (!gfits_fread_ftable_data (missing[0].f, &ftable)) { 182 if (VERBOSE) fprintf (stderr, "can't read table missing data ");182 if (VERBOSE) fprintf (stderr, "can't read table missing data\n"); 183 183 return (FALSE); 184 184 } … … 192 192 } 193 193 catalog[0].missing_catalog = missing; 194 dvo_catalog_test (catalog, FALSE); 194 195 195 196 /*** Secfilt Table ***/ … … 198 199 if (catalog[0].catflags & LOAD_SECF) { 199 200 ALLOCATE (secfilt, Catalog, 1); 200 secfilt[0].measure_catalog = NULL; 201 secfilt[0].missing_catalog = NULL; 202 secfilt[0].secfilt_catalog = NULL; 201 dvo_catalog_init (secfilt, TRUE); 203 202 204 203 /* get split filename from main header (paths relative to cpt file) */ … … 220 219 /* matrix should be empty */ 221 220 if (!gfits_fread_matrix (secfilt[0].f, &matrix, &secfilt[0].header)) { 222 if (VERBOSE) fprintf (stderr, "can't read primary matrix ");221 if (VERBOSE) fprintf (stderr, "can't read primary matrix\n"); 223 222 return (FALSE); 224 223 } 225 224 /* read secfilt table header */ 226 225 if (!gfits_fread_header (secfilt[0].f, &header)) { 227 if (VERBOSE) fprintf (stderr, "can't read table secfilt header ");226 if (VERBOSE) fprintf (stderr, "can't read table secfilt header\n"); 228 227 return (FALSE); 229 228 } 230 229 /* read secfilt table data */ 231 230 if (!gfits_fread_ftable_data (secfilt[0].f, &ftable)) { 232 if (VERBOSE) fprintf (stderr, "can't read table secfilt data ");231 if (VERBOSE) fprintf (stderr, "can't read table secfilt data\n"); 233 232 return (FALSE); 234 233 } … … 242 241 } 243 242 catalog[0].secfilt_catalog = secfilt; 243 dvo_catalog_test (catalog, FALSE); 244 244 245 245 /* save the current number so we can do partial updates */ -
trunk/Ohana/src/libdvo/src/skyregion_gsc.c
r8342 r8386 2 2 # define NDECBANDS 24 3 3 # define NDIV 4 4 # define DEBUG 0 4 5 5 6 static int DecLines[] = {593, 584, 551, 530, 522, 465, 406, 362, 280, 198, 123, 25, 597, 578, 574, 577, 534, 499, 442, 376, 294, 212, 144, 48}; … … 85 86 L0.regions[0].childE = NDECBANDS; 86 87 strcpy (L0.regions[0].name, "fullsky"); 87 //SkyRegionPrint (&L0.regions[0]);88 if (DEBUG) SkyRegionPrint (&L0.regions[0]); 88 89 89 90 /* allocate space for all levels */ … … 93 94 ALLOCATE (L3.regions, SkyRegion, 1); 94 95 ALLOCATE (L4.regions, SkyRegion, 1); 96 97 // skipLines = 0; 98 // for (i = 0; i < 16; i++) skipLines += DecLines[i]; 99 // for (i = 16; i < 17; i++) { 95 100 96 101 /* L1 : dec bands */ … … 107 112 L1.regions[i].table = -1; 108 113 strcpy (L1.regions[i].name, DecNames[i]); 109 //SkyRegionPrint (&L1.regions[i]);114 if (DEBUG) SkyRegionPrint (&L1.regions[i]); 110 115 111 116 /* build the L2 regions for this L1 region (based on zones) */ … … 123 128 /* subdivide each zone */ 124 129 for (j = 0; j < Nzones; j++) { 130 if (DEBUG) fprintf (stderr, "zone: %d : %f - %f : %f - %f\n", j, zones[j].Rmin, zones[j].Rmax, zones[j].Dmin, zones[j].Dmax); 125 131 SkyTableL2fromZone (&L2, &L3, &L4, band, &zones[j], i); 126 132 } … … 273 279 Dmax = MAX (regions[i].Dmax, Dmax); 274 280 dDec = regions[i].Dmax - regions[i].Dmin; 275 if ( dDec != zones[Nz].dDec) {281 if (fabs(dDec - zones[Nz].dDec) > 0.001) { 276 282 /* we've found the end of the current zone */ 277 283 zones[Nz].L3end = i; … … 347 353 *p = '/'; 348 354 strcpy (L2[0].regions[Nr].name, name); 349 //SkyRegionPrint (&L2[0].regions[Nr]);355 if (DEBUG) SkyRegionPrint (&L2[0].regions[Nr]); 350 356 351 357 /* childS and childE are set in SkyTableL3fromL2 */ … … 383 389 L3[0].regions[Nr].childE = 0; 384 390 385 //SkyRegionPrint (&L3[0].regions[Nr]);391 if (DEBUG) SkyRegionPrint (&L3[0].regions[Nr]); 386 392 /* name is set for the band in SkyRegionForDecBand */ 387 393 … … 432 438 sprintf (name, "%s.%02d", L3[0].name, Nbox); 433 439 strcpy (L4[0].regions[Nr].name, name); 434 //SkyRegionPrint (&L4[0].regions[Nr]);440 if (DEBUG) SkyRegionPrint (&L4[0].regions[Nr]); 435 441 436 442 Nr ++;
Note:
See TracChangeset
for help on using the changeset viewer.
