LSST Applications  21.0.0-131-g8cabc107+528f53ee53,22.0.0+00495a2688,22.0.0+0ef2527977,22.0.0+11a2aa21cd,22.0.0+269b7e55e3,22.0.0+2c6b6677a3,22.0.0+64c1bc5aa5,22.0.0+7b3a3f865e,22.0.0+e1b6d2281c,22.0.0+ff3c34362c,22.0.1-1-g1b65d06+c95cbdf3df,22.0.1-1-g7058be7+1cf78af69b,22.0.1-1-g7dab645+2a65e40b06,22.0.1-1-g8760c09+64c1bc5aa5,22.0.1-1-g949febb+64c1bc5aa5,22.0.1-1-ga324b9c+269b7e55e3,22.0.1-1-gf9d8b05+ff3c34362c,22.0.1-10-g781e53d+9b51d1cd24,22.0.1-10-gba590ab+b9624b875d,22.0.1-13-g76f9b8d+2c6b6677a3,22.0.1-14-g22236948+57af756299,22.0.1-18-g3db9cf4b+9b7092c56c,22.0.1-18-gb17765a+2264247a6b,22.0.1-2-g8ef0a89+2c6b6677a3,22.0.1-2-gcb770ba+c99495d3c6,22.0.1-24-g2e899d296+4206820b0d,22.0.1-3-g7aa11f2+2c6b6677a3,22.0.1-3-g8c1d971+f253ffa91f,22.0.1-3-g997b569+ff3b2f8649,22.0.1-4-g1930a60+6871d0c7f6,22.0.1-4-g5b7b756+6b209d634c,22.0.1-6-ga02864e+6871d0c7f6,22.0.1-7-g3402376+a1a2182ac4,22.0.1-7-g65f59fa+54b92689ce,master-gcc5351303a+e1b6d2281c,w.2021.32
LSST Data Management Base Package
Public Member Functions | Public Attributes | List of all members
lsst.cp.pipe.ptc.astierCovPtcFit.CovFit Class Reference

Public Member Functions

def __init__ (self, meanSignals, covariances, covsSqrtWeights, maxRangeFromTuple=8, meanSignalsMask=[])
 
def copy (self)
 
def initFit (self)
 
def getParamValues (self)
 
def setParamValues (self, p)
 
def evalCovModel (self, mu=None)
 
def getA (self)
 
def getB (self)
 
def getC (self)
 
def getACov (self)
 
def getASig (self)
 
def getBCov (self)
 
def getCCov (self)
 
def getGainErr (self)
 
def getNoiseCov (self)
 
def getNoiseSig (self)
 
def getGain (self)
 
def getRon (self)
 
def getRonErr (self)
 
def getNoise (self)
 
def getMaskCov (self, i, j)
 
def setAandB (self, a, b)
 
def chi2 (self)
 
def weightedRes (self, params=None)
 
def fitFullModel (self, pInit=None)
 
def getFitData (self, i, j, divideByMu=False, unitsElectrons=False, returnMasked=False)
 

Public Attributes

 mu
 
 cov
 
 sqrtW
 
 r
 
 logger
 
 params
 
 covParams
 

Detailed Description

A class to fit the models in Astier+19 to flat covariances.

This code implements the model(and the fit thereof) described in
Astier+19: https://arxiv.org/pdf/1905.08677.pdf

Parameters
----------
meanSignals : `list`[`float`]
    List with means of the difference image of two flats,
    for a particular amplifier in the detector.

covariances : `list`[`numpy.array`]
    List with 2D covariance arrays at a given mean signal.

