Changeset 15813
- Timestamp:
- Dec 13, 2007, 12:07:35 PM (18 years ago)
- Location:
- trunk/psModules/src/camera
- Files:
-
- 2 edited
-
pmReadoutFake.c (modified) (9 diffs)
-
pmReadoutFake.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmReadoutFake.c
r15756 r15813 22 22 #include "pmModelUtils.h" 23 23 24 #define MODEL_TYPE "PS_MODEL_RGAUSS" // Type of model to use 25 26 27 bool pmReadoutFakeFromSources(pmReadout *readout, int numCols, int numRows, const psArray *sources, 28 const psVector *xOffset, const psVector *yOffset, pmPSF *psf, float minFlux, 29 int radius) 24 #include "pmReadoutFake.h" 25 26 #define MODEL_TYPE "PS_MODEL_RGAUSS" // Type of model to use 27 #define MAX_AXIS_RATIO 20.0 // Maximum axis ratio for PSF model 28 29 30 #ifdef PAP_WORK 31 // Given an object model, circularise it by setting the axes to be identical 32 static bool circulariseModel(pmModel *model // Model to circularise 33 ) 34 { 35 assert(model); 36 37 psF32 *params = model->params->data.F32; // Model parameters 38 psEllipseAxes axes = pmPSF_ModelToAxes(params, MAX_AXIS_RATIO); // Ellipse axes 39 // Curiously, the minor axis can be larger than the major axis, so need to check. 40 if (axes.major >= axes.minor) { 41 axes.minor = axes.major; 42 } else { 43 axes.major = axes.minor; 44 } 45 return pmPSF_AxesToModel(params, axes); 46 } 47 #endif 48 49 bool pmReadoutFakeFromSources( 50 #ifdef PAP_WORK 51 pmReadout *readout, int numCols, int numRows, const psArray *sources, 52 const psVector *xOffset, const psVector *yOffset, pmPSF *psf, 53 float minFlux, int radius, bool circularise 54 #else 55 pmReadout *readout, int numCols, int numRows, const psArray *sources, 56 float fwhm, float minFlux 57 #endif 58 ) 30 59 { 31 60 PS_ASSERT_PTR_NON_NULL(readout, false); … … 33 62 PS_ASSERT_INT_LARGER_THAN(numRows, 0, false); 34 63 PS_ASSERT_ARRAY_NON_NULL(sources, false); 64 65 #ifdef PAP_WORK 35 66 if (xOffset || yOffset) { 36 67 PS_ASSERT_VECTOR_NON_NULL(xOffset, false); … … 51 82 return false; 52 83 } 53 84 #endif 54 85 55 86 readout->image = psImageRecycle(readout->image, numCols, numRows, PS_TYPE_F32); … … 58 89 int numSources = sources->n; // Number of stars 59 90 60 #if 091 #ifndef PAP_WORK 61 92 pmModelType modelType = pmModelClassGetType(MODEL_TYPE); // Type of PSF model 62 93 assert(modelType >= 0); … … 85 116 psAbort("Unsupported model type: %d", modelType); 86 117 } 87 #endif 88 118 #else 89 119 pmModel *fakeModel = pmModelFromPSFforXY(psf, (float)numCols / 2.0, (float)numRows / 2.0, 90 120 1.0); // Fake model, with central intensity of 1.0 121 #endif 122 91 123 float flux0 = fakeModel->modelFlux(fakeModel->params); // Flux for central intensity of 1.0 124 125 #ifdef PAP_WORK 126 if (circularise && !circulariseModel(fakeModel)) { 127 psError(PS_ERR_UNKNOWN, false, "Unable to circularise PSF model."); 128 psFree(fakeModel); 129 return false; 130 } 131 psFree(fakeModel); 132 #endif 92 133 93 134 for (int i = 0; i < numSources; i++) { … … 105 146 } 106 147 148 #ifdef PAP_WORK 149 pmModel *fakeModel = pmModelFromPSFforXY(psf, x, y, powf(10.0, -0.4 * source->psfMag) / flux0); 150 if (!fakeModel) { 151 psError(PS_ERR_UNKNOWN, false, "Unable to generate model for source %d (%.1f,%.1f)", i, x, y); 152 return false; 153 } 154 if (circularise && !circulariseModel(fakeModel)) { 155 psError(PS_ERR_UNKNOWN, false, "Unable to circularise PSF model."); 156 psFree(fakeModel); 157 return false; 158 } 159 #else 160 fakeModel->params->data.F32[PM_PAR_I0] = powf(10.0, -0.4 * source->psfMag) / flux0; 107 161 fakeModel->params->data.F32[PM_PAR_XPOS] = x; 108 162 fakeModel->params->data.F32[PM_PAR_YPOS] = y; 109 fakeModel->params->data.F32[PM_PAR_I0] = powf(10.0, -0.4 * source->psfMag) / flux0; 163 #endif 110 164 111 165 psTrace("psModules.camera", 10, "Adding source at %f,%f with flux %f\n", … … 115 169 pmSource *fakeSource = pmSourceAlloc(); // Fake source to generate 116 170 fakeSource->peak = pmPeakAlloc(x, y, fakeModel->params->data.F32[PM_PAR_I0], PM_PEAK_LONE); 117 float fakeRadius = radius > 0 ? radius : fakeModel->modelRadius(fakeModel->params, minFlux); // Radius 118 171 float fakeRadius = 172 #ifdef PAP_WORK 173 radius > 0 ? radius : 174 #endif 175 fakeModel->modelRadius(fakeModel->params, minFlux); // Radius 176 177 #ifdef PAP_WORK 119 178 if (xOffset) { 120 179 if (!pmSourceDefinePixels(fakeSource, readout, x + xOffset->data.S32[i], … … 132 191 return false; 133 192 } 134 } else { 193 } else 194 #endif 195 { 135 196 if (!pmSourceDefinePixels(fakeSource, readout, x, y, fakeRadius)) { 136 197 psError(PS_ERR_UNKNOWN, false, "Unable to define pixels for source."); … … 147 208 } 148 209 psFree(fakeSource); 149 } 150 151 psFree(fakeModel); 210 #ifdef PAP_WORK 211 psFree(fakeModel); 212 #endif 213 } 152 214 153 215 return true; -
trunk/psModules/src/camera/pmReadoutFake.h
r15756 r15813 13 13 14 14 15 //#define PAP_WORK 16 17 18 #ifdef PAP_WORK 15 19 /// Generate a fake readout from an array of sources 16 20 bool pmReadoutFakeFromSources(pmReadout *readout, ///< Output readout, or NULL … … 21 25 pmPSF *psf, ///< PSF for sources 22 26 float minFlux, ///< Minimum flux to bother about; for setting source radius 23 int radius ///< Fixed radius for sources 27 int radius, ///< Fixed radius for sources 28 bool circularise ///< Circularise PSF model? 24 29 ); 30 #else 31 bool pmReadoutFakeFromSources(pmReadout *readout, ///< Output readout, or NULL 32 int numCols, int numRows, ///< Dimension of image 33 const psArray *sources, ///< Array of pmSource 34 float target, ///< Target FWHM 35 float minFlux ///< Minimum flux to bother about; for setting source radius 36 ); 37 #endif // PAP_WORK 38 39 40 25 41 26 42 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
