Changeset 4375 for trunk/psphot/src/psphot-utils.c
- Timestamp:
- Jun 24, 2005, 5:38:37 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphot-utils.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphot-utils.c
r4251 r4375 77 77 params = model->params; 78 78 dparams = model->dparams; 79 fprintf (f, "%7.1f %7.1f %5.1f %7. 1f %7.4f ",79 fprintf (f, "%7.1f %7.1f %5.1f %7.3f %7.4f ", 80 80 params[0].data.F32[2], params[0].data.F32[3], 81 params[0].data.F32[0], params[0].data.F32[1], (dparams[0].data.F32[1]/params[0].data.F32[1]));82 for (j = 0; j < model->params->n - 4; j++) { 83 fprintf (f, "%9. 3g", params[0].data.F32[j+4]);84 } 85 for (j = 0; j < model->params->n - 4; j++) { 86 fprintf (f, "%9. 3g", dparams[0].data.F32[j+4]);81 params[0].data.F32[0], -2.5*log10(params[0].data.F32[1]), (dparams[0].data.F32[1]/params[0].data.F32[1])); 82 for (j = 0; j < model->params->n - 4; j++) { 83 fprintf (f, "%9.6f ", params[0].data.F32[j+4]); 84 } 85 for (j = 0; j < model->params->n - 4; j++) { 86 fprintf (f, "%9.6f ", dparams[0].data.F32[j+4]); 87 87 } 88 88 fprintf (f, ": %2d %7.4f %7.4f %7.2f (%d %d)\n", source[0].type, log10(model[0].chisq), source[0].moments->SN, model[0].radius, model[0].nDOF, model[0].nIter); 89 } 90 fclose (f); 91 return true; 92 } 93 94 // dump the sources to an output file 95 bool DumpModelFLT (psArray *sources, char *filename) 96 { 97 98 int i, j; 99 FILE *f; 100 psVector *params; 101 psVector *dparams; 102 psModel *model; 103 104 f = fopen (filename, "w"); 105 if (f == NULL) { 106 psLogMsg ("DumpObjects", 3, "can't open output file for moments%s\n", filename); 107 return false; 108 } 109 110 // write sources with models first 111 for (i = 0; i < sources->n; i++) { 112 psSource *source = (psSource *) sources->data[i]; 113 model = (psModel *) source->modelFLT; 114 if (model == NULL) continue; 115 params = model->params; 116 dparams = model->dparams; 117 fprintf (f, "%7.1f %7.1f %5.1f %7.3f %7.4f ", 118 params[0].data.F32[2], params[0].data.F32[3], 119 params[0].data.F32[0], -2.5*log10(params[0].data.F32[1]), (dparams[0].data.F32[1]/params[0].data.F32[1])); 120 for (j = 0; j < model->params->n - 4; j++) { 121 fprintf (f, "%9.6f ", params[0].data.F32[j+4]); 122 } 123 for (j = 0; j < model->params->n - 4; j++) { 124 fprintf (f, "%9.6f ", dparams[0].data.F32[j+4]); 125 } 126 fprintf (f, ": %2d %7.4f %7.4f %7.2f (%d %d)\n", source[0].type, log10(model[0].chisq), source[0].moments->SN, model[0].radius, model[0].nDOF, model[0].nIter); 127 } 128 fclose (f); 129 return true; 130 } 131 132 // dump the sources to an output file 133 bool DumpModelNULL (psArray *sources, char *filename) 134 { 135 136 int i, j; 137 FILE *f; 138 psVector *params; 139 psVector *dparams; 140 psModel *model; 141 142 f = fopen (filename, "w"); 143 if (f == NULL) { 144 psLogMsg ("DumpObjects", 3, "can't open output file for moments%s\n", filename); 145 return false; 146 } 147 148 // write sources with models first 149 for (i = 0; i < sources->n; i++) { 150 psSource *source = (psSource *) sources->data[i]; 151 if (source->modelFLT != NULL) continue; 152 if (source->modelPSF != NULL) continue; 153 if (source->moments == NULL) continue; 154 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", 155 source->peak->x, source->peak->y, source->peak->counts, 156 source->moments->x, source->moments->y, 157 source->moments->Sx, source->moments->Sy, 158 source->moments->Sum, source->moments->Peak, 159 source->moments->Sky, source->moments->SN, 160 source->moments->nPixels, source->type); 89 161 } 90 162 fclose (f); … … 118 190 params[0].data.F32[0], params[0].data.F32[1]); 119 191 for (j = 0; j < model->params->n - 4; j++) { 120 fprintf (f, "%9. 3g", params[0].data.F32[j+4]);121 } 122 for (j = 0; j < model->params->n - 4; j++) { 123 fprintf (f, "%9. 3g", dparams[0].data.F32[j+4]);192 fprintf (f, "%9.6f ", params[0].data.F32[j+4]); 193 } 194 for (j = 0; j < model->params->n - 4; j++) { 195 fprintf (f, "%9.6f ", dparams[0].data.F32[j+4]); 124 196 } 125 197 fprintf (f, ": %7.1f (%d %d)\n", model[0].chisq, model[0].nDOF, model[0].nIter); … … 138 210 } 139 211 212 bool pmSourcePhotometry (float *fitMag, float *obsMag, psModel *model, psImage *image, psImage *mask) { 213 214 float obsSum = 0; 215 float fitSum = 0; 216 float sky = model->params->data.F32[0]; 217 218 psModelFlux modelFluxFunc = psModelFlux_GetFunction (model->type); 219 fitSum = modelFluxFunc (model->params); 220 221 for (int ix = 0; ix < image->numCols; ix++) { 222 for (int iy = 0; iy < image->numRows; iy++) { 223 if (mask->data.U8[iy][ix]) continue; 224 obsSum += image->data.F32[iy][ix] - sky; 225 // fitSum += psModelEval (model, image, ix, iy) - sky; 226 } 227 } 228 if (obsSum <= 0) return false; 229 if (fitSum <= 0) return false; 230 231 *fitMag = -2.5*log10(fitSum); 232 *obsMag = -2.5*log10(obsSum); 233 return (true); 234 } 235 140 236 # if (0) 141 237 void pmSourceMaskSaturated (psSource *source, float saturate) {
Note:
See TracChangeset
for help on using the changeset viewer.
