Changeset 28989
- Timestamp:
- Aug 20, 2010, 11:04:39 AM (16 years ago)
- Location:
- branches/eam_branches/ipp-20100621/Ohana/src/opihi
- Files:
-
- 11 edited
-
dvo/ImageSelection.c (modified) (2 diffs)
-
dvo/LoadImages.c (modified) (3 diffs)
-
dvo/dbExtractMeasures.c (modified) (3 diffs)
-
dvo/dbFields.c (modified) (1 diff)
-
dvo/gimages.c (modified) (2 diffs)
-
dvo/images.c (modified) (1 diff)
-
dvo/imdense.c (modified) (1 diff)
-
dvo/imextract.c (modified) (1 diff)
-
dvo/mextract.c (modified) (2 diffs)
-
dvo/photometry.c (modified) (2 diffs)
-
include/dvoshell.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/Ohana/src/opihi/dvo/ImageSelection.c
r27435 r28989 38 38 /* free loaded images */ 39 39 void FreeImageSelection () { 40 if (image != NULL) free(image);40 if (image != NULL) FreeImages(image); 41 41 if (subset != NULL) free (subset); 42 42 image = NULL; … … 45 45 } 46 46 47 Image *MatchImage (unsigned int time, short int source ) {47 Image *MatchImage (unsigned int time, short int source, unsigned int imageID) { 48 48 49 49 int m; 50 50 51 m = match_image_subset (image, subset, Nsubset, time, source); 51 if ((imageID != 0) && (imageID < Nimage)) { 52 m = (int) imageID - 1; 53 } else { 54 m = match_image_subset (image, subset, Nsubset, time, source); 55 } 52 56 if (m == -1) return (NULL); 53 57 if (!FindMosaicForImage (image, Nimage, m)) return (NULL); -
branches/eam_branches/ipp-20100621/Ohana/src/opihi/dvo/LoadImages.c
r28723 r28989 1 1 # include "dvoshell.h" 2 3 // XXX: Maybe make this a command line option 4 int dvoUseImageCache = 1; 5 6 static char *lastFilename = NULL; 7 static time_t lastModified = 0; 8 static Image *imageCache = NULL; 9 static off_t cacheNimage = 0; 10 11 static time_t getLastModified(char *filename); 2 12 3 13 Image *LoadImages (off_t *Nimage) { … … 12 22 catdir = GetCATDIR (); 13 23 sprintf (filename, "%s/Images.dat", catdir); 24 25 if (lastFilename) { 26 if (dvoUseImageCache && !strcmp(lastFilename, filename)) { 27 // Make sure the file hasn't changed since we loaded it 28 if (getLastModified(filename) == lastModified) { 29 *Nimage = cacheNimage; 30 return imageCache; 31 } 32 } 33 free(lastFilename); 34 lastFilename = NULL; 35 free(imageCache); 36 imageCache = NULL; 37 cacheNimage = 0; 38 lastModified = 0; 39 } 40 14 41 15 42 gfits_db_init (&db); … … 40 67 if (!image) { 41 68 fprintf (stderr, "ERROR: failed to read images\n"); 42 exit (2); 69 return (NULL); 70 } 71 if (dvoUseImageCache && image) { 72 cacheNimage = *Nimage; 73 imageCache = image; 74 lastFilename = strdup(filename); 75 lastModified = getLastModified(filename); 43 76 } 44 77 return (image); 45 78 } 79 80 static time_t getLastModified(char *filename) { 81 struct stat statbuf; 82 if (!stat(filename, &statbuf)) { 83 return statbuf.st_mtime; 84 } else { 85 return 0; 86 } 87 } 88 89 void FreeImages(Image *images) { 90 if (!dvoUseImageCache && (images != NULL)) { 91 free(images); 92 } else { 93 // defer free until next LoadImages with a different or modified Images.dat 94 } 95 } 96 -
branches/eam_branches/ipp-20100621/Ohana/src/opihi/dvo/dbExtractMeasures.c
r28213 r28989 358 358 ra = average[0].R - measure[0].dR / 3600.0; 359 359 dec = average[0].D - measure[0].dD / 3600.0; 360 image = MatchImage (measure[0].t, measure[0].photcode );360 image = MatchImage (measure[0].t, measure[0].photcode, measure[0].imageID); 361 361 if (image == NULL) break; 362 362 RD_to_XY (&x, &y, ra, dec, &image[0].coords); … … 374 374 ra = average[0].R - measure[0].dR / 3600.0; 375 375 dec = average[0].D - measure[0].dD / 3600.0; 376 image = MatchImage (measure[0].t, measure[0].photcode );376 image = MatchImage (measure[0].t, measure[0].photcode, measure[0].imageID); 377 377 if (image == NULL) break; 378 378 RD_to_XY (&x, &y, ra, dec, &image[0].coords); … … 440 440 value.Flt = measure[0].extNsigma; 441 441 break; 442 case MEAS_EXTERN_ID: /* OK */ 443 { 444 Image *image; 445 image = MatchImage (measure[0].t, measure[0].photcode, measure[0].imageID); 446 if (image == NULL) break; 447 value.Int = image->externID; 448 } 449 break; 442 450 443 451 // add the star/galaxy sep -- -
branches/eam_branches/ipp-20100621/Ohana/src/opihi/dvo/dbFields.c
r27587 r28989 212 212 if (!strcasecmp (fieldName, "SKY")) ESCAPE (MEAS_SKY, MAG_NONE, OPIHI_FLT); 213 213 if (!strcasecmp (fieldName, "SKY_ERR")) ESCAPE (MEAS_dSKY, MAG_NONE, OPIHI_FLT); 214 if (!strcasecmp (fieldName, "externID")) ESCAPE (MEAS_EXTERN_ID, MAG_NONE, OPIHI_INT); 214 215 215 216 // for words that don't parse, try a photcode -
branches/eam_branches/ipp-20100621/Ohana/src/opihi/dvo/gimages.c
r27435 r28989 235 235 sprintf (name, "IMAGEname:%d", Nfound); 236 236 set_str_variable (name, image[i].name); 237 sprintf (name, "IMAGEphotcode:%d", Nfound); 238 set_int_variable (name, image[i].photcode); 237 239 Nfound ++; 238 240 free (date); … … 243 245 set_int_variable ("IMAGEccd:n", Nfound); 244 246 set_int_variable ("IMAGEname:n", Nfound); 245 246 free (image); 247 set_int_variable ("IMAGEphotcode:n", Nfound); 248 249 FreeImages (image); 247 250 free (subset); 248 251 -
branches/eam_branches/ipp-20100621/Ohana/src/opihi/dvo/images.c
r27530 r28989 319 319 free (Xvec.elements.Flt); 320 320 free (Yvec.elements.Flt); 321 free(image);321 FreeImages (image); 322 322 return (TRUE); 323 323 -
branches/eam_branches/ipp-20100621/Ohana/src/opihi/dvo/imdense.c
r27435 r28989 70 70 free (Xvec.elements.Flt); 71 71 free (Yvec.elements.Flt); 72 free(image);72 FreeImages (image); 73 73 return (TRUE); 74 74 -
branches/eam_branches/ipp-20100621/Ohana/src/opihi/dvo/imextract.c
r27587 r28989 137 137 138 138 // free (subset); 139 free(image);139 FreeImages (image); 140 140 141 141 if (vec) free (vec); -
branches/eam_branches/ipp-20100621/Ohana/src/opihi/dvo/mextract.c
r28241 r28989 88 88 mosaicMode = FALSE; 89 89 for (i = 0; !loadImages && (i < Nfields); i++) { 90 if (fields[i].ID == MEAS_XCCD) loadImages = TRUE; 91 if (fields[i].ID == MEAS_YCCD) loadImages = TRUE; 90 if (fields[i].ID == MEAS_XCCD) loadImages = TRUE; // Are these still needed? Xccd and Yccd are in measurement 91 if (fields[i].ID == MEAS_YCCD) loadImages = TRUE; // and dbExtractMeasures doesn't look at the image for these 92 92 if (fields[i].ID == MEAS_XMOSAIC) loadImages = mosaicMode = TRUE; 93 93 if (fields[i].ID == MEAS_YMOSAIC) loadImages = mosaicMode = TRUE; 94 if (fields[i].ID == MEAS_EXTERN_ID) loadImages = mosaicMode = TRUE; 94 95 } 95 96 if (loadImages && !SetImageSelection (mosaicMode, selection)) goto escape; … … 305 306 gprint (GP_ERR, " catID : catalog ID (32 bit)\n"); 306 307 gprint (GP_ERR, " imageID : ID of source image (32 bit)\n"); 308 gprint (GP_ERR, " externID : externID of source image (32 bit)\n"); 307 309 return (FALSE); 308 310 } -
branches/eam_branches/ipp-20100621/Ohana/src/opihi/dvo/photometry.c
r27587 r28989 1178 1178 ra = average[0].R - measure[0].dR / 3600.0; 1179 1179 dec = average[0].D - measure[0].dD / 3600.0; 1180 image = MatchImage (measure[0].t, measure[0].photcode );1180 image = MatchImage (measure[0].t, measure[0].photcode, measure[0].imageID); 1181 1181 if (image == NULL) break; 1182 1182 RD_to_XY (&x, &y, ra, dec, &image[0].coords); … … 1191 1191 ra = average[0].R - measure[0].dR / 3600.0; 1192 1192 dec = average[0].D - measure[0].dD / 3600.0; 1193 image = MatchImage (measure[0].t, measure[0].photcode );1193 image = MatchImage (measure[0].t, measure[0].photcode, measure[0].imageID); 1194 1194 if (image == NULL) break; 1195 1195 RD_to_XY (&x, &y, ra, dec, &image[0].coords); -
branches/eam_branches/ipp-20100621/Ohana/src/opihi/include/dvoshell.h
r27594 r28989 121 121 MEAS_CR_NSIGMA, 122 122 MEAS_EXT_NSIGMA, 123 MEAS_EXTERN_ID, 123 124 }; 124 125 … … 301 302 int InitPhotcodes PROTO((void)); 302 303 Image *LoadImages PROTO((off_t *Nimage)); 303 Image *MatchImage PROTO((unsigned int time, short int source)); 304 void FreeImages PROTO((Image *images)); 305 Image *MatchImage PROTO((unsigned int time, short int source, unsigned int imageID)); 304 306 Coords *MatchMosaic PROTO((unsigned int time, short int source)); 305 307 int Quality PROTO((Measure *measure, int IsDophot));
Note:
See TracChangeset
for help on using the changeset viewer.
