Changeset 38717
- Timestamp:
- Sep 8, 2015, 11:37:39 AM (11 years ago)
- Location:
- branches/eam_branches/ipp-20150625/Ohana/src/dvomerge
- Files:
-
- 3 edited
-
include/dvoutils.h (modified) (2 diffs)
-
src/dvoutils_load_image_index.c (modified) (3 diffs)
-
src/dvoutils_uniq_images.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150625/Ohana/src/dvomerge/include/dvoutils.h
r38622 r38717 22 22 } DVOUTILS_OP_TYPE; 23 23 24 typedef struct { 25 int *externID; 26 short *photcode; 27 int Nimages; 28 } ImageData; 29 24 30 int VERBOSE; 25 31 int DVOUTILS_OP; … … 30 36 int dvoutils_args (int *argc, char **argv); 31 37 int dvoutils_uniq_images (char *filename); 32 int *dvoutils_load_image_index (char *filename, int *nindex); 38 39 ImageData *dvoutils_load_image_index (char *filename); 33 40 34 41 Image *dvoutils_load_image_table (char *filename, int *nimage); -
branches/eam_branches/ipp-20150625/Ohana/src/dvomerge/src/dvoutils_load_image_index.c
r38441 r38717 2 2 3 3 // load the array of EXTERN_ID from the ImageIndex.fits tables 4 int *dvoutils_load_image_index (char *filename, int *nindex) {4 ImageData *dvoutils_load_image_index (char *filename) { 5 5 6 6 int Ncol; 7 off_t Nrow ;7 off_t Nrow, Nphot; 8 8 Header header; 9 9 Header theader; … … 46 46 fclose (f); 47 47 48 int *externID = gfits_get_bintable_column_data (&theader, &ftable, "EXTERN_ID", type, &Nrow, &Ncol); 48 ImageData *imdata = NULL; 49 ALLOCATE (imdata, ImageData, 1); 50 51 imdata->externID = gfits_get_bintable_column_data (&theader, &ftable, "EXTERN_ID", type, &Nrow, &Ncol); 49 52 myAssert (!strcmp(type, "int"), "wrong column type"); 53 54 imdata->photcode = gfits_get_bintable_column_data (&theader, &ftable, "PHOTCODE", type, &Nphot, &Ncol); 55 myAssert (Nphot == Nrow, "photcode & extern_id mis-match"); 56 57 imdata->Nimages = Nrow; 50 58 51 59 gfits_free_header (&header); … … 54 62 gfits_free_table (&ftable); 55 63 56 *nindex = Nrow; 57 58 return externID; 64 return imdata; 59 65 } 60 66 -
branches/eam_branches/ipp-20150625/Ohana/src/dvomerge/src/dvoutils_uniq_images.c
r38441 r38717 40 40 } 41 41 42 int Nimage; 43 // Image *image = dvoutils_load_image_table (imFile, &Nimage); 44 int *extern_id = dvoutils_load_image_index (imFile, &Nimage); 45 if (!extern_id) continue; 42 ImageData *imdata = dvoutils_load_image_index (imFile); 43 if (!imdata) continue; 46 44 47 45 DBlist[Ndb] = strcreate (imFile); … … 57 55 58 56 int i; 59 for (i = 0; i < Nimage; i++) { 60 if (!extern_id[i]) continue; 61 myMaxID = MAX(extern_id[i], myMaxID); 62 myMinID = MIN(extern_id[i], myMinID); 57 int Nbad = 0; 58 for (i = 0; i < imdata->Nimages; i++) { 59 if (!imdata->photcode[i] && imdata->externID[i]) myAbort ("invalid combo"); 60 61 if (!imdata->photcode[i]) continue; 62 if (!imdata->externID[i]) { 63 Nbad ++; 64 continue; 65 } 66 myMaxID = MAX(imdata->externID[i], myMaxID); 67 myMinID = MIN(imdata->externID[i], myMinID); 63 68 } 64 69 65 fprintf (stderr, "read %s, %d images, %d - %d vs %d - %d\n", imFile, (int) Nimage, myMinID, myMaxID, minID, maxID); 70 fprintf (stderr, "read %s, %d images, %d - %d vs %d - %d\n", imFile, (int) imdata->Nimages, myMinID, myMaxID, minID, maxID); 71 72 if (Nbad) { 73 fprintf (stderr, "WARNING: %d images without extern_id set\n", (int) Nbad); 74 } 66 75 67 76 // if this is new, we treat it a bit differently … … 124 133 } 125 134 126 for (i = 0; i < Nimage; i++) {127 if (! extern_id[i]) continue;128 int n = extern_id[i] - minID;135 for (i = 0; i < imdata->Nimages; i++) { 136 if (!imdata->externID[i]) continue; 137 int n = imdata->externID[i] - minID; 129 138 if (IDlist[n] == 0) { 130 139 DBfound[n] = Ndb; … … 133 142 IDlist[n] ++; 134 143 if (VERBOSE && (IDlist[n] > 1)) { 135 fprintf (stderr, "duplicate ext_id %d in file %s\n", extern_id[i], imFile);144 fprintf (stderr, "duplicate ext_id %d in file %s\n", imdata->externID[i], imFile); 136 145 } 137 146 } … … 140 149 fprintf (stderr, "------------ %s ----------\n", imFile); 141 150 142 for (i = 0; i < Nimage; i++) {143 if (! extern_id[i]) continue;144 fprintf (stderr, "%d => %d\n", extern_id[i], extern_id[i] - minID);151 for (i = 0; i < imdata->Nimages; i++) { 152 if (!imdata->externID[i]) continue; 153 fprintf (stderr, "%d => %d\n", imdata->externID[i], imdata->externID[i] - minID); 145 154 } 146 155 … … 165 174 int n = DBfound[i]; 166 175 myAssert (n > -1, "impossible!"); 167 fprintf (stdout, " %d : %d -- in %s (%d) : %d \n", i + minID, IDlist[i], DBlist[n], DBfound[i], DBindex[i]);176 fprintf (stdout, "primary %d : %d -- in %s (%d) : %d \n", i + minID, IDlist[i], DBlist[n], DBfound[i], DBindex[i]); 168 177 } 169 178
Note:
See TracChangeset
for help on using the changeset viewer.
