Changeset 36769
- Timestamp:
- May 23, 2014, 9:42:18 AM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140423/Ohana/src/relastro/src
- Files:
-
- 5 edited
-
FitChip.c (modified) (2 diffs)
-
bcatalog.c (modified) (8 diffs)
-
launch_region_hosts.c (modified) (2 diffs)
-
relastro_images.c (modified) (1 diff)
-
relastro_parallel_images.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140423/Ohana/src/relastro/src/FitChip.c
r33652 r36769 50 50 relastroVisualPlotChipFit(raw, ref, dRmax, Nmatch); 51 51 52 // fit the requested order polynomial 52 // set the maximum order for the polynomial (based on number of stars) 53 int order_use = 0; 54 if (Nmatch > 5) order_use = 1; // 4 stars per polynomial term (per dimension) 55 if (Nmatch > 30) order_use = 2; // 5 stars per polynomial term (per dimension) 56 if (Nmatch > 60) order_use = 3; // 6 stars per polynomial term (per dimension) 57 if (order_use < 1) { 58 if (VERBOSE2) fprintf (stderr, "insufficient measurements (%d) for linear fit\n", Nmatch); 59 image[0].flags |= ID_IMAGE_ASTROM_FEW; 60 return FALSE; 61 } 62 image[0].coords.Npolyterms = order_use; 63 64 # if (0) 53 65 if (CHIPORDER > 0) { 54 66 int Ndof_min = 3; … … 62 74 image[0].coords.Npolyterms = order_use; 63 75 } 76 # endif 64 77 65 78 if (fit) fit_free (fit); -
branches/eam_branches/ipp-20140423/Ohana/src/relastro/src/bcatalog.c
r34429 r36769 1 1 # include "relastro.h" 2 2 3 static int Nkeep1 = 0; 4 static int Nkeep2 = 0; 3 5 static int Nskip1 = 0; 4 6 static int Nskip2 = 0; 5 static unsigned int Tref = 1323353985; 6 static short Cref = 10355; 7 8 // test image: 2013/06/15,13:25:51, GPC1.r.XY50 9 static int CHECK_TEST_IMAGE = FALSE; 10 static unsigned int Tref = 1378812312; 11 static short Cref = 10001; 12 13 int LimitDensityCatalog_ByNmeasureGrid (Catalog *subcatalog, Catalog *oldcatalog); 7 14 8 15 int bcatalog (Catalog *subcatalog, Catalog *catalog) { … … 60 67 if (!MeasFilterTest(&catalog[0].measure[offset], TRUE)) { 61 68 catalog[0].measure[offset].dbFlags &= ~ID_MEAS_USED_CHIP; 62 if ( FALSE && (abs(catalog[0].measure[offset].t - Tref) < 10) && (catalog[0].measure[offset].photcode == Cref)) {69 if (CHECK_TEST_IMAGE && (abs(catalog[0].measure[offset].t - Tref) < 10) && (catalog[0].measure[offset].photcode == Cref)) { 63 70 Nskip1 ++; 64 71 } 65 72 continue; 73 } 74 if (CHECK_TEST_IMAGE && (abs(catalog[0].measure[offset].t - Tref) < 10) && (catalog[0].measure[offset].photcode == Cref)) { 75 Nkeep1 ++; 66 76 } 67 77 … … 87 97 // but before the final average properties are calculated, these measurements may be 88 98 // allowed. 99 100 if (CHECK_TEST_IMAGE && (abs(catalog[0].measure[offset].t - Tref) < 10) && (catalog[0].measure[offset].photcode == Cref)) { 101 Nkeep2 ++; 102 } 89 103 90 104 CopyMeasureToTiny (&subcatalog[0].measureT[Nmeasure], &catalog[0].measure[offset]); … … 125 139 // limit the total number of stars in the catalog 126 140 if (MaxDensityUse) { 127 LimitDensityCatalog_ByNmeasure (subcatalog, catalog);141 LimitDensityCatalog_ByNmeasureGrid (subcatalog, catalog); 128 142 } else { 129 143 if (VERBOSE2) { … … 134 148 } 135 149 } 150 if (CHECK_TEST_IMAGE && (Nkeep1 + Nkeep2 + Nskip1 + Nskip2 > 0)) { 151 fprintf (stderr, "kept %d %d, skipped %d %d\n", Nkeep1, Nkeep2, Nskip1, Nskip2); 152 } 153 136 154 return (TRUE); 137 155 } … … 139 157 void bcatalog_show_skips () { 140 158 fprintf (stderr, "Nskip: %d, %d\n", Nskip1, Nskip2); 159 fprintf (stderr, "Nkeep: %d, %d\n", Nkeep1, Nkeep2); 141 160 } 142 161 … … 155 174 # undef COMPARE 156 175 176 } 177 178 /* generate a grid in a locally-projected coordinate system, try to select average entries 179 from each grid cell in decending Nmeasure order. 180 */ 181 int LimitDensityCatalog_ByNmeasureGrid (Catalog *subcatalog, Catalog *oldcatalog) { 182 183 off_t i, j; 184 int ix, iy; 185 186 Catalog tmpcatalog; 187 188 double Rmin, Rmax, Dmin, Dmax; 189 190 int Nsecfilt = GetPhotcodeNsecfilt (); 191 192 gfits_scan (&oldcatalog[0].header, "RA0", "%lf", 1, &Rmin); 193 gfits_scan (&oldcatalog[0].header, "DEC0", "%lf", 1, &Dmin); 194 gfits_scan (&oldcatalog[0].header, "RA1", "%lf", 1, &Rmax); 195 gfits_scan (&oldcatalog[0].header, "DEC1", "%lf", 1, &Dmax); 196 197 if (VERBOSE2) fprintf (stderr, "extracting from catalog covering region %f,%f to %f,%f\n", Rmin, Dmin, Rmax, Dmax); 198 199 float AREA = fabs(Dmax - Dmin) * fabs(Rmax - Rmin) * cos (0.5*RAD_DEG*(Dmax + Dmin)); 200 assert (AREA > 0); 201 202 off_t Nmax = MaxDensityValue * AREA; 203 if (subcatalog[0].Naverage <= Nmax) { 204 if (VERBOSE) { 205 fprintf (stderr, "subcatalog has less than the max density\n"); 206 } 207 return (TRUE); 208 } 209 210 off_t Naverage = subcatalog[0].Naverage; 211 212 // generate a grid in locally projected space 213 double Rc = 0.5*(Rmin + Rmax); 214 double Dc = 0.5*(Dmin + Dmax); 215 216 /* project coordinates to a plane centered on the object with units of arcsec */ 217 Coords coords; 218 coords.crval1 = Rc; 219 coords.crval2 = Dc; 220 coords.crpix1 = 0; 221 coords.crpix2 = 0; 222 coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0; 223 coords.pc1_1 = coords.pc2_2 = 1.0; 224 coords.pc1_2 = coords.pc2_1 = 0.0; 225 coords.Npolyterms = 1; 226 strcpy (coords.ctype, "DEC--SIN"); 227 228 // convert all average R,D values to X,Y: 229 double *X, *Y; 230 ALLOCATE (X, double, Naverage); 231 ALLOCATE (Y, double, Naverage); 232 float Xmin = +10000.0, Ymin = +10000.0; 233 float Xmax = -10000.0, Ymax = -10000.0; 234 for (i = 0; i < Naverage; i++) { 235 X[i] = NAN; 236 Y[i] = NAN; 237 // skip any stars which are outside of nominal catalog range 238 if (subcatalog[0].average[i].R < Rmin) continue; 239 if (subcatalog[0].average[i].R > Rmax) continue; 240 if (subcatalog[0].average[i].D < Dmin) continue; 241 if (subcatalog[0].average[i].D > Dmax) continue; 242 RD_to_XY (&X[i], &Y[i], subcatalog[0].average[i].R, subcatalog[0].average[i].D, &coords); 243 Xmin = MIN (Xmin, X[i]); 244 Xmax = MAX (Xmax, X[i]); 245 Ymin = MIN (Ymin, Y[i]); 246 Ymax = MAX (Ymax, Y[i]); 247 } 248 249 // how many grid cells? what is the grid spacing? 250 float dX = Xmax - Xmin; 251 float dY = Ymax - Ymin; 252 253 // *** XXX for the moment, I'm using a hard-wired cell size (200 arcsec ~ 3.3 arcmin) 254 int NX = (int)(dX / 200) + 1; 255 int NY = (int)(dY / 200) + 1; 256 // fprintf (stderr, "Density Grid: %d x %d\n", NX, NY); 257 // XXX check that NX,NY are sensible (5 degrees / 200 arcsec seems like the absolute max) 258 if (NX > 1000) { 259 fprintf (stderr, "serious problem with %s: NX = %d\n", subcatalog[0].filename, NX); 260 exit (3); 261 } 262 if (NY > 1000) { 263 fprintf (stderr, "serious problem with %s: NY = %d\n", subcatalog[0].filename, NY); 264 exit (3); 265 } 266 267 // kind of ugly : generate a grid of index, Nmeasure arrays 268 // to be filled below (I also need NN and Nn to track the number of 269 // entries in each). 270 int **NN_grid; 271 int **Nn_grid; 272 int ***Nm_grid; 273 off_t ***idxgrid; 274 ALLOCATE (NN_grid, int *, NX); 275 ALLOCATE (Nn_grid, int *, NX); 276 ALLOCATE (Nm_grid, int **, NX); 277 ALLOCATE (idxgrid, off_t **, NX); 278 279 for (ix = 0; ix < NX; ix++) { 280 ALLOCATE (NN_grid[ix], int, NY); 281 ALLOCATE (Nn_grid[ix], int, NY); 282 ALLOCATE (Nm_grid[ix], int *, NY); 283 ALLOCATE (idxgrid[ix], off_t *, NY); 284 for (iy = 0; iy < NY; iy++) { 285 Nn_grid[ix][iy] = 0; 286 NN_grid[ix][iy] = 100; 287 ALLOCATE (Nm_grid[ix][iy], int, NN_grid[ix][iy]); 288 ALLOCATE (idxgrid[ix][iy], off_t, NN_grid[ix][iy]); 289 } 290 } 291 292 // assign all of the average entries to a grid cell 293 for (i = 0; i < Naverage; i++) { 294 if (isnan(X[i])) continue; 295 if (isnan(Y[i])) continue; 296 ix = (X[i] - Xmin) / 200.0; 297 iy = (Y[i] - Ymin) / 200.0; 298 int Nn = Nn_grid[ix][iy]; 299 Nm_grid[ix][iy][Nn] = subcatalog[0].average[i].Nmeasure; 300 301 // if we are resetting to a given photcode, we need to have that photcode... 302 if (NphotcodesReset) { 303 int k; 304 int foundReset = FALSE; 305 int m = subcatalog[0].average[i].measureOffset; 306 MeasureTiny *measure = &subcatalog[0].measureT[m]; 307 for (j = 0; (j < subcatalog[0].average[i].Nmeasure) && !foundReset; j++) { 308 if (CHECK_TEST_IMAGE && (abs(measure[j].t - Tref) < 10) && (measure[j].photcode == Cref)) { 309 fprintf (stderr, "."); 310 } 311 for (k = 0; (k < NphotcodesReset) && !foundReset; k++) { 312 if (photcodesReset[k][0].code == measure[j].photcode) foundReset = TRUE; 313 } 314 } 315 if (!foundReset) { 316 Nm_grid[ix][iy][Nn] = 0; 317 } 318 } 319 320 idxgrid[ix][iy][Nn] = i; 321 Nn_grid[ix][iy] ++; 322 if (Nn_grid[ix][iy] >= NN_grid[ix][iy]) { 323 NN_grid[ix][iy] += 100; 324 REALLOCATE (Nm_grid[ix][iy], int, NN_grid[ix][iy]); 325 REALLOCATE (idxgrid[ix][iy], off_t, NN_grid[ix][iy]); 326 } 327 } 328 329 // sort all of the grid cells 330 for (ix = 0; ix < NX; ix++) { 331 for (iy = 0; iy < NY; iy++) { 332 sort_by_Nmeasure (Nm_grid[ix][iy], idxgrid[ix][iy], Nn_grid[ix][iy]); 333 NN_grid[ix][iy] = 0; // I'm going to use this array to track which element I've already selected 334 } 335 } 336 337 // cycle over the grid until we ready Nmax 338 off_t *keepidx = NULL; 339 ALLOCATE (keepidx, off_t, Naverage); 340 memset (keepidx, 0, Naverage*sizeof(off_t)); 341 int Nkeep = 0; 342 343 for (i = 0; (i < 20) && (Nkeep < Nmax); i++) { 344 for (ix = 0; (ix < NX) && (Nkeep < Nmax); ix++) { 345 for (iy = 0; (iy < NY) && (Nkeep < Nmax); iy++) { 346 if (NN_grid[ix][iy] >= Nn_grid[ix][iy]) continue; // all used up! 347 int Nn = NN_grid[ix][iy]; 348 keepidx[Nkeep] = idxgrid[ix][iy][Nn]; 349 Nkeep ++; 350 NN_grid[ix][iy] ++; 351 } 352 } 353 } 354 355 // count the number of measurements this selection will yield 356 off_t ave, NMEASURE = 0; 357 for (i = 0; i < Nkeep; i++) { 358 ave = keepidx[i]; 359 NMEASURE += subcatalog[0].average[ave].Nmeasure; 360 } 361 362 // test catID : 37262 37261 37257 37258 363 int dumpit = FALSE; 364 dumpit |= (oldcatalog[0].catID == 37007); 365 // dumpit |= (oldcatalog[0].catID == 37261); 366 // dumpit |= (oldcatalog[0].catID == 37257); 367 // dumpit |= (oldcatalog[0].catID == 37258); 368 if (dumpit) { 369 char name[64]; 370 snprintf (name, 64, "cat.%05d.dump.dat", oldcatalog[0].catID); 371 FILE *fdump = fopen (name, "w"); 372 for (i = 0; i < Nkeep; i++) { 373 ave = keepidx[i]; 374 fprintf (fdump, "%10.6f %10.6f %d\n", subcatalog[0].average[ave].R, subcatalog[0].average[ave].D, subcatalog[0].average[ave].Nmeasure); 375 } 376 fclose (fdump); 377 } 378 379 // allocate the output data 380 ALLOCATE (tmpcatalog.average, Average, Nkeep); 381 ALLOCATE (tmpcatalog.measureT, MeasureTiny, NMEASURE); 382 ALLOCATE (tmpcatalog.secfilt, SecFilt, Nkeep * Nsecfilt); 383 384 off_t Nmeasure = 0; 385 386 // copy the Nkeep selected entries from subcatalog to tmpcatalog (adjusting links) 387 for (i = 0; i < Nkeep; i++) { 388 ave = keepidx[i]; 389 tmpcatalog.average[i] = subcatalog[0].average[ave]; 390 tmpcatalog.average[i].measureOffset = Nmeasure; 391 for (j = 0; j < tmpcatalog.average[i].Nmeasure; j++) { 392 off_t offset = subcatalog[0].average[ave].measureOffset + j; 393 tmpcatalog.measureT[Nmeasure] = subcatalog[0].measureT[offset]; 394 tmpcatalog.measureT[Nmeasure].averef = i; 395 Nmeasure ++; 396 } 397 for (j = 0; j < Nsecfilt; j++) { 398 tmpcatalog.secfilt[i*Nsecfilt + j] = subcatalog[0].secfilt[ave*Nsecfilt + j]; 399 } 400 } 401 402 if (VERBOSE2) { 403 char *basename = filebasename (oldcatalog[0].filename); 404 fprintf (stderr, "limited to %d ("OFF_T_FMT" subset, "OFF_T_FMT" total) stars, "OFF_T_FMT" ("OFF_T_FMT" subset, "OFF_T_FMT" total) measures for catalog %s\n", 405 Nkeep, subcatalog[0].Naverage, oldcatalog[0].Naverage, Nmeasure, subcatalog[0].Nmeasure, oldcatalog[0].Nmeasure, basename); 406 free (basename); 407 } 408 409 free (X); 410 free (Y); 411 412 for (ix = 0; ix < NX; ix++) { 413 for (iy = 0; iy < NY; iy++) { 414 free (Nm_grid[ix][iy]); 415 free (idxgrid[ix][iy]); 416 } 417 free (NN_grid[ix]); 418 free (Nn_grid[ix]); 419 free (Nm_grid[ix]); 420 free (idxgrid[ix]); 421 } 422 free (NN_grid); 423 free (Nn_grid); 424 free (Nm_grid); 425 free (idxgrid); 426 427 free (keepidx); 428 429 free (subcatalog[0].average); 430 free (subcatalog[0].measureT); 431 free (subcatalog[0].secfilt); 432 433 subcatalog[0].average = tmpcatalog.average; 434 subcatalog[0].measureT = tmpcatalog.measureT; 435 subcatalog[0].secfilt = tmpcatalog.secfilt; 436 subcatalog[0].Naverage = Nkeep; 437 subcatalog[0].Nmeasure = Nmeasure; 438 subcatalog[0].Nsecfilt = oldcatalog[0].Nsecfilt; 439 subcatalog[0].Nsecf_mem = Naverage * oldcatalog[0].Nsecfilt; 440 441 return (TRUE); 157 442 } 158 443 … … 205 490 NMEASURE += subcatalog[0].average[ave].Nmeasure; 206 491 } 492 493 # if (0) 494 if (oldcatalog[0].catID == 59962) { 495 FILE *fdump = fopen ("cat.dump.dat", "w"); 496 for (i = 0; i < Nmax; i++) { 497 ave = index[i]; 498 fprintf (fdump, "%10.6f %10.6f %d\n", subcatalog[0].average[ave].R, subcatalog[0].average[ave].D, subcatalog[0].average[ave].Nmeasure); 499 } 500 fclose (fdump); 501 } 502 # endif 207 503 208 504 // allocate the output data -
branches/eam_branches/ipp-20140423/Ohana/src/relastro/src/launch_region_hosts.c
r36630 r36769 88 88 if (PHOTCODE_KEEP_LIST) strextend (command, "+photcode %s", PHOTCODE_KEEP_LIST); 89 89 if (PHOTCODE_SKIP_LIST) strextend (command, "-photcode %s", PHOTCODE_SKIP_LIST); 90 if (PHOTCODE_RESET_LIST) strextend (command, "-reset-to-photcode %s", PHOTCODE_RESET_LIST); 90 91 91 92 if (MaxDensityUse) strextend (command, "-max-density %f", MaxDensityValue); … … 97 98 if (MinBadQF > 0.0) strextend (command, "-min-bad-psfqf %f", MinBadQF); 98 99 if (MaxMeanOffset != 10.0) strextend (command, "-max-mean-offset %f", MaxMeanOffset); 100 101 strextend (command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW); 102 strextend (command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM); 103 strextend (command, "-D RELASTRO_DPOS_MAX %f", DPOS_MAX); 104 strextend (command, "-D ADDSTAR_RADIUS %d", ADDSTAR_RADIUS); 99 105 100 106 if (TimeSelect) { -
branches/eam_branches/ipp-20140423/Ohana/src/relastro/src/relastro_images.c
r36746 r36769 34 34 MARKTIME("load catalog data: %f sec\n", dtime); 35 35 36 photcodesKeep = photcodesReset; 37 NphotcodesKeep = NphotcodesReset; 36 if (photcodesReset) { 37 photcodesKeep = photcodesReset; 38 NphotcodesKeep = NphotcodesReset; 39 } 38 40 39 41 if (Ncatalog == 0) { -
branches/eam_branches/ipp-20140423/Ohana/src/relastro/src/relastro_parallel_images.c
r36630 r36769 48 48 MARKTIME("-- load catalog data: %f sec\n", dtime); 49 49 50 if (photcodesReset) { 51 photcodesKeep = photcodesReset; 52 NphotcodesKeep = NphotcodesReset; 53 } 54 50 55 // NOTE: if I let all hosts load blindly, I saturate the data clients with too many 51 56 // relastro_client requests. I need to have the master mediate this. the master
Note:
See TracChangeset
for help on using the changeset viewer.
