Changeset 5806 for branches/eam_rel9_b0/psModules/src/objects/pmObjects.c
- Timestamp:
- Dec 17, 2005, 10:41:29 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_rel9_b0/psModules/src/objects/pmObjects.c
r5727 r5806 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.3.4. 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-12- 07 20:01:05$8 * @version $Revision: 1.3.4.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-12-17 20:41:29 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 134 134 tmp->modelPSF = NULL; 135 135 tmp->modelFLT = NULL; 136 tmp->type = 0; 136 tmp->type = PM_SOURCE_UNKNOWN; 137 tmp->mode = PM_SOURCE_DEFAULT; 137 138 psMemSetDeallocator(tmp, (psFreeFunc) sourceFree); 138 139 … … 749 750 psS32 numPixels = 0; 750 751 psF32 Sum = 0.0; 752 psF32 Var = 0.0; 751 753 psF32 X1 = 0.0; 752 754 psF32 Y1 = 0.0; … … 786 788 787 789 psF32 pDiff = source->pixels->data.F32[row][col] - sky; 790 psF32 wDiff = source->weight->data.F32[row][col]; 788 791 789 792 // XXX EAM : check for valid S/N in pixel … … 793 796 } 794 797 798 Var += wDiff; 795 799 Sum += pDiff; 796 800 X1 += xDiff * pDiff; … … 805 809 } 806 810 } 811 812 // if we have less than (1/4) of the possible pixels, force a retry 807 813 // XXX EAM - the limit is a bit arbitrary. make it user defined? 808 if ((numPixels < 3) || (Sum <= 0)) {809 psTrace (".psModules.pmSourceMoments", 5, "no valid pixels for source\n");814 if ((numPixels < 0.75*R2) || (Sum <= 0)) { 815 psTrace (".psModules.pmSourceMoments", 3, "no valid pixels for source\n"); 810 816 psTrace(__func__, 3, "---- %s(false) end ----\n", __func__); 811 817 return (false); … … 824 830 y = Y1/Sum; 825 831 if ((fabs(x) > radius) || (fabs(y) > radius)) { 826 psTrace (".psModules.pmSourceMoments", 5,832 psTrace (".psModules.pmSourceMoments", 3, 827 833 "large centroid swing; invalid peak %d, %d\n", 828 834 source->peak->x, source->peak->y); … … 837 843 source->moments->Sxy = XY/Sum - x*y; 838 844 source->moments->Sum = Sum; 845 source->moments->SN = Sum / sqrt(Var); 839 846 source->moments->Peak = peakPixel; 840 847 source->moments->nPixels = numPixels; … … 1064 1071 XXX: How can this function ever return FALSE? 1065 1072 1066 XXX EAM : add the saturated mask value to metadata 1073 EAM: I moved S/N calculation to pmSourceMoments, using weight image 1067 1074 *****************************************************************************/ 1068 1075 … … 1079 1086 int Ncr = 0; 1080 1087 int Nsatstar = 0; 1081 psRegion allArray = psRegionSet (0, 0, 0, 0); 1082 1088 // psRegion allArray = psRegionSet (0, 0, 0, 0); 1089 psRegion inner; 1090 1091 // report stats on S/N values for star-like objects 1083 1092 psVector *starsn = psVectorAlloc (sources->n, PS_TYPE_F32); 1084 1093 starsn->n = 0; … … 1086 1095 // check return status value (do these exist?) 1087 1096 bool status; 1088 psF32 RDNOISE = psMetadataLookupF32 (&status, metadata, "RDNOISE");1089 psF32 GAIN = psMetadataLookupF32 (&status, metadata, "GAIN");1090 1097 psF32 PSF_SN_LIM = psMetadataLookupF32 (&status, metadata, "PSF_SN_LIM"); 1091 // psF32 SATURATE = psMetadataLookupF32 (&status, metadata, "SATURATE");1092 1098 1093 1099 // XXX allow clump size to be scaled relative to sigmas? … … 1102 1108 psF32 sigY = tmpSrc->moments->Sy; 1103 1109 1104 // calculate and save signal-to-noise estimates1105 psF32 S = tmpSrc->moments->Sum;1106 psF32 A = 4 * M_PI * sigX * sigY;1107 psF32 B = tmpSrc->moments->Sky;1108 psF32 RT = sqrt(S + (A * B) + (A * PS_SQR(RDNOISE) / sqrt(GAIN)));1109 psF32 SN = (S * sqrt(GAIN) / RT);1110 tmpSrc->moments->SN = SN;1111 1112 1110 // XXX EAM : can we use the value of SATURATE if mask is NULL? 1113 int Nsatpix = psImageCountPixelMask (tmpSrc->mask, allArray, PSPHOT_MASK_SATURATED); 1111 inner = psRegionForSquare (tmpSrc->peak->x - tmpSrc->mask->col0, tmpSrc->peak->y - tmpSrc->mask->row0, 2); 1112 int Nsatpix = psImageCountPixelMask (tmpSrc->mask, inner, PSPHOT_MASK_SATURATED); 1114 1113 1115 1114 // saturated star (size consistent with PSF or larger) … … 1117 1116 bool big = (sigX > (clump.X - clump.dX)) && (sigY > (clump.Y - clump.dY)); 1118 1117 if ((Nsatpix > 1) && big) { 1119 tmpSrc->type = PM_SOURCE_SATSTAR; 1118 tmpSrc->type = PM_SOURCE_STAR; 1119 tmpSrc->mode = PM_SOURCE_SATSTAR; 1120 1120 Nsatstar ++; 1121 1121 continue; … … 1125 1125 if (Nsatpix > 1) { 1126 1126 tmpSrc->type = PM_SOURCE_SATURATED; 1127 tmpSrc->mode = PM_SOURCE_DEFAULT; 1127 1128 Nsat ++; 1128 1129 continue; … … 1134 1135 if ((sigX < 0.05) || (sigY < 0.05)) { 1135 1136 tmpSrc->type = PM_SOURCE_DEFECT; 1137 tmpSrc->mode = PM_SOURCE_DEFAULT; 1136 1138 Ncr ++; 1137 1139 continue; … … 1141 1143 if ((sigX > (clump.X + 3*clump.dX)) || (sigY > (clump.Y + 3*clump.dY))) { 1142 1144 tmpSrc->type = PM_SOURCE_GALAXY; 1145 tmpSrc->mode = PM_SOURCE_DEFAULT; 1143 1146 Ngal ++; 1144 1147 continue; … … 1146 1149 1147 1150 // the rest are probable stellar objects 1148 starsn->data.F32[starsn->n] = SN;1151 starsn->data.F32[starsn->n] = tmpSrc->moments->SN; 1149 1152 starsn->n ++; 1150 1153 Nstar ++; 1151 1154 1152 // PSF star (within 1.5 sigma of clump center 1155 // PSF star (within 1.5 sigma of clump center, S/N > limit) 1153 1156 psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY); 1154 if ((SN > PSF_SN_LIM) && (radius < 1.5)) { 1155 tmpSrc->type = PM_SOURCE_PSFSTAR; 1157 if ((tmpSrc->moments->SN > PSF_SN_LIM) && (radius < 1.5)) { 1158 tmpSrc->type = PM_SOURCE_STAR; 1159 tmpSrc->mode = PM_SOURCE_PSFSTAR; 1156 1160 Npsf ++; 1157 1161 continue; … … 1159 1163 1160 1164 // random type of star 1161 tmpSrc->type = PM_SOURCE_OTHER; 1165 tmpSrc->type = PM_SOURCE_STAR; 1166 tmpSrc->mode = PM_SOURCE_DEFAULT; 1162 1167 } 1163 1168 … … 1698 1703 } 1699 1704 1705 source->mode |= PM_SOURCE_FITTED; 1706 1700 1707 psFree(x); 1701 1708 psFree(y); … … 1729 1736 psBool onPic = true; 1730 1737 psBool rc = true; 1731 psF32 Ro, ymodel;1738 // psF32 Ro, ymodel; 1732 1739 1733 1740 psVector *params = model->params; … … 1739 1746 // XXX EAM : I need to use the sky value to constrain the weight model 1740 1747 int nParams = PSF ? params->n - 4 : params->n; 1741 psF32 So = params->data.F32[0];1748 // psF32 So = params->data.F32[0]; 1742 1749 1743 1750 // find the number of valid pixels … … 1776 1783 1777 1784 // compare observed flux to model flux to adjust weight 1778 ymodel = modelFunc (NULL, model->params, coord);1785 // ymodel = modelFunc (NULL, model->params, coord); 1779 1786 1780 1787 // this test enhances the weight based on deviation from the model flux 1781 Ro = 1.0 + fabs (y->data.F32[tmpCnt] - ymodel) / sqrt(PS_SQR(ymodel - So) + PS_SQR(So));1788 // Ro = 1.0 + sqrt (fabs (y->data.F32[tmpCnt] - ymodel) / (PS_SQR(ymodel - So) + 1.0)); 1782 1789 1783 1790 // psMinimizeLMChi2_EAM takes wt = 1/dY^2 … … 1785 1792 yErr->data.F32[tmpCnt] = 0.0; 1786 1793 } else { 1787 yErr->data.F32[tmpCnt] = 1.0 / (source->weight->data.F32[i][j] * Ro); 1794 // yErr->data.F32[tmpCnt] = 1.0 / (source->weight->data.F32[i][j] * Ro); 1795 yErr->data.F32[tmpCnt] = 1.0 / source->weight->data.F32[i][j]; 1788 1796 } 1789 1797 tmpCnt++; … … 1865 1873 model->status = PM_MODEL_OFFIMAGE; 1866 1874 } 1875 1876 source->mode |= PM_SOURCE_FITTED; 1867 1877 1868 1878 psFree(x);
Note:
See TracChangeset
for help on using the changeset viewer.
