Changeset 37604
- Timestamp:
- Nov 14, 2014, 8:42:00 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140904/Ohana/src/relastro
- Files:
-
- 9 edited
-
include/relastro.h (modified) (1 diff)
-
src/FitChip.c (modified) (1 diff)
-
src/FrameCorrection.c (modified) (3 diffs)
-
src/ICRF.c (modified) (1 diff)
-
src/ImageOps.c (modified) (1 diff)
-
src/UpdateObjects.c (modified) (1 diff)
-
src/bcatalog.c (modified) (4 diffs)
-
src/initialize.c (modified) (1 diff)
-
src/load_catalogs.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140904/Ohana/src/relastro/include/relastro.h
r37562 r37604 284 284 int args PROTO((int argc, char **argv)); 285 285 int args_client PROTO((int argc, char **argv)); 286 int bcatalog PROTO((Catalog *subcatalog, Catalog *catalog ));286 int bcatalog PROTO((Catalog *subcatalog, Catalog *catalog, int Nsubcatalog)); 287 287 void clean_images PROTO((void)); 288 288 void clean_measures PROTO((Catalog *catalog, int Ncatalog, int final)); -
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/FitChip.c
r37479 r37604 72 72 return FALSE; 73 73 } 74 // fprintf (stderr, "using %d for %s\n", order_use, image[0].name); 74 // XXX WATCH OUT HERE!! 75 if (!CHIPMAP) order_use = MIN(order_use, 1); 76 fprintf (stderr, "using %d for %s\n", order_use, image[0].name); 75 77 76 78 // when fitting the map, first fit a linear model (below? change Npolyterms to -1) -
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/FrameCorrection.c
r37562 r37604 180 180 181 181 Average *average = &catalog[cat].average[ave]; 182 Measure *measure = &catalog[cat].measure[meas]; // MeasureTiny?182 MeasureTiny *measure = &catalog[cat].measureT[meas]; // MeasureTiny? 183 183 184 184 // record these in arcsec or degree? … … 240 240 int FrameCorrectionFitLocal (Catalog *catalog, int Ncatalog, AstromOffsetMap *map, Coords *coords) { 241 241 242 int i; 242 243 double Xave, Yave, Xmeas, Ymeas; 243 244 float *X, *Y, *dX, *dY; 244 245 246 int Nicrf = ICRFmax(); 247 if (!Nicrf) { 248 fprintf (stderr, "no matched ICRF quasars for reference correction, skipping\n"); 249 return FALSE; 250 } 251 252 double *Rave, *Dave, *Rmeas, *Dmeas; 253 float *dXf, *dYf, *dPos; 254 245 255 int Npts = 0; 246 int NPTS = 100; 247 248 ALLOCATE (X, float, NPTS); 249 ALLOCATE (Y, float, NPTS); 250 ALLOCATE (dX, float, NPTS); 251 ALLOCATE (dY, float, NPTS); 252 253 int Nicrf = ICRFmax(); 254 255 int i; 256 ALLOCATE (Rave, double, Nicrf); 257 ALLOCATE (Dave, double, Nicrf); 258 ALLOCATE (Rmeas, double, Nicrf); 259 ALLOCATE (Dmeas, double, Nicrf); 260 261 ALLOCATE (X, float, Nicrf); 262 ALLOCATE (Y, float, Nicrf); 263 ALLOCATE (dX, float, Nicrf); 264 ALLOCATE (dY, float, Nicrf); 265 ALLOCATE (dXf, float, Nicrf); 266 ALLOCATE (dYf, float, Nicrf); 267 268 ALLOCATE (dPos, float, Nicrf); 269 270 int *mask = NULL; 271 ALLOCATE (mask, int, Nicrf); 272 memset (mask, 0, Nicrf*sizeof(int)); 273 274 // select the ICRF QSOS and save the necessary data 256 275 for (i = 0; i < Nicrf; i++) { 257 276 258 int cat, meas, ave;259 ICRFdata (i, &cat, & meas, &ave);277 int cat, ave, meas; 278 ICRFdata (i, &cat, &ave, &meas); 260 279 261 280 Average *average = &catalog[cat].average[ave]; 262 Measure *measure = &catalog[cat].measure[meas]; // MeasureTiny?281 MeasureTiny *measure = &catalog[cat].measureT[meas]; // MeasureTiny? 263 282 264 283 // this local correction is defined for (Rmin < R < Rmax, Dmin < D < Dmax) … … 278 297 dX[Npts] = Xave - Xmeas; 279 298 dY[Npts] = Yave - Ymeas; 299 Rave[Npts] = average->R; 300 Dave[Npts] = average->D; 301 Rmeas[Npts] = measure->R; 302 Dmeas[Npts] = measure->D; 280 303 Npts ++; 281 if (Npts == NPTS) { 282 NPTS += 100; 283 REALLOCATE (X, float, NPTS); 284 REALLOCATE (Y, float, NPTS); 285 REALLOCATE (dX, float, NPTS); 286 REALLOCATE (dY, float, NPTS); 287 } 288 } 289 290 AstromOffsetMapFit (map, X, Y, dX, Npts, TRUE); 291 AstromOffsetMapFit (map, X, Y, dY, Npts, FALSE); 304 } 305 306 float *Xfit, *Yfit, *dXfit, *dYfit; 307 ALLOCATE (Xfit, float, Npts); 308 ALLOCATE (Yfit, float, Npts); 309 ALLOCATE (dXfit, float, Npts); 310 ALLOCATE (dYfit, float, Npts); 311 312 int Niter; 313 for (Niter = 0; Niter < 3; Niter ++) { 314 int Nkeep = 0; 315 for (i = 0; i < Npts; i++) { 316 if (mask[i]) continue; 317 318 Xfit[Nkeep] = X[i]; 319 Yfit[Nkeep] = Y[i]; 320 dXfit[Nkeep] = dX[i]; 321 dYfit[Nkeep] = dY[i]; 322 Nkeep ++; 323 } 324 325 AstromOffsetMapFit (map, Xfit, Yfit, dXfit, Nkeep, TRUE); 326 AstromOffsetMapFit (map, Xfit, Yfit, dYfit, Nkeep, FALSE); 327 328 for (i = 0; i < Npts; i++) { 329 dXf[i] = AstromOffsetMapValue (map, X[i], Y[i], TRUE); 330 dYf[i] = AstromOffsetMapValue (map, X[i], Y[i], FALSE); 331 } 332 333 // generate a histogram of the dPos = sqrt((dXf - dX)^2 + (dYf - dY)^2) values 334 Nkeep = 0; 335 for (i = 0; i < Npts; i++) { 336 if (mask[i]) continue; 337 float dP = hypot((dXf[i] - dX[i]), (dYf[i] - dY[i])); 338 if (isnan(dP)) continue; // not all points are in the map 339 dPos[Nkeep] = dP; 340 Nkeep ++; 341 } 342 fsort (dPos, Nkeep); 343 344 float dPmax = 1.5*dPos[(int)(0.95*Nkeep)]; 345 346 // mask points based on dPmax 347 Nkeep = 0; 348 for (i = 0; i < Npts; i++) { 349 float dP = hypot((dXf[i] - dX[i]), (dYf[i] - dY[i])); 350 if (dP > dPmax) mask[i] = 1; 351 if (isnan(dP)) mask[i] = 1; 352 if (mask[i]) Nkeep++; 353 } 354 fprintf (stderr, "keeping %d of %d points\n", Nkeep, Npts); 355 } 356 free (Xfit); 357 free (Yfit); 358 free (dXfit); 359 free (dYfit); 360 361 // *** save the icrf points and fit residuals 362 { 363 FILE *f = fopen ("map.dat", "w"); 364 365 for (i = 0; i < Npts; i++) { 366 fprintf (f, "%3d %12.8f %12.8f %12.8f %12.8f %f %f : %f %f : %f %f : %d\n", i, Rave[i], Dave[i], Rmeas[i], Dmeas[i], X[i], Y[i], dX[i], dY[i], dXf[i], dYf[i], mask[i]); 367 } 368 fclose (f); 369 } 370 371 // write out the maps as images 372 { 373 Header header; 374 Matrix matrix; 375 376 gfits_init_header (&header); 377 header.bitpix = -32; 378 header.Naxes = 2; 379 header.Naxis[0] = map->Nx; 380 header.Naxis[1] = map->Ny; 381 382 gfits_create_header (&header); 383 gfits_create_matrix (&header, &matrix); 384 PutCoords (coords, &header); 385 386 float *buffer = (float *)matrix.buffer; 387 388 int ix, iy; 389 for (ix = 0; ix < map->Nx; ix++) { 390 for (iy = 0; iy < map->Ny; iy++) { 391 buffer[ix + map->Nx*iy] = map->dXv[ix][iy]; 392 } 393 } 394 395 gfits_write_header ("map.dX.fits", &header); 396 gfits_write_matrix ("map.dX.fits", &matrix); 397 398 for (ix = 0; ix < map->Nx; ix++) { 399 for (iy = 0; iy < map->Ny; iy++) { 400 buffer[ix + map->Nx*iy] = map->dYv[ix][iy]; 401 } 402 } 403 gfits_write_header ("map.dY.fits", &header); 404 gfits_write_matrix ("map.dY.fits", &matrix); 405 } 292 406 293 407 return TRUE; -
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/ICRF.c
r37545 r37604 18 18 int ICRFsave (int cat, int ave, int meas) { 19 19 20 fprintf (stderr, "ICRF: %d %d %d\n", cat, ave, meas); 21 20 22 ICRFtoCatalog[Nicrf] = cat; 21 23 ICRFtoAverage[Nicrf] = ave; -
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/ImageOps.c
r37545 r37604 810 810 // XXX subtract off dR,dD GAL here 811 811 if (USE_GALAXY_MODEL) { 812 ref[i].R += measure[0].RoffGAL ;813 ref[i].D += measure[0].DoffGAL ;812 ref[i].R += measure[0].RoffGAL / 3600.0; 813 ref[i].D += measure[0].DoffGAL / 3600.0; 814 814 } 815 815 -
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateObjects.c
r37545 r37604 210 210 211 211 if (USE_GALAXY_MODEL) { 212 Ri -= measure[ 0].RoffGAL;213 Di -= measure[ 0].DoffGAL;212 Ri -= measure[k].RoffGAL / 3600.0; 213 Di -= measure[k].DoffGAL / 3600.0; 214 214 } 215 215 -
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/bcatalog.c
r37545 r37604 19 19 int LimitDensityCatalog_ByNmeasureGrid (Catalog *subcatalog, Catalog *oldcatalog); 20 20 21 int bcatalog (Catalog *subcatalog, Catalog *catalog ) {21 int bcatalog (Catalog *subcatalog, Catalog *catalog, int Nsubcatalog) { 22 22 23 23 off_t i, j, offset; … … 62 62 63 63 int Nicrf = 0; 64 65 FILE *f = fopen ("test.icrf.dat", "a"); 64 66 65 67 /* exclude stars not in range or with too few measurements */ … … 98 100 // we need to save the location of the ICRF QSOs in the database 99 101 if (subcatalog[0].measureT[Nmeasure].dbFlags & ID_MEAS_ICRF_QSO) { 100 ICRFsave (i, Naverage, Nmeasure); 102 ICRFsave (Nsubcatalog, Naverage, Nmeasure); 103 fprintf (f, "%d %d %d : %f %f : %f %f\n", (int) Nsubcatalog, (int) Naverage, (int) Nmeasure, 104 catalog[0].average[i].R, catalog[0].average[i].D, 105 catalog[0].measure[offset].R, catalog[0].measure[offset].D); 101 106 Nicrf ++; 102 107 } … … 224 229 subcatalog[0].catID = catalog[0].catID; 225 230 assert (Nsecfilt == catalog[0].Nsecfilt); 231 232 fclose (f); 226 233 227 234 // limit the total number of stars in the catalog -
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/initialize.c
r37038 r37604 63 63 initstats (STATMODE); 64 64 65 if (USE_ICRF_CORRECT) ICRFinit(); 66 65 67 /* XXX drop irrelevant entries */ 66 68 if (SHOW_PARAMS) { -
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/load_catalogs.c
r37545 r37604 68 68 // results are in Average, Secfilt, and MeasureTiny 69 69 // Ncat tracks the actually used catalogs 70 bcatalog (&catalog[Ncat], &tcatalog );70 bcatalog (&catalog[Ncat], &tcatalog, Ncat); 71 71 dvo_catalog_unlock (&tcatalog); 72 72 dvo_catalog_free (&tcatalog);
Note:
See TracChangeset
for help on using the changeset viewer.
