Changeset 25433
- Timestamp:
- Sep 17, 2009, 2:26:32 PM (17 years ago)
- Location:
- branches/eam_branches/20090715/psphot/src
- Files:
-
- 22 edited
-
Makefile.am (modified) (1 diff)
-
pmPetrosian.h (modified) (1 diff)
-
psphot.h (modified) (1 diff)
-
psphotBlendFit.c (modified) (1 diff)
-
psphotEfficiency.c (modified) (1 diff)
-
psphotEllipticalContour.c (modified) (6 diffs)
-
psphotEllipticalProfile.c (modified) (2 diffs)
-
psphotFitSourcesLinear.c (modified) (1 diff)
-
psphotImageQuality.c (modified) (1 diff)
-
psphotPSFConvModel.c (modified) (1 diff)
-
psphotPetrosianAnalysis.c (modified) (3 diffs)
-
psphotPetrosianProfile.c (modified) (1 diff)
-
psphotPetrosianRadialBins.c (modified) (5 diffs)
-
psphotPetrosianStats.c (modified) (3 diffs)
-
psphotPetrosianStudy.c (modified) (1 diff)
-
psphotPetrosianVisual.c (modified) (3 diffs)
-
psphotRadialProfileByAngle.c (modified) (4 diffs)
-
psphotRadiiFromProfiles.c (modified) (6 diffs)
-
psphotRadiusChecks.c (modified) (1 diff)
-
psphotSourceFits.c (modified) (9 diffs)
-
psphotSourceSize.c (modified) (3 diffs)
-
psphotVisual.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090715/psphot/src/Makefile.am
r25409 r25433 147 147 psphotPetrosianStats.c \ 148 148 psphotPetrosianAnalysis.c \ 149 pmPetrosian.c 149 pmPetrosian.c \ 150 150 psphotEfficiency.c 151 151 -
branches/eam_branches/20090715/psphot/src/pmPetrosian.h
r25275 r25433 35 35 bool psphotPetrosianFreeVectors(pmPetrosian *petrosian); 36 36 37 bool psphotPetrosianProfile (pm Source *source, float skynoise);38 bool psphotRadialProfilesByAngles (pm Petrosian *petro, pmSource *source, int Nsec, float Rmax);39 float psphotRadiusFromProfile (p sVector *radius, psVector *flux, float fluxMin, float fluxMax);40 bool psphotRadiiFromProfiles (pm Petrosian *petrosian, float fluxMin, float fluxMax);37 bool psphotPetrosianProfile (pmReadout *readout, pmSource *source, float skynoise); 38 bool psphotRadialProfilesByAngles (pmSource *source, pmPetrosian *petro, int Nsec, float Rmax); 39 float psphotRadiusFromProfile (pmSource *source, psVector *radius, psVector *flux, float fluxMin, float fluxMax); 40 bool psphotRadiiFromProfiles (pmSource *source, pmPetrosian *petrosian, float fluxMin, float fluxMax); 41 41 bool psphotEllipticalProfile (pmSource *source, pmPetrosian *petrosian); 42 bool psphotEllipticalContour (pm Petrosian *petrosian);42 bool psphotEllipticalContour (pmSource *source, pmPetrosian *petrosian); 43 43 bool psphotPetrosianRadialBins (pmSource *source, pmPetrosian *petrosian, float radiusMax, float skynoise); 44 bool psphotPetrosianStats (pm Petrosian *petrosian);44 bool psphotPetrosianStats (pmSource *source, pmPetrosian *petrosian); 45 45 46 46 bool psphotPetrosianSortPair (psVector *index, psVector *extra); -
branches/eam_branches/20090715/psphot/src/psphot.h
r25409 r25433 110 110 bool psphotInitRadiusEXT (psMetadata *recipe, pmModelType type); 111 111 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal); 112 float psphotSetRadiusEXT (pmReadout *readout, pmSource *source, psImageMaskType markVal); 112 113 113 114 // output functions -
branches/eam_branches/20090715/psphot/src/psphotBlendFit.c
r24029 r25433 374 374 *nfail = Nfail; 375 375 376 // moments are modified by the fit; re-display 377 psphotVisualPlotMoments (recipe, sources); 378 psphotVisualShowResidualImage (readout); 379 376 380 return true; 377 381 } -
branches/eam_branches/20090715/psphot/src/psphotEfficiency.c
r25409 r25433 134 134 psFree(fakeRO); 135 135 psFree(magAll); 136 psFree(xAll); 137 psFree(yAll); 136 138 return false; 137 139 } 138 140 psFree(magAll); 141 psFree(xAll); 142 psFree(yAll); 139 143 140 144 psBinaryOp(ro->image, ro->image, "+", fakeRO->image); -
branches/eam_branches/20090715/psphot/src/psphotEllipticalContour.c
r25178 r25433 1 1 # include "psphotInternal.h" 2 3 // XXX consistency : theta in radians here and in calling functions4 2 5 3 // model parameters … … 7 5 psF32 psphotEllipticalContourFunc (psVector *deriv, const psVector *params, const psVector *coord); 8 6 9 bool psphotEllipticalContour (pm Petrosian *petrosian) {7 bool psphotEllipticalContour (pmSource *source, pmPetrosian *petrosian) { 10 8 11 9 // use LMM to fit theta vs radius to an ellipse … … 19 17 // arrays to hold the data to be fitted 20 18 // we fit x and y vs theta in separate passes. 21 psArray *x = psArrayAlloc (2*radius->n);22 psVector *y = psVectorAlloc (2*radius->n, PS_TYPE_F32);23 psVector *yErr = psVectorAlloc (2*radius->n, PS_TYPE_F32);19 psArray *x = psArrayAllocEmpty(2*radius->n); 20 psVector *y = psVectorAllocEmpty(2*radius->n, PS_TYPE_F32); 21 psVector *yErr = psVectorAllocEmpty(2*radius->n, PS_TYPE_F32); 24 22 25 23 int n = 0; 26 24 for (int i = 0; i < radius->n; i++) { 25 if (!isfinite(radius->data.F32[i])) continue; 27 26 28 27 psVector *coord = NULL; … … 50 49 Rmax = MAX (Rmax, radius->data.F32[i]); 51 50 } 52 assert (x->n == n); 53 assert (y->n == n); 51 x->n = n; 52 y->n = n; 53 yErr->n = n; 54 55 if (n < 4) { 56 psFree (x); 57 psFree (y); 58 psFree (yErr); 59 return false; 60 } 54 61 55 62 psVector *params = psVectorAlloc (3, PS_TYPE_F32); … … 61 68 62 69 // XXX for now, no parameter masks, skip checkLimits 70 // XXX might help to add a limit to the angle or re-parameterize the ellipse in terms of Rxx, Ryy, Rxy 63 71 // constraint->checkLimits = psastroModelBoresiteLimits; 64 72 … … 84 92 } 85 93 86 fprintf (stderr, "# fitted values:\n");87 fprintf (stderr, "Po: %f\n", params->data.F32[PAR_PHI]*PS_DEG_RAD);88 fprintf (stderr, "Ep: %f\n", params->data.F32[PAR_EPSILON]);89 fprintf (stderr, "Rm: %f\n", params->data.F32[PAR_RMIN]);90 94 psTrace ("psphot", 4, "# fitted values:\n"); 95 psTrace ("psphot", 4, "Phi: %f\n", petrosian->axes.theta*PS_DEG_RAD); 96 psTrace ("psphot", 4, "Rmaj: %f\n", petrosian->axes.major); 97 psTrace ("psphot", 4, "Rmin: %f\n", petrosian->axes.minor); 98 91 99 // show the results 92 psphotPetrosianVisualEllipticalContour (petrosian);100 // psphotPetrosianVisualEllipticalContour (petrosian); 93 101 94 102 psFree (x); 95 103 psFree (y); 96 104 psFree (yErr); 105 psFree (params); 106 psFree (covar); 107 psFree (myMin); 108 psFree (constraint); 97 109 98 110 return true; -
branches/eam_branches/20090715/psphot/src/psphotEllipticalProfile.c
r25363 r25433 32 32 float Syy = shape.sy; 33 33 34 // XXX drop these two vectors? 34 35 psVector *radiusRaw = psVectorAllocEmpty(100, PS_TYPE_F32); 35 36 psVector *fluxRaw = psVectorAllocEmpty(100, PS_TYPE_F32); … … 65 66 66 67 // psphotPetrosianVisualProfileRadii (radius, flux, radiusRaw, fluxRaw, 0.0); 67 psphotPetrosianVisualProfileByAngle (radius, flux); 68 // psphotPetrosianVisualProfileByAngle (radius, flux); 69 70 psFree (radiusRaw); 71 psFree (fluxRaw); 68 72 return true; 69 73 } -
branches/eam_branches/20090715/psphot/src/psphotFitSourcesLinear.c
r25409 r25433 239 239 240 240 psphotVisualShowResidualImage (readout); 241 psphotVisualShowFlags (sources);241 // psphotVisualShowFlags (sources); 242 242 243 243 return true; -
branches/eam_branches/20090715/psphot/src/psphotImageQuality.c
r23989 r25433 279 279 #endif 280 280 281 psLogMsg ("psphot", PS_LOG_INFO, "Image Quality Stats from %ld psf stars : FWHM (major, minor) : %f, %f\n",281 psLogMsg ("psphot", PS_LOG_INFO, "Image Quality Stats from %ld psf stars : FWHM (major, minor) [pixels]: %f, %f\n", 282 282 M2->n, fwhm_major, fwhm_minor); 283 283 284 psLogMsg ("psphot", PS_LOG_INFO, "M_2 : %f +/- %f, M_3 : %f +/- %f, M_4 : %f +/- %f \n",284 psLogMsg ("psphot", PS_LOG_INFO, "M_2 : %f +/- %f, M_3 : %f +/- %f, M_4 : %f +/- %f [pixels^n]\n", 285 285 vM2, dM2, vM3, dM3, vM4, dM4); 286 286 -
branches/eam_branches/20090715/psphot/src/psphotPSFConvModel.c
r21183 r25433 68 68 psVector *dparams = modelConv->dparams; 69 69 70 // XXX this needs to be changed to use the new psphotSetRadiusEXT function 70 71 psphotCheckRadiusEXT (readout, source, modelConv, markVal); 71 72 -
branches/eam_branches/20090715/psphot/src/psphotPetrosianAnalysis.c
r25275 r25433 12 12 // XXX temporary user-supplied systematic sky noise measurement (derive from background model) 13 13 float skynoise = psMetadataLookupF32 (&status, recipe, "SKY.NOISE"); 14 15 # if (0) 16 // if backModel or backStdev are missing, the values of sky and/or skyErr will be set to NAN 17 // XXX use this to set skynoise 18 pmReadout *backModel = psphotSelectBackground (config, view); 19 pmReadout *backStdev = psphotSelectBackgroundStdev (config, view); 20 # endif 14 21 15 22 // S/N limit to perform full non-linear fits … … 33 40 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 34 41 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 42 if (source->mode & PM_SOURCE_MODE_DEFECT) continue; 43 if (source->mode & PM_SOURCE_MODE_SATSTAR) continue; 44 if (!(source->mode & PM_SOURCE_MODE_EXT_LIMIT)) continue; 35 45 36 46 // limit selection to some SN limit 37 47 assert (source->peak); // how can a source not have a peak? 38 48 if (source->peak->SN < SN_LIM) continue; 39 if (source->extNsigma < 10.0) continue; // XXX this should not be hardwired40 49 41 50 // limit selection by analysis region … … 50 59 } 51 60 52 psphotPetrosianProfile (source, skynoise); 61 psphotPetrosianProfile (readout, source, skynoise); 62 63 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 64 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 53 65 } 66 67 psphotVisualShowResidualImage (readout); 54 68 55 69 // pause and wait for user input: -
branches/eam_branches/20090715/psphot/src/psphotPetrosianProfile.c
r25275 r25433 7 7 // structure to something the pmRadialProfile 8 8 9 bool psphotPetrosianProfile (pm Source *source, float skynoise) {9 bool psphotPetrosianProfile (pmReadout *readout, pmSource *source, float skynoise) { 10 10 11 // container to hold results from the radial profile analysis12 pmPetrosian *petrosian = pmPetrosianAlloc();11 // container to hold results from the radial profile analysis 12 pmPetrosian *petrosian = pmPetrosianAlloc(); 13 13 14 int Nsec = 24;15 float Rmax = 200;16 float fluxMin = 0.0;17 float fluxMax = source->peak->flux;14 int Nsec = 24; 15 float Rmax = 200; 16 float fluxMin = 0.0; 17 float fluxMax = source->peak->flux; 18 18 19 // generate a series of radial profiles at Nsec evenly spaced angles. the profile flux 20 // is measured by interpolation for small radii; for large radii, the pixels in a box 21 // are averaged to increase the S/N (XXX not yet done) 22 if (!psphotRadialProfilesByAngles (petrosian, source, Nsec, Rmax)) { 23 psError (PS_ERR_UNKNOWN, false, "failed to measure radial profile for petrosian"); 24 return false; 25 } 19 // generate a series of radial profiles at Nsec evenly spaced angles. the profile flux 20 // is measured by interpolation for small radii; for large radii, the pixels in a box 21 // are averaged to increase the S/N (XXX not yet done) 22 if (!psphotRadialProfilesByAngles (source, petrosian, Nsec, Rmax)) { 23 psError (PS_ERR_UNKNOWN, false, "failed to measure radial profile for petrosian"); 24 psFree (petrosian); 25 return false; 26 } 26 27 27 // use the radial profiles to determine the radius of a given isophote. this isophote 28 // is used to determine the elliptical shape of the object, so it has a relatively high 29 // value (nominally 50% of the peak) 30 if (!psphotRadiiFromProfiles (petrosian, fluxMin, fluxMax)) { 31 psError (PS_ERR_UNKNOWN, false, "failed to measure isophotal radii from profiles"); 32 return false; 33 } 28 // use the radial profiles to determine the radius of a given isophote. this isophote 29 // is used to determine the elliptical shape of the object, so it has a relatively high 30 // value (nominally 50% of the peak) 31 if (!psphotRadiiFromProfiles (source, petrosian, fluxMin, fluxMax)) { 32 psError (PS_ERR_UNKNOWN, false, "failed to measure isophotal radii from profiles"); 33 psFree (petrosian); 34 return false; 35 } 34 36 35 // convert the isophotal radius vs angle measurements to an elliptical contour 36 if (!psphotEllipticalContour (petrosian)) { 37 psError (PS_ERR_UNKNOWN, false, "failed to measure elliptical contour"); 38 return false; 39 } 37 // convert the isophotal radius vs angle measurements to an elliptical contour 38 if (!psphotEllipticalContour (source, petrosian)) { 39 psLogMsg ("psphot", 3, "failed to measure elliptical contour"); 40 psFree (petrosian); 41 return false; 42 } 40 43 41 // generate a single, normalized radial profile following the elliptical contours. 42 // the radius is normalized by the axis ratio so that on the major axis, 1 pixel = 1 pixel 43 if (!psphotEllipticalProfile (source, petrosian)) { 44 psError (PS_ERR_UNKNOWN, false, "failed to generate elliptical profile"); 45 return false; 46 } 44 // generate a single, normalized radial profile following the elliptical contours. 45 // the radius is normalized by the axis ratio so that on the major axis, 1 pixel = 1 pixel 46 if (!psphotEllipticalProfile (source, petrosian)) { 47 psError (PS_ERR_UNKNOWN, false, "failed to generate elliptical profile"); 48 psFree (petrosian); 49 return false; 50 } 47 51 48 // integrate the radial profile for radial bins defined for the petrosian measurement: 49 // SB_i (r_i) where \alpha r_i < r < \beta r_i 50 if (!psphotPetrosianRadialBins (source, petrosian, Rmax, skynoise)) { 51 psError (PS_ERR_UNKNOWN, false, "failed to generate elliptical profile"); 52 return false; 53 } 52 // integrate the radial profile for radial bins defined for the petrosian measurement: 53 // SB_i (r_i) where \alpha r_i < r < \beta r_i 54 if (!psphotPetrosianRadialBins (source, petrosian, Rmax, skynoise)) { 55 psError (PS_ERR_UNKNOWN, false, "failed to generate elliptical profile"); 56 psFree (petrosian); 57 return false; 58 } 54 59 55 // use the SB_i from above to calculate the petrosian radius and the flux within that radius 56 if (!psphotPetrosianStats (petrosian)) { 57 psError (PS_ERR_UNKNOWN, false, "failed to generate elliptical profile"); 58 return false; 59 } 60 // use the SB_i from above to calculate the petrosian radius and the flux within that radius 61 if (!psphotPetrosianStats (source, petrosian)) { 62 psError (PS_ERR_UNKNOWN, false, "failed to generate elliptical profile"); 63 psFree (petrosian); 64 return false; 65 } 60 66 61 // XXX this will only work in the psphot context, not the psphotPetrosianStudy... 62 // XXX add the petrosian to the pmSource structure... 63 psphotVisualShowPetrosian (source, petrosian); 67 // XXX this will only work in the psphot context, not the psphotPetrosianStudy... 68 // XXX add the petrosian to the pmSource structure... 69 // psphotVisualShowResidualImage (readout); 70 psphotVisualShowPetrosian (source, petrosian); 64 71 65 psphotPetrosianFreeVectors(petrosian);72 psphotPetrosianFreeVectors(petrosian); 66 73 67 fprintf (stdout, "\n petrosian radius: %f\n flux: %f\n axis ratio: %f\n angle: %f\n",68 petrosian->petrosianRadius, petrosian->petrosianFlux, petrosian->axes.minor/petrosian->axes.major, PS_DEG_RAD*petrosian->axes.theta);74 psTrace ("psphot", 3, "source at %f,%f: petrosian radius: %f, flux: %f, axis ratio: %f, angle: %f", 75 source->peak->xf, source->peak->yf, petrosian->petrosianRadius, petrosian->petrosianFlux, petrosian->axes.minor/petrosian->axes.major, PS_DEG_RAD*petrosian->axes.theta); 69 76 70 return true; 77 psFree (petrosian); 78 return true; 71 79 } -
branches/eam_branches/20090715/psphot/src/psphotPetrosianRadialBins.c
r25275 r25433 18 18 19 19 float skyModelErrorSQ = PS_SQR(skynoise); 20 21 # if (0)22 // if backModel or backStdev are missing, the values of sky and/or skyErr will be set to NAN23 pmReadout *backModel = psphotSelectBackground (config, view);24 pmReadout *backStdev = psphotSelectBackgroundStdev (config, view);25 # endif26 20 27 21 psVector *radius = petrosian->radiusElliptical; … … 104 98 binArea->data.F32[i] = M_PI * (rMax2 - rMin2); 105 99 106 if (0) { 107 fprintf (stderr, "%3d %5.1f %5.1f : %5.1f : %5.1f %5.1f\n", 100 psTrace ("psphot", 6, "%3d %5.1f %5.1f : %5.1f : %5.1f %5.1f\n", 108 101 i, radAlp->data.F32[i], radMin->data.F32[i], binRad->data.F32[i], 109 102 radMax->data.F32[i], radBet->data.F32[i]); 110 }111 103 } 112 104 … … 131 123 if (radius->data.F32[i] > Rmax) { 132 124 // calculate the value for the nOut bin 133 psVectorStats (stats, values, NULL, NULL, 0); 125 float value, dvalue; 126 if (values->n > 0) { 127 psVectorStats (stats, values, NULL, NULL, 0); 128 value = stats->robustMedian; 129 dvalue = stats->robustStdev; 130 } else { 131 value = NAN; 132 dvalue = NAN; 133 } 134 134 // binSB->data.F32[nOut] = stats->sampleMedian; 135 binSB->data.F32[nOut] = stats->robustMedian;136 binSBstdev->data.F32[nOut] = sqrt(PS_SQR( stats->robustStdev) / values->n + skyModelErrorSQ);135 binSB->data.F32[nOut] = value; 136 binSBstdev->data.F32[nOut] = sqrt(PS_SQR(dvalue) / values->n + skyModelErrorSQ); 137 137 // binSB->data.F32[nOut] = stats->fittedMean; 138 138 // binSBstdev->data.F32[nOut] = sqrt(PS_SQR(stats->fittedStdev) / values->n + skyModelErrorSQ); … … 142 142 // residual flux, but the sky from the sky model) 143 143 144 if (1) { 145 fprintf (stderr, "%3d %5.1f %5.1f : %5.1f %5.2f\n", 146 nOut, radAlp->data.F32[nOut], radBet->data.F32[nOut], binSB->data.F32[nOut], binSBstdev->data.F32[nOut]); 147 } 144 psTrace ("psphot", 5, "%3d %5.1f %5.1f : %5.1f %5.2f\n", 145 nOut, radAlp->data.F32[nOut], radBet->data.F32[nOut], binSB->data.F32[nOut], binSBstdev->data.F32[nOut]); 148 146 149 147 nOut ++; … … 170 168 petrosian->binSBstdev = binSBstdev; 171 169 172 psphotPetrosianVisualProfileRadii (radius, flux, binRad, binSB, source->peak->flux, 0.0);170 // psphotPetrosianVisualProfileRadii (radius, flux, binRad, binSB, source->peak->flux, 0.0); 173 171 174 172 psFree(radMin); -
branches/eam_branches/20090715/psphot/src/psphotPetrosianStats.c
r25275 r25433 8 8 float InterpolateValues (float X0, float Y0, float X1, float Y1, float X); 9 9 10 bool psphotPetrosianStats (pm Petrosian *petrosian) {10 bool psphotPetrosianStats (pmSource *source, pmPetrosian *petrosian) { 11 11 12 12 float petRadius, petFlux; … … 77 77 psVectorAppend(refRadius, binRad->data.F32[i]); 78 78 79 if (1) { 80 fprintf (stderr, "%3d : %5.2f : %5.3f %5.3f : %5.3f %5.3f : %5.3f %5.3f : %5.3f %5.3f : %5.1f %5.1f\n", 81 i, refRadius->data.F32[nOut], 82 binSB->data.F32[i], binSBstdev->data.F32[i], 83 meanSB->data.F32[nOut], meanSBerr, 84 petRatio->data.F32[nOut], petRatioErr->data.F32[nOut], 85 fluxSum->data.F32[nOut], sqrt(fluxSumErr2->data.F32[nOut]), areaSum->data.F32[nOut], areaInner); 86 } 79 psTrace ("psphot", 4, "%3d : %5.2f : %5.3f %5.3f : %5.3f %5.3f : %5.3f %5.3f : %5.3f %5.3f : %5.1f %5.1f\n", 80 i, refRadius->data.F32[nOut], 81 binSB->data.F32[i], binSBstdev->data.F32[i], 82 meanSB->data.F32[nOut], meanSBerr, 83 petRatio->data.F32[nOut], petRatioErr->data.F32[nOut], 84 fluxSum->data.F32[nOut], sqrt(fluxSumErr2->data.F32[nOut]), areaSum->data.F32[nOut], areaInner); 87 85 88 86 // anytime we transition below the PETROSIAN_RATIO, calculate the radius and flux … … 149 147 150 148 psFree(fluxSum); 149 psFree(fluxSumErr2); 150 psFree(refRadius); 151 151 psFree(petRatio); 152 psFree(petRatioErr); 152 153 psFree(meanSB); 153 154 psFree(areaSum); -
branches/eam_branches/20090715/psphot/src/psphotPetrosianStudy.c
r25275 r25433 136 136 } 137 137 138 psphotPetrosianProfile ( source, skynoise);138 psphotPetrosianProfile (readout, source, skynoise); 139 139 140 140 psFree (source); -
branches/eam_branches/20090715/psphot/src/psphotPetrosianVisual.c
r25275 r25433 19 19 20 20 static int kapa = -1; 21 static int kapa2 = -1; 21 22 22 23 // if no valid data is supplied (NULL or n <- 0), leave limits as they were … … 53 54 54 55 // return true; 55 if (!pmVisualIsVisual()) return true;56 57 if (kapa == -1) {58 kapa = KapaOpenNamedSocket ("kapa", "psphot:plots");59 if (kapa == -1) {56 // if (!pmVisualIsVisual()) return true; 57 58 if (kapa2 == -1) { 59 kapa2 = KapaOpenNamedSocket ("kapa", "psphot:plots"); 60 if (kapa2 == -1) { 60 61 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 61 62 pmVisualSetVisual(false); … … 64 65 } 65 66 66 KapaClearPlots (kapa );67 KapaClearPlots (kapa2); 67 68 KapaInitGraph (&graphdata); 68 KapaSetFont (kapa , "courier", 14);69 KapaSetFont (kapa2, "courier", 14); 69 70 70 71 pmVisualLimitsFromVectors (&graphdata, radius, flux); 71 KapaSetLimits (kapa , &graphdata);72 73 KapaBox (kapa , &graphdata);74 KapaSendLabel (kapa , "radius", KAPA_LABEL_XM);75 KapaSendLabel (kapa , "flux", KAPA_LABEL_YM);76 77 graphdata.color = KapaColorByName ("black"); 78 graphdata.style = 2; 79 graphdata.ptype = 0; 80 graphdata.size = 1.0; 81 KapaPrepPlot (kapa , radius->n, &graphdata);82 KapaPlotVector (kapa , radius->n, radius->data.F32, "x");83 KapaPlotVector (kapa , radius->n, flux->data.F32, "y");72 KapaSetLimits (kapa2, &graphdata); 73 74 KapaBox (kapa2, &graphdata); 75 KapaSendLabel (kapa2, "radius", KAPA_LABEL_XM); 76 KapaSendLabel (kapa2, "flux", KAPA_LABEL_YM); 77 78 graphdata.color = KapaColorByName ("black"); 79 graphdata.style = 2; 80 graphdata.ptype = 0; 81 graphdata.size = 1.0; 82 KapaPrepPlot (kapa2, radius->n, &graphdata); 83 KapaPlotVector (kapa2, radius->n, radius->data.F32, "x"); 84 KapaPlotVector (kapa2, radius->n, flux->data.F32, "y"); 84 85 85 86 // pause and wait for user input: -
branches/eam_branches/20090715/psphot/src/psphotRadialProfileByAngle.c
r25361 r25433 1 1 # include "psphotInternal.h" 2 2 3 // Given a source at (x,y), generate a collection of radial profiles at even angular 4 // separations 5 3 // Given a source at (x,y), generate a collection of radial profiles at even angular separations 4 5 // These functions are used to calculate the stats in a rectangle at arbitrary orientation. 6 // XXX Move these elsewhere (psLib?) 6 7 float psphotMeanSectorValue (psImage *image, float x, float y, float dL, float dW, float theta); 7 8 psVector *psphotBoxValues (psImage *image, float x0, float y0, float dL, float dW, float theta); … … 9 10 psVector *psphotLineValuesBresen (psImage *image, int X1, int Y1, int X2, int Y2, int dW, int swapcoords); 10 11 11 bool psphotRadialProfilesByAngles (pm Petrosian *petrosian, pmSource *source, int Nsec, float Rmax) {12 bool psphotRadialProfilesByAngles (pmSource *source, pmPetrosian *petrosian, int Nsec, float Rmax) { 12 13 13 14 // we want to have an even number of sectors so we can do 180 deg symmetrizing … … 124 125 125 126 psVector *values = psphotBoxValues (image, x, y, dL, dW, theta); 127 if (!values) goto escape; 128 if (!values->n) goto escape; 126 129 127 130 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); … … 134 137 135 138 return value; 139 140 escape: 141 psFree(values); 142 return NAN; 136 143 } 137 144 -
branches/eam_branches/20090715/psphot/src/psphotRadiiFromProfiles.c
r25275 r25433 3 3 // Given the Petrosian data (radii, fluxes) determine the radius for each profile at the desisred isophote 4 4 5 bool psphotRadiiFromProfiles (pm Petrosian *petrosian, float fluxMin, float fluxMax) {5 bool psphotRadiiFromProfiles (pmSource *source, pmPetrosian *petrosian, float fluxMin, float fluxMax) { 6 6 7 7 petrosian->isophotalRadii = psVectorAlloc(petrosian->theta->n, PS_TYPE_F32); … … 10 10 psVector *radii = petrosian->radii->data[i]; 11 11 psVector *fluxes = petrosian->fluxes->data[i]; 12 float radius = psphotRadiusFromProfile ( radii, fluxes, fluxMin, fluxMax);12 float radius = psphotRadiusFromProfile (source, radii, fluxes, fluxMin, fluxMax); 13 13 14 14 // psphotPetrosianVisualProfileByAngle (radii, fluxes, radius); … … 20 20 } 21 21 22 float psphotRadiusFromProfile (p sVector *radius, psVector *flux, float fluxMin, float fluxMax) {22 float psphotRadiusFromProfile (pmSource *source, psVector *radius, psVector *flux, float fluxMin, float fluxMax) { 23 23 24 24 // 'flux' is a noisy sample of the galaxy radial profile at points 'radius' … … 49 49 psVectorAppend (values, radius->data.F32[i]); 50 50 } 51 psVectorStats (stats, values, NULL, NULL, 0); 51 if (values->n > 1) { 52 psVectorStats (stats, values, NULL, NULL, 0); 52 53 53 // if we have a valid range, rebin with bin size 1/2 of median radius 54 if (isfinite(stats->sampleMedian)) { 55 Rbin = MAX(1, 0.5*stats->sampleMedian); 54 // if we have a valid range, rebin with bin size 1/2 of median radius 55 if (isfinite(stats->sampleMedian)) { 56 Rbin = MAX(1, 0.5*stats->sampleMedian); 57 } 56 58 } 59 psFree (values); 60 psFree (stats); 57 61 } 58 62 Rbin = 3; … … 90 94 // calculate the value for the nOut bin 91 95 // XXX need to fix this as well psStats (stats, values); 92 psVectorStats (stats, values, NULL, NULL, 0); 93 fluxBinned->data.F32[nOut] = stats->sampleMedian; 96 float value; 97 if (values->n > 0) { 98 psVectorStats (stats, values, NULL, NULL, 0); 99 value = stats->sampleMedian; 100 } else { 101 value = NAN; 102 } 103 fluxBinned->data.F32[nOut] = value; 94 104 nOut ++; 95 105 radiusBinned->data.F32[nOut] = (nOut + 0.5)*Rbin; … … 118 128 // XXX is there a macro in psLib that does this interpolation? 119 129 if (i == 0) { 120 psWarning ("impossible condition f[0] < Fo"); 121 continue; 122 } else { 123 Ro = radiusBinned->data.F32[i-1] + (radiusBinned->data.F32[i] - radiusBinned->data.F32[i-1]) * (Fo - fluxBinned->data.F32[i-1]) / (fluxBinned->data.F32[i] - fluxBinned->data.F32[i-1]); 124 } 130 psLogMsg ("psphot", 3, "bogus radial profile for ..., skipping"); 131 psFree (fluxBinned); 132 psFree (radiusBinned); 133 return NAN; 134 } 135 Ro = radiusBinned->data.F32[i-1] + (radiusBinned->data.F32[i] - radiusBinned->data.F32[i-1]) * (Fo - fluxBinned->data.F32[i-1]) / (fluxBinned->data.F32[i] - fluxBinned->data.F32[i-1]); 125 136 above = FALSE; 126 137 } -
branches/eam_branches/20090715/psphot/src/psphotRadiusChecks.c
r21183 r25433 86 86 87 87 // call this function whenever you (re)-define the EXT model 88 float psphotSetRadiusEXT (pmReadout *readout, pmSource *source, psImageMaskType markVal) { 89 90 psAssert (source, "source not defined??"); 91 psAssert (source->peak, "peak not defined??"); 92 93 pmPeak *peak = source->peak; 94 95 // set the radius based on the footprint: 96 if (!peak->footprint) goto escape; 97 pmFootprint *footprint = peak->footprint; 98 if (!footprint->spans) goto escape; 99 if (footprint->spans->n < 1) goto escape; 100 101 // find the max radius 102 float radius = 0.0; 103 for (int j = 0; j < footprint->spans->n; j++) { 104 pmSpan *span = footprint->spans->data[j]; 105 106 float dY = span->y - peak->yf; 107 float dX0 = span->x0 - peak->xf; 108 float dX1 = span->x1 - peak->xf; 109 110 radius = PS_MAX (radius, hypot(dY, dX0)); 111 radius = PS_MAX (radius, hypot(dY, dX1)); 112 } 113 114 radius += EXT_FIT_PADDING; 115 if (isnan(radius)) psAbort("error in radius"); 116 117 // redefine the pixels if needed 118 pmSourceRedefinePixels (source, readout, peak->xf, peak->yf, radius); 119 120 // set the mask to flag the excluded pixels 121 psImageKeepCircle (source->maskObj, peak->xf, peak->yf, radius, "OR", markVal); 122 return radius; 123 124 escape: 125 return NAN; 126 // bool result = psphotCheckRadiusEXT_old (readout, source, model, markVal); 127 // return result; 128 } 129 130 // call this function whenever you (re)-define the EXT model 88 131 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal) { 132 133 psAbort ("do not use this function"); 89 134 90 135 psF32 *PAR = model->params->data.F32; -
branches/eam_branches/20090715/psphot/src/psphotSourceFits.c
r24592 r25433 223 223 if (source->peak->SN < EXT_MIN_SN) return false; 224 224 225 float radius = psphotSetRadiusEXT (readout, source, markVal); 226 227 // XXX note that this changes the source moments that are published... 225 228 // recalculate the source moments using the larger extended-source moments radius 226 229 // at this stage, skip Gaussian windowing, and do not clip pixels by S/N 227 if (!pmSourceMoments (source, EXT_MOMENTS_RAD, 0.0, 0.0)) return false; 230 // XXX use the deteremined value of PSF_MOMENTS_RADIUS and SIGMA and scale up? 231 // XXX increase the moments radius iteratively until the measured sigma / input < f? 232 // XXX use the footprint somehow to judge both radius and aperture? 233 if (!pmSourceMoments (source, radius, 0.0, 0.0)) return false; 228 234 229 235 psTrace ("psphot", 5, "trying blob...\n"); … … 277 283 278 284 // both models failed; reject them both 285 // XXX -- change type flags to psf in this case and keep original moments? 279 286 psFree (EXT); 280 287 psFree (DBL); … … 287 294 // save new model 288 295 source->modelEXT = EXT; 296 source->modelEXT->radiusFit = radius; 289 297 source->type = PM_SOURCE_TYPE_EXTENDED; 290 298 source->mode |= PM_SOURCE_MODE_EXTMODEL; … … 294 302 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 295 303 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 304 305 # if (PS_TRACE_ON) 296 306 psTrace ("psphot", 5, "blob as EXT: %f %f\n", EXT->params->data.F32[PM_PAR_XPOS], EXT->params->data.F32[PM_PAR_YPOS]); 307 if (psTraceGetLevel("psphot") >= 6) { 308 psLogMsg ("psphot", 1, "source 2:\n"); 309 for (int i = 0; i < source->modelEXT->params->n; i++) { 310 psLogMsg ("psphot", 1, "PAR %d : %f +/- %f\n", i, source->modelEXT->params->data.F32[i], source->modelEXT->dparams->data.F32[i]); 311 } 312 } 313 # endif 314 297 315 return true; 298 316 … … 306 324 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 307 325 source->mode |= PM_SOURCE_MODE_PAIR; 326 source->modelPSF->radiusFit = radius; 308 327 309 328 // copy most data from the primary source (modelEXT, blends stay NULL) 310 // XXX use pmSourceCopy?311 329 pmSource *newSrc = pmSourceCopy (source); 312 330 newSrc->modelPSF = psMemIncrRefCounter (DBL->data[1]); 331 newSrc->modelPSF->radiusFit = radius; 313 332 314 333 // build cached models and subtract … … 317 336 pmSourceCacheModel (newSrc, maskVal); 318 337 pmSourceSub (newSrc, PM_MODEL_OP_FULL, maskVal); 338 339 # if (PS_TRACE_ON) 319 340 psTrace ("psphot", 5, "blob as DBL: %f %f\n", ONE->params->data.F32[PM_PAR_XPOS], ONE->params->data.F32[PM_PAR_YPOS]); 341 if (psTraceGetLevel("psphot") >= 6) { 342 psLogMsg ("psphot", 1, "source 1:\n"); 343 for (int i = 0; i < newSrc->modelPSF->params->n; i++) { 344 psLogMsg ("psphot", 1, "PAR %d : %f +/- %f\n", i, newSrc->modelPSF->params->data.F32[i], newSrc->modelPSF->dparams->data.F32[i]); 345 } 346 psLogMsg ("psphot", 1, "source 2:\n"); 347 for (int i = 0; i < source->modelPSF->params->n; i++) { 348 psLogMsg ("psphot", 1, "PAR %d : %f +/- %f\n", i, source->modelPSF->params->data.F32[i], source->modelPSF->dparams->data.F32[i]); 349 } 350 psphotVisualShowResidualImage (readout); 351 } 352 # endif 320 353 321 354 psArrayAdd (newSources, 100, newSrc); … … 356 389 // save the PSF model from the Ensemble fit 357 390 PSF = source->modelPSF; 358 psphotCheckRadiusPSFBlend (readout, source, PSF, markVal, 8.0);391 // psphotCheckRadiusPSFBlend (readout, source, PSF, markVal, 8.0); 359 392 if (isnan(PSF->params->data.F32[1])) psAbort("nan in dbl fit"); 360 393 … … 390 423 391 424 // if (isnan(EXT->params->data.F32[1])) psAbort("nan in ext fit"); 392 393 psphotCheckRadiusEXT (readout, source, EXT, markVal); 425 // psphotCheckRadiusEXT (readout, source, EXT, markVal); 394 426 395 427 if ((source->moments->Mxx < 1e-3) || (source->moments->Myy < 1e-3)) { … … 401 433 return (EXT); 402 434 } 403 -
branches/eam_branches/20090715/psphot/src/psphotSourceSize.c
r25390 r25433 194 194 bool psphotSourceSizePSF (psphotSourceSizeOptions *options, psArray *sources, pmPSF *psf) { 195 195 196 // select the psf stars 197 psArray *psfstars = psArrayAllocEmpty (100); 198 196 // select stats from the psf stars 199 197 psVector *Ap = psVectorAllocEmpty (100, PS_TYPE_F32); 200 198 psVector *ApErr = psVectorAllocEmpty (100, PS_TYPE_F32); … … 205 203 pmSource *source = sources->data[i]; 206 204 if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue; 207 psArrayAdd (psfstars, 100, source);208 205 209 206 // XXX can we test if psfMag is set and calculate only if needed? … … 229 226 options->ApSysErr = psVectorSystematicError(dAp, ApErr, 0.05); 230 227 fprintf (stderr, "psf-sum: %f +/- %f\n", options->ApResid, options->ApSysErr); 228 229 psFree (Ap); 230 psFree (ApErr); 231 psFree (stats); 232 psFree (dAp); 231 233 232 234 return true; -
branches/eam_branches/20090715/psphot/src/psphotVisual.c
r25388 r25433 166 166 bool psphotVisualShowImage (pmReadout *readout) { 167 167 168 if (!pmVisualIsVisual()) return true;168 // if (!pmVisualIsVisual()) return true; 169 169 170 170 int kapa = psphotKapaChannel (1); … … 2000 2000 bool psphotVisualShowResidualImage (pmReadout *readout) { 2001 2001 2002 if (!pmVisualIsVisual()) return true;2002 // if (!pmVisualIsVisual()) return true; 2003 2003 2004 2004 int myKapa = psphotKapaChannel (1); … … 2100 2100 if (source == NULL) return true; 2101 2101 2102 if (!pmVisualIsVisual()) return true;2103 2104 int kapa = psphotKapaChannel ( 3);2102 // if (!pmVisualIsVisual()) return true; 2103 2104 int kapa = psphotKapaChannel (1); 2105 2105 if (kapa == -1) return false; 2106 2106
Note:
See TracChangeset
for help on using the changeset viewer.
