Changeset 15838
- Timestamp:
- Dec 14, 2007, 3:12:29 PM (18 years ago)
- Location:
- trunk/psModules/src/camera
- Files:
-
- 2 edited
-
pmReadoutFake.c (modified) (10 diffs)
-
pmReadoutFake.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmReadoutFake.c
r15815 r15838 28 28 29 29 30 #ifdef PAP_WORK31 30 // Given an object model, circularise it by setting the axes to be identical 32 31 static bool circulariseModel(pmModel *model // Model to circularise … … 45 44 return pmPSF_AxesToModel(params, axes); 46 45 } 47 #endif48 46 49 #ifdef PAP_WORK50 47 bool pmReadoutFakeFromSources(pmReadout *readout, int numCols, int numRows, const psArray *sources, 51 const psVector *xOffset, const psVector *yOffset, pmPSF *psf,48 const psVector *xOffset, const psVector *yOffset, const pmPSF *psf, 52 49 float minFlux, int radius, bool circularise) 53 #else54 pmReadout *pmReadoutFakeFromSources(int numCols, int numRows, const psArray *sources,55 float fwhm, float minFlux)56 #endif57 50 { 58 #ifdef PAP_WORK59 51 PS_ASSERT_PTR_NON_NULL(readout, false); 60 #else61 pmReadout *readout = pmReadoutAlloc(NULL);62 #endif63 52 PS_ASSERT_INT_LARGER_THAN(numCols, 0, false); 64 53 PS_ASSERT_INT_LARGER_THAN(numRows, 0, false); 65 54 PS_ASSERT_ARRAY_NON_NULL(sources, false); 66 55 67 #ifdef PAP_WORK68 56 if (xOffset || yOffset) { 69 57 PS_ASSERT_VECTOR_NON_NULL(xOffset, false); … … 84 72 return false; 85 73 } 86 #endif87 74 88 75 readout->image = psImageRecycle(readout->image, numCols, numRows, PS_TYPE_F32); … … 91 78 int numSources = sources->n; // Number of stars 92 79 93 #ifndef PAP_WORK94 pmModelType modelType = pmModelClassGetType(MODEL_TYPE); // Type of PSF model95 assert(modelType >= 0);96 pmModel *fakeModel = pmModelAlloc(modelType);97 98 float sigma = fwhm / (2.0 * sqrtf(2.0 * log(2.0))); // Gaussian sigma99 100 fakeModel->params->data.F32[PM_PAR_SKY] = 0.0;101 fakeModel->params->data.F32[PM_PAR_I0] = 1.0;102 fakeModel->params->data.F32[PM_PAR_XPOS] = NAN;103 fakeModel->params->data.F32[PM_PAR_YPOS] = NAN;104 fakeModel->params->data.F32[PM_PAR_SXX] = sigma * M_SQRT2;105 fakeModel->params->data.F32[PM_PAR_SYY] = sigma * M_SQRT2;106 fakeModel->params->data.F32[PM_PAR_SXY] = 0.0;107 switch (modelType) {108 case 0: // GAUSS109 case 1: // PGAUSS110 break;111 case 2: // QGAUSS112 fakeModel->params->data.F32[PM_PAR_7] = 1.0;113 break;114 case 3: // RGAUSS115 fakeModel->params->data.F32[PM_PAR_7] = 2.0;116 break;117 default:118 psAbort("Unsupported model type: %d", modelType);119 }120 #else121 80 pmModel *fakeModel = pmModelFromPSFforXY(psf, (float)numCols / 2.0, (float)numRows / 2.0, 122 81 1.0); // Fake model, with central intensity of 1.0 123 #endif124 82 125 83 float flux0 = fakeModel->modelFlux(fakeModel->params); // Flux for central intensity of 1.0 126 84 127 #ifdef PAP_WORK128 85 if (circularise && !circulariseModel(fakeModel)) { 129 86 psError(PS_ERR_UNKNOWN, false, "Unable to circularise PSF model."); … … 132 89 } 133 90 psFree(fakeModel); 134 #endif135 91 136 92 for (int i = 0; i < numSources; i++) { … … 148 104 } 149 105 150 #ifdef PAP_WORK151 106 pmModel *fakeModel = pmModelFromPSFforXY(psf, x, y, powf(10.0, -0.4 * source->psfMag) / flux0); 152 107 if (!fakeModel) { … … 159 114 return false; 160 115 } 161 #else162 fakeModel->params->data.F32[PM_PAR_I0] = powf(10.0, -0.4 * source->psfMag) / flux0;163 fakeModel->params->data.F32[PM_PAR_XPOS] = x;164 fakeModel->params->data.F32[PM_PAR_YPOS] = y;165 #endif166 116 167 117 psTrace("psModules.camera", 10, "Adding source at %f,%f with flux %f\n", … … 171 121 pmSource *fakeSource = pmSourceAlloc(); // Fake source to generate 172 122 fakeSource->peak = pmPeakAlloc(x, y, fakeModel->params->data.F32[PM_PAR_I0], PM_PEAK_LONE); 173 float fakeRadius = 174 #ifdef PAP_WORK 175 radius > 0 ? radius : 176 #endif 177 fakeModel->modelRadius(fakeModel->params, minFlux); // Radius 123 float fakeRadius = radius > 0 ? radius : fakeModel->modelRadius(fakeModel->params, minFlux); // Radius 178 124 179 #ifdef PAP_WORK180 125 if (xOffset) { 181 126 if (!pmSourceDefinePixels(fakeSource, readout, x + xOffset->data.S32[i], … … 193 138 return false; 194 139 } 195 } else 196 #endif 197 { 140 } else { 198 141 if (!pmSourceDefinePixels(fakeSource, readout, x, y, fakeRadius)) { 199 142 psError(PS_ERR_UNKNOWN, false, "Unable to define pixels for source."); … … 210 153 } 211 154 psFree(fakeSource); 212 #ifdef PAP_WORK213 155 psFree(fakeModel); 214 #endif215 156 } 216 157 217 return 218 #ifdef PAP_WORK 219 true 220 #else 221 readout 222 #endif 223 ; 224 158 return true; 225 159 } -
trunk/psModules/src/camera/pmReadoutFake.h
r15815 r15838 12 12 #include <pmPSF.h> 13 13 14 15 //#define PAP_WORK16 17 18 #ifdef PAP_WORK19 14 /// Generate a fake readout from an array of sources 20 15 bool pmReadoutFakeFromSources(pmReadout *readout, ///< Output readout, or NULL … … 23 18 const psVector *xOffset, ///< x offsets for sources (source -> img), or NULL 24 19 const psVector *yOffset, ///< y offsets for sources (source -> img), or NULL 25 pmPSF *psf, ///< PSF for sources20 const pmPSF *psf, ///< PSF for sources 26 21 float minFlux, ///< Minimum flux to bother about; for setting source radius 27 22 int radius, ///< Fixed radius for sources 28 23 bool circularise ///< Circularise PSF model? 29 24 ); 30 #else31 pmReadout *pmReadoutFakeFromSources(int numCols, int numRows, ///< Dimension of image32 const psArray *sources, ///< Array of pmSource33 float target, ///< Target FWHM34 float minFlux ///< Minimum flux to bother about; for setting source radius35 );36 #endif // PAP_WORK37 38 39 40 25 41 26 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
