Changeset 12488
- Timestamp:
- Mar 18, 2007, 12:09:07 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/addstar/src/gstars.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/src/gstars.c
r12461 r12488 5 5 Stars *gstars (char *filename, int *Nstars, Image **images, int *Nimages, int photcode) { 6 6 7 int i, j, N file, Nheader, NHEADER, Nimage, NIMAGE;7 int i, j, N, Nfile, Nheader, NHEADER, Nimage, NIMAGE; 8 8 int Nskip, Nhead, Ndata, done, status, mode, NinStars; 9 9 char **file, *name; … … 52 52 Nimage = Nfile; 53 53 ALLOCATE (image, Image, Nimage); 54 for (i = 0; i < Nfile; i++) { 54 for (i = N = 0; i < Nfile; i++) { 55 // XXX we should not drop all input images if one fails 55 56 if (i > 0) { 56 57 f = fopen (file[i], "r"); 57 58 if (f == NULL) { 58 fprintf (stderr, " ERROR: can't read header for %s\n", file[i]);59 exit (1);59 fprintf (stderr, "can't read header for %s, skipping\n", file[i]); 60 continue; 60 61 } 61 62 gfits_fread_header (f, header); 62 63 } 63 64 64 ReadImageHeader (header, &image[i], photcode); 65 if (!ReadImageHeader (header, &image[N], photcode)) { 66 fprintf (stderr, "skipping %s\n", file[i]); 67 continue; 68 } 65 69 66 70 /* find image rootname */ 67 71 name = filebasename (file[i]); 68 snprintf (image[ i].name, 32, name);72 snprintf (image[N].name, 32, name); 69 73 free (name); 70 74 … … 72 76 case SIMPLE_CMP: 73 77 case MOSAIC_CMP: 74 inStars = ReadStarsTEXT (f, &image[ i].nstar);75 inStars = FilterStars (inStars, &image[ i]);76 stars = MergeStars (stars, Nstars, inStars, image[ i].nstar);78 inStars = ReadStarsTEXT (f, &image[N].nstar); 79 inStars = FilterStars (inStars, &image[N]); 80 stars = MergeStars (stars, Nstars, inStars, image[N].nstar); 77 81 break; 78 82 79 83 case SIMPLE_CMF: 80 84 case MOSAIC_CMF: 81 inStars = ReadStarsFITS (f, header, NULL, &image[ i].nstar);82 inStars = FilterStars (inStars, &image[ i]);83 stars = MergeStars (stars, Nstars, inStars, image[ i].nstar);85 inStars = ReadStarsFITS (f, header, NULL, &image[N].nstar); 86 inStars = FilterStars (inStars, &image[N]); 87 stars = MergeStars (stars, Nstars, inStars, image[N].nstar); 84 88 break; 85 89 … … 91 95 fclose (f); 92 96 gfits_free_header (header); 97 N++; 93 98 } 94 *Nimages = N image;99 *Nimages = N; 95 100 *images = image; 96 101 102 if (N == 0) { 103 fprintf (stderr, "ERROR: no valid image data in %s, giving up\n", filename); 104 exit (1); 105 } 106 97 107 return stars; 98 108 } … … 206 216 207 217 // now run through the images, interpret the headers and read the stars 208 for (i = 0; i < Nimage; i++) {218 for (i = N = 0; i < Nimage; i++) { 209 219 Nhead = extnum_head[i]; 210 220 211 221 if (VERBOSE) fprintf (stderr, "reading header for %s (%s)\n", exthead[i], extdata[i]); 212 ReadImageHeader (headers[Nhead], &image[i], 0); 222 if (!ReadImageHeader (headers[Nhead], &image[N], 0)) { 223 fprintf (stderr, "skipping %s\n", exthead[i]); 224 continue; 225 } 213 226 214 227 // XXX use something to set the chip name? EXTNAME? 215 228 if (!strcmp(exthead[i], "PHU") && (Nimage == 1)) { 216 snprintf (image[ i].name, 32, "%s", name);229 snprintf (image[N].name, 32, "%s", name); 217 230 } else { 218 snprintf (image[i].name, 32, "%s.%s", name, exthead[i]); 219 } 220 221 // this is an error we should not encounter 222 if (!strcmp(extdata[i], "PHU")) Shutdown ("error in data segment: PHU cannot be table"); 231 snprintf (image[N].name, 32, "%s.%s", name, exthead[i]); 232 } 233 234 // skip the table if there is not data segment (eg, mosaic WRP image) 235 if (!strcmp(extdata[i], "NONE")) { 236 N++; 237 continue; 238 } 223 239 224 240 // advance the pointer to the start of the corresponding table block … … 230 246 fseek (f, Nskip, SEEK_SET); 231 247 232 inStars = ReadStarsFITS (f, headers[Nhead], headers[Ndata], &image[i].nstar); 233 inStars = FilterStars (inStars, &image[i]); 234 stars = MergeStars (stars, Nstars, inStars, image[i].nstar); 248 inStars = ReadStarsFITS (f, headers[Nhead], headers[Ndata], &image[N].nstar); 249 inStars = FilterStars (inStars, &image[N]); 250 stars = MergeStars (stars, Nstars, inStars, image[N].nstar); 251 N++; 235 252 } 236 253 free (name); 237 *Nimages = N image;254 *Nimages = N; 238 255 *images = image; 256 257 if (N == 0) { 258 fprintf (stderr, "ERROR: no valid image data in %s, giving up\n", filename); 259 exit (1); 260 } 239 261 240 262 return stars;
Note:
See TracChangeset
for help on using the changeset viewer.
