LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
Classes | Functions
lsst.cp.pipe.astierCovPtcFit Namespace Reference

Classes

class  CovFit
 
class  Pol2d
 

Functions

def computeApproximateAcoeffs (covModel, muEl, gain)
 
def makeCovArray (inputTuple, maxRangeFromTuple=8)
 
def symmetrize (inputArray)
 

Function Documentation

◆ computeApproximateAcoeffs()

def lsst.cp.pipe.astierCovPtcFit.computeApproximateAcoeffs (   covModel,
  muEl,
  gain 
)
Compute the "a" coefficients of the Antilogus+14 (1402.0725) model as in
Guyonnet+15 (1501.01577, eq. 16, the slope of cov/var at a given flux mu in electrons).

Eq. 16 of 1501.01577 is an approximation to the more complete model in Astier+19 (1905.08677).

Parameters
---------
covModel : `list`
    Covariance model from Eq. 20 in Astier+19.

muEl : `np.array`
    Mean signal in electrons

gain : `float`
    Gain in e-/ADU.

Returns
-------
aCoeffsOld: `numpy.array`
    Slope of cov/var at a given flux mu in electrons.

Notes
-----
Returns the "a" array, computed this way, to be compared to the actual a_array from the full model
(fit.geA()).

Definition at line 35 of file astierCovPtcFit.py.

35 def computeApproximateAcoeffs(covModel, muEl, gain):
36  """Compute the "a" coefficients of the Antilogus+14 (1402.0725) model as in
37  Guyonnet+15 (1501.01577, eq. 16, the slope of cov/var at a given flux mu in electrons).
38 
39  Eq. 16 of 1501.01577 is an approximation to the more complete model in Astier+19 (1905.08677).
40 
41  Parameters
42  ---------
43  covModel : `list`
44  Covariance model from Eq. 20 in Astier+19.
45 
46  muEl : `np.array`
47  Mean signal in electrons
48 
49  gain : `float`
50  Gain in e-/ADU.
51 
52  Returns
53  -------
54  aCoeffsOld: `numpy.array`
55  Slope of cov/var at a given flux mu in electrons.
56 
57  Notes
58  -----
59  Returns the "a" array, computed this way, to be compared to the actual a_array from the full model
60  (fit.geA()).
61  """
62  covModel = np.array(covModel)
63  var = covModel[0, 0, 0] # ADU^2
64  # For a result in electrons^-1, we have to use mu in electrons.
65  return covModel[0, :, :]/(var*muEl)
66 
67 

◆ makeCovArray()

def lsst.cp.pipe.astierCovPtcFit.makeCovArray (   inputTuple,
  maxRangeFromTuple = 8 
)
Make covariances array from tuple.

Parameters
----------
inputTuple: `numpy.recarray`
    Recarray with rows with at least (mu, cov, var, i, j, npix), where:
    mu : 0.5*(m1 + m2), where:
        mu1: mean value of flat1
        mu2: mean value of flat2
    cov: covariance value at lag(i, j)
    var: variance(covariance value at lag(0, 0))
    i: lag dimension
    j: lag dimension
    npix: number of pixels used for covariance calculation.

maxRangeFromTuple: `int`
    Maximum range to select from tuple.

Returns
-------
cov: `numpy.array`
    Covariance arrays, indexed by mean signal mu.

vCov: `numpy.array`
    Variance arrays, indexed by mean signal mu.

muVals: `numpy.array`
    List of mean signal values.

Notes
-----

The input tuple should contain  the following rows:
(mu, cov, var, i, j, npix), with one entry per lag, and image pair.
Different lags(i.e. different i and j) from the same
image pair have the same values of mu1 and mu2. When i==j==0, cov
= var.

If the input tuple contains several video channels, one should
select the data of a given channel *before* entering this
routine, as well as apply(e.g.) saturation cuts.

The routine returns cov[k_mu, j, i], vcov[(same indices)], and mu[k]
where the first index of cov matches the one in mu.

This routine implements the loss of variance due to
clipping cuts when measuring variances and covariance, but this should happen inside
the measurement code, where the cuts are readily available.

Definition at line 68 of file astierCovPtcFit.py.

68 def makeCovArray(inputTuple, maxRangeFromTuple=8):
69  """Make covariances array from tuple.
70 
71  Parameters
72  ----------
73  inputTuple: `numpy.recarray`
74  Recarray with rows with at least (mu, cov, var, i, j, npix), where:
75  mu : 0.5*(m1 + m2), where:
76  mu1: mean value of flat1
77  mu2: mean value of flat2
78  cov: covariance value at lag(i, j)
79  var: variance(covariance value at lag(0, 0))
80  i: lag dimension
81  j: lag dimension
82  npix: number of pixels used for covariance calculation.
83 
84  maxRangeFromTuple: `int`
85  Maximum range to select from tuple.
86 
87  Returns
88  -------
89  cov: `numpy.array`
90  Covariance arrays, indexed by mean signal mu.
91 
92  vCov: `numpy.array`
93  Variance arrays, indexed by mean signal mu.
94 
95  muVals: `numpy.array`
96  List of mean signal values.
97 
98  Notes
99  -----
100 
101  The input tuple should contain the following rows:
102  (mu, cov, var, i, j, npix), with one entry per lag, and image pair.
103  Different lags(i.e. different i and j) from the same
104  image pair have the same values of mu1 and mu2. When i==j==0, cov
105  = var.
106 
107  If the input tuple contains several video channels, one should
108  select the data of a given channel *before* entering this
109  routine, as well as apply(e.g.) saturation cuts.
110 
111  The routine returns cov[k_mu, j, i], vcov[(same indices)], and mu[k]
112  where the first index of cov matches the one in mu.
113 
114  This routine implements the loss of variance due to
115  clipping cuts when measuring variances and covariance, but this should happen inside
116  the measurement code, where the cuts are readily available.
117 
118  """
119  if maxRangeFromTuple is not None:
120  cut = (inputTuple['i'] < maxRangeFromTuple) & (inputTuple['j'] < maxRangeFromTuple)
121  cutTuple = inputTuple[cut]
122  else:
123  cutTuple = inputTuple
124  # increasing mu order, so that we can group measurements with the same mu
125  muTemp = cutTuple['mu']
126  ind = np.argsort(muTemp)
127 
128  cutTuple = cutTuple[ind]
129  # should group measurements on the same image pairs(same average)
130  mu = cutTuple['mu']
131  xx = np.hstack(([mu[0]], mu))
132  delta = xx[1:] - xx[:-1]
133  steps, = np.where(delta > 0)
134  ind = np.zeros_like(mu, dtype=int)
135  ind[steps] = 1
136  ind = np.cumsum(ind) # this acts as an image pair index.
137  # now fill the 3-d cov array(and variance)
138  muVals = np.array(np.unique(mu))
139  i = cutTuple['i'].astype(int)
140  j = cutTuple['j'].astype(int)
141  c = 0.5*cutTuple['cov']
142  n = cutTuple['npix']
143  v = 0.5*cutTuple['var']
144  # book and fill
145  cov = np.ndarray((len(muVals), np.max(i)+1, np.max(j)+1))
146  var = np.zeros_like(cov)
147  cov[ind, i, j] = c
148  var[ind, i, j] = v**2/n
149  var[:, 0, 0] *= 2 # var(v) = 2*v**2/N
150  # compensate for loss of variance and covariance due to outlier elimination(sigma clipping)
151  # when computing variances(cut to 4 sigma): 1 per mill for variances and twice as
152  # much for covariances:
153  fact = 1.0 # 1.00107
154  cov *= fact*fact
155  cov[:, 0, 0] /= fact
156 
157  return cov, var, muVals
158 
159 

◆ symmetrize()

def lsst.cp.pipe.astierCovPtcFit.symmetrize (   inputArray)
Copy array over 4 quadrants prior to convolution.

Parameters
----------
inputarray: `numpy.array`
    Input array to symmetrize.

Returns
-------
aSym: `numpy.array`
    Symmetrized array.

Definition at line 160 of file astierCovPtcFit.py.

160 def symmetrize(inputArray):
161  """ Copy array over 4 quadrants prior to convolution.
162 
163  Parameters
164  ----------
165  inputarray: `numpy.array`
166  Input array to symmetrize.
167 
168  Returns
169  -------
170  aSym: `numpy.array`
171  Symmetrized array.
172  """
173 
174  targetShape = list(inputArray.shape)
175  r1, r2 = inputArray.shape[-1], inputArray.shape[-2]
176  targetShape[-1] = 2*r1-1
177  targetShape[-2] = 2*r2-1
178  aSym = np.ndarray(tuple(targetShape))
179  aSym[..., r2-1:, r1-1:] = inputArray
180  aSym[..., r2-1:, r1-1::-1] = inputArray
181  aSym[..., r2-1::-1, r1-1::-1] = inputArray
182  aSym[..., r2-1::-1, r1-1:] = inputArray
183 
184  return aSym
185 
186 
lsst.cp.pipe.astierCovPtcFit.makeCovArray
def makeCovArray(inputTuple, maxRangeFromTuple=8)
Definition: astierCovPtcFit.py:68
lsst.cp.pipe.astierCovPtcFit.computeApproximateAcoeffs
def computeApproximateAcoeffs(covModel, muEl, gain)
Definition: astierCovPtcFit.py:35
list
daf::base::PropertyList * list
Definition: fits.cc:913
lsst.cp.pipe.astierCovPtcFit.symmetrize
def symmetrize(inputArray)
Definition: astierCovPtcFit.py:160