8 #ifndef ccdDetector_hpp
9 #define ccdDetector_hpp
14 #include "../../improc/imageTransforms.hpp"
15 #include "../../math/randomT.hpp"
17 #include "wavefront.hpp"
37 template<
typename _realT>
47 typedef Eigen::Array<realT, Eigen::Dynamic, Eigen::Dynamic> imageT;
93 void qe(
const realT & q);
97 void darkCurrent(
const realT & dc);
101 void ron(
const realT & r);
105 void cic(
const realT &
c);
109 void gain(
const realT & g);
113 void expTime(
const realT &dt);
117 void rows(
const int & r);
121 void cols(
const int &
c);
123 void setSize(
const int &r,
const int &
c);
127 void noNoise(
bool nn);
150 template<
typename realT>
151 ccdDetector<realT>::ccdDetector()
184 template<
typename realT>
190 template<
typename realT>
196 template<
typename realT>
197 realT ccdDetector<realT>::darkCurrent()
199 return m_darkCurrent;
202 template<
typename realT>
203 void ccdDetector<realT>::darkCurrent(
const realT & dc)
208 template<
typename realT>
209 realT ccdDetector<realT>::ron()
214 template<
typename realT>
215 void ccdDetector<realT>::ron(
const realT & r)
220 template<
typename realT>
221 realT ccdDetector<realT>::cic()
226 template<
typename realT>
227 void ccdDetector<realT>::cic(
const realT &
c)
232 template<
typename realT>
233 realT ccdDetector<realT>::gain()
238 template<
typename realT>
239 void ccdDetector<realT>::gain(
const realT & g)
244 template<
typename realT>
245 realT ccdDetector<realT>::expTime()
250 template<
typename realT>
251 void ccdDetector<realT>::expTime(
const realT & dt)
257 template<
typename realT>
258 int ccdDetector<realT>::rows()
263 template<
typename realT>
264 void ccdDetector<realT>::rows(
const int & r)
269 template<
typename realT>
270 int ccdDetector<realT>::cols()
275 template<
typename realT>
276 void ccdDetector<realT>::cols(
const int &
c)
281 template<
typename realT>
282 void ccdDetector<realT>::setSize(
const int & r,
const int &
c)
289 template<
typename realT>
290 bool ccdDetector<realT>::noNoise()
295 template<
typename realT>
296 void ccdDetector<realT>::noNoise(
bool nn)
302 template<
typename realT>
306 using poisson_param_t =
typename std::poisson_distribution<int>::param_type;
307 using gamma_param_t =
typename std::gamma_distribution<realT>::param_type;
311 out.resize(m_rows, m_cols);
319 if(m_noNoise)
return;
321 for(
int i=0;i<m_rows;++i)
323 for(
int j=0; j<m_cols;++j)
325 realT charge = (out(i,j)*m_qe + m_darkCurrent) * m_expTime + m_cic;
329 out(i,j) = charge + m_normVar*sqrt(charge);
333 m_poissonVar.distribution.param(poisson_param_t{charge});
334 out(i,j) = m_poissonVar;
339 m_gammaVar.distribution.param(gamma_param_t{out(i,j), m_gain});
342 out(i,j) = m_gammaVar;
346 out(i,j) += m_normVar*m_ron;
348 if(m_gain > 1) out(i,j) /= m_gain;
350 out(i,j) = round(out(i,j));
A simulated CCD detector.
realT m_ron
The readout noise, electrons per pixel per read #include "mx/randomT.hpp".
realT m_darkCurrent
The dark current, per pixel per second.
realT m_qe
The quantum efficiency.
realT qe()
Get the current value of qe.
realT m_cic
EMCCD clock induced charge, electrons per pixel per read.
int m_cols
The detector size, in columns.
realT m_expTime
The exposure time, in seconds.
norm_distT m_normVar
Gets normal-distributed variates.
gamma_distT m_gammaVar
Gets gamma distributed variates.
int m_rows
The detector size, in rows.
poisson_distT m_poissonVar
Gets Poisson distributed variates.
bool m_noNoise
If true no noise is added to the exposed image.
void exposeImage(imageT &out, imageT &in)
Rebin and add noise to the input image, placing the result in the output image.
realT m_gain
Electron multiplication gain. If >1, then EMCCD is modeled.
A random number type, which functions like any other arithmetic type.
constexpr units::realT c()
The speed of light.
Structure containing the phase and amplitude of a wavefront