Changeset 25208
- Timestamp:
- Aug 26, 2009, 11:29:27 AM (17 years ago)
- Location:
- trunk/Ohana/src/getstar
- Files:
-
- 3 edited
-
include/dvoImagesAtCoords.h (modified) (2 diffs)
-
src/MatchCoords.c (modified) (3 diffs)
-
src/dvoImagesAtCoords.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/getstar/include/dvoImagesAtCoords.h
r24914 r25208 18 18 Coords *MOSAIC; // carries the mosaic into ReadImageHeader 19 19 20 typedef struct { 21 int id; 22 double ra; 23 double dec; 24 int Nmatches; 25 int *matches; 26 int arrayLength; 27 } Point; 28 20 29 int WITH_PHU; 21 30 int SOLO_PHU; … … 33 42 Image *ReadImageFiles (char *filename, int *Nimages); 34 43 int ReadImageHeader (Header *header, Image *image); 35 int *MatchCoords(Image *, int, double, double, int *);44 int MatchCoords(Image *, int, Point *, int); 36 45 37 46 int GetFileMode (Header *header); 38 // int edge_check (double *x1, double *y1, double *x2, double *y2);39 // double opening_angle (double x1, double y1, double x2, double y2, double x3, double y3); -
trunk/Ohana/src/getstar/src/MatchCoords.c
r25106 r25208 5 5 6 6 /* given coordinate, find images in list that contain the point */ 7 int *MatchCoords (Image *dbImages, int NdbImages, double ra, double dec, int *Nmatch) {7 int MatchCoords (Image *dbImages, int NdbImages, Point *points, int Npoints) { 8 8 9 int i, j, N , addtolist, status;10 int NMATCH, nmatch, *match;9 int i, j, N; 10 int totalMatches = 0; 11 11 Coords tcoords; 12 12 double r, d; … … 15 15 double xmin, xmax, ymin, ymax; 16 16 17 *Nmatch = 0;18 19 /* match represents the subset of overlapping images */20 nmatch = 0;21 NMATCH = 20;22 ALLOCATE (match, int, NMATCH);23 17 24 18 /* setup links for mosaic WRP and DIS entries */ … … 49 43 } 50 44 51 // transform input point to image coords 52 double x, y; 53 int status = RD_to_XY(&x, &y, ra, dec, &dbImages[i].coords); 45 for (j = 0; j < Npoints; j++) { 46 Point *pt = points + j; 54 47 55 if (!status) { 56 // avoid matching antipodal skycells 57 continue; 58 } 48 // transform input point to image coords 49 double x, y; 50 int status = RD_to_XY(&x, &y, pt->ra, pt->dec, &dbImages[i].coords); 59 51 60 if ((x >= xmin && x <= xmax) && (y >= ymin && y <= ymax)) { 52 if (!status) { 53 // avoid matching antipodal skycells 54 continue; 55 } 61 56 62 match[nmatch] = i; 63 nmatch ++; 64 if (nmatch == NMATCH) { 65 NMATCH += 20; 66 REALLOCATE (match, int, NMATCH); 57 if ((x >= xmin && x <= xmax) && (y >= ymin && y <= ymax)) { 58 totalMatches++; 59 60 pt->matches[pt->Nmatches] = i; 61 pt->Nmatches ++; 62 63 if (pt->Nmatches == pt->arrayLength) { 64 pt->arrayLength += 20; 65 REALLOCATE (pt->matches, int, pt->arrayLength); 66 } 67 67 } 68 68 } 69 70 } 71 if (VERBOSE) fprintf (stderr, "found %d overlapping images\n", nmatch); 69 } 70 if (VERBOSE) fprintf (stderr, "found %d overlapping images\n", totalMatches); 72 71 73 *Nmatch = nmatch; 74 return (match); 72 return (totalMatches); 75 73 } 76 74 -
trunk/Ohana/src/getstar/src/dvoImagesAtCoords.c
r24921 r25208 1 1 # include "dvoImagesAtCoords.h" 2 2 3 typedef struct {4 int id;5 double ra;6 double dec;7 } Point;8 9 3 static int readPoints(char *filename, Point **pointsOut); 10 static int ListImagesAtCoords (Image *dbImages, int id, double ra, double dec, int *matches, int Nmatches);4 static int ListImagesAtCoords (Image *dbImages, Point *points, int Npoints); 11 5 12 6 int main (int argc, char **argv) { … … 30 24 if (astromFile) { 31 25 dbImages = ReadImageFiles(astromFile, &NdbImages); 32 } else {26 } else { 33 27 /*** update the image table ***/ 34 28 /* setup image table format and lock */ … … 53 47 } 54 48 55 Point *pt; 56 for (i = 0, pt = points; i < Npoints; i++, pt++) { 57 matches = MatchCoords (dbImages, NdbImages, pt->ra, pt->dec, &Nmatches); 58 ListImagesAtCoords(dbImages, pt->id, pt->ra, pt->dec, matches, Nmatches); 49 if (MatchCoords (dbImages, NdbImages, points, Npoints)) { 50 ListImagesAtCoords(dbImages, points, Npoints); 59 51 } 60 52 // XXX: should we exit with nonzero status if no matches were found? 61 53 exit (0); 62 54 } … … 83 75 84 76 while ((Nread = fscanf(f, "%d %lf %lf\n", &pts[Npoints].id, &pts[Npoints].ra, &pts[Npoints].dec)) == 3) { 85 Npoints++; 86 if (Npoints >= LEN) { 77 pts[Npoints].Nmatches = 0; 78 ALLOCATE(pts[Npoints].matches, int, 20); 79 pts[Npoints].arrayLength = 20; 80 81 if (++Npoints >= LEN) { 87 82 LEN += 20; 88 83 REALLOCATE(pts, Point, LEN); … … 99 94 } 100 95 101 static int ListImagesAtCoords (Image *dbImages, int id, double ra, double dec, int *matches, int Nmatches)96 static int ListImagesAtCoords (Image *dbImages, Point *points, int Npoints) 102 97 { 98 int j; 103 99 int i; 104 for (i = 0; i < Nmatches; i++) { 105 int N = matches[i]; 100 for (j = 0; j < Npoints; j++) { 101 Point *pt = points + j; 102 for (i = 0; i < pt->Nmatches; i++) { 103 int N = pt->matches[i]; 106 104 107 char *name; 108 // output of lookup is filename[class_id.hdr] for astrometry files 109 char *left_bracket = rindex(dbImages[N].name, '['); 110 if (left_bracket) { 111 name = strdup(left_bracket + 1); 112 // zap the .hdr] 113 char *dot = index(name, '.'); 114 if (dot) { 115 *dot = 0; 105 char *name; 106 char *copy = NULL; 107 // output of lookup is filename[class_id.hdr] for astrometry files 108 char *left_bracket = rindex(dbImages[N].name, '['); 109 if (left_bracket) { 110 copy = strdup(left_bracket + 1); 111 name = copy; 112 // zap the .hdr] 113 char *dot = index(name, '.'); 114 if (dot) { 115 *dot = 0; 116 } 117 } else { 118 name = dbImages[N].name; 116 119 } 117 } else { 118 name = dbImages[N].name; 120 fprintf (stdout, "%d %lf %lf %s\n", pt->id, pt->ra, pt->dec, name); 121 if (copy) { 122 free(copy); 123 } 119 124 } 120 fprintf (stdout, "%d %lf %lf %s\n", id, ra, dec, name);121 125 } 122 126
Note:
See TracChangeset
for help on using the changeset viewer.