covsSqrtWeights : `list`[`numpy.array`]
    List with 2D arrays with weights from `vcov as defined in
    `makeCovArray`: weight = 1/sqrt(vcov).

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

meanSignalMask: `list`[`bool`], optional
    Mask of mean signal 1D array. Use all entries if empty.

Definition at line 149 of file astierCovPtcFit.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.__init__ (   self,
  meanSignals,
  covariances,
  covsSqrtWeights,
  maxRangeFromTuple = 8,
  meanSignalsMask = [] 
)

Definition at line 175 of file astierCovPtcFit.py.

175  def __init__(self, meanSignals, covariances, covsSqrtWeights, maxRangeFromTuple=8, meanSignalsMask=[]):
176  assert (len(meanSignals) == len(covariances))
177  assert (len(covariances) == len(covsSqrtWeights))
178  if len(meanSignalsMask) == 0:
179  meanSignalsMask = np.repeat(True, len(meanSignals))
180  self.mu = meanSignals[meanSignalsMask]
181  self.cov = np.nan_to_num(covariances)[meanSignalsMask]
182  # make it nan safe, replacing nan's with 0 in weights
183  self.sqrtW = np.nan_to_num(covsSqrtWeights)[meanSignalsMask]
184  self.r = maxRangeFromTuple
185  self.logger = lsstLog.Log.getDefaultLogger()
186 

Member Function Documentation

◆ chi2()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.chi2 (   self)
Calculate weighted chi2 of full-model fit.

Definition at line 421 of file astierCovPtcFit.py.

421  def chi2(self):
422  """Calculate weighted chi2 of full-model fit."""
423  return(self.weightedRes()**2).sum()
424 

◆ copy()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.copy (   self)
Make a copy of params

Definition at line 187 of file astierCovPtcFit.py.

187  def copy(self):
188  """Make a copy of params"""
189  cop = copy.deepcopy(self)
190  # deepcopy does not work for FitParameters.
191  if hasattr(self, 'params'):
192  cop.params = self.params.copy()
193  return cop
194 

◆ evalCovModel()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.evalCovModel (   self,
  mu = None 
)
Computes full covariances model (Eq. 20 of Astier+19).

Parameters
----------
mu: `numpy.array`, optional
    List of mean signals.

Returns
-------
covModel: `numpy.array`
    Covariances model.

Notes
-----
By default, computes the covModel for the mu's stored(self.mu).

Returns cov[Nmu, self.r, self.r]. The variance for the PTC is cov[:, 0, 0].
mu and cov are in ADUs and ADUs squared. To use electrons for both,
the gain should be set to 1. This routine implements the model in Astier+19 (1905.08677).

The parameters of the full model for C_ij(mu) ("C_ij" and "mu" in ADU^2 and ADU, respectively)
in Astier+19 (Eq. 20) are:

"a" coefficients (r by r matrix), units: 1/e
"b" coefficients (r by r matrix), units: 1/e
noise matrix (r by r matrix), units: e^2
gain, units: e/ADU

"b" appears in Eq. 20 only through the "ab" combination, which is defined in this code as "c=ab".

Definition at line 245 of file astierCovPtcFit.py.

245  def evalCovModel(self, mu=None):
246  """Computes full covariances model (Eq. 20 of Astier+19).
247 
248  Parameters
249  ----------
250  mu: `numpy.array`, optional
251  List of mean signals.
252 
253  Returns
254  -------
255  covModel: `numpy.array`
256  Covariances model.
257 
258  Notes
259  -----
260  By default, computes the covModel for the mu's stored(self.mu).
261 
262  Returns cov[Nmu, self.r, self.r]. The variance for the PTC is cov[:, 0, 0].
263  mu and cov are in ADUs and ADUs squared. To use electrons for both,
264  the gain should be set to 1. This routine implements the model in Astier+19 (1905.08677).
265 
266  The parameters of the full model for C_ij(mu) ("C_ij" and "mu" in ADU^2 and ADU, respectively)
267  in Astier+19 (Eq. 20) are:
268 
269  "a" coefficients (r by r matrix), units: 1/e
270  "b" coefficients (r by r matrix), units: 1/e
271  noise matrix (r by r matrix), units: e^2
272  gain, units: e/ADU
273 
274  "b" appears in Eq. 20 only through the "ab" combination, which is defined in this code as "c=ab".
275  """
276  sa = (self.r, self.r)
277  a = self.params['a'].full.reshape(sa)
278  c = self.params['c'].full.reshape(sa)
279  gain = self.params['gain'].full[0]
280  noise = self.params['noise'].full.reshape(sa)
281  # pad a with zeros and symmetrize
282  aEnlarged = np.zeros((int(sa[0]*1.5)+1, int(sa[1]*1.5)+1))
283  aEnlarged[0:sa[0], 0:sa[1]] = a
284  aSym = symmetrize(aEnlarged)
285  # pad c with zeros and symmetrize
286  cEnlarged = np.zeros((int(sa[0]*1.5)+1, int(sa[1]*1.5)+1))
287  cEnlarged[0:sa[0], 0:sa[1]] = c
288  cSym = symmetrize(cEnlarged)
289  a2 = fftconvolve(aSym, aSym, mode='same')
290  a3 = fftconvolve(a2, aSym, mode='same')
291  ac = fftconvolve(aSym, cSym, mode='same')
292  (xc, yc) = np.unravel_index(np.abs(aSym).argmax(), a2.shape)
293  range = self.r
294  a1 = a[np.newaxis, :, :]
295  a2 = a2[np.newaxis, xc:xc + range, yc:yc + range]
296  a3 = a3[np.newaxis, xc:xc + range, yc:yc + range]
297  ac = ac[np.newaxis, xc:xc + range, yc:yc + range]
298  c1 = c[np.newaxis, ::]
299  if mu is None:
300  mu = self.mu
301  # assumes that mu is 1d
302  bigMu = mu[:, np.newaxis, np.newaxis]*gain
303  # c(=a*b in Astier+19) also has a contribution to the last term, that is absent for now.
304  covModel = (bigMu/(gain*gain)*(a1*bigMu+2./3.*(bigMu*bigMu)*(a2 + c1)
305  + (1./3.*a3 + 5./6.*ac)*(bigMu*bigMu*bigMu)) + noise[np.newaxis, :, :]/gain**2)
306  # add the Poisson term, and the read out noise (variance)
307  covModel[:, 0, 0] += mu/gain
308 
309  return covModel
310 

◆ fitFullModel()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.fitFullModel (   self,
  pInit = None 
)
Fit measured covariances to full model in Astier+19 (Eq. 20)

Parameters
----------
pInit : `list`
    Initial parameters of the fit.
    len(pInit) = #entries(a) + #entries(c) + #entries(noise) + 1
    len(pInit) = r^2 + r^2 + r^2 + 1, where "r" is the maximum lag considered for the
    covariances calculation, and the extra "1" is the gain.
    If "b" is 0, then "c" is 0, and len(pInit) will have r^2 fewer entries.

Returns
-------
params : `np.array`
    Fit parameters (see "Notes" below).

Notes
-----
The parameters of the full model for C_ij(mu) ("C_ij" and "mu" in ADU^2 and ADU, respectively)
in Astier+19 (Eq. 20) are:

    "a" coefficients (r by r matrix), units: 1/e
    "b" coefficients (r by r matrix), units: 1/e
    noise matrix (r by r matrix), units: e^2
    gain, units: e/ADU

"b" appears in Eq. 20 only through the "ab" combination, which is defined in this code as "c=ab".

Definition at line 442 of file astierCovPtcFit.py.

442  def fitFullModel(self, pInit=None):
443  """Fit measured covariances to full model in Astier+19 (Eq. 20)
444 
445  Parameters
446  ----------
447  pInit : `list`
448  Initial parameters of the fit.
449  len(pInit) = #entries(a) + #entries(c) + #entries(noise) + 1
450  len(pInit) = r^2 + r^2 + r^2 + 1, where "r" is the maximum lag considered for the
451  covariances calculation, and the extra "1" is the gain.
452  If "b" is 0, then "c" is 0, and len(pInit) will have r^2 fewer entries.
453 
454  Returns
455  -------
456  params : `np.array`
457  Fit parameters (see "Notes" below).
458 
459  Notes
460  -----
461  The parameters of the full model for C_ij(mu) ("C_ij" and "mu" in ADU^2 and ADU, respectively)
462  in Astier+19 (Eq. 20) are:
463 
464  "a" coefficients (r by r matrix), units: 1/e
465  "b" coefficients (r by r matrix), units: 1/e
466  noise matrix (r by r matrix), units: e^2
467  gain, units: e/ADU
468 
469  "b" appears in Eq. 20 only through the "ab" combination, which is defined in this code as "c=ab".
470  """
471 
472  if pInit is None:
473  pInit = self.getParamValues()
474  params, paramsCov, _, mesg, ierr = leastsq(self.weightedRes, pInit, full_output=True)
475  self.covParams = paramsCov
476 
477  return params
478 

◆ getA()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getA (   self)
'a' matrix from Astier+19(e.g., Eq. 20)

Definition at line 311 of file astierCovPtcFit.py.

311  def getA(self):
312  """'a' matrix from Astier+19(e.g., Eq. 20)"""
313  return self.params['a'].full.reshape(self.r, self.r)
314 

◆ getACov()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getACov (   self)
Get covariance matrix of "a" coefficients from fit

Definition at line 334 of file astierCovPtcFit.py.

334  def getACov(self):
335  """Get covariance matrix of "a" coefficients from fit"""
336  if self._getCovParams('a') is not None:
337  cova = self._getCovParams('a').reshape((self.r, self.r, self.r, self.r))
338  else:
339  cova = None
340  return cova
341 

◆ getASig()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getASig (   self)
Square root of diagonal of the parameter covariance of the fitted "a" matrix

Definition at line 342 of file astierCovPtcFit.py.

342  def getASig(self):
343  """Square root of diagonal of the parameter covariance of the fitted "a" matrix"""
344  if self._getCovParams('a') is not None:
345  sigA = np.sqrt(self._getCovParams('a').diagonal()).reshape((self.r, self.r))
346  else:
347  sigA = None
348  return sigA
349 

◆ getB()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getB (   self)
'b' matrix from Astier+19(e.g., Eq. 20)

Definition at line 315 of file astierCovPtcFit.py.

315  def getB(self):
316  """'b' matrix from Astier+19(e.g., Eq. 20)"""
317  return self.params['c'].full.reshape(self.r, self.r)/self.getA()
318 

◆ getBCov()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getBCov (   self)
Get covariance matrix of "a" coefficients from fit
b = c /a

Definition at line 350 of file astierCovPtcFit.py.

350  def getBCov(self):
351  """Get covariance matrix of "a" coefficients from fit
352  b = c /a
353  """
354  covb = self._getCovParams('c')
355  aval = self.getA().flatten()
356  factor = np.outer(aval, aval)
357  covb /= factor
358  return covb.reshape((self.r, self.r, self.r, self.r))
359 

◆ getC()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getC (   self)
'c'='ab' matrix from Astier+19(e.g., Eq. 20)

Definition at line 319 of file astierCovPtcFit.py.

319  def getC(self):
320  """'c'='ab' matrix from Astier+19(e.g., Eq. 20)"""
321  return np.array(self.params['c'].full.reshape(self.r, self.r))
322 

◆ getCCov()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getCCov (   self)
Get covariance matrix of "c" coefficients from fit

Definition at line 360 of file astierCovPtcFit.py.

360  def getCCov(self):
361  """Get covariance matrix of "c" coefficients from fit"""
362  cova = self._getCovParams('c')
363  return cova.reshape((self.r, self.r, self.r, self.r))
364 

◆ getFitData()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getFitData (   self,
  i,
  j,
  divideByMu = False,
  unitsElectrons = False,
  returnMasked = False 
)
Get measured signal and covariance, cov model, weigths, and mask at covariance lag (i, j).

Parameters
---------
i: `int`
    Lag for covariance matrix.

j: `int`
    Lag for covariance matrix.

divideByMu: `bool`, optional
    Divide covariance, model, and weights by signal mu?

unitsElectrons : `bool`, optional
    mu, covariance, and model are in ADU (or powers of ADU) If tthis parameter is true, these are
    multiplied by the adequte factors of the gain to return quantities in electrons
    (or powers of electrons).

returnMasked : `bool`, optional
    Use mask (based on weights) in returned arrays (mu, covariance, and model)?

Returns
-------
mu: `numpy.array`
    list of signal values (mu).

covariance: `numpy.array`
    Covariance arrays, indexed by mean signal mu (self.cov[:, i, j]).

covarianceModel: `numpy.array`
    Covariance model (model).

weights: `numpy.array`
    Weights (self.sqrtW)

mask : `numpy.array`, optional
    Boolean mask of the covariance at (i,j).

Notes
-----
Using a CovFit object, selects from (i, j) and returns
mu*gain, self.cov[:, i, j]*gain**2 model*gain**2, and self.sqrtW/gain**2
in electrons or ADU if unitsElectrons=False.

Definition at line 479 of file astierCovPtcFit.py.

479  def getFitData(self, i, j, divideByMu=False, unitsElectrons=False, returnMasked=False):
480  """Get measured signal and covariance, cov model, weigths, and mask at covariance lag (i, j).
481 
482  Parameters
483  ---------
484  i: `int`
485  Lag for covariance matrix.
486 
487  j: `int`
488  Lag for covariance matrix.
489 
490  divideByMu: `bool`, optional
491  Divide covariance, model, and weights by signal mu?
492 
493  unitsElectrons : `bool`, optional
494  mu, covariance, and model are in ADU (or powers of ADU) If tthis parameter is true, these are
495  multiplied by the adequte factors of the gain to return quantities in electrons
496  (or powers of electrons).
497 
498  returnMasked : `bool`, optional
499  Use mask (based on weights) in returned arrays (mu, covariance, and model)?
500 
501  Returns
502  -------
503  mu: `numpy.array`
504  list of signal values (mu).
505 
506  covariance: `numpy.array`
507  Covariance arrays, indexed by mean signal mu (self.cov[:, i, j]).
508 
509  covarianceModel: `numpy.array`
510  Covariance model (model).
511 
512  weights: `numpy.array`
513  Weights (self.sqrtW)
514 
515  mask : `numpy.array`, optional
516  Boolean mask of the covariance at (i,j).
517 
518  Notes
519  -----
520  Using a CovFit object, selects from (i, j) and returns
521  mu*gain, self.cov[:, i, j]*gain**2 model*gain**2, and self.sqrtW/gain**2
522  in electrons or ADU if unitsElectrons=False.
523  """
524  if unitsElectrons:
525  gain = self.getGain()
526  else:
527  gain = 1.0
528 
529  mu = self.mu*gain
530  covariance = self.cov[:, i, j]*(gain**2)
531  covarianceModel = self.evalCovModel()[:, i, j]*(gain**2)
532  weights = self.sqrtW[:, i, j]/(gain**2)
533 
534  # select data used for the fit:
535  mask = self.getMaskCov(i, j)
536  if returnMasked:
537  weights = weights[mask]
538  covarianceModel = covarianceModel[mask]
539  mu = mu[mask]
540  covariance = covariance[mask]
541 
542  if divideByMu:
543  covariance /= mu
544  covarianceModel /= mu
545  weights *= mu
546 
547  return mu, covariance, covarianceModel, weights, mask

◆ getGain()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getGain (   self)
Get gain (e/ADU)

Definition at line 387 of file astierCovPtcFit.py.

387  def getGain(self):
388  """Get gain (e/ADU)"""
389  return self.params['gain'].full[0]
390 

◆ getGainErr()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getGainErr (   self)
Get error on fitted gain parameter

Definition at line 365 of file astierCovPtcFit.py.

365  def getGainErr(self):
366  """Get error on fitted gain parameter"""
367  if self._getCovParams('gain') is not None:
368  gainErr = np.sqrt(self._getCovParams('gain')[0][0])
369  else:
370  gainErr = 0.0
371  return gainErr
372 

◆ getMaskCov()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getMaskCov (   self,
  i,
  j 
)
Get mask of Cov[i,j]

Definition at line 409 of file astierCovPtcFit.py.

409  def getMaskCov(self, i, j):
410  """Get mask of Cov[i,j]"""
411  weights = self.sqrtW[:, i, j]
412  mask = weights != 0
413  return mask
414 

◆ getNoise()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getNoise (   self)
Get noise matrix

Definition at line 405 of file astierCovPtcFit.py.

405  def getNoise(self):
406  """Get noise matrix"""
407  return self.params['noise'].full.reshape(self.r, self.r)
408 

◆ getNoiseCov()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getNoiseCov (   self)
Get covariances of noise matrix from fit

Definition at line 373 of file astierCovPtcFit.py.

373  def getNoiseCov(self):
374  """Get covariances of noise matrix from fit"""
375  covNoise = self._getCovParams('noise')
376  return covNoise.reshape((self.r, self.r, self.r, self.r))
377 

◆ getNoiseSig()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getNoiseSig (   self)
Square root of diagonal of the parameter covariance of the fitted "noise" matrix

Definition at line 378 of file astierCovPtcFit.py.

378  def getNoiseSig(self):
379  """Square root of diagonal of the parameter covariance of the fitted "noise" matrix"""
380  if self._getCovParams('noise') is not None:
381  covNoise = self._getCovParams('noise')
382  noise = np.sqrt(covNoise.diagonal()).reshape((self.r, self.r))
383  else:
384  noise = None
385  return noise
386 

◆ getParamValues()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getParamValues (   self)
Return an array of free parameter values (it is a copy).

Definition at line 236 of file astierCovPtcFit.py.

236  def getParamValues(self):
237  """Return an array of free parameter values (it is a copy)."""
238  return self.params.free + 0.
239 

◆ getRon()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getRon (   self)
Get readout noise (e^2)

Definition at line 391 of file astierCovPtcFit.py.

391  def getRon(self):
392  """Get readout noise (e^2)"""
393  return self.params['noise'].full[0]
394 

◆ getRonErr()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.getRonErr (   self)
Get error on readout noise parameter

Definition at line 395 of file astierCovPtcFit.py.

395  def getRonErr(self):
396  """Get error on readout noise parameter"""
397  ronSqrt = np.sqrt(np.fabs(self.getRon()))
398  if self.getNoiseSig() is not None:
399  noiseSigma = self.getNoiseSig()[0][0]
400  ronErr = 0.5*(noiseSigma/np.fabs(self.getRon()))*ronSqrt
401  else:
402  ronErr = np.nan
403  return ronErr
404 

◆ initFit()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.initFit (   self)
 Performs a crude parabolic fit of the data in order to start
the full fit close to the solution.

Definition at line 195 of file astierCovPtcFit.py.

195  def initFit(self):
196  """ Performs a crude parabolic fit of the data in order to start
197  the full fit close to the solution.
198  """
199  # number of parameters for 'a' array.
200  lenA = self.r*self.r
201  # define parameters: c corresponds to a*b in Astier+19 (Eq. 20).
202  self.params = FitParameters([('a', lenA), ('c', lenA), ('noise', lenA), ('gain', 1)])
203  self.params['gain'] = 1.
204  # c=0 in a first go.
205  self.params['c'].fix(val=0.)
206  # plumbing: extract stuff from the parameter structure
207  a = self.params['a'].full.reshape(self.r, self.r)
208  noise = self.params['noise'].full.reshape(self.r, self.r)
209  gain = self.params['gain'].full[0]
210 
211  # iterate the fit to account for higher orders
212  # the chi2 does not necessarily go down, so one could
213  # stop when it increases
214  oldChi2 = 1e30
215  for _ in range(5):
216  model = np.nan_to_num(self.evalCovModel()) # this computes the full model.
217  # loop on lags
218  for i in range(self.r):
219  for j in range(self.r):
220  # fit a parabola for a given lag
221  parsFit = np.polyfit(self.mu, self.cov[:, i, j] - model[:, i, j],
222  2, w=self.sqrtW[:, i, j])
223  # model equation(Eq. 20) in Astier+19:
224  a[i, j] += parsFit[0]
225  noise[i, j] += parsFit[2]*gain*gain
226  if(i + j == 0):
227  gain = 1./(1/gain+parsFit[1])
228  self.params['gain'].full[0] = gain
229  chi2 = self.chi2()
230  if chi2 > oldChi2:
231  break
232  oldChi2 = chi2
233 
234  return
235 

◆ setAandB()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.setAandB (   self,
  a,
  b 
)
Set "a" and "b" coeffcients forfull Astier+19 model (Eq. 20). "c=a*b".

Definition at line 415 of file astierCovPtcFit.py.

415  def setAandB(self, a, b):
416  """Set "a" and "b" coeffcients forfull Astier+19 model (Eq. 20). "c=a*b"."""
417  self.params['a'].full = a.flatten()
418  self.params['c'].full = a.flatten()*b.flatten()
419  return
420 

◆ setParamValues()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.setParamValues (   self,
  p 
)
Set parameter values.

Definition at line 240 of file astierCovPtcFit.py.

240  def setParamValues(self, p):
241  """Set parameter values."""
242  self.params.free = p
243  return
244 

◆ weightedRes()

def lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.weightedRes (   self,
  params = None 
)
Weighted residuals.

Notes
-----
To be used via:
c = CovFit(meanSignals, covariances, covsSqrtWeights)
c.initFit()
coeffs, cov, _, mesg, ierr = leastsq(c.weightedRes, c.getParamValues(), full_output=True)

Definition at line 425 of file astierCovPtcFit.py.

425  def weightedRes(self, params=None):
426  """Weighted residuals.
427 
428  Notes
429  -----
430  To be used via:
431  c = CovFit(meanSignals, covariances, covsSqrtWeights)
432  c.initFit()
433  coeffs, cov, _, mesg, ierr = leastsq(c.weightedRes, c.getParamValues(), full_output=True)
434  """
435  if params is not None:
436  self.setParamValues(params)
437  covModel = np.nan_to_num(self.evalCovModel())
438  weightedRes = (covModel-self.cov)*self.sqrtW
439 
440  return weightedRes.flatten()
441 

Member Data Documentation

◆ cov

lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.cov

Definition at line 181 of file astierCovPtcFit.py.

◆ covParams

lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.covParams

Definition at line 475 of file astierCovPtcFit.py.

◆ logger

lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.logger

Definition at line 185 of file astierCovPtcFit.py.

◆ mu

lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.mu

Definition at line 180 of file astierCovPtcFit.py.

◆ params

lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.params

Definition at line 202 of file astierCovPtcFit.py.

◆ r

lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.r

Definition at line 184 of file astierCovPtcFit.py.

◆ sqrtW

lsst.cp.pipe.ptc.astierCovPtcFit.CovFit.sqrtW

Definition at line 183 of file astierCovPtcFit.py.


The documentation for this class was generated from the following file: