Changeset 37490
- Timestamp:
- Oct 16, 2014, 11:10:21 AM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140904/Ohana/src/dvomerge
- Files:
-
- 1 added
- 3 edited
-
Makefile (modified) (1 diff)
-
include/dvoutils.h (modified) (1 diff)
-
src/dvoutils_load_image_index.c (added)
-
src/dvoutils_uniq_images.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/Makefile
r37489 r37490 154 154 $(SRC)/dvoutils.$(ARCH).o \ 155 155 $(SRC)/dvoutils_args.$(ARCH).o \ 156 $(SRC)/dvoutils_uniq_images.$(ARCH).o 156 $(SRC)/dvoutils_uniq_images.$(ARCH).o \ 157 $(SRC)/dvoutils_load_image_index.$(ARCH).o 157 158 158 159 $(DVOUTILS) : $(INC)/dvoutils.h -
branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/include/dvoutils.h
r37489 r37490 30 30 int dvoutils_args (int *argc, char **argv); 31 31 int dvoutils_uniq_images (char *filename); 32 int *dvoutils_load_image_index (char *filename, int *nindex); 33 34 Image *dvoutils_load_image_table (char *filename, int *nimage); -
branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/src/dvoutils_uniq_images.c
r37489 r37490 17 17 } 18 18 19 int minID = -1; 20 int maxID = -1; 21 int *IDlist = NULL; 19 int minID = -1; 20 int maxID = -1; 21 int *IDlist = NULL; 22 int *DBfound = NULL; 23 int *DBindex = NULL; 22 24 25 int Ndb = 0; 26 int NDB = 100; 27 char **DBlist = NULL; 28 ALLOCATE (DBlist, char *, NDB); // list of the names of the image database tables. 29 23 30 char imFile[1024]; 24 31 while (scan_line_maxlen (f, imFile, 1024) != EOF) { … … 33 40 } 34 41 35 FITS_DB db; 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; 36 46 37 gfits_db_init (&db); 38 db.lockstate = LCK_SOFT; 39 db.timeout = 120.0; 40 41 if (!gfits_db_lock (&db, imFile)) { 42 fprintf (stderr, "error opening image catalog %s (1)\n", imFile); 43 exit (3); 44 } 45 46 if (db.dbstate == LCK_EMPTY) { 47 fprintf (stderr, "note: image catalog is empty\n"); 48 // free db 49 continue; 50 } 51 52 int status = dvo_image_load (&db, TRUE, FALSE); 53 gfits_db_close (&db); 54 55 if (!status) { 56 fprintf (stderr, "problem loading image database table\n"); 57 exit (4); 58 } 59 60 off_t Nimage; 61 Image *image = gfits_table_get_Image (&db.ftable, &Nimage, &db.swapped); 62 if (!image) { 63 fprintf (stderr, "ERROR: failed to read images\n"); 64 exit (5); 65 } 47 DBlist[Ndb] = strcreate (imFile); 66 48 67 49 // now loop over all of the images and accumulate the array of extern_id values (skip … … 76 58 int i; 77 59 for (i = 0; i < Nimage; i++) { 78 if (! image[i].externID) continue;79 myMaxID = MAX( image[i].externID, myMaxID);80 myMinID = MIN( image[i].externID, myMinID);60 if (!extern_id[i]) continue; 61 myMaxID = MAX(extern_id[i], myMaxID); 62 myMinID = MIN(extern_id[i], myMinID); 81 63 } 82 64 … … 86 68 if (!IDlist) { 87 69 int Nindex = myMaxID - myMinID + 1; 88 ALLOCATE (IDlist, int, Nindex); 89 memset (IDlist, 0, Nindex*sizeof(int)); 70 ALLOCATE (IDlist, int, Nindex); // number of times this ID is seen. IDlist[i] corresponds to extern_id = i + minID 71 ALLOCATE (DBfound, int, Nindex); // index of first DB in which this ID is seen (if n = DBfound[i], the correspond ID was seen in DB n 72 ALLOCATE (DBindex, int, Nindex); // sequence of this image in the first DB for which this ID was found 73 74 for (i = 0; i < Nindex; i++) { 75 IDlist[i] = 0; 76 DBfound[i] = -1; 77 DBindex[i] = -1; 78 } 79 90 80 minID = myMinID; 91 81 maxID = myMaxID; … … 99 89 myAssert (oldNindex <= Nindex, "impossible!"); 100 90 101 int *newIDlist = NULL; 102 ALLOCATE (newIDlist, int, Nindex); 103 memset (newIDlist, 0, Nindex*sizeof(int)); 91 int *newIDlist = NULL; 92 int *newDBfound = NULL; 93 int *newDBindex = NULL; 94 95 ALLOCATE (newIDlist, int, Nindex); 96 ALLOCATE (newDBfound, int, Nindex); 97 ALLOCATE (newDBindex, int, Nindex); 98 99 for (i = 0; i < Nindex; i++) { 100 newIDlist[i] = 0; 101 newDBfound[i] = -1; 102 newDBindex[i] = -1; 103 } 104 104 105 105 // if myMinID >= minID, newMinID = minID -> offset = 0 … … 108 108 109 109 // save the old values 110 memcpy (&newIDlist[offset], IDlist, oldNindex*sizeof(int)); 110 memcpy (&newIDlist [offset], IDlist, oldNindex*sizeof(int)); 111 memcpy (&newDBfound[offset], DBfound, oldNindex*sizeof(int)); 112 memcpy (&newDBindex[offset], DBindex, oldNindex*sizeof(int)); 111 113 112 114 free (IDlist); 113 IDlist = newIDlist; 115 free (DBfound); 116 free (DBindex); 117 118 IDlist = newIDlist; 119 DBfound = newDBfound; 120 DBindex = newDBindex; 114 121 115 122 minID = newMinID; … … 118 125 119 126 for (i = 0; i < Nimage; i++) { 120 if (!image[i].externID) continue; 121 int n = image[i].externID - minID; 127 if (!extern_id[i]) continue; 128 int n = extern_id[i] - minID; 129 if (IDlist[n] == 0) { 130 DBfound[n] = Ndb; 131 DBindex[n] = i; 132 } 122 133 IDlist[n] ++; 123 134 } … … 127 138 128 139 for (i = 0; i < Nimage; i++) { 129 if (! image[i].externID) continue;130 fprintf (stderr, "%d => %d\n", image[i].externID, image[i].externID- minID);140 if (!extern_id[i]) continue; 141 fprintf (stderr, "%d => %d\n", extern_id[i], extern_id[i] - minID); 131 142 } 132 143 … … 138 149 } 139 150 } 151 152 // we are done with the db file, bump the counter 153 Ndb ++; 154 CHECK_REALLOCATE (DBlist, char *, NDB, Ndb, 100); 140 155 } 141 156 … … 147 162 for (i = 0; i < Nindex; i++) { 148 163 if (IDlist[i] < 2) continue; 149 fprintf (stderr, "%d : %d\n", i + minID, IDlist[i]); 164 int n = DBfound[i]; 165 myAssert (n > -1, "impossible!"); 166 fprintf (stderr, "%d : %d -- in %s (%d) : %d \n", i + minID, IDlist[i], DBlist[n], DBfound[i], DBindex[i]); 150 167 } 151 168
Note:
See TracChangeset
for help on using the changeset viewer.
