Changeset 37684
- Timestamp:
- Nov 28, 2014, 7:02:38 AM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140904/Ohana/src/relastro
- Files:
-
- 7 edited
-
Makefile (modified) (3 diffs)
-
include/relastro.h (modified) (1 diff)
-
src/FitChip.c (modified) (4 diffs)
-
src/ImageOps.c (modified) (4 diffs)
-
src/UpdateChips.c (modified) (10 diffs)
-
src/relastro_images.c (modified) (2 diffs)
-
src/relastro_parallel_images.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140904/Ohana/src/relastro/Makefile
r37665 r37684 60 60 $(SRC)/CoordOps.$(ARCH).o \ 61 61 $(SRC)/extra.$(ARCH).o \ 62 $(SRC)/FixProblemImages.$(ARCH).o \63 62 $(SRC)/StarMaps.$(ARCH).o \ 64 63 $(SRC)/high_speed_catalogs.$(ARCH).o \ … … 125 124 $(SRC)/relastro_objects.$(ARCH).o \ 126 125 $(SRC)/save_catalogs.$(ARCH).o \ 127 $(SRC)/CoordOps.$(ARCH).o \128 126 $(SRC)/extra.$(ARCH).o \ 129 127 $(SRC)/high_speed_catalogs.$(ARCH).o \ … … 141 139 $(SRC)/BrightCatalog.$(ARCH).o 142 140 143 #$(SRC)/FitChip.$(ARCH).o \144 #$(SRC)/FitMosaic.$(ARCH).o \145 #$(SRC)/UpdateChips.$(ARCH).o \146 #$(SRC)/UpdateMosaic.$(ARCH).o \147 #$(SRC)/UpdateSimple.$(ARCH).o \148 #$(SRC)/write_coords.$(ARCH).o \149 #$(SRC)/FixProblemImages.$(ARCH).o \150 #$(SRC)/StarMaps.$(ARCH).o \151 152 141 $(RELASTRO_CLIENT): $(INC)/relastro.h 153 142 $(BIN)/relastro_client.$(ARCH): $(RELASTRO_CLIENT) -
branches/eam_branches/ipp-20140904/Ohana/src/relastro/include/relastro.h
r37677 r37684 489 489 int relastroGetVisual(void); 490 490 491 int FixProblemImages (SkyList *skylist);492 491 int *getCatlist (int *N, off_t im); 493 492 494 void initCoords (void); 495 void getOffsets (double *dPos, off_t *nPos, off_t N); 496 void saveOffsets (double dPos, off_t nPos, off_t N); 497 void setBadCoords (off_t N); 498 int badCoords (off_t N); 499 Coords *getCoords (off_t N); 500 int saveCoords (Coords *coords, off_t N); 501 void resetImageRaw (Catalog *catalog, int Ncatalog, off_t im); 493 void SaveCoords (Coords *tgt, Coords *src); 494 void RestoreCoords (Coords *tgt, Coords *src, Image *image); 502 495 503 496 int high_speed_catalogs (SkyTable *sky, SkyList *skylist, int hostID, char *hostpath); -
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/FitChip.c
r37681 r37684 14 14 15 15 for (Niter = 0; Niter < IMFIT_CLIP_NITER; Niter ++) { 16 16 17 17 // measure the scatter for the unmarked (good) measurements with dM < limit 18 18 // SIGMA_LIM here is redundant with ImageOps.c:915 … … 119 119 lockUpdateChips (); 120 120 AstromOffsetTable *table = get_astrom_table (); 121 AstromOffsetTableNewMap(table, order_use, image);121 AstromOffsetTableNewMap(table, order_use, order_use, image); 122 122 unlockUpdateChips (); 123 123 } 124 // XXX Need to check / update the order of the map here. if we already have a map, it might have been 125 // allocated with too small arrays 126 AstromOffsetMapSetOrder (image[0].coords.offsetMap, order_use, order_use, image); 127 image[0].coords.offsetMap->keep = TRUE; // if we are trying or re-trying this map, we should keep it unless it fails 124 128 fit_map (image[0].coords.offsetMap, raw, ref, Nmatch); 125 129 image[0].coords.Npolyterms = -1; … … 262 266 L,M -> X,Y (polynomial transformation : WRP) 263 267 264 Some details about this function:265 266 - the initial value of the clipping radius is set based on the distribution of the dR267 values for the bright sources.268 269 - NITER clipping passes are performed270 271 - the per-star astrometric errors are included in the fit. The photcode table controls272 whether only the reported positional errors are used, or if the magnitudes errors are273 scaled to determine the error, and if there is a systematic floor for all sources.274 275 - input detections are pre-filtered on the basis of the photFlags, etc, in bcatalog276 277 - outlying detections are clipped in the iterative passes, but the clipped detections are278 not recorded268 Some details about this function: 269 270 - the initial value of the clipping radius is set based on the distribution of the dR 271 values for the bright sources. 272 273 - NITER clipping passes are performed 274 275 - the per-star astrometric errors are included in the fit. The photcode table controls 276 whether only the reported positional errors are used, or if the magnitudes errors are 277 scaled to determine the error, and if there is a systematic floor for all sources. 278 279 - input detections are pre-filtered on the basis of the photFlags, etc, in bcatalog 280 281 - outlying detections are clipped in the iterative passes, but the clipped detections are 282 not recorded 279 283 280 284 */ … … 282 286 /* example using fit_apply() : 283 287 284 f = fopen ("test3.dat", "w");285 286 // apply new coords to raw (X,Y -> L,M)287 for (i = 0; i < Nmatch; i++) {288 fprintf (f, "%f %f %f %f ", raw[i].X, raw[i].Y, raw[i].L, raw[i].M);289 fit_apply (newfit, &L1, &M1, raw[i].X - coords[0].crpix1, raw[i].Y - coords[0].crpix2);290 fprintf (f, "%f %f\n", L1, M1);291 }292 fclose (f);288 f = fopen ("test3.dat", "w"); 289 290 // apply new coords to raw (X,Y -> L,M) 291 for (i = 0; i < Nmatch; i++) { 292 fprintf (f, "%f %f %f %f ", raw[i].X, raw[i].Y, raw[i].L, raw[i].M); 293 fit_apply (newfit, &L1, &M1, raw[i].X - coords[0].crpix1, raw[i].Y - coords[0].crpix2); 294 fprintf (f, "%f %f\n", L1, M1); 295 } 296 fclose (f); 293 297 */ 294 298 -
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/ImageOps.c
r37682 r37684 336 336 # endif 337 337 338 /*339 Coords *getCoords (off_t meas, int cat) {340 341 off_t i;342 343 i = MeasureToImage[cat][meas];344 if (i == -1) return (NULL);345 return (&image[i].coords);346 }347 */348 349 338 float getColorBlue (off_t meas, int cat) { 350 339 … … 434 423 Mosaic *mosaic; 435 424 Coords *moscoords, *imcoords; 436 437 // check if this image is bad and should be skipped438 if (badCoords(im)) return;439 425 440 426 // WRP images need to have an associated mosaic … … 598 584 int Noff = NoffRAave + NoffDECave + NoffRAori + NoffDECori; 599 585 if (VERBOSE2 && (Noff > 0)) fprintf (stderr, "Noff ave RA %d, Noff ave DEC %d, Noff ori RA %d, Noff ori DEC %d\n", NoffRAave, NoffDECave, NoffRAori, NoffDECori); 600 saveOffsets (dPos, nPos, im);601 586 602 587 return; … … 605 590 void printNcatTotal () { 606 591 fprintf (stderr, "NcatTotal: %d\n", NcatTotal); 607 }608 609 // return StarData values for detections in the specified image, converting coordinates from the610 // chip positions: X,Y -> L,M -> P,Q -> R,D611 void resetImageRaw (Catalog *catalog, int Ncatalog, off_t im) {612 613 off_t i, m, c, n;614 double X, Y, L, M, P, Q, R, D;615 616 Mosaic *mosaic;617 Coords *moscoords, *imcoords, *oldcoords;618 619 fprintf (stderr, "fix resetImageRaw wrt MeasureTiny\n");620 abort();621 622 // check if this image is bad and should be skipped623 if (!badCoords(im)) {624 fprintf (stderr, "ERROR: inconsistent result?");625 abort();626 }627 628 // replace the current coords with the old coords:629 oldcoords = getCoords (im);630 memcpy (&image[im].coords, oldcoords, sizeof(Coords));631 632 // WRP images need to have an associated mosaic633 moscoords = NULL;634 if (!strcmp(&image[im].coords.ctype[4], "-WRP")) {635 mosaic = getMosaicForImage (im);636 if (mosaic == NULL) return; // if we cannot find the associated image, skip it637 moscoords = &mosaic[0].coords;638 }639 imcoords = &image[im].coords;640 641 for (i = 0; i < N_onImage[im]; i++) {642 m = ImageToMeasure[im][i];643 c = ImageToCatalog[im][i];644 645 // XXX unclear if this should use Measure or MeasureTiny; it is only called by FixProblemImages, which has not been updated646 Measure *measure = &catalog[c].measure[m];647 648 X = measure[0].Xccd;649 Y = measure[0].Yccd;650 if (USE_FIXED_PIXCOORDS) {651 if (isfinite(measure[0].Xfix) && isfinite(measure[0].Yfix)) {652 float dX = measure[0].Xfix - measure[0].Xccd;653 float dY = measure[0].Yfix - measure[0].Yccd;654 if (hypot(dX,dY) < 2.0) {655 X = measure[0].Xfix;656 Y = measure[0].Yfix;657 }658 }659 }660 n = measure[0].averef;661 662 if (moscoords == NULL) {663 // this is a Simple image (not a mosaic)664 // note that for a Simple image, L,M = P,Q665 XY_to_LM (&L, &M, X, Y, imcoords);666 LM_to_RD (&R, &D, L, M, imcoords);667 } else {668 XY_to_LM (&L, &M, X, Y, imcoords);669 XY_to_LM (&P, &Q, L, M, moscoords);670 LM_to_RD (&R, &D, P, Q, moscoords);671 }672 measure[0].R = R;673 measure[0].D = D;674 675 float dRoff = dvoOffsetR(measure, &catalog[c].average[n]);676 677 if (dRoff > +180.0*3600.0) {678 // average on high end of boundary, move star up679 measure[0].R += 360.0;680 dRoff -= 360.0*3600.0;681 }682 if (dRoff < -180.0*3600.0) {683 measure[0].R -= 360.0;684 dRoff += 360.0*3600.0;685 }686 }687 688 return;689 592 } 690 593 -
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateChips.c
r37677 r37684 36 36 off_t i, Nraw, Nref, nFitAstr; 37 37 StarData *raw, *ref; 38 Coords *oldCoords;39 38 float dXpixSys, dYpixSys; 40 39 double *Ro, *Do; … … 96 95 97 96 // save these in case of failure 98 saveCoords (&image[i].coords, i); 97 Coords oldCoords; 98 SaveCoords (&oldCoords, &image[i].coords); 99 99 100 dXpixSys = image[i].dXpixSys; 100 101 dYpixSys = image[i].dYpixSys; … … 106 107 if (VERBOSE) fprintf (stderr, "reject fit for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT" of %d\n", image[i].name, i, Nraw, image[i].nstar); 107 108 108 // restore status quo ante 109 oldCoords = getCoords (i); 110 memcpy (&image[i].coords, oldCoords, sizeof(Coords)); 109 // restore status quo ante (replace truMap with tmpMap) 110 RestoreCoords (&image[i].coords, &oldCoords, &image[i]); 111 111 image[i].dXpixSys = dXpixSys; 112 112 image[i].dYpixSys = dYpixSys; … … 123 123 if (!checkStarMap (i)) { 124 124 if (VERBOSE) fprintf (stderr, "fit diverges too much for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT"\n", image[i].name, i, Nraw); 125 // restore status quo ante 126 oldCoords = getCoords (i);127 memcpy (&image[i].coords, oldCoords, sizeof(Coords));125 126 // restore status quo ante (replace truMap with tmpMap) 127 RestoreCoords (&image[i].coords, &oldCoords, &image[i]); 128 128 image[i].dXpixSys = dXpixSys; 129 129 image[i].dYpixSys = dYpixSys; … … 139 139 } 140 140 141 // apply the modified R,D back to the measures 141 // Apply the modified coords back to the measure.R,D. Note that raw.R,D, ref.L,M, etc 142 // are all automatically updated in this block because they are re-generated from 143 // image.coords on each pass. 142 144 setImageRaw (catalog, Ncatalog, i, raw, Nraw, MODE_MOSAIC); 143 145 if (USE_GALAXY_MODEL) { … … 247 249 off_t Nraw, Nref, nFitAstr; 248 250 StarData *raw, *ref; 249 Coords *oldCoords;250 251 float dXpixSys, dYpixSys; 251 252 … … 294 295 295 296 // save these in case of failure 296 saveCoords (&image[i].coords, i); 297 Coords oldCoords; 298 SaveCoords (&oldCoords, &image[i].coords); 297 299 dXpixSys = image[i].dXpixSys; 298 300 dYpixSys = image[i].dYpixSys; … … 304 306 if (VERBOSE) fprintf (stderr, "reject fit for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT" of %d\n", image[i].name, i, Nraw, image[i].nstar); 305 307 306 // restore status quo ante 307 oldCoords = getCoords (i); 308 memcpy (&image[i].coords, oldCoords, sizeof(Coords)); 308 // restore status quo ante (replace truMap with tmpMap) 309 RestoreCoords (&image[i].coords, &oldCoords, &image[i]); 309 310 image[i].dXpixSys = dXpixSys; 310 311 image[i].dYpixSys = dYpixSys; … … 321 322 if (!checkStarMap (i)) { 322 323 if (VERBOSE) fprintf (stderr, "fit diverges too much for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT"\n", image[i].name, i, Nraw); 323 // restore status quo ante 324 oldCoords = getCoords (i);325 memcpy (&image[i].coords, oldCoords, sizeof(Coords));324 325 // restore status quo ante (replace truMap with tmpMap) 326 RestoreCoords (&image[i].coords, &oldCoords, &image[i]); 326 327 image[i].dXpixSys = dXpixSys; 327 328 image[i].dYpixSys = dYpixSys; … … 522 523 } 523 524 525 // save the coords and offset map in src at tgt 526 void SaveCoords (Coords *tgt, Coords *src) { 527 myAssert (tgt, "oops"); 528 myAssert (src, "oops"); 529 CopyCoords (tgt, src); // src retains a pointer to the AstromOffsetMap table, to be saved 530 tgt->offsetMap = AstromOffsetMapCopy(src->offsetMap); // oldCoords now saves the old values in a new structure 531 } 532 533 // restore the coords and offset map at tgt from src 534 void RestoreCoords (Coords *tgt, Coords *src, Image *image) { 535 536 AstromOffsetMap *truMap = tgt->offsetMap; 537 AstromOffsetMap *tmpMap = src->offsetMap; 538 539 // copy the coords structure data first, then fix the offsetMap pointers 540 CopyCoords (tgt, src); 541 542 // we want to keep the old solution, which is (maybe) a pointer to a stand-alone 543 // map. the image has a bad solution, but it is a pointer to the map in the I/O 544 // table. those values will be saved on exit. 545 546 if (!tmpMap && !truMap) return; 547 548 if (tmpMap && truMap) { 549 AstromOffsetMapSetOrder (truMap, tmpMap->Nx, tmpMap->Ny, image); 550 AstromOffsetMapCopyData (truMap, tmpMap); 551 return; 552 } 553 554 if (tmpMap && !truMap) { 555 // is this even possible? 556 lockUpdateChips (); 557 AstromOffsetTable *table = get_astrom_table (); 558 AstromOffsetTableNewMap(table, tmpMap->Nx, tmpMap->Ny, image); // registers the map with the image 559 unlockUpdateChips (); 560 AstromOffsetMapCopyData (truMap, tmpMap); 561 return; 562 } 563 if (!tmpMap && truMap) { 564 truMap->keep = FALSE; 565 return; 566 } 567 myAbort ("oops"); 568 } -
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_images.c
r37658 r37684 23 23 MARKTIME("load images: %f sec\n", dtime); 24 24 25 initCoords();26 27 25 /* load catalog data from region files : subselect high-quality measurements */ 28 // XXX pass in the image table29 // XXX who carries the image grid?30 26 31 27 // photcodesKeep is used here to allow measurements from the images being calibrated … … 119 115 UpdateObjectOffsets (skylist, 0, NULL); 120 116 121 // iterate over catalogs to make detection coordinates consistant122 // FixProblemImages (skylist);123 124 117 if (!PARALLEL) { 125 118 // save the updated image parameters -
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_parallel_images.c
r37665 r37684 56 56 SkyTableSetFilenames (sky, CATDIR, "cpt"); 57 57 SkyList *skylist = SkyListByBounds (sky, -1, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 58 59 initCoords();60 58 61 59 /* load catalog data from region files (hostID is 0 since we are not a client */
Note:
See TracChangeset
for help on using the changeset viewer.
