Changeset 40575
- Timestamp:
- Dec 5, 2018, 2:13:03 PM (8 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 3 edited
-
dvo/avselect.c (modified) (1 diff)
-
dvo/skyregion.c (modified) (1 diff)
-
include/dvoshell.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/avselect.c
r40525 r40575 102 102 } 103 103 104 RADIUS = atof (argv[1]); 105 104 106 /* load regions which contain all supplied RA,DEC coordinates */ 105 if ((skylist = SelectRegionsByCoordVectors (RAvec, DECvec)) == NULL) goto escape;107 if ((skylist = SelectRegionsByCoordVectorsAndRadius (RAvec, DECvec, RADIUS/3600.0)) == NULL) goto escape; 106 108 107 109 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results -
trunk/Ohana/src/opihi/dvo/skyregion.c
r35416 r40575 147 147 } 148 148 149 void sort_skylist_by_index (SkyList *list) { 150 151 # define SWAPFUNC(A,B){ \ 152 SkyRegion *tmp; tmp = list[0].regions[A]; list[0].regions[A] = list[0].regions[B]; list[0].regions[B] = tmp; \ 153 char *tmpname; tmpname = list[0].filename[A]; list[0].filename[A] = list[0].filename[B]; list[0].filename[B] = tmpname; \ 154 } 155 # define COMPARE(A,B)(list[0].regions[A][0].index < list[0].regions[B][0].index) 156 157 OHANA_SORT (list[0].Nregions, COMPARE, SWAPFUNC); 158 159 # undef SWAPFUNC 160 # undef COMPARE 161 162 } 163 164 SkyList *SkyListUniqueSubset (SkyList *input) { 165 166 sort_skylist_by_index (input); 167 for (int i = 0; i < input->Nregions; i++) { 168 fprintf (stderr, "idx: %s : %s : %d\n", input->regions[i][0].name, input->filename[i], input->regions[i][0].index); 169 } 170 171 SkyList *list; 172 173 int Nout = 0; 174 int NOUT = input->Nregions; 175 176 ALLOCATE (list, SkyList, 1); 177 ALLOCATE (list[0].regions, SkyRegion *, NOUT); 178 ALLOCATE (list[0].filename, char *, NOUT); 179 list[0].ownElements = FALSE; // this list is only holding a view to the elements 180 181 if (input->Nregions == 0) { 182 list->Nregions = 0; 183 return list; 184 } 185 186 list->regions[Nout] = input->regions[0]; 187 list->filename[Nout] = input->filename[0]; 188 189 for (int i = 0; i < input->Nregions; i++) { 190 if (list->regions[Nout][0].index == input->regions[i][0].index) continue; 191 Nout ++; 192 list->regions[Nout] = input->regions[i]; 193 list->filename[Nout] = input->filename[i]; 194 } 195 list->Nregions = Nout; 196 REALLOCATE (list[0].regions, SkyRegion *, Nout); 197 REALLOCATE (list[0].filename, char *, Nout); 198 199 // free the input list? 200 return list; 201 } 202 203 // return a list of all regions covered by this list of coordinates and the given radius 204 SkyList *SelectRegionsByCoordVectorsAndRadius (Vector *RA, Vector *DEC, float Radius) { 205 206 int Npts, Nout, NOUT, *found; 207 double ra, dec; 208 SkyList *list; 209 SkyTable *sky; 210 211 sky = GetSkyTable (); 212 213 Npts = RA->Nelements; 214 ALLOCATE (found, int, Npts); 215 memset (found, 0, Npts*sizeof(int)); 216 217 // output list 218 Nout = 0; 219 NOUT = 100; 220 ALLOCATE (list, SkyList, 1); 221 ALLOCATE (list[0].regions, SkyRegion *, NOUT); 222 ALLOCATE (list[0].filename, char *, NOUT); 223 list[0].Nregions = 0; 224 list[0].ownElements = FALSE; // this list is only holding a view to the elements 225 strcpy (list[0].hosts, sky[0].hosts); 226 227 for (int i = 0; i < Npts; i++) { 228 if (found[i]) continue; 229 230 SkyList *new = SkyListByRadius (sky, -1, RA->elements.Flt[i], DEC->elements.Flt[i], Radius); 231 if (new->Nregions == 0) continue; 232 233 // append new regions to output list 234 if (Nout + new->Nregions >= NOUT) { 235 NOUT += new->Nregions + 100; 236 REALLOCATE (list[0].regions, SkyRegion *, NOUT); 237 REALLOCATE (list[0].filename, char *, NOUT); 238 } 239 240 for (int n = 0; n < new->Nregions; n++) { 241 list[0].regions[Nout] = new[0].regions[n]; 242 list[0].filename[Nout] = new[0].filename[n]; 243 Nout ++; 244 } 245 found[i] = TRUE; 246 247 // scan over the remaining points to find any that lie within these regions 248 // if we sorted the ra,dec inputs we could break out of this more quickly 249 for (int j = i + 1; j < Npts; j++) { 250 ra = RA->elements.Flt[j]; 251 dec = DEC->elements.Flt[j]; 252 for (int n = 0; !found[j] && (n < new->Nregions); n++) { 253 if (ra < new[0].regions[n][0].Rmin) continue; 254 if (ra > new[0].regions[n][0].Rmax) continue; 255 if (dec < new[0].regions[n][0].Dmin) continue; 256 if (dec > new[0].regions[n][0].Dmax) continue; 257 found[j] = TRUE; 258 } 259 } 260 SkyListFree (new); 261 } 262 list[0].Nregions = Nout; 263 264 // before I go any further, I need to strip down to a unique subset 265 SkyList *uniq = SkyListUniqueSubset(list); 266 267 free (found); 268 269 return (uniq); 270 } 271 -
trunk/Ohana/src/opihi/include/dvoshell.h
r40523 r40575 103 103 int SkyRegionByPoint_r PROTO((SkyTable *table, SkyList *list, int depth, double ra, double dec)); 104 104 SkyList *SelectRegionsByCoordVectors PROTO((Vector *RA, Vector *DEC)); 105 SkyList *SelectRegionsByCoordVectorsAndRadius (Vector *RA, Vector *DEC, float Radius); 105 106 106 107 int find_matches_by_vectors_closest PROTO((SkyRegion *region, Catalog *catalog, Vector *RAvec, Vector *DECvec, float RADIUS, off_t *index));
Note:
See TracChangeset
for help on using the changeset viewer.
