Changeset 25028 for branches/pap/psModules
- Timestamp:
- Aug 7, 2009, 4:35:14 PM (17 years ago)
- Location:
- branches/pap/psModules/src/camera
- Files:
-
- 2 edited
-
pmReadoutFake.c (modified) (7 diffs)
-
pmReadoutFake.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap/psModules/src/camera/pmReadoutFake.c
r25027 r25028 50 50 } 51 51 52 bool pmReadoutFakeFromSources(pmReadout *readout, int numCols, int numRows, const psArray *sources, 53 const psVector *xOffset, const psVector *yOffset, const pmPSF *psf, 54 float minFlux, int radius, bool circularise, bool normalisePeak) 52 53 bool pmReadoutFakeFromVectors(pmReadout *readout, int numCols, int numRows, 54 const psVector *x, const psVector *y, const psVector *mag, 55 const psVector *xOffset, const psVector *yOffset, 56 const pmPSF *psf, float minFlux, int radius, 57 bool circularise, bool normalisePeak) 55 58 { 56 59 PS_ASSERT_PTR_NON_NULL(readout, false); 57 60 PS_ASSERT_INT_LARGER_THAN(numCols, 0, false); 58 61 PS_ASSERT_INT_LARGER_THAN(numRows, 0, false); 59 PS_ASSERT_ARRAY_NON_NULL(sources, false); 60 62 PS_ASSERT_VECTOR_NON_NULL(x, false); 63 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, false); 64 PS_ASSERT_VECTOR_NON_NULL(y, false); 65 PS_ASSERT_VECTOR_TYPE(y, PS_TYPE_F32, false); 66 PS_ASSERT_VECTORS_SIZE_EQUAL(y, x, false); 67 PS_ASSERT_VECTOR_NON_NULL(mag, false); 68 PS_ASSERT_VECTOR_TYPE(mag, PS_TYPE_F32, false); 69 PS_ASSERT_VECTORS_SIZE_EQUAL(mag, x, false); 70 long numSources = x->n; // Number of sources 61 71 if (xOffset || yOffset) { 62 72 PS_ASSERT_VECTOR_NON_NULL(xOffset, false); … … 64 74 PS_ASSERT_VECTORS_SIZE_EQUAL(xOffset, yOffset, false); 65 75 PS_ASSERT_VECTOR_TYPE(xOffset, PS_TYPE_S32, false); 66 PS_ASSERT_VECTOR_TYPE _EQUAL(xOffset, yOffset, false);67 if (xOffset->n != sources->n) {76 PS_ASSERT_VECTOR_TYPE(yOffset, PS_TYPE_S32, false); 77 if (xOffset->n != numSources) { 68 78 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 69 79 "Number of offset vectors (%ld) and sources (%ld) doesn't match", 70 xOffset->n, sources->n);80 xOffset->n, numSources); 71 81 return false; 72 82 } … … 81 91 psImageInit(readout->image, 0); 82 92 83 int numSources = sources->n; // Number of stars 84 for (int i = 0; i < numSources; i++) { 85 pmSource *source = sources->data[i]; // Source of interest 86 if (!source) { 87 continue; 88 } 89 if (source->mode & SOURCE_MASK) { 90 continue; 91 } 92 if (!isfinite(source->psfMag)) { 93 continue; 94 } 95 float x, y; // Coordinates of source 96 if (source->modelPSF) { 97 x = source->modelPSF->params->data.F32[PM_PAR_XPOS]; 98 y = source->modelPSF->params->data.F32[PM_PAR_YPOS]; 99 } else { 100 x = source->peak->xf; 101 y = source->peak->yf; 102 } 103 104 float flux = powf(10.0, -0.4 * source->psfMag); // Flux of source 93 for (long i = 0; i < numSources; i++) { 94 float flux = powf(10.0, -0.4 * mag->data.F32[i]); // Flux of source 95 float xSrc = x->data.F32[i], ySrc = y->data.F32[i]; // Coordinates of source 105 96 106 97 if (normalisePeak) { … … 126 117 continue; 127 118 } 119 128 120 if (circularise && !circulariseModel(fakeModel)) { 129 121 psError(PS_ERR_UNKNOWN, false, "Unable to circularise PSF model."); … … 137 129 138 130 pmSource *fakeSource = pmSourceAlloc(); // Fake source to generate 139 fakeSource->peak = pmPeakAlloc(x , y, fakeModel->params->data.F32[PM_PAR_I0], PM_PEAK_LONE);131 fakeSource->peak = pmPeakAlloc(xSrc, ySrc, fakeModel->params->data.F32[PM_PAR_I0], PM_PEAK_LONE); 140 132 float fakeRadius = radius > 0 ? radius : 141 133 PS_MAX(1.0, fakeModel->modelRadius(fakeModel->params, minFlux)); // Radius of fake source 142 134 143 135 if (xOffset) { 144 if (!pmSourceDefinePixels(fakeSource, readout, x + xOffset->data.S32[i],145 y + yOffset->data.S32[i], fakeRadius)) {136 if (!pmSourceDefinePixels(fakeSource, readout, xSrc + xOffset->data.S32[i], 137 ySrc + yOffset->data.S32[i], fakeRadius)) { 146 138 psErrorClear(); 147 139 continue; … … 153 145 } 154 146 } else { 155 if (!pmSourceDefinePixels(fakeSource, readout, x , y, fakeRadius)) {147 if (!pmSourceDefinePixels(fakeSource, readout, xSrc, ySrc, fakeRadius)) { 156 148 psErrorClear(); 157 149 continue; … … 168 160 return true; 169 161 } 162 163 164 165 166 167 168 169 170 bool pmReadoutFakeFromSources(pmReadout *readout, int numCols, int numRows, const psArray *sources, 171 const psVector *xOffset, const psVector *yOffset, const pmPSF *psf, 172 float minFlux, int radius, bool circularise, bool normalisePeak) 173 { 174 PS_ASSERT_ARRAY_NON_NULL(sources, false); 175 176 int numSources = sources->n; // Number of stars 177 psVector *x = psVectorAllocEmpty(numSources, PS_TYPE_F32); 178 psVector *y = psVectorAllocEmpty(numSources, PS_TYPE_F32); 179 psVector *mag = psVectorAllocEmpty(numSources, PS_TYPE_F32); 180 181 int numGood = 0; // Number of good sources 182 for (int i = 0; i < numSources; i++) { 183 pmSource *source = sources->data[i]; // Source of interest 184 if (!source) { 185 continue; 186 } 187 if (source->mode & SOURCE_MASK) { 188 continue; 189 } 190 if (!isfinite(source->psfMag)) { 191 continue; 192 } 193 float xSrc, ySrc; // Coordinates of source 194 if (source->modelPSF) { 195 xSrc = source->modelPSF->params->data.F32[PM_PAR_XPOS]; 196 ySrc = source->modelPSF->params->data.F32[PM_PAR_YPOS]; 197 } else { 198 xSrc = source->peak->xf; 199 ySrc = source->peak->yf; 200 } 201 202 x->data.F32[numGood] = xSrc; 203 y->data.F32[numGood] = ySrc; 204 mag->data.F32[numGood] = source->psfMag; 205 numGood++; 206 } 207 x->n = numGood; 208 y->n = numGood; 209 mag->n = numGood; 210 211 bool status = pmReadoutFakeFromVectors(readout, numCols, numRows, x, y, mag, xOffset, yOffset, psf, 212 minFlux, radius, circularise, normalisePeak); 213 psFree(x); 214 psFree(y); 215 psFree(mag); 216 217 return status; 218 } -
branches/pap/psModules/src/camera/pmReadoutFake.h
r20999 r25028 12 12 #include <pmPSF.h> 13 13 14 /// Generate a fake readout from vectors of position and magnitude 15 bool pmReadoutFakeFromVectors( 16 pmReadout *readout, ///< Output readout, or NULL 17 int numCols, int numRows, ///< Dimension of image 18 const psVector *x, const psVector *y, ///< Coordinates of sources 19 const psVector *mag, ///< Magnitudes of sources 20 const psVector *xOffset, ///< x offsets for sources (source -> img), or NULL 21 const psVector *yOffset, ///< y offsets for sources (source -> img), or NULL 22 const pmPSF *psf, ///< PSF for sources 23 float minFlux, ///< Minimum flux to bother about; for setting source radius 24 int radius, ///< Fixed radius for sources 25 bool circularise, ///< Circularise PSF model? 26 bool normalise ///< Normalise the peak value? 27 ); 28 29 14 30 /// Generate a fake readout from an array of sources 15 bool pmReadoutFakeFromSources(pmReadout *readout, ///< Output readout, or NULL 16 int numCols, int numRows, ///< Dimension of image 17 const psArray *sources, ///< Array of pmSource 18 const psVector *xOffset, ///< x offsets for sources (source -> img), or NULL 19 const psVector *yOffset, ///< y offsets for sources (source -> img), or NULL 20 const pmPSF *psf, ///< PSF for sources 21 float minFlux, ///< Minimum flux to bother about; for setting source radius 22 int radius, ///< Fixed radius for sources 23 bool circularise, ///< Circularise PSF model? 24 bool normalise ///< Normalise the peak value? 31 bool pmReadoutFakeFromSources( 32 pmReadout *readout, ///< Output readout, or NULL 33 int numCols, int numRows, ///< Dimension of image 34 const psArray *sources, ///< Array of pmSource 35 const psVector *xOffset, ///< x offsets for sources (source -> img), or NULL 36 const psVector *yOffset, ///< y offsets for sources (source -> img), or NULL 37 const pmPSF *psf, ///< PSF for sources 38 float minFlux, ///< Minimum flux to bother about; for setting source radius 39 int radius, ///< Fixed radius for sources 40 bool circularise, ///< Circularise PSF model? 41 bool normalise ///< Normalise the peak value? 25 42 ); 26 43
Note:
See TracChangeset
for help on using the changeset viewer.
