Changeset 33652 for trunk/Ohana/src/relastro/src/high_speed_objects.c
- Timestamp:
- Apr 1, 2012, 3:00:19 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relastro/src/high_speed_objects.c
r31635 r33652 6 6 int high_speed_objects (SkyRegion *region, Catalog *catalog) { 7 7 8 // XXX seems silly to require region here just to find the catalog bounds / center9 10 off_t i, j, m, J, ni, nj, *N1, Nslow, Ninvalid, NgroupA, NgroupB, NgroupAbad, NgroupBbad,l,i1,Noff,Nmeasure,Naverage, NAVERAGE, NMEASURE;11 int *slowMoving, *groupA, *groupB, status, Nmatch, Nmatchmeas, Nepoch,nv[2],Nmatchmeasobj;12 int foundA, foundB ;8 off_t i, j, m, J, ni, nj, *N1; 9 off_t Nslow, Ninvalid, NgroupA, NgroupB, NgroupAbad, NgroupBbad; 10 off_t l, i1, NAVERAGE, NMEASURE; 11 int *slowMoving, *groupA, *groupB, status, Nmatch, Nmatchmeas, Nepoch, nv[2], Nmatchmeasobj; 12 int foundA, foundB, XVERB; 13 13 double *X1, *Y1; 14 14 double dX, dY, dR, RADIUS2; 15 15 Coords tcoords; 16 Catalog catalog 1;16 Catalog catalogOut; 17 17 18 18 int Nsecfilt; 19 19 char filename[1024]; 20 Noff = strlen(CATDIR); 21 sprintf (filename, "%s%s", HIGH_SPEED_DIR, &catalog[0].filename[Noff]); 22 fprintf(stderr, "%s\n",filename); 23 dvo_catalog_init(&catalog1, TRUE); /*initialise new catalogue*/ 24 catalog1.filename = strcreate(filename); 20 21 snprintf (filename, 1024, "%s/%s.cpt", HIGH_SPEED_DIR, region[0].name); 22 fprintf (stderr, "%s\n",filename); 23 24 dvo_catalog_init (&catalogOut, TRUE); /*initialise new catalogue*/ 25 catalogOut.filename = strcreate(filename); 25 26 26 27 SIGMA_LIM = 0.0; 27 28 28 29 Nsecfilt = GetPhotcodeNsecfilt(); 29 Naverage=catalog[0].Naverage; 30 Nmeasure=catalog[0].Nmeasure; 31 catalog1.filename = filename; // based on the input name, need to keep everything below the catdir portion 32 catalog1.Nsecfilt = Nsecfilt; 33 // always load all of the data (if any exists) 34 catalog1.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 30 // off_t Naverage = catalog[0].Naverage; 31 // off_t Nmeasure = catalog[0].Nmeasure; 32 catalogOut.filename = filename; // based on the input name, need to keep everything below the catdir portion 33 catalogOut.Nsecfilt = Nsecfilt; 34 catalogOut.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; // load all data 35 35 36 catalog 1.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data37 catalog 1.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data38 39 if (!dvo_catalog_open (&catalog 1, region, VERBOSE,"w")) {36 catalogOut.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 37 catalogOut.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 38 39 if (!dvo_catalog_open (&catalogOut, region, VERBOSE2,"w")) { 40 40 fprintf (stderr, "ERROR: failure to open catalog file %s\n", 41 41 filename); … … 45 45 NAVERAGE = 1000; 46 46 NMEASURE = 10000; 47 REALLOCATE (catalog 1.average, Average, NAVERAGE);48 REALLOCATE (catalog 1.measure, Measure, NMEASURE);49 REALLOCATE (catalog1.secfilt, SecFilt, NAVERAGE*Nsecfilt);47 REALLOCATE (catalogOut.average, Average, NAVERAGE); 48 REALLOCATE (catalogOut.measure, Measure, NMEASURE); 49 REALLOCATE (catalogOut.secfilt, SecFilt, NAVERAGE*Nsecfilt); 50 50 51 51 // high-speed between different surveys (easier case): … … 77 77 // mark (exclude) objects with both sets of target photcodes 78 78 for (i = 0; i < catalog[0].Naverage; i++) { 79 80 XVERB = (catalog[0].average[i].objID == OBJ_ID_SRC) && (catalog[0].average[i].catID == CAT_ID_SRC); 81 XVERB |= (catalog[0].average[i].objID == OBJ_ID_DST) && (catalog[0].average[i].catID == CAT_ID_DST); 82 if (XVERB) { 83 fprintf (stderr, "test object\n"); 84 } 85 79 86 // do any of the measures for this object match group A? 80 87 m = catalog[0].average[i].measureOffset; … … 114 121 // fprintf (stderr, "skip "OFF_T_FMT" (group A)\n", i); 115 122 } 116 117 } else if (foundB && !foundA) {118 123 continue; 124 } 125 if (foundB && !foundA) { 119 126 if (applyConstraintsB(catalog, i)) { 120 127 groupB[i] = TRUE; … … 124 131 NgroupBbad++; 125 132 } 133 continue; 126 134 } 127 135 // this object does not have a detection matching the contraints from either gorupA or groupB -- skip as if slow … … 173 181 nj = N1[j]; 174 182 183 XVERB = (catalog[0].average[ni].objID == OBJ_ID_SRC) && (catalog[0].average[ni].catID == CAT_ID_SRC); 184 XVERB |= (catalog[0].average[nj].objID == OBJ_ID_DST) && (catalog[0].average[nj].catID == CAT_ID_DST); 185 if (XVERB) { 186 fprintf (stderr, "test object %d or %d\n", (int) ni, (int) nj); 187 } 188 175 189 if (slowMoving[ni]) NEXT_I; 176 190 if (slowMoving[nj]) NEXT_J; … … 185 199 // look for pairs that are within the maximum separation 186 200 dX = X1[i] - X1[j]; 201 if (XVERB) { 202 fprintf (stderr, "%d %d : %f\n", (int) ni, (int) nj, dX); 203 } 187 204 188 205 if (dX <= -1.02*RADIUS) NEXT_I; // negative dX: i is too small … … 197 214 nj = N1[J]; 198 215 if (!groupB[nj]) continue; 216 217 XVERB = (catalog[0].average[ni].objID == OBJ_ID_SRC) && (catalog[0].average[ni].catID == CAT_ID_SRC); 218 XVERB |= (catalog[0].average[nj].objID == OBJ_ID_DST) && (catalog[0].average[nj].catID == CAT_ID_DST); 219 if (XVERB) { 220 fprintf (stderr, "test object pt2 %d or %d : %f\n", (int) ni, (int) nj, dX); 221 fprintf (stderr, ".\n"); 222 } 199 223 200 224 dY = Y1[i] - Y1[J]; … … 209 233 nv[1]=nj; 210 234 211 catalog 1.average[Nmatch]=catalog[0].average[nv[0]];235 catalogOut.average[Nmatch]=catalog[0].average[nv[0]]; 212 236 /*Loop over index values and set measurements in new catalogue*/ 213 237 Nmatchmeasobj=0; 214 catalog 1.average[Nmatch].measureOffset=Nmatchmeas;238 catalogOut.average[Nmatch].measureOffset=Nmatchmeas; 215 239 for(l=0;l<Nepoch;l++) { 216 240 m = catalog[0].average[nv[l]].measureOffset; 217 241 for(i1=0;i1<catalog[0].average[nv[l]].Nmeasure;i1++) { 218 catalog 1.measure[Nmatchmeas]=catalog[0].measure[m+i1];242 catalogOut.measure[Nmatchmeas]=catalog[0].measure[m+i1]; 219 243 /*Set offset RA and Dec wrt correct average value*/ 220 catalog 1.measure[Nmatchmeas].dR=catalog[0].measure[m+i1].dR+3600.0*(catalog[0].average[nv[0]].R-catalog[0].average[nv[l]].R);221 catalog 1.measure[Nmatchmeas].dD=catalog[0].measure[m+i1].dD+3600.0*(catalog[0].average[nv[0]].D-catalog[0].average[nv[l]].D);222 catalog 1.measure[Nmatchmeas].averef = Nmatch;244 catalogOut.measure[Nmatchmeas].dR=catalog[0].measure[m+i1].dR+3600.0*(catalog[0].average[nv[0]].R-catalog[0].average[nv[l]].R); 245 catalogOut.measure[Nmatchmeas].dD=catalog[0].measure[m+i1].dD+3600.0*(catalog[0].average[nv[0]].D-catalog[0].average[nv[l]].D); 246 catalogOut.measure[Nmatchmeas].averef = Nmatch; 223 247 Nmatchmeasobj++; 224 248 Nmatchmeas++; … … 226 250 if (Nmatchmeas == NMEASURE - 1) { 227 251 NMEASURE += 10000; 228 REALLOCATE (catalog 1.measure, Measure, NMEASURE);252 REALLOCATE (catalogOut.measure, Measure, NMEASURE); 229 253 } 230 254 } 231 255 } 232 catalog 1.average[Nmatch].Nmeasure=Nmatchmeasobj;256 catalogOut.average[Nmatch].Nmeasure = Nmatchmeasobj; 233 257 Nmatch ++; 234 258 235 259 if (Nmatch == NAVERAGE - 1) { 236 260 NAVERAGE += 1000; 237 REALLOCATE (catalog 1.average, Average, NAVERAGE);238 REALLOCATE(catalog 1.secfilt, SecFilt, NAVERAGE*Nsecfilt);261 REALLOCATE (catalogOut.average, Average, NAVERAGE); 262 REALLOCATE(catalogOut.secfilt, SecFilt, NAVERAGE*Nsecfilt); 239 263 } 240 264 } 241 265 i++; 242 266 } 243 catalog1.Naverage=Nmatch; 244 catalog1.Nmeasure=Nmatchmeas; 245 catalog1.Nsecfilt=Nsecfilt; 246 catalog1.Nsecf_mem=Nmatch*Nsecfilt; 247 248 UpdateObjects(&catalog1, 1); 267 catalogOut.Naverage=Nmatch; 268 catalogOut.Nmeasure=Nmatchmeas; 269 catalogOut.Nsecfilt=Nsecfilt; 270 catalogOut.Nsecf_mem=Nmatch*Nsecfilt; 271 272 populate_tiny_values (&catalogOut, DVO_TV_MEASURE); 273 UpdateObjects (&catalogOut, 1); 249 274 250 275 fprintf (stderr, "found %d matches\n", Nmatch); 251 dvo_catalog_save (&catalog 1, VERBOSE);252 dvo_catalog_unlock (&catalog 1);253 dvo_catalog_free (&catalog 1);276 dvo_catalog_save (&catalogOut, VERBOSE2); 277 dvo_catalog_unlock (&catalogOut); 278 dvo_catalog_free (&catalogOut); 254 279 free (slowMoving); 255 280 free (groupA); … … 262 287 } 263 288 264 // return TRUE if any measure->photcodes match the photcodeSet 289 // return TRUE if measure->photcode match any in the photcodeSet 290 // (but, return FALSE if the measurement is bad) 265 291 int MeasMatchesPhotcode(Measure *measure, PhotCode **photcodeSet, int Nset) { 266 292 267 293 int found, k; 268 294 269 assert (Nset > 0); 270 271 if (!finite(measure[0].dR) || !finite(measure[0].dD)) return FALSE; 272 if (!finite(measure[0].M)) return FALSE; 295 if (!Nset) return TRUE; 296 // XXX require a set or not? assert (Nset > 0); 297 298 if (!finite(measure[0].dR)) return FALSE; 299 if (!finite(measure[0].dD)) return FALSE; 300 if (!finite(measure[0].M)) return FALSE; 273 301 302 float dX = GetAstromError (measure, ERROR_MODE_RA); 303 if (isnan(dX)) return FALSE; 304 305 float dY = GetAstromError (measure, ERROR_MODE_DEC); 306 if (isnan(dY)) return FALSE; 307 274 308 /* select measurements by photcode, or equiv photcode, if specified */ 275 if (Nset > 0) { 276 found = FALSE; 277 for (k = 0; (k < Nset) && !found; k++) { 278 if (photcodeSet[k][0].code == measure[0].photcode) found = TRUE; 279 if (photcodeSet[k][0].code == GetPhotcodeEquivCodebyCode(measure[0].photcode)) found = TRUE; 280 } 281 if (!found) return FALSE; 282 } 283 284 return TRUE; 309 found = FALSE; 310 for (k = 0; (k < Nset) && !found; k++) { 311 if (photcodeSet[k][0].code == measure[0].photcode) found = TRUE; 312 if (photcodeSet[k][0].code == GetPhotcodeEquivCodebyCode(measure[0].photcode)) found = TRUE; 313 } 314 315 return found; 285 316 }
Note:
See TracChangeset
for help on using the changeset viewer.
