Changeset 33515
- Timestamp:
- Mar 13, 2012, 4:11:23 PM (14 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src/relastro
- Files:
-
- 3 edited
-
include/relastro.h (modified) (1 diff)
-
src/ImageOps.c (modified) (14 diffs)
-
src/load_catalogs.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/relastro/include/relastro.h
r33475 r33515 4 4 # include <signal.h> 5 5 # include <assert.h> 6 7 // choose off_t or int depending on full-scale relphot analysis resources 8 // # define IDX_T off_t 9 # define IDX_T int 6 10 7 11 typedef enum { -
branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/ImageOps.c
r33448 r33515 3 3 # define USE_IMAGE_ID 1 4 4 5 static off_t **bin; // link from catalog,measure to image 6 static int **clist; // catalog which supplied measurement on image 7 static off_t **mlist; // measure reference for measurement on image 8 static off_t *Nlist; // number of measurements on image 9 static off_t *NLIST; // allocated number of measurements on image 10 5 // we have an array of images: image[ImageIndex] (ImageIndex : 0 < Nimage) 11 6 static Image *image; // list of available images 12 7 static off_t Nimage; // number of available images 8 9 // if we read only a subset of the rows from the Image FITS, LineNumber tells us to which row 10 // each image belongs 13 11 static off_t *LineNumber; // match of subset to full image table 14 12 15 static int *Ncatlist; // catalogs associated with each image 16 static int *NCATLIST; // catalogs associated with each image 13 static off_t *N_onImage; // number of measurements on image 14 static off_t *N_ONIMAGE; // allocated number of measurements on image 15 16 static int *Ncatlist; // catalogs associated with each image 17 static int *NCATLIST; // catalogs associated with each image 17 18 static int **catlist; // catalogs associated with each image 19 20 static IDX_T **MeasureToImage; // link from catalog,measure to image 21 static IDX_T **ImageToCatalog; // catalog which supplied measurement on image 22 static IDX_T **ImageToMeasure; // measure reference for measurement on image 18 23 19 24 // if we search by image ID, we sort (imageIDs, imageIdx) by imageIDs to get a sorted … … 28 33 # endif 29 34 35 // MeasureToImage was 'bin' 36 // ImageToCatalog was 'clist' 37 // ImageToMeasure was 'mlist' 38 39 // N_onImage was 'Nlist' 40 // N_ONIMAGE was 'NLIST' 41 30 42 Image *getimages (off_t *N, off_t **line_number) { 31 43 … … 105 117 off_t i, j; 106 118 107 ALLOCATE ( bin, off_t*, Ncatalog);119 ALLOCATE (MeasureToImage, IDX_T *, Ncatalog); 108 120 for (i = 0; i < Ncatalog; i++) { 109 ALLOCATE ( bin[i], off_t, MAX (catalog[i].Nmeasure, 1));110 for (j = 0; j < catalog[i].Nmeasure; j++) bin[i][j] = -1;111 } 112 113 ALLOCATE (N list, off_t, Nimage);114 ALLOCATE (N LIST, off_t, Nimage);115 ALLOCATE ( clist, int*, Nimage);116 ALLOCATE ( mlist, off_t*, Nimage);121 ALLOCATE (MeasureToImage[i], IDX_T, MAX (catalog[i].Nmeasure, 1)); 122 for (j = 0; j < catalog[i].Nmeasure; j++) MeasureToImage[i][j] = -1; 123 } 124 125 ALLOCATE (N_onImage, off_t, Nimage); 126 ALLOCATE (N_ONIMAGE, off_t, Nimage); 127 ALLOCATE (ImageToCatalog, IDX_T *, Nimage); 128 ALLOCATE (ImageToMeasure, IDX_T *, Nimage); 117 129 118 130 for (i = 0; i < Nimage; i++) { 119 N list[i] = 0;120 N LIST[i] = 100;121 clist[i] = NULL; // we allocate these iff they are needed in matchImage122 mlist[i] = NULL; // we allocate these iff they are needed in matchImage131 N_onImage[i] = 0; 132 N_ONIMAGE[i] = 30; 133 ImageToCatalog[i] = NULL; // we allocate these iff they are needed in matchImage 134 ImageToMeasure[i] = NULL; // we allocate these iff they are needed in matchImage 123 135 } 124 136 … … 141 153 142 154 for (i = 0; i < Ncatalog; i++) { 143 free ( bin[i]);144 } 145 free ( bin);155 free (MeasureToImage[i]); 156 } 157 free (MeasureToImage); 146 158 for (i = 0; i < Nimage; i++) { 147 if ( clist[i]) { free (clist[i]); }148 if ( mlist[i]) { free (mlist[i]); }149 } 150 free ( clist);151 free ( mlist);152 free (N list);153 free (N LIST);159 if (ImageToCatalog[i]) { free (ImageToCatalog[i]); } 160 if (ImageToMeasure[i]) { free (ImageToMeasure[i]); } 161 } 162 free (ImageToCatalog); 163 free (ImageToMeasure); 164 free (N_onImage); 165 free (N_ONIMAGE); 154 166 } 155 167 … … 171 183 for (i = 0; VERBOSE2 && (i < Nimage); i++) { 172 184 name = GetPhotcodeNamebyCode (image[i].photcode); 173 fprintf (stderr, "image "OFF_T_FMT" has "OFF_T_FMT" measures (%s, %s)\n", i, N list[i],185 fprintf (stderr, "image "OFF_T_FMT" has "OFF_T_FMT" measures (%s, %s)\n", i, N_onImage[i], 174 186 ohana_sec_to_date(image[i].tzero), name); 175 187 } … … 194 206 195 207 // index for (catalog, measure) -> image 196 bin[cat][meas] = idx;208 MeasureToImage[cat][meas] = idx; 197 209 198 210 // if we need to allocate an image index table, do so here 199 if (! clist[idx]) {200 ALLOCATE ( clist[idx], int, NLIST[idx]);201 } 202 if (! mlist[idx]) {203 ALLOCATE ( mlist[idx], off_t, NLIST[idx]);211 if (!ImageToCatalog[idx]) { 212 ALLOCATE (ImageToCatalog[idx], IDX_T, N_ONIMAGE[idx]); 213 } 214 if (!ImageToMeasure[idx]) { 215 ALLOCATE (ImageToMeasure[idx], IDX_T, N_ONIMAGE[idx]); 204 216 } 205 217 206 218 // index for image, Nentry -> catalog 207 clist[idx][Nlist[idx]] = cat;219 ImageToCatalog[idx][N_onImage[idx]] = cat; 208 220 209 221 // index for image, Nentry -> measure 210 mlist[idx][Nlist[idx]] = meas;211 N list[idx] ++;212 213 if (N list[idx] == NLIST[idx]) {214 N LIST[idx] += 100;215 REALLOCATE ( clist[idx], int, NLIST[idx]);216 REALLOCATE ( mlist[idx], off_t, NLIST[idx]);222 ImageToMeasure[idx][N_onImage[idx]] = meas; 223 N_onImage[idx] ++; 224 225 if (N_onImage[idx] == N_ONIMAGE[idx]) { 226 N_ONIMAGE[idx] += 30; 227 REALLOCATE (ImageToCatalog[idx], IDX_T, N_ONIMAGE[idx]); 228 REALLOCATE (ImageToMeasure[idx], IDX_T, N_ONIMAGE[idx]); 217 229 } 218 230 … … 255 267 256 268 // index for (catalog, measure) -> image 257 bin[cat][meas] = i;269 MeasureToImage[cat][meas] = i; 258 270 259 271 // index for image, Nentry -> catalog 260 clist[i][Nlist[i]] = cat;272 ImageToCatalog[i][N_onImage[i]] = cat; 261 273 262 274 // index for image, Nentry -> measure 263 mlist[i][Nlist[i]] = meas;264 N list[i] ++;265 266 if (N list[i] == NLIST[i]) {267 N LIST[i] += 100;268 REALLOCATE ( clist[i], int, NLIST[i]);269 REALLOCATE ( mlist[i], off_t, NLIST[i]);275 ImageToMeasure[i][N_onImage[i]] = meas; 276 N_onImage[i] ++; 277 278 if (N_onImage[i] == N_ONIMAGE[i]) { 279 N_ONIMAGE[i] += 30; 280 REALLOCATE (ImageToCatalog[i], IDX_T, N_ONIMAGE[i]); 281 REALLOCATE (ImageToMeasure[i], IDX_T, N_ONIMAGE[i]); 270 282 } 271 283 return; … … 281 293 off_t i; 282 294 283 i = bin[cat][meas];295 i = MeasureToImage[cat][meas]; 284 296 if (i == -1) return (NULL); 285 297 return (&image[i].coords); … … 402 414 } 403 415 404 for (i = 0; i < N list[im]; i++) {405 m = mlist[im][i];406 c = clist[im][i];416 for (i = 0; i < N_onImage[im]; i++) { 417 m = ImageToMeasure[im][i]; 418 c = ImageToCatalog[im][i]; 407 419 408 420 Measure *measure = &catalog[c].measure[m]; … … 512 524 imcoords = &image[im].coords; 513 525 514 for (i = 0; i < N list[im]; i++) {515 m = mlist[im][i];516 c = clist[im][i];526 for (i = 0; i < N_onImage[im]; i++) { 527 m = ImageToMeasure[im][i]; 528 c = ImageToCatalog[im][i]; 517 529 518 530 // XXX unclear if this should use Measure or MeasureTiny; it is only called by FixProblemImages, which has not been updated … … 575 587 } 576 588 577 ALLOCATE (raw, StarData, N list[im]);578 579 for (i = 0; i < N list[im]; i++) {580 m = mlist[im][i];581 c = clist[im][i];589 ALLOCATE (raw, StarData, N_onImage[im]); 590 591 for (i = 0; i < N_onImage[im]; i++) { 592 m = ImageToMeasure[im][i]; 593 c = ImageToCatalog[im][i]; 582 594 583 595 MeasureTiny *measure = &catalog[c].measureT[m]; … … 623 635 } 624 636 625 *Nstars = N list[im];637 *Nstars = N_onImage[im]; 626 638 return (raw); 627 639 } … … 649 661 } 650 662 651 ALLOCATE (ref, StarData, N list[im]);652 653 for (i = 0; i < N list[im]; i++) {654 m = mlist[im][i];655 c = clist[im][i];663 ALLOCATE (ref, StarData, N_onImage[im]); 664 665 for (i = 0; i < N_onImage[im]; i++) { 666 m = ImageToMeasure[im][i]; 667 c = ImageToCatalog[im][i]; 656 668 657 669 MeasureTiny *measure = &catalog[c].measureT[m]; … … 687 699 } 688 700 689 *Nstars = N list[im];701 *Nstars = N_onImage[im]; 690 702 return (ref); 691 703 } -
branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/load_catalogs.c
r33480 r33515 82 82 } 83 83 84 // XXX keep this test?85 84 Nstar = 0; 86 85 for (i = 0; i < Ncat; i++) { 87 86 Nstar += catalog[i].Naverage; 87 if ((sizeof(IDX_T) == 8) && (catalog[i].Nmeasure > 0xffffffff)) { 88 fprintf (stderr, "ERROR: using small-sized IDX_T on data with more than 2G detections per table will cause errors\n"); 89 fprintf (stderr, " If you need to do this, and you can afford the RAM, rebuild with IDX_T set to off_t (see relastro.h, ImagesOps.c)\n"); 90 exit (3); 91 } 88 92 } 89 93 if (Nstar < 2) {
Note:
See TracChangeset
for help on using the changeset viewer.
