- Timestamp:
- May 3, 2010, 8:45:22 AM (16 years ago)
- Location:
- branches/simmosaic_branches
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
Ohana (modified) (1 prop)
-
Ohana/src/relastro (modified) (1 prop)
-
Ohana/src/relastro/src/MosaicOps.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simmosaic_branches
- Property svn:mergeinfo changed
-
branches/simmosaic_branches/Ohana
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/Ohana merged eligible /branches/eam_branches/Ohana.20100407 27635-27772 /branches/pap_delete/Ohana 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simmosaic_branches/Ohana/src/relastro
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/Ohana/src/relastro merged eligible /branches/eam_branches/20091201/Ohana/src/relastro 26295-26885 /branches/eam_branches/Ohana.20100407/src/relastro 27635-27772 /branches/eam_branches/largefiles.20100314/Ohana/src/relastro 27281-27430 /branches/eam_branches/relastro.20100326 27487-27559 /branches/pap_delete/Ohana/src/relastro 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simmosaic_branches/Ohana/src/relastro/src/MosaicOps.c
r21508 r27839 2 2 3 3 // array of mosaic definition structures 4 static intNmosaic;4 static off_t Nmosaic; 5 5 static Mosaic *mosaic; 6 6 7 7 // list of all images associated with a mosaic 8 static int *Nmosaic_own_images; // number of images for this mosaic9 static int *Amosaic_own_images; // size of allocated array10 static int **mosaic_own_images; // array of arrays: mosaic -> images8 static off_t *Nmosaic_own_images; // number of images for this mosaic 9 static off_t *Amosaic_own_images; // size of allocated array 10 static off_t **mosaic_own_images; // array of arrays: mosaic -> images 11 11 12 12 // list of mosaic associated with each image 13 static int Nmosaic_for_images; // number of images (for internal checks)14 static int *mosaic_for_images; // array of: image -> mosaic15 16 Mosaic *getmosaics ( int *N) {13 static off_t Nmosaic_for_images; // number of images (for off_ternal checks) 14 static off_t *mosaic_for_images; // array of: image -> mosaic 15 16 Mosaic *getmosaics (off_t *N) { 17 17 *N = Nmosaic; 18 18 return (mosaic); 19 19 } 20 20 21 off_t getMosaicByTimes (unsigned int start, unsigned int stop, unsigned int *startMos, unsigned int *stopMos, off_t *indexMos) { 22 23 // use bisection to find the overlapping mosaic 24 25 off_t Nlo, Nhi, N; 26 27 // find the last mosaic before start 28 Nlo = 0; Nhi = Nmosaic; 29 while (Nhi - Nlo > 10) { 30 N = 0.5*(Nlo + Nhi); 31 if (startMos[N] < start) { 32 Nlo = MAX(N, 0); 33 } else { 34 Nhi = MIN(N + 1, Nmosaic); 35 } 36 } 37 38 // check for the matched mosaic starting from Nlo 39 // we may have to go much beyond Nlo since stop is not sorted 40 // can we use a sorted version of stop to check when we are beyond the valid range?? 41 for (N = Nlo; N < Nmosaic; N++) { 42 if (stop < stopMos[N]) continue; 43 if (start > startMos[N]) continue; 44 if (stop < startMos[N]) return (-1); 45 return (indexMos[N]); 46 } 47 48 return (-1); 49 } 50 51 // sort two times vectors and an index by first time vector 52 void sort_mosaic_times (unsigned int *S, unsigned int *E, off_t *I, off_t N) { 53 54 # define SWAPFUNC(A,B){ unsigned int tmp_t; off_t tmp_i; \ 55 tmp_t = S[A]; S[A] = S[B]; S[B] = tmp_t; \ 56 tmp_t = E[A]; E[A] = E[B]; E[B] = tmp_t; \ 57 tmp_i = I[A]; I[A] = I[B]; I[B] = tmp_i; \ 58 } 59 # define COMPARE(A,B)(S[A] < S[B]) 60 61 OHANA_SORT (N, COMPARE, SWAPFUNC); 62 63 # undef SWAPFUNC 64 # undef COMPARE 65 66 } 67 68 // first, let's continue to use the time to make the match, but use bracketing to make it faster: 69 21 70 // find mosaic frames (unique time periods & photcode name matches mosaic) 22 void initMosaics (Image *image, int Nimage) {23 24 int i, j, found, NMOSAIC;71 void initMosaics (Image *image, off_t Nimage) { 72 73 off_t i, Nmos, NMOSAIC; 25 74 unsigned int start, stop; 75 76 unsigned int *startMos, *stopMos; 77 off_t *indexMos; 26 78 27 79 Nmosaic = 0; … … 29 81 ALLOCATE (mosaic, Mosaic, NMOSAIC); 30 82 31 ALLOCATE (Nmosaic_own_images, int, NMOSAIC); 32 ALLOCATE (Amosaic_own_images, int, NMOSAIC); 33 ALLOCATE (mosaic_own_images, int *, NMOSAIC); 83 ALLOCATE (Nmosaic_own_images, off_t, NMOSAIC); 84 ALLOCATE (Amosaic_own_images, off_t, NMOSAIC); 85 ALLOCATE (mosaic_own_images, off_t *, NMOSAIC); 86 ALLOCATE (startMos, unsigned int, NMOSAIC); 87 ALLOCATE (stopMos, unsigned int, NMOSAIC); 88 ALLOCATE (indexMos, off_t, NMOSAIC); 34 89 35 90 /* find the mosaic images (coords.ctype = DIS); generate list of unique mosaics */ … … 54 109 Nmosaic_own_images[Nmosaic] = 0; 55 110 Amosaic_own_images[Nmosaic] = 10; 56 ALLOCATE (mosaic_own_images[Nmosaic], int, Amosaic_own_images[Nmosaic]); 111 ALLOCATE (mosaic_own_images[Nmosaic], off_t, Amosaic_own_images[Nmosaic]); 112 113 startMos[Nmosaic] = start; 114 stopMos[Nmosaic] = stop; 115 indexMos[Nmosaic] = Nmosaic; 57 116 58 117 Nmosaic ++; … … 60 119 NMOSAIC += 10; 61 120 REALLOCATE (mosaic, Mosaic, NMOSAIC); 62 REALLOCATE (mosaic_own_images, int *, NMOSAIC); 63 REALLOCATE (Nmosaic_own_images, int, NMOSAIC); 64 REALLOCATE (Amosaic_own_images, int, NMOSAIC); 65 } 66 } 67 121 REALLOCATE (mosaic_own_images, off_t *, NMOSAIC); 122 REALLOCATE (Nmosaic_own_images, off_t, NMOSAIC); 123 REALLOCATE (Amosaic_own_images, off_t, NMOSAIC); 124 REALLOCATE (startMos, unsigned int, NMOSAIC); 125 REALLOCATE (stopMos, unsigned int, NMOSAIC); 126 REALLOCATE (indexMos, off_t, NMOSAIC); 127 } 128 } 129 130 // sort the index, start, and stop by the start times: 131 sort_mosaic_times (startMos, stopMos, indexMos, Nmosaic); 132 68 133 // array to store image->mosaic index 69 134 Nmosaic_for_images = Nimage; 70 ALLOCATE (mosaic_for_images, int, Nmosaic_for_images);135 ALLOCATE (mosaic_for_images, off_t, Nmosaic_for_images); 71 136 72 137 /* now assign the WRP images to these mosaics */ … … 80 145 stop = image[i].tzero + MAX(1.01*image[i].trate*image[i].NY, 1); 81 146 82 /* find existing mosaic with this time range */ 83 found = FALSE; 84 for (j = 0; !found && (j < Nmosaic); j++) { 85 if (stop < mosaic[j].start) continue; 86 if (start > mosaic[j].stop) continue; 87 found = TRUE; 88 break; 89 } 90 /* if no matching mosaic exists, skip this image */ 91 if (!found) continue; 147 Nmos = getMosaicByTimes (start, stop, startMos, stopMos, indexMos); 148 if (Nmos == -1) { 149 fprintf (stderr, "cannot match mosaic for %s\n", image[i].name); 150 continue; 151 } 92 152 93 153 // mosaic corresponding to this image 94 mosaic_for_images[i] = j;154 mosaic_for_images[i] = Nmos; 95 155 96 156 // add image to mosaic_own_image list 97 mosaic_own_images[j][Nmosaic_own_images[j]] = i; 98 Nmosaic_own_images[j] ++; 99 if (Nmosaic_own_images[j] == Amosaic_own_images[j]) { 100 Amosaic_own_images[j] += 10; 101 REALLOCATE (mosaic_own_images[j], int, Amosaic_own_images[j]); 102 } 103 assert (Nmosaic_own_images[j] < Amosaic_own_images[j]); 104 } 105 157 mosaic_own_images[Nmos][Nmosaic_own_images[Nmos]] = i; 158 Nmosaic_own_images[Nmos] ++; 159 if (Nmosaic_own_images[Nmos] == Amosaic_own_images[Nmos]) { 160 Amosaic_own_images[Nmos] += 10; 161 REALLOCATE (mosaic_own_images[Nmos], off_t, Amosaic_own_images[Nmos]); 162 } 163 assert (Nmosaic_own_images[Nmos] < Amosaic_own_images[Nmos]); 164 } 165 166 free (startMos); 167 free (stopMos); 168 free (indexMos); 106 169 return; 107 170 } … … 109 172 // return StarData values for detections in the specified image, converting coordinates from the 110 173 // chip positions: X,Y -> L,M -> P,Q -> R,D 111 StarData *getMosaicRaw (Catalog *catalog, int Ncatalog, int mos, int *Nstars) {112 113 int i, j, im, Nraw, Nnew;174 StarData *getMosaicRaw (Catalog *catalog, int Ncatalog, off_t mos, off_t *Nstars) { 175 176 off_t i, j, im, Nraw, Nnew; 114 177 StarData *raw, *new; 115 178 … … 125 188 // this function does the reverse-lookup for the mosaic corresponding to this image 126 189 new = getImageRaw (catalog, Ncatalog, im, &Nnew, MODE_MOSAIC); 190 if (!new) { 191 fprintf (stderr, "inconsistent: missing mosaic for image already associated with a mosaic? (1)\n"); 192 abort(); 193 } 127 194 128 195 // merge new and raw … … 142 209 // return StarData values for averages positions in the specified image, converting coordinates from 143 210 // the sky positions: R,D -> P,Q -> L,M -> X,Y 144 StarData *getMosaicRef (Catalog *catalog, int Ncatalog, int mos, int *Nstars) {145 146 int i, j, im, Nref, Nnew;211 StarData *getMosaicRef (Catalog *catalog, int Ncatalog, off_t mos, off_t *Nstars) { 212 213 off_t i, j, im, Nref, Nnew; 147 214 StarData *ref, *new; 148 215 … … 157 224 // this function does the reverse-lookup for the mosaic corresponding to this image 158 225 new = getImageRef (catalog, Ncatalog, im, &Nnew, MODE_MOSAIC); 226 if (!new) { 227 fprintf (stderr, "inconsistent: missing mosaic for image already associated with a mosaic? (2)\n"); 228 abort(); 229 } 159 230 160 231 // merge new and ref … … 172 243 } 173 244 174 Mosaic *getMosaicForImage ( int im) {175 176 int mos;245 Mosaic *getMosaicForImage (off_t im) { 246 247 off_t mos; 177 248 178 249 if (im < 0) abort();
Note:
See TracChangeset
for help on using the changeset viewer.
