Changeset 5719
- Timestamp:
- Dec 7, 2005, 8:49:38 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_rel8_b2/psModules/src/objects/pmObjects.c
r5659 r5719 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.2.6.1.2. 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-12-0 2 21:27:57$8 * @version $Revision: 1.2.6.1.2.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-12-07 18:49:38 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 1117 1117 bool big = (sigX > (clump.X - clump.dX)) && (sigY > (clump.Y - clump.dY)); 1118 1118 if ((Nsatpix > 1) && big) { 1119 tmpSrc->type |= PM_SOURCE_SATSTAR;1119 tmpSrc->type = PM_SOURCE_SATSTAR; 1120 1120 Nsatstar ++; 1121 1121 continue; … … 1124 1124 // saturated object (not a star, eg bleed trails, hot pixels) 1125 1125 if (Nsatpix > 1) { 1126 tmpSrc->type |= PM_SOURCE_SATURATED;1126 tmpSrc->type = PM_SOURCE_SATURATED; 1127 1127 Nsat ++; 1128 1128 continue; … … 1133 1133 // only set candidate defects if 1134 1134 if ((sigX < 0.05) || (sigY < 0.05)) { 1135 tmpSrc->type |= PM_SOURCE_DEFECT;1135 tmpSrc->type = PM_SOURCE_DEFECT; 1136 1136 Ncr ++; 1137 1137 continue; … … 1140 1140 // likely unsaturated galaxy (too large to be stellar) 1141 1141 if ((sigX > (clump.X + 3*clump.dX)) || (sigY > (clump.Y + 3*clump.dY))) { 1142 tmpSrc->type |= PM_SOURCE_GALAXY;1142 tmpSrc->type = PM_SOURCE_GALAXY; 1143 1143 Ngal ++; 1144 1144 continue; … … 1153 1153 psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY); 1154 1154 if ((SN > PSF_SN_LIM) && (radius < 1.5)) { 1155 tmpSrc->type |= PM_SOURCE_PSFSTAR;1155 tmpSrc->type = PM_SOURCE_PSFSTAR; 1156 1156 Npsf ++; 1157 1157 continue; … … 1159 1159 1160 1160 // random type of star 1161 tmpSrc->type |= PM_SOURCE_OTHER;1161 tmpSrc->type = PM_SOURCE_OTHER; 1162 1162 } 1163 1163 … … 1745 1745 psFree(paramMask); 1746 1746 1747 psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, rc);1747 psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, (onPic && fitStatus)); 1748 1748 return(onPic && fitStatus); 1749 1749 } … … 1767 1767 psBool fitStatus = true; 1768 1768 psBool onPic = true; 1769 psBool rc = true;1770 1769 psF32 Ro, ymodel; 1771 1770 … … 1794 1793 psTrace (".pmObjects.pmSourceFitModel", 4, "insufficient valid pixels\n"); 1795 1794 psTrace(__func__, 3, "---- %s(false) end ----\n", __func__); 1795 model->status = PM_MODEL_BADARGS; 1796 1796 return(false); 1797 1797 } … … 1869 1869 } 1870 1870 1871 // XXX EAM: we need to do something (give an error?) if rc is false 1872 // XXX EAM: psMinimizeLMChi2 does not check convergence 1873 1874 // XXX models can go insane: reject these 1875 onPic &= (params->data.F32[2] >= source->pixels->col0); 1876 onPic &= (params->data.F32[2] < source->pixels->col0 + source->pixels->numCols); 1877 onPic &= (params->data.F32[3] >= source->pixels->row0); 1878 onPic &= (params->data.F32[3] < source->pixels->row0 + source->pixels->numRows); 1879 1880 // XXX EAM: save the resulting chisq, nDOF, nIter 1871 // save the resulting chisq, nDOF, nIter 1881 1872 model->chisq = myMin->value; 1882 1873 model->nIter = myMin->iter; 1883 1874 model->nDOF = y->n - nParams; 1884 1875 1885 // XXX EAMget the Gauss-Newton distance for fixed model parameters1876 // get the Gauss-Newton distance for fixed model parameters 1886 1877 if (paramMask != NULL) { 1887 1878 psVector *delta = psVectorAlloc (params->n, PS_TYPE_F64); … … 1894 1885 } 1895 1886 1896 psFree(paramMask); 1887 // set the model success or failure status 1888 if (!fitStatus) { 1889 model->status = PM_MODEL_NONCONVERGE; 1890 } else { 1891 model->status = PM_MODEL_SUCCESS; 1892 } 1893 1894 // models can go insane: reject these, and save this status 1895 onPic &= (params->data.F32[2] >= source->pixels->col0); 1896 onPic &= (params->data.F32[2] < source->pixels->col0 + source->pixels->numCols); 1897 onPic &= (params->data.F32[3] >= source->pixels->row0); 1898 onPic &= (params->data.F32[3] < source->pixels->row0 + source->pixels->numRows); 1899 if (!onPic) { 1900 model->status = PM_MODEL_OFFIMAGE; 1901 } 1902 1897 1903 psFree(x); 1898 1904 psFree(y); 1905 psFree(yErr); 1899 1906 psFree(myMin); 1900 1901 rc = (onPic && fitStatus); 1902 psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, rc); 1903 return(rc); 1907 psFree(covar); 1908 psFree(paramMask); 1909 1910 psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, (onPic && fitStatus)); 1911 return(onPic && fitStatus); 1904 1912 } 1905 1913 … … 1908 1916 pmModel *model, 1909 1917 bool center, 1910 psS32 flag) 1918 bool sky, 1919 bool add 1920 ) 1911 1921 { 1912 1922 psTrace(__func__, 3, "---- %s() begin ----\n", __func__); … … 1921 1931 psS32 imageCol; 1922 1932 psS32 imageRow; 1933 psF32 skyValue = params->data.F32[0]; 1934 psF32 pixelValue; 1923 1935 1924 1936 for (psS32 i = 0; i < image->numRows; i++) { … … 1926 1938 if ((mask != NULL) && mask->data.U8[i][j]) 1927 1939 continue; 1928 psF32 pixelValue; 1929 // XXX: Should you be adding the pixels for the entire subImage, 1930 // or a radius of pixels around it? 1931 1932 // Convert i/j to imace coord space: 1933 // XXX: Make sure you have col/row order correct. 1934 // XXX EAM : 'center' option changes this 1935 // XXX EAM : i == numCols/2 -> x = model->params->data.F32[2] 1940 1941 // Convert i/j to image coord space (depending on 'center'): 1936 1942 if (center) { 1937 1943 imageCol = j - 0.5*image->numCols + model->params->data.F32[2]; … … 1942 1948 } 1943 1949 1950 // build the model coordinate 1944 1951 x->data.F32[0] = (float) imageCol; 1945 1952 x->data.F32[1] = (float) imageRow; 1946 pixelValue = modelFunc (NULL, params, x); 1947 // fprintf (stderr, "%f %f %d %d %f\n", x->data.F32[0], x->data.F32[1], i, j, pixelValue); 1948 1949 if (flag == 1) { 1950 pixelValue = -pixelValue; 1951 } 1952 1953 // XXX: Must figure out how to calculate the image coordinates and 1954 // how to use the boolean "center" flag. 1955 1956 image->data.F32[i][j]+= pixelValue; 1953 1954 // set the appropriate pixel value for this coordinate 1955 if (sky) { 1956 pixelValue = modelFunc (NULL, params, x); 1957 } else { 1958 pixelValue = modelFunc (NULL, params, x) - skyValue; 1959 } 1960 1961 // add or subtract the value 1962 if (add 1963 ) { 1964 image->data.F32[i][j] += pixelValue; 1965 } 1966 else { 1967 image->data.F32[i][j] -= pixelValue; 1968 } 1957 1969 } 1958 1970 } … … 1969 1981 psImage *mask, 1970 1982 pmModel *model, 1971 bool center) 1972 { 1973 psTrace(__func__, 3, "---- %s() begin ----\n", __func__); 1974 psBool rc = p_pmSourceAddOrSubModel(image, mask, model, center, 0); 1983 bool center, 1984 bool sky) 1985 { 1986 psTrace(__func__, 3, "---- %s() begin ----\n", __func__); 1987 psBool rc = p_pmSourceAddOrSubModel(image, mask, model, center, sky, true); 1975 1988 psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, rc); 1976 1989 return(rc); … … 1982 1995 psImage *mask, 1983 1996 pmModel *model, 1984 bool center) 1985 { 1986 psTrace(__func__, 3, "---- %s() begin ----\n", __func__); 1987 psBool rc = p_pmSourceAddOrSubModel(image, mask, model, center, 1); 1997 bool center, 1998 bool sky) 1999 { 2000 psTrace(__func__, 3, "---- %s() begin ----\n", __func__); 2001 psBool rc = p_pmSourceAddOrSubModel(image, mask, model, center, sky, false); 1988 2002 psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, rc); 1989 2003 return(rc);
Note:
See TracChangeset
for help on using the changeset viewer.
