Changeset 31668
- Timestamp:
- Jun 22, 2011, 12:43:18 AM (15 years ago)
- Location:
- trunk/Ohana/src/relphot
- Files:
-
- 11 edited
-
doc/allsky.txt (modified) (1 diff)
-
include/relphot.h (modified) (5 diffs)
-
src/ImageOps.c (modified) (11 diffs)
-
src/MosaicOps.c (modified) (14 diffs)
-
src/StarOps.c (modified) (1 diff)
-
src/args.c (modified) (1 diff)
-
src/bcatalog.c (modified) (3 diffs)
-
src/load_catalogs.c (modified) (3 diffs)
-
src/load_images.c (modified) (3 diffs)
-
src/reload_catalogs.c (modified) (3 diffs)
-
src/relphot.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relphot/doc/allsky.txt
r31450 r31668 1 2 2011.05.10 3 4 Looking into them memory usage of relphot: 5 AverageTiny = 32 bytes (including 8 byte padding) 6 MeasureTiny = 56 bytes (including 8 byte padding) 7 Image Indexes: 8 bin : Nmeasure * off_t 9 clist : Nmeasure * off_t 10 mlist : Nmeasure * off_t 11 Mosaic Indexes: 12 bin : Nmeasure * off_t 13 clist : Nmeasure * off_t 14 mlist : Nmeasure * off_t 15 Total: 16 32 bytes * Naverage (values) 17 56 bytes * Nmeasure (values) 18 64 bytes * Nmeasure (indexes) 19 20 In my test run, I have 3.3M average + 37.6M measure: 21 2.1GB values 22 2.2GB indexes 23 24 This matches the memory usage graph. But, after the indexes have 25 been loaded, the memory footprint grows (slowly) by another 1GB as 26 the processing runs along. 27 28 29 using 23153493 of 640663697 stars (192585953 of 289672671 measurements) 30 using 3306896 of 48399614 stars ( 37582679 of 193863612 measurements) 31 32 1 33 2 34 2011.04.12 -
trunk/Ohana/src/relphot/include/relphot.h
r31639 r31668 63 63 int RESET; 64 64 int UPDATE; 65 int SAVE_IMAGE_UPDATES; 65 66 int PLOTSTUFF; 66 67 int SAVEPLOT; … … 139 140 void dump_grid PROTO((void)); 140 141 int edge_check PROTO((double *x1, double *y1, double *x2, double *y2)); 141 void findImages PROTO((Catalog *catalog, int Ncatalog ));142 int findMosaics PROTO((Catalog *catalog, int Ncatalog ));142 void findImages PROTO((Catalog *catalog, int Ncatalog, int doImageList)); 143 int findMosaics PROTO((Catalog *catalog, int Ncatalog, int doMosaicList)); 143 144 144 145 void set_db (FITS_DB *in); … … 149 150 150 151 void freeGridBins PROTO((int Ncatalog)); 151 void freeImageBins PROTO((int Ncatalog ));152 void freeMosaicBins PROTO((int Ncatalog ));152 void freeImageBins PROTO((int Ncatalog, int doImageList)); 153 void freeMosaicBins PROTO((int Ncatalog, int doMosaicList)); 153 154 void free_catalogs PROTO((Catalog *catalog, int Ncatalog)); 154 155 int gcatalog PROTO((Catalog *catalog, int FINAL)); … … 160 161 float getMrel PROTO((Catalog *catalog, off_t meas, int cat)); 161 162 Image *getimage PROTO((off_t N)); 162 Image *getimages PROTO((off_t *N ));163 Image *getimages PROTO((off_t *N, off_t **LineNumber)); 163 164 void global_stats PROTO((Catalog *catalog, int Ncatalog)); 164 165 void initGrid PROTO((int dX, int dY)); 165 166 void initGridBins PROTO((Catalog *catalog, int Ncatalog)); 166 void initImageBins PROTO((Catalog *catalog, int Ncatalog ));167 void initImages PROTO((Image *input, off_t N));168 void initMosaicBins PROTO((Catalog *catalog, int Ncatalog ));167 void initImageBins PROTO((Catalog *catalog, int Ncatalog, int doImageList)); 168 void initImages PROTO((Image *input, off_t *LineNumber, off_t N)); 169 void initMosaicBins PROTO((Catalog *catalog, int Ncatalog, int doMosaicList)); 169 170 void initMosaicGrid PROTO((Image *image, off_t Nimage)); 170 171 void initMosaics PROTO((Image *image, off_t Nimage)); … … 179 180 int main PROTO((int argc, char **argv)); 180 181 void mark_images PROTO((Image *image, off_t Nimage, Image *timage, off_t Ntimage)); 181 void matchImage PROTO((Catalog *catalog, off_t meas, int cat ));182 void matchMosaics PROTO((Catalog *catalog, off_t meas, int cat ));182 void matchImage PROTO((Catalog *catalog, off_t meas, int cat, int doImageList)); 183 void matchMosaics PROTO((Catalog *catalog, off_t meas, int cat, int doMosaicList)); 183 184 double opening_angle PROTO((double x1, double y1, double x2, double y2, double x3, double y3)); 184 185 void plot_chisq PROTO((Catalog *catalog, int Ncatalog)); -
trunk/Ohana/src/relphot/src/ImageOps.c
r31450 r31668 9 9 static Image *image; // list of available images 10 10 static off_t Nimage; // number of available images 11 static off_t *LineNumber; // match of subset to full image table 11 12 12 13 // to search by image ID, we sort (imageIDs, imageIdx) by imageIDs to get a sorted index … … 14 15 static off_t *imageIdx; // list of index for image IDs 15 16 16 Image *getimages (off_t *N ) {17 Image *getimages (off_t *N, off_t **line_number) { 17 18 18 19 *N = Nimage; 20 if (line_number) *line_number = LineNumber; 19 21 return (image); 20 22 } … … 24 26 } 25 27 26 void initImages (Image *input, off_t N) {28 void initImages (Image *input, off_t *line_number, off_t N) { 27 29 28 30 off_t i; 29 31 30 32 image = input; 33 LineNumber = line_number; 31 34 Nimage = N; 32 35 … … 66 69 } 67 70 68 void initImageBins (Catalog *catalog, int Ncatalog ) {71 void initImageBins (Catalog *catalog, int Ncatalog, int doImageList) { 69 72 70 73 off_t i, j; … … 76 79 } 77 80 78 ALLOCATE (Nlist, off_t, Nimage); 79 ALLOCATE (NLIST, off_t, Nimage); 80 ALLOCATE (clist, off_t *, Nimage); 81 ALLOCATE (mlist, off_t *, Nimage); 82 83 for (i = 0; i < Nimage; i++) { 84 Nlist[i] = 0; 85 NLIST[i] = 100; 86 ALLOCATE (clist[i], off_t, NLIST[i]); 87 ALLOCATE (mlist[i], off_t, NLIST[i]); 88 } 89 } 90 91 void freeImageBins (int Ncatalog) { 81 if (doImageList) { 82 ALLOCATE (Nlist, off_t, Nimage); 83 ALLOCATE (NLIST, off_t, Nimage); 84 ALLOCATE (clist, off_t *, Nimage); 85 ALLOCATE (mlist, off_t *, Nimage); 86 87 for (i = 0; i < Nimage; i++) { 88 Nlist[i] = 0; 89 NLIST[i] = 100; 90 ALLOCATE (clist[i], off_t, NLIST[i]); 91 ALLOCATE (mlist[i], off_t, NLIST[i]); 92 } 93 } 94 } 95 96 void freeImageBins (int Ncatalog, int doImageList) { 92 97 93 98 off_t i; … … 97 102 } 98 103 free (bin); 99 for (i = 0; i < Nimage; i++) { 100 free (clist[i]); 101 free (mlist[i]); 102 } 103 free (clist); 104 free (mlist); 105 free (Nlist); 106 free (NLIST); 104 105 if (doImageList) { 106 for (i = 0; i < Nimage; i++) { 107 free (clist[i]); 108 free (mlist[i]); 109 } 110 free (clist); 111 free (mlist); 112 free (Nlist); 113 free (NLIST); 114 } 107 115 } 108 116 109 117 /* select all image equivalent to the active photcode set */ 110 void findImages (Catalog *catalog, int Ncatalog ) {118 void findImages (Catalog *catalog, int Ncatalog, int doImageList) { 111 119 112 120 off_t j; … … 122 130 } 123 131 if (!found) continue; 124 matchImage (catalog, j, i );132 matchImage (catalog, j, i, doImageList); 125 133 Nmatch ++; 126 134 } … … 178 186 } 179 187 180 void matchImage (Catalog *catalog, off_t meas, int cat ) {188 void matchImage (Catalog *catalog, off_t meas, int cat, int doImageList) { 181 189 182 190 off_t idx, ID; … … 204 212 bin[cat][meas] = idx; 205 213 206 // index for image, Nentry -> catalog 207 clist[idx][Nlist[idx]] = cat; 208 209 // index for image, Nentry -> measure 210 mlist[idx][Nlist[idx]] = meas; 211 Nlist[idx] ++; 212 213 if (Nlist[idx] == NLIST[idx]) { 214 NLIST[idx] += 100; 215 REALLOCATE (clist[idx], off_t, NLIST[idx]); 216 REALLOCATE (mlist[idx], off_t, NLIST[idx]); 217 } 214 if (doImageList) { 215 // index for image, Nentry -> catalog 216 clist[idx][Nlist[idx]] = cat; 217 218 // index for image, Nentry -> measure 219 mlist[idx][Nlist[idx]] = meas; 220 Nlist[idx] ++; 221 222 if (Nlist[idx] == NLIST[idx]) { 223 NLIST[idx] += 100; 224 REALLOCATE (clist[idx], off_t, NLIST[idx]); 225 REALLOCATE (mlist[idx], off_t, NLIST[idx]); 226 } 227 } 218 228 219 229 return; … … 343 353 344 354 liststats (list, dlist, N, &stats); 355 356 float CLOUD_TOLERANCE = 0.01; 345 357 image[i].Mcal = stats.mean; 346 358 image[i].dMcal = stats.error; … … 348 360 image[i].nFitPhotom = N; 349 361 image[i].Xm = 100.0*log10(stats.chisq); 362 363 if (image[i].Mcal < -CLOUD_TOLERANCE) { 364 image[i].Mcal = 0.0; 365 } 350 366 } 351 367 free (list); -
trunk/Ohana/src/relphot/src/MosaicOps.c
r31450 r31668 195 195 if (!MOSAIC_ZEROPT) return; 196 196 197 image = getimages (&Nimage); 198 197 image = getimages (&Nimage, NULL); 198 199 // copy the mosaic results to the images. set the mosaic Mcal to 0.0 since we have moved its 200 // impact to the images 199 201 for (i = 0; i < Nmosaic; i++) { 200 202 for (j = 0; j < Nimlist[i]; j++) { 201 203 im = imlist[i][j]; 202 image[im].Mcal = mosaic[i].Mcal;204 image[im].Mcal += mosaic[i].Mcal; 203 205 image[im].dMcal = mosaic[i].dMcal; 204 206 image[im].Xm = mosaic[i].Xm; … … 208 210 image[im].flags |= (mosaic[i].flags & ID_IMAGE_PHOTOM_POOR); 209 211 } 212 mosaic[i].Mcal = 0.0; 210 213 } 211 214 } 212 215 213 void initMosaicBins (Catalog *catalog, int Ncatalog ) {216 void initMosaicBins (Catalog *catalog, int Ncatalog, int doMosaicList) { 214 217 215 218 off_t i, j; … … 224 227 } 225 228 226 /* mosaic -> measure */ 227 ALLOCATE (Nlist, off_t, Nmosaic); 228 ALLOCATE (NLIST, off_t, Nmosaic); 229 ALLOCATE (clist, int *, Nmosaic); 230 ALLOCATE (mlist, off_t *, Nmosaic); 231 232 for (i = 0; i < Nmosaic; i++) { 233 Nlist[i] = 0; 234 NLIST[i] = 100; 235 ALLOCATE (clist[i], int, NLIST[i]); 236 ALLOCATE (mlist[i], off_t, NLIST[i]); 237 } 238 } 239 240 void freeMosaicBins (int Ncatalog) { 229 if (doMosaicList) { 230 /* mosaic -> measure */ 231 ALLOCATE (Nlist, off_t, Nmosaic); 232 ALLOCATE (NLIST, off_t, Nmosaic); 233 ALLOCATE (clist, int *, Nmosaic); 234 ALLOCATE (mlist, off_t *, Nmosaic); 235 236 for (i = 0; i < Nmosaic; i++) { 237 Nlist[i] = 0; 238 NLIST[i] = 100; 239 ALLOCATE (clist[i], int, NLIST[i]); 240 ALLOCATE (mlist[i], off_t, NLIST[i]); 241 } 242 } 243 } 244 245 void freeMosaicBins (int Ncatalog, int doMosaicList) { 241 246 242 247 off_t i; … … 250 255 free (bin); 251 256 252 /* mosaic -> measure */ 253 for (i = 0; i < Nmosaic; i++) { 254 free (clist[i]); 255 free (mlist[i]); 256 } 257 free (Nlist); 258 free (NLIST); 259 free (clist); 260 free (mlist); 261 } 262 263 int findMosaics (Catalog *catalog, int Ncatalog) { 257 if (doMosaicList) { 258 /* mosaic -> measure */ 259 for (i = 0; i < Nmosaic; i++) { 260 free (clist[i]); 261 free (mlist[i]); 262 } 263 free (Nlist); 264 free (NLIST); 265 free (clist); 266 free (mlist); 267 } 268 } 269 270 int findMosaics (Catalog *catalog, int Ncatalog, int doMosaicList) { 264 271 265 272 int i, ecode, found, Ns; … … 281 288 } 282 289 if (!found) continue; 283 matchMosaics (catalog, j, i );290 matchMosaics (catalog, j, i, doMosaicList); 284 291 Nmatch ++; 285 292 } … … 289 296 } 290 297 291 void matchMosaics (Catalog *catalog, off_t meas, int cat ) {298 void matchMosaics (Catalog *catalog, off_t meas, int cat, int doMosaicList) { 292 299 293 300 off_t idx, ID, mosID; … … 322 329 bin[cat][meas] = mosID; 323 330 324 clist[mosID][Nlist[mosID]] = cat; 325 mlist[mosID][Nlist[mosID]] = meas; 326 Nlist[mosID] ++; 331 if (doMosaicList) { 332 clist[mosID][Nlist[mosID]] = cat; 333 mlist[mosID][Nlist[mosID]] = meas; 334 Nlist[mosID] ++; 327 335 328 if (Nlist[mosID] == NLIST[mosID]) { 329 NLIST[mosID] += 100; 330 REALLOCATE (clist[mosID], int, NLIST[mosID]); 331 REALLOCATE (mlist[mosID], off_t, NLIST[mosID]); 332 } 336 if (Nlist[mosID] == NLIST[mosID]) { 337 NLIST[mosID] += 100; 338 REALLOCATE (clist[mosID], int, NLIST[mosID]); 339 REALLOCATE (mlist[mosID], off_t, NLIST[mosID]); 340 } 341 } 333 342 return; 334 343 } … … 361 370 if (FREEZE_MOSAICS) return (FALSE); 362 371 363 image = getimages (&N );372 image = getimages (&N, NULL); 364 373 365 374 Nsecfilt = GetPhotcodeNsecfilt (); … … 442 451 liststats (list, dlist, N, &stats); 443 452 if (PoorImages) fprintf (stderr, "Mmos: %f %f %d "OFF_T_FMT"\n", stats.mean, stats.sigma, stats.Nmeas, N); 453 454 float CLOUD_TOLERANCE = 0.01; 444 455 mosaic[i].Mcal = stats.mean; 445 456 mosaic[i].dMcal = stats.error; … … 447 458 mosaic[i].nFitPhotom = N; 448 459 mosaic[i].Xm = 100.0*log10(stats.chisq); 460 461 if (mosaic[i].Mcal < -CLOUD_TOLERANCE) { 462 mosaic[i].Mcal = 0.0; 463 } 449 464 } 450 465 free (list); … … 482 497 if (FREEZE_MOSAICS) return (FALSE); 483 498 484 image = getimages (&Nimage );499 image = getimages (&Nimage, NULL); 485 500 486 501 ALLOCATE (imageOffset, double, Nmosaic); 487 488 502 ALLOCATE ( Slist, int *, Nmosaic); // array of calibrated star indexes on this mosaic 489 503 ALLOCATE (NSlist, int, Nmosaic); // number of stars on mosaic … … 621 635 float dM = 0.0; 622 636 for (j = 0; j < NSlist[i]; j++) { 623 Nstars= Slist[i][j];624 if (starNcount[ Nstars][Ns] > 1) {625 dM += (starOffset[ Nstars][Ns] / starNcount[Nstars][Ns]);637 k = Slist[i][j]; 638 if (starNcount[k][Ns] > 1) { 639 dM += (starOffset[k][Ns] / starNcount[k][Ns]); 626 640 } 627 641 } … … 647 661 free (starNcount); 648 662 663 free (seclist); 664 free (NSlist); 665 free (NSLIST); 649 666 for (i = 0; i < Nmosaic; i++){ 650 667 free (Slist[i]); 651 668 } 652 free (NSlist); 653 free (NSLIST); 669 free (Slist); 654 670 free (imageOffset); 655 free (seclist);656 671 return (TRUE); 657 672 } … … 853 868 if (!MOSAIC_ZEROPT) return; 854 869 855 image = getimages (&Nimage );870 image = getimages (&Nimage, NULL); 856 871 857 872 N = 0; -
trunk/Ohana/src/relphot/src/StarOps.c
r31450 r31668 587 587 initstats (STATMODE); 588 588 if (VERBOSE) fprintf (stderr, OFF_T_FMT" measures marked poor, "OFF_T_FMT" total\n", Ndel, Nave); 589 free (list); 590 free (dlist); 589 591 free (ilist); 590 592 free (tlist); -
trunk/Ohana/src/relphot/src/args.c
r31450 r31668 128 128 } 129 129 130 SAVE_IMAGE_UPDATES = TRUE; 131 if ((N = get_argument (argc, argv, "-skip-image-updates"))) { 132 remove_argument (N, &argc, argv); 133 SAVE_IMAGE_UPDATES = FALSE; 134 } 135 130 136 MaxDensityUse = FALSE; 131 137 if ((N = get_argument (argc, argv, "-max-density"))) { -
trunk/Ohana/src/relphot/src/bcatalog.c
r31450 r31668 5 5 int CopyAverageTiny (AverageTiny *averageT, Average *average) { 6 6 7 averageT[0].R = average[0].R;8 averageT[0].D = average[0].D;9 averageT[0].flags = average[0].flags;7 averageT[0].R = average[0].R; 8 averageT[0].D = average[0].D; 9 averageT[0].flags = average[0].flags; 10 10 averageT[0].Nmeasure = average[0].Nmeasure; 11 11 averageT[0].measureOffset = average[0].measureOffset; … … 293 293 off_t i; 294 294 295 AverageTiny *averageT; 296 Average *average; 297 298 MeasureTiny *measureT; 299 Measure *measure; 300 295 301 ALLOCATE (catalog[0].measureT, MeasureTiny, catalog[0].Nmeasure); 296 302 ALLOCATE (catalog[0].averageT, AverageTiny, catalog[0].Naverage); 297 303 304 average = catalog[0].average; 305 averageT = catalog[0].averageT; 306 307 measure = catalog[0].measure; 308 measureT = catalog[0].measureT; 309 298 310 for (i = 0; i < catalog[0].Naverage; i++) { 299 CopyAverageTiny (&catalog[0].averageT[i], &catalog[0].average[i]); 311 // CopyAverageTiny (&catalog[0].averageT[i], &catalog[0].average[i]); 312 averageT[i].R = average[i].R; 313 averageT[i].D = average[i].D; 314 averageT[i].flags = average[i].flags; 315 averageT[i].Nmeasure = average[i].Nmeasure; 316 averageT[i].measureOffset = average[i].measureOffset; 300 317 } 301 318 302 319 for (i = 0; i < catalog[0].Nmeasure; i++) { 303 CopyMeasureTiny (&catalog[0].measureT[i], &catalog[0].measure[i]); 320 // CopyMeasureTiny (&catalog[0].measureT[i], &catalog[0].measure[i]); 321 measureT[i].dR = measure[i].dR; 322 measureT[i].dD = measure[i].dD; 323 measureT[i].M = measure[i].M; 324 measureT[i].Mcal = measure[i].Mcal; 325 measureT[i].dM = measure[i].dM; 326 measureT[i].airmass = measure[i].airmass; 327 measureT[i].Xccd = measure[i].Xccd; 328 measureT[i].Yccd = measure[i].Yccd; 329 measureT[i].t = measure[i].t; 330 measureT[i].dt = measure[i].dt; 331 measureT[i].averef = measure[i].averef; 332 measureT[i].imageID = measure[i].imageID; 333 measureT[i].dbFlags = measure[i].dbFlags; 334 measureT[i].photcode = measure[i].photcode; 304 335 } 305 336 … … 309 340 int free_tiny_values (Catalog *catalog) { 310 341 311 free (catalog[0].averageT);312 free (catalog[0].measureT);313 return (TRUE); 314 } 315 342 if (catalog[0].averageT) free (catalog[0].averageT); 343 if (catalog[0].measureT) free (catalog[0].measureT); 344 return (TRUE); 345 } 346 -
trunk/Ohana/src/relphot/src/load_catalogs.c
r30616 r31668 3 3 Catalog *load_catalogs (SkyList *skylist, int *Ncatalog) { 4 4 5 int i, Nmeas, Nstar, Nmeas_total, Nstar_total;5 off_t i, Nmeas, Nstar, Nmeas_total, Nstar_total; 6 6 Catalog *catalog, tcatalog; 7 7 … … 14 14 // load data from each region file, only use bright stars 15 15 for (i = 0; i < skylist[0].Nregions; i++) { 16 dvo_catalog_init (&catalog[i], TRUE); 16 17 17 18 // set up the basic catalog info … … 49 50 } 50 51 if (Nstar < 2) { 51 fprintf (stderr, "warning: insufficient stars %d\n", Nstar);52 fprintf (stderr, "warning: insufficient stars "OFF_T_FMT"\n", Nstar); 52 53 } 53 54 54 fprintf (stderr, "using %d of %d stars (%d of %dmeasurements)\n", Nstar, Nstar_total, Nmeas, Nmeas_total);55 fprintf (stderr, "using "OFF_T_FMT" of "OFF_T_FMT" stars ("OFF_T_FMT" of "OFF_T_FMT" measurements)\n", Nstar, Nstar_total, Nmeas, Nmeas_total); 55 56 if (Nstar < 1) Shutdown ("%s", "ERROR: no stars match the minimum requirements; exiting \n"); 56 57 -
trunk/Ohana/src/relphot/src/load_images.c
r31450 r31668 25 25 SkyTableSetFilenames (sky, CATDIR, "cpt"); 26 26 27 // determine the populated SkyRegions overlapping the requested area28 if (RegionSelect) {29 skylist = SkyListByPatch (sky, -1, region);30 } else {31 Nchar = strlen(regionName);32 if (!strcmp (®ionName[Nchar-4], ".cpt")) regionName[Nchar-4] = 0;33 skylist = SkyListByName (sky, regionName);34 }35 36 27 // convert database table to internal structure (binary to Image) 28 // 'image' points to the same memory as db->ftable->buffer 37 29 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped); 38 30 if (!image) { … … 42 34 MARKTIME("read image table: %f sec\n", dtime); 43 35 44 // select the images which overlap the selected sky regions 45 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset); 46 MARKTIME("selected %d overlapping images: %f sec\n", (int) Nsubset, dtime); 36 // determine the populated SkyRegions overlapping the requested area 37 if (RegionSelect) { 38 if (region[0].Rmin > region[0].Rmax) { 39 SkyRegion subregion; 40 subregion = *region; 41 subregion.Rmin = 0.0; subregion.Rmax = region[0].Rmax; 42 skylist = SkyListByPatch (sky, -1, &subregion); 43 44 subregion.Rmin = region[0].Rmin; subregion.Rmax = 360.0; 45 SkyList *extraList = SkyListByPatch (sky, -1, &subregion); 46 47 // select the images which overlap the selected sky regions 48 // 'subset' points to a new copy of the data (different from 'image') 49 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset); 50 MARKTIME("selected %d overlapping images: %f sec\n", (int) Nsubset, dtime); 51 52 Image *subsetExtra; 53 off_t NsubsetExtra; 54 off_t *LineNumberExtra, i; 55 56 subsetExtra = select_images (extraList, image, Nimage, &LineNumberExtra, &NsubsetExtra); 57 MARKTIME("selected %d overlapping images: %f sec\n", (int) Nsubset, dtime); 58 59 REALLOCATE (subset, Image, MAX (Nsubset + NsubsetExtra, 1)); 60 REALLOCATE (LineNumber, off_t, MAX (Nsubset + NsubsetExtra, 1)); 61 62 for (i = 0; i < NsubsetExtra; i++) { 63 subset[i+Nsubset] = subsetExtra[i]; 64 LineNumber[i+Nsubset] = LineNumberExtra[i]; 65 } 66 Nsubset += NsubsetExtra; 67 MARKTIME("selected %d overlapping images: %f sec\n", (int) NsubsetExtra, dtime); 68 } else { 69 skylist = SkyListByPatch (sky, -1, region); 70 71 // select the images which overlap the selected sky regions 72 // 'subset' points to a new copy of the data (different from 'image') 73 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset); 74 MARKTIME("selected %d overlapping images: %f sec\n", (int) Nsubset, dtime); 75 } 76 } else { 77 Nchar = strlen(regionName); 78 if (!strcmp (®ionName[Nchar-4], ".cpt")) regionName[Nchar-4] = 0; 79 skylist = SkyListByName (sky, regionName); 80 81 // select the images which overlap the selected sky regions 82 // 'subset' points to a new copy of the data (different from 'image') 83 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset); 84 MARKTIME("selected %d overlapping images: %f sec\n", (int) Nsubset, dtime); 85 } 86 47 87 48 88 // generate db->vtable from db->ftable based on the selection 49 89 // XXX does this simply duplicate the memory needlessly? we recreate these lines 50 90 // in reload_images. If we had saved the line numbers, we could avoid this 51 gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, LineNumber, Nsubset); 52 MARKTIME("converted ftable to vtable: %f sec\n", dtime); 91 // vtable points *another* copy of the subset rows 92 // (the later call to 'reload_images' copies the subset elements back on top of 93 // the rows of the vtable) 94 // gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, LineNumber, Nsubset); 95 // MARKTIME("converted ftable to vtable: %f sec\n", dtime); 53 96 54 97 // save the subset of images in the static reference in ImageOps, set up indexes 55 initImages (subset, Nsubset);98 initImages (subset, LineNumber, Nsubset); 56 99 MARKTIME("init images: %f sec\n", dtime); 57 100 … … 66 109 67 110 Image *image; 68 off_t Nimage, Nx, i ;111 off_t Nimage, Nx, i, *LineNumber; 69 112 VTable *vtable; 70 113 71 image = getimages (&Nimage );114 image = getimages (&Nimage, &LineNumber); 72 115 116 gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, LineNumber, Nimage); 73 117 vtable = &db[0].vtable; 74 118 -
trunk/Ohana/src/relphot/src/reload_catalogs.c
r31450 r31668 18 18 double time1 = 0.0; 19 19 double time2 = 0.0; 20 double time3 = 0.0; 20 double time3a = 0.0; 21 double time3b = 0.0; 21 22 double time4 = 0.0; 22 23 double time5 = 0.0; … … 57 58 58 59 populate_tiny_values(&catalog); 60 TIMESTAMP(time3a); 59 61 60 initImageBins (&catalog, 1 );61 initMosaicBins (&catalog, 1 );62 initImageBins (&catalog, 1, FALSE); 63 initMosaicBins (&catalog, 1, FALSE); 62 64 initGridBins (&catalog, 1); 63 TIMESTAMP(time3 );65 TIMESTAMP(time3b); 64 66 65 findImages (&catalog, 1 ); // FX66 findMosaics (&catalog, 1 ); //67 findImages (&catalog, 1, FALSE); 68 findMosaics (&catalog, 1, FALSE); 67 69 TIMESTAMP(time4); 68 70 … … 77 79 TIMESTAMP(time6); 78 80 79 freeImageBins (1 );80 freeMosaicBins (1 );81 freeImageBins (1, FALSE); 82 freeMosaicBins (1, FALSE); 81 83 freeGridBins (1); 82 84 TIMESTAMP(time7); 83 85 } 84 86 85 fprintf (stderr, "time1 %f : find catalog\n", time1); 86 fprintf (stderr, "time2 %f : load catalog\n", time2); 87 fprintf (stderr, "time3 %f : init imbins\n", time3); 88 fprintf (stderr, "time4 %f : find images\n", time4); 89 fprintf (stderr, "time5 %f : set Mrel\n", time5); 90 fprintf (stderr, "time6 %f : save catalog\n", time6); 91 fprintf (stderr, "time7 %f : free catalog\n", time7); 87 fprintf (stderr, "time1 %f : find catalog\n", time1); 88 fprintf (stderr, "time2 %f : load catalog\n", time2); 89 fprintf (stderr, "time3a %f : init imbins\n", time3a); 90 fprintf (stderr, "time3b %f : init imbins\n", time3b); 91 fprintf (stderr, "time4 %f : find images\n", time4); 92 fprintf (stderr, "time5 %f : set Mrel\n", time5); 93 fprintf (stderr, "time6 %f : save catalog\n", time6); 94 fprintf (stderr, "time7 %f : free catalog\n", time7); 92 95 } -
trunk/Ohana/src/relphot/src/relphot.c
r31450 r31668 1 1 # include "relphot.h" 2 2 # define USE_DIRECT 0 3 4 # define TIMESTAMP(TIME) \ 5 gettimeofday (&stop, (void *) NULL); \ 6 dtime = DTIME (stop, start); \ 7 TIME += dtime; \ 8 gettimeofday (&start, (void *) NULL); 3 9 4 10 # define MARKTIME(MSG,...) { \ … … 17 23 18 24 gettimeofday (&start, (void *) NULL); 25 26 // XXX quick and stupid test: 27 if (0) { 28 int i, j; 29 off_t *Nlist, *NLIST, **mlist; 30 off_t *NlistI, *NLISTI, **mlistI; 31 int **clist; 32 int **clistI; 33 float dtime; 34 float time1 = 0.0; 35 float time2 = 0.0; 36 37 int Nmosaic = 10000; 38 int Nimage = 600000; 39 40 for (j = 0; j < 19000; j++) { 41 42 // mosaic indexes 43 ALLOCATE (Nlist, off_t, Nmosaic); 44 ALLOCATE (NLIST, off_t, Nmosaic); 45 ALLOCATE (clist, int *, Nmosaic); 46 ALLOCATE (mlist, off_t *, Nmosaic); 47 48 for (i = 0; i < Nmosaic; i++) { 49 Nlist[i] = 0; 50 NLIST[i] = 100; 51 ALLOCATE (clist[i], int, NLIST[i]); 52 ALLOCATE (mlist[i], off_t, NLIST[i]); 53 } 54 55 // image indexes 56 ALLOCATE (NlistI, off_t, Nimage); 57 ALLOCATE (NLISTI, off_t, Nimage); 58 ALLOCATE (clistI, int *, Nimage); 59 ALLOCATE (mlistI, off_t *, Nimage); 60 61 for (i = 0; i < Nimage; i++) { 62 NlistI[i] = 0; 63 NLISTI[i] = 100; 64 ALLOCATE (clistI[i], int, NLISTI[i]); 65 ALLOCATE (mlistI[i], off_t, NLISTI[i]); 66 } 67 68 TIMESTAMP(time1); 69 70 // free mosaic indexes 71 for (i = 0; i < Nmosaic; i++) { 72 free (clist[i]); 73 free (mlist[i]); 74 } 75 free (Nlist); 76 free (NLIST); 77 free (clist); 78 free (mlist); 79 80 // free image indexes 81 for (i = 0; i < Nimage; i++) { 82 free (clistI[i]); 83 free (mlistI[i]); 84 } 85 free (NlistI); 86 free (NLISTI); 87 free (clistI); 88 free (mlistI); 89 90 TIMESTAMP(time2); 91 92 if (j % 100 == 0) { 93 fprintf (stderr, "done with %d\n", j); 94 fprintf (stderr, "time1 %f : init mosaic\n", time1); 95 fprintf (stderr, "time2 %f : free mosaic\n", time2); 96 } 97 } 98 99 fprintf (stderr, "time1 %f : init mosaic\n", time1); 100 fprintf (stderr, "time2 %f : free mosaic\n", time2); 101 exit (1); 102 } 19 103 20 104 /* get configuration info, args */ … … 66 150 67 151 /* match measurements with images, mosaics */ 68 initImageBins (catalog, Ncatalog );152 initImageBins (catalog, Ncatalog, TRUE); 69 153 MARKTIME("-- make image bins: %f sec\n", dtime); 70 154 71 initMosaicBins (catalog, Ncatalog );155 initMosaicBins (catalog, Ncatalog, TRUE); 72 156 initGridBins (catalog, Ncatalog); 73 157 initMrel (catalog, Ncatalog); 74 158 75 findImages (catalog, Ncatalog );159 findImages (catalog, Ncatalog, TRUE); 76 160 MARKTIME("-- set up image indexes: %f sec\n", dtime); 77 161 78 findMosaics (catalog, Ncatalog ); /* also sets Grid values */162 findMosaics (catalog, Ncatalog, TRUE); /* also sets Grid values */ 79 163 MARKTIME("-- set up mosaic indexes: %f sec\n", dtime); 80 164 … … 123 207 plot_chisq (catalog, Ncatalog); 124 208 } 125 if (i % 6 ==1) rationalize_mosaics (catalog, Ncatalog);209 // if (i < NLOOP - 1) rationalize_mosaics (catalog, Ncatalog); 126 210 // if (i % 6 == 1) rationalize_images (); 127 211 if (i % 6 == 2) clean_measures (catalog, Ncatalog, FALSE); … … 148 232 149 233 if (USE_GRID) dump_grid (); 150 if (!UPDATE) exit (0);151 234 152 235 /* set Mcal & Mmos for bad images */ … … 155 238 MARKTIME("-- finalize Mcal values: %f sec\n", dtime); 156 239 240 setMcalFinal (); // copy per-mosaic calibrations to the images 241 242 if (SAVE_IMAGE_UPDATES) { 243 244 FITS_DB dbX; 245 off_t *LineNumber; 246 Image *image, *subset; 247 off_t Nimage, Nsubset, i, Nx; 248 char filename[1024]; 249 250 gfits_db_init (&dbX); 251 dbX.lockstate = LCK_XCLD; 252 dbX.timeout = 60.0; 253 dbX.mode = db.mode; 254 dbX.format = db.format; 255 256 snprintf (filename, 1024, "%s.bck", ImageCat); 257 if (!gfits_db_lock (&dbX, filename)) { 258 fprintf (stderr, "can't lock backup image image catalog\n"); 259 return (FALSE); 260 } 261 262 // apply the changes from the image subset to the full table: 263 264 // convert database table to internal structure (binary to Image) 265 // 'image' points to the same memory as db->ftable->buffer 266 image = gfits_table_get_Image (&db.ftable, &Nimage, &db.swapped); 267 if (!image) { 268 fprintf (stderr, "ERROR: failed to read images\n"); 269 exit (2); 270 } 271 gfits_scan (db.ftable.header, "NAXIS1", OFF_T_FMT, 1, &Nx); 272 273 subset = getimages (&Nsubset, &LineNumber); 274 for (i = 0; i < Nsubset; i++) { 275 if (LineNumber[i] == -1) continue; 276 memcpy (&image[LineNumber[i]], &subset[i], Nx); 277 } 278 279 // copy Images.dat data (all or only the subset / vtable elements?) I think I need to dump 280 // the entire Image table, but with the updates in place I think this says: re-work the 281 // ftable/vtable usage in this program to be more sensible... 282 gfits_copy_header (&db.header, &dbX.header); 283 gfits_copy_matrix (&db.matrix, &dbX.matrix); 284 gfits_copy_header (&db.theader, &dbX.theader); 285 gfits_copy_ftable (&db.ftable, &dbX.ftable); 286 287 dbX.ftable.header = &dbX.theader; 288 dbX.virtual = FALSE; 289 290 // copy Images.dat to another structure 291 dvo_image_save (&dbX, VERBOSE); 292 dvo_image_unlock (&dbX); 293 MARKTIME("-- save Image.dat.bck: %f sec\n", dtime); 294 } 295 296 // only change the real database if -update is requested 297 if (!UPDATE) exit (0); 298 299 reload_images (&db); 300 157 301 /* at this point, we have correct cal coeffs in the image/mosaic structures */ 158 302 for (i = 0; i < Ncatalog; i++) { … … 160 304 dvo_catalog_free (&catalog[i]); 161 305 } 162 freeImageBins (Ncatalog );163 freeMosaicBins (Ncatalog );306 freeImageBins (Ncatalog, TRUE); 307 freeMosaicBins (Ncatalog, TRUE); 164 308 freeGridBins (Ncatalog); 165 309 … … 168 312 MARKTIME("-- updated all catalogs: %f sec\n", dtime); 169 313 170 setMcalFinal ();171 reload_images (&db);172 173 314 dvo_image_update (&db, VERBOSE); 174 315 dvo_image_unlock (&db);
Note:
See TracChangeset
for help on using the changeset viewer.
