Changeset 5659
- Timestamp:
- Dec 2, 2005, 11:27:57 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_rel8_b2/psModules/src/objects/pmObjects.c
r5606 r5659 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.2.6.1 $ $Name: not supported by cvs2svn $9 * @date $Date: 2005-1 1-26 02:48:02$8 * @version $Revision: 1.2.6.1.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-12-02 21:27:57 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 81 81 tmp->chisq = 0.0; 82 82 tmp->nIter = 0; 83 tmp->radius = 0; 84 tmp->status = PM_MODEL_UNTRIED; 85 83 86 psS32 Nparams = pmModelParameterCount(type); 84 87 if (Nparams == 0) { … … 916 919 psImage *splane = NULL; 917 920 int binX, binY; 921 bool status; 922 923 psF32 SX_MAX = psMetadataLookupF32 (&status, metadata, "MOMENTS_SX_MAX"); 924 if (!status) 925 SX_MAX = 10.0; 926 psF32 SY_MAX = psMetadataLookupF32 (&status, metadata, "MOMENTS_SY_MAX"); 927 if (!status) 928 SY_MAX = 10.0; 918 929 919 930 // construct a sigma-plane image 920 931 // psImageAlloc does zero the data 921 splane = psImageAlloc ( NPIX/SCALE, NPIX/SCALE, PS_TYPE_F32);932 splane = psImageAlloc (SX_MAX/SCALE, SY_MAX/SCALE, PS_TYPE_F32); 922 933 for (int i = 0; i < splane->numRows; i++) 923 934 { … … 1031 1042 psfClump.dY = stats->clippedStdev; 1032 1043 1033 ps Trace (".pmObjects.pmSourceRoughClass", 2, "clump X, Y: %f, %f\n", psfClump.X, psfClump.Y);1034 ps Trace (".pmObjects.pmSourceRoughClass", 2, "clump DX, DY: %f, %f\n", psfClump.dX, psfClump.dY);1044 psLogMsg ("pmObjects", 4, "clump X, Y: %f, %f\n", psfClump.X, psfClump.Y); 1045 psLogMsg ("pmObjects", 4, "clump DX, DY: %f, %f\n", psfClump.dX, psfClump.dY); 1035 1046 // these values should be pushed on the metadata somewhere 1036 1047 … … 1160 1171 } 1161 1172 1162 psTrace (".pmObjects.pmSourceRoughClass", 2, "Nstar: %3d\n", Nstar); 1163 psTrace (".pmObjects.pmSourceRoughClass", 2, "Npsf: %3d\n", Npsf); 1164 psTrace (".pmObjects.pmSourceRoughClass", 2, "Ngal: %3d\n", Ngal); 1165 psTrace (".pmObjects.pmSourceRoughClass", 2, "Nsatstar: %3d\n", Nsatstar); 1166 psTrace (".pmObjects.pmSourceRoughClass", 2, "Nsat: %3d\n", Nsat); 1167 psTrace (".pmObjects.pmSourceRoughClass", 2, "Ncr: %3d\n", Ncr); 1173 psLogMsg ("pmObjects", 4, "Nstar: %3d\n", Nstar); 1174 psLogMsg ("pmObjects", 4, "Npsf: %3d\n", Npsf); 1175 psLogMsg ("pmObjects", 4, "Ngal: %3d\n", Ngal); 1176 psLogMsg ("pmObjects", 4, "Nsatstar: %3d\n", Nsatstar); 1177 psLogMsg ("pmObjects", 4, "Nsat: %3d\n", Nsat); 1178 psLogMsg ("pmObjects", 4, "Ncr: %3d\n", Ncr); 1179 1180 // optional dump of all rough source data 1181 { 1182 bool status; 1183 char *output = psMetadataLookupPtr (&status, metadata, "MOMENTS_OUTPUT_FILE"); 1184 if (status && (output != NULL) && (output[0])) 1185 { 1186 pmMomentsWriteText (sources, output); 1187 psFree (output); 1188 } 1189 } 1168 1190 1169 1191 psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, rc); 1170 1192 return(rc); 1193 } 1194 1195 // write the moments to an output file 1196 bool pmMomentsWriteText (psArray *sources, char *filename) 1197 { 1198 1199 int i; 1200 FILE *f; 1201 pmSource *source; 1202 1203 f = fopen (filename, "w"); 1204 if (f == NULL) { 1205 psLogMsg ("pmMomentsWriteText", 3, "can't open output file for moments%s\n", filename); 1206 return false; 1207 } 1208 1209 for (i = 0; i < sources->n; i++) { 1210 source = (pmSource *) sources->data[i]; 1211 if (source->moments == NULL) 1212 continue; 1213 fprintf (f, "%5d %5d %7.1f %7.1f %7.1f %6.3f %6.3f %8.1f %7.1f %7.1f %7.1f %4d %2d\n", 1214 source->peak->x, source->peak->y, source->peak->counts, 1215 source->moments->x, source->moments->y, 1216 source->moments->Sx, source->moments->Sy, 1217 source->moments->Sum, source->moments->Peak, 1218 source->moments->Sky, source->moments->SN, 1219 source->moments->nPixels, source->type); 1220 } 1221 fclose (f); 1222 return true; 1171 1223 } 1172 1224 … … 1575 1627 psBool fitStatus = true; 1576 1628 psBool onPic = true; 1577 psBool rc = true;1578 1629 1579 1630 // XXX EAM : is it necessary for the mask & weight to exist? the … … 1602 1653 psTrace (".pmObjects.pmSourceFitModel", 4, "insufficient valid pixels\n"); 1603 1654 psTrace(__func__, 3, "---- %s(false) end ----\n", __func__); 1655 model->status = PM_MODEL_BADARGS; 1604 1656 return(false); 1605 1657 } … … 1642 1694 } 1643 1695 1644 // XXX EAM : covar must be F64?1696 // covar must be F64 1645 1697 psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F64); 1646 1698 … … 1653 1705 } 1654 1706 1655 // XXX EAM: we need to do something (give an error?) if rc is false 1656 // XXX EAM: psMinimizeLMChi2 does not check convergence 1657 1658 // XXX models can go insane: reject these 1659 onPic &= (params->data.F32[2] >= source->pixels->col0); 1660 onPic &= (params->data.F32[2] < source->pixels->col0 + source->pixels->numCols); 1661 onPic &= (params->data.F32[3] >= source->pixels->row0); 1662 onPic &= (params->data.F32[3] < source->pixels->row0 + source->pixels->numRows); 1663 1664 // XXX EAM: save the resulting chisq, nDOF, nIter 1707 // save the resulting chisq, nDOF, nIter 1665 1708 model->chisq = myMin->value; 1666 1709 model->nIter = myMin->iter; 1667 1710 model->nDOF = y->n - nParams; 1668 1711 1669 // XXX EAMget the Gauss-Newton distance for fixed model parameters1712 // get the Gauss-Newton distance for fixed model parameters 1670 1713 if (paramMask != NULL) { 1671 1714 psVector *delta = psVectorAlloc (params->n, PS_TYPE_F64); … … 1679 1722 } 1680 1723 1724 // set the model success or failure status 1725 if (!fitStatus) { 1726 model->status = PM_MODEL_NONCONVERGE; 1727 } else { 1728 model->status = PM_MODEL_SUCCESS; 1729 } 1730 1731 // models can go insane: save this status instead 1732 onPic &= (params->data.F32[2] >= source->pixels->col0); 1733 onPic &= (params->data.F32[2] < source->pixels->col0 + source->pixels->numCols); 1734 onPic &= (params->data.F32[3] >= source->pixels->row0); 1735 onPic &= (params->data.F32[3] < source->pixels->row0 + source->pixels->numRows); 1736 if (!onPic) { 1737 model->status = PM_MODEL_OFFIMAGE; 1738 } 1739 1681 1740 psFree(x); 1682 1741 psFree(y); … … 1686 1745 psFree(paramMask); 1687 1746 1688 rc = (onPic && fitStatus);1689 1747 psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, rc); 1690 return( rc);1748 return(onPic && fitStatus); 1691 1749 } 1692 1750
Note:
See TracChangeset
for help on using the changeset viewer.
