Changeset 40523
- Timestamp:
- Aug 30, 2018, 5:07:23 PM (8 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 1 added
- 7 edited
-
dvo/Makefile (modified) (1 diff)
-
dvo/avmatch.c (modified) (1 diff)
-
dvo/avperiodomatch.c (modified) (1 diff)
-
dvo/avselect.c (added)
-
dvo/find_matches.c (modified) (2 diffs)
-
dvo/init.c (modified) (2 diffs)
-
dvo/mmatch.c (modified) (5 diffs)
-
include/dvoshell.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/Makefile
r40408 r40523 46 46 $(SRC)/avextract.$(ARCH).o \ 47 47 $(SRC)/avmatch.$(ARCH).o \ 48 $(SRC)/avselect.$(ARCH).o \ 48 49 $(SRC)/avperiodogram.$(ARCH).o \ 49 50 $(SRC)/avperiodomatch.$(ARCH).o \ -
trunk/Ohana/src/opihi/dvo/avmatch.c
r39457 r40523 209 209 } 210 210 211 find_matches_by_vectors (skylist[0].regions[i], &catalog, RAvec, DECvec, RADIUS, index);211 find_matches_by_vectors_closest (skylist[0].regions[i], &catalog, RAvec, DECvec, RADIUS, index); 212 212 213 213 for (j = 0; (j < NPTS) && !interrupt; j++) { -
trunk/Ohana/src/opihi/dvo/avperiodomatch.c
r40408 r40523 264 264 dvo_catalog_unlock (&catalog); 265 265 266 find_matches_by_vectors (skylist[0].regions[i], &catalog, RAvec, DECvec, RADIUS, idxValue);266 find_matches_by_vectors_closest (skylist[0].regions[i], &catalog, RAvec, DECvec, RADIUS, idxValue); 267 267 268 268 // Scan the catalog for objects which match the WHERE clause -
trunk/Ohana/src/opihi/dvo/find_matches.c
r37807 r40523 5 5 // attempt to match every RA,DEC entry with an entry in the catalog. the result is stored in 'index' 6 6 // index >= 0 : valid match; index == -2 : no valid match; index == -1 : not contained by this catalog 7 int find_matches_by_vectors (SkyRegion *region, Catalog *catalog, Vector *RAvec, Vector *DECvec, float RADIUS, off_t *index) {7 int find_matches_by_vectors_closest (SkyRegion *region, Catalog *catalog, Vector *RAvec, Vector *DECvec, float RADIUS, off_t *index) { 8 8 9 9 off_t i, j, J, Jmin, Npoints, Nmatch; … … 148 148 return (TRUE); 149 149 } 150 151 // attempt to match every RA,DEC entry with an entry in the catalog. the result is stored in 'result' 152 AvselectResult *find_matches_by_vectors_allmatch (SkyRegion *region, Catalog *catalog, Vector *RAvec, Vector *DECvec, float RADIUS, off_t *nresult) { 153 154 off_t i, j, J; 155 double dX, dY, dR, Doff, Dmin, Dmax, Rmin, Rmax; 156 int status; 157 double RADIUS2; 158 Coords tcoords; 159 160 // XXX dvoconvert does not correctly maintain 'sorted' 161 // assert(catalog[0].sorted); 162 163 off_t Npoints = RAvec->Nelements; 164 165 /** allocate local arrays (points) **/ 166 ALLOCATE_PTR (X1, double, Npoints); 167 ALLOCATE_PTR (Y1, double, Npoints); 168 ALLOCATE_PTR (N1, off_t, Npoints); 169 170 ALLOCATE_PTR (inCatalog, int, Npoints); 171 172 /** allocate local arrays (catalog) **/ 173 off_t Nave = catalog[0].Naverage; 174 ALLOCATE_PTR (X2, double, Nave); 175 ALLOCATE_PTR (Y2, double, Nave); 176 ALLOCATE_PTR (N2, off_t, Nave); 177 178 off_t Nresult = 0; 179 off_t NRESULT = 1000; 180 ALLOCATE_PTR (result, AvselectResult, NRESULT); 181 182 /* project onto rectilinear grid with 1 arcsec pixels. the choice of ARC projection has 183 * the advantage that every point in R,D has a mapping to a unique X,Y. However, note 184 * that not all possible X,Y points map back to R,D and the local plate scale changes 185 * far from the projection pole. We use the center of the region (catalog) for crval1,2. 186 */ 187 InitCoords (&tcoords, "DEC--ARC"); 188 tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax); 189 if (region[0].Dmax < 90) { 190 tcoords.crval2 = 0.5*(region[0].Dmin + region[0].Dmax); 191 } else { 192 tcoords.crval2 = 90.0; 193 } 194 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 195 196 // this region includes a boundary layer of size RADIUS 197 if (fabs(region[0].Dmin) < fabs(region[0].Dmax)) { 198 Doff = RAD_DEG*region[0].Dmax; 199 } else { 200 Doff = RAD_DEG*region[0].Dmin; 201 } 202 if (Doff < 80) { 203 Rmin = region[0].Rmin - RADIUS / 3600.0 / cos(Doff); 204 Rmax = region[0].Rmax + RADIUS / 3600.0 / cos(Doff); 205 } else { 206 Rmin = 0.0; 207 Rmax = 360.0; 208 } 209 Dmin = region[0].Dmin - RADIUS / 3600.0; 210 Dmax = region[0].Dmax + RADIUS / 3600.0; 211 212 // identify the entries contained by this catalog 213 for (i = 0; i < Npoints; i++) { 214 inCatalog[i] = FALSE; 215 if (RAvec->elements.Flt[i] < Rmin) continue; 216 if (RAvec->elements.Flt[i] > Rmax) continue; 217 if (DECvec->elements.Flt[i] < Dmin) continue; 218 if (DECvec->elements.Flt[i] > Dmax) continue; 219 inCatalog[i] = TRUE; 220 } 221 222 /* build spatial index (RA sort) referencing input array sequence */ 223 for (i = 0; i < Npoints; i++) { 224 // we need to have a finite number for the sort below; inCatalog == 0 entries are skipped 225 // in the matching process 226 X1[i] = Y1[i] = 0.0; 227 N1[i] = i; 228 if (!inCatalog[i]) continue; 229 status = RD_to_XY (&X1[i], &Y1[i], RAvec->elements.Flt[i], DECvec->elements.Flt[i], &tcoords); 230 assert (status); 231 } 232 if (Npoints > 1) sort_coords_index (X1, Y1, N1, Npoints); 233 234 /* build spatial index (RA sort) */ 235 for (i = 0; i < Nave; i++) { 236 RD_to_XY (&X2[i], &Y2[i], catalog[0].average[i].R, catalog[0].average[i].D, &tcoords); 237 N2[i] = i; 238 } 239 if (Nave > 1) sort_coords_index (X2, Y2, N2, Nave); 240 241 /* choose a radius for matches */ 242 RADIUS2 = RADIUS*RADIUS; 243 244 # define NEXTi { i++; continue; } 245 # define NEXTj { j++; continue; } 246 247 /** find matched stars **/ 248 for (i = j = 0; (i < Npoints) && (j < Nave); ) { 249 if (!inCatalog[N1[i]]) NEXTi; 250 if (!finite(X1[i]) || !finite(Y1[i])) NEXTi; 251 if (!finite(X2[j]) || !finite(Y2[j])) NEXTj; 252 253 /* negative dX: j is too large */ 254 dX = X1[i] - X2[j]; 255 if (dX <= -1.02*RADIUS) NEXTi; 256 257 /* positive dX, i is too large */ 258 if (dX >= 1.02*RADIUS) NEXTj; 259 260 /* within match range; look for matches */ 261 for (J = j; (dX > -1.02*RADIUS) && (J < Nave); J++) { 262 /* find closest match for this detection */ 263 dX = X1[i] - X2[J]; 264 dY = Y1[i] - Y2[J]; 265 dR = dX*dX + dY*dY; 266 if (dR > RADIUS2) continue; 267 268 /*** a match is found, set the result for this entry ***/ 269 result[Nresult].Ncat = N2[J]; 270 result[Nresult].Nseq = N1[i]; 271 result[Nresult].Roff = sqrt(dR); 272 273 Nresult ++; 274 CHECK_REALLOCATE (result, AvselectResult, NRESULT, Nresult, 1000); 275 } 276 NEXTi; 277 } 278 279 free (X1); 280 free (Y1); 281 free (N1); 282 free (N2); 283 free (X2); 284 free (Y2); 285 286 *nresult = Nresult; 287 return (result); 288 } -
trunk/Ohana/src/opihi/dvo/init.c
r40408 r40523 3 3 int avextract PROTO((int, char **)); 4 4 int avmatch PROTO((int, char **)); 5 int avselect PROTO((int, char **)); 5 6 int avperiodogram PROTO((int, char **)); 6 7 int avperiodomatch PROTO((int, char **)); … … 69 70 {1, "avextract", avextract, "extract average data values"}, 70 71 {1, "avmatch", avmatch, "extract average data values matched to RA,DEC points"}, 72 {1, "avselect", avselect, "extract average data values within range of a list of RA,DEC points"}, 71 73 {1, "avperiodogram", avperiodogram, "perform periodogram on objects based on restrictions"}, 72 74 {1, "avperiodomatch", avperiodomatch, "perform periodogram on objects based on ra,dec list"}, -
trunk/Ohana/src/opihi/dvo/mmatch.c
r39457 r40523 84 84 85 85 // parse the fields to be extracted and returned 86 int first = 3; 87 if (CoordsFile) { 88 first = 1; 89 } 86 // this is a syntax check that we can perform before reading the input vectors 87 // NOTE: This block is missing in avmatch / avselect 88 int first = CoordsFile ? 1 : 3; 90 89 fields = dbCmdlineFields (argc-first, &argv[first], DVO_TABLE_MEASURE, &last, &Nfields); 91 90 if (fields == NULL) goto help; … … 166 165 } 167 166 167 // NOTE: image metadata is only needed to mmatch (not avmatch) since measures are tied to images, not averages 168 168 if (loadImages) { 169 169 Image *image; … … 245 245 char hostfile[1024]; 246 246 snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name); 247 247 248 dvo_catalog_init (&catalog, TRUE); 248 249 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; … … 265 266 266 267 // returns the matches to AVERAGE objects; what do we do for each MEASURE? 267 find_matches_by_vectors (skylist[0].regions[i], &catalog, RAvec, DECvec, RADIUS, index);268 find_matches_by_vectors_closest (skylist[0].regions[i], &catalog, RAvec, DECvec, RADIUS, index); 268 269 269 270 for (j = 0; (j < Nelem) && !interrupt; j++) { … … 331 332 ClearInterrupt (old_sigaction); 332 333 334 // XXXX ???? this seems odd 333 335 for (n = 0; n < Nfields; n++) { 334 336 ResetVector (vec[n], fields[n].type, Npts); -
trunk/Ohana/src/opihi/include/dvoshell.h
r40408 r40523 52 52 } PeriodogramResult; 53 53 54 typedef struct { 55 off_t Ncat; 56 off_t Nseq; 57 float Roff; 58 } AvselectResult; 59 54 60 /*** Periodogram functions (avperiodogram and avperiodomatch) ***/ 55 61 void PeriodogramResultFree (PeriodogramResult *result); … … 98 104 SkyList *SelectRegionsByCoordVectors PROTO((Vector *RA, Vector *DEC)); 99 105 100 int find_matches_by_vectors PROTO((SkyRegion *region, Catalog *catalog, Vector *RAvec, Vector *DECvec, float RADIUS, off_t *index)); 106 int find_matches_by_vectors_closest PROTO((SkyRegion *region, Catalog *catalog, Vector *RAvec, Vector *DECvec, float RADIUS, off_t *index)); 107 AvselectResult *find_matches_by_vectors_allmatch PROTO((SkyRegion *region, Catalog *catalog, Vector *RAvec, Vector *DECvec, float RADIUS, off_t *Nresult)); 101 108 102 109 int SetImageSelection PROTO((int mode, SkyRegionSelection *selection));
Note:
See TracChangeset
for help on using the changeset viewer.
