lsst.cp.pipe  20.0.0-4-gf68bb90+2
Public Member Functions | Public Attributes | List of all members
lsst.cp.pipe.astierCovPtcFit.CovFit Class Reference

Public Member Functions

def __init__ (self, inputTuple, maxRangeFromTuple=8)
 
def subtractDistantOffset (self, maxLag=8, startLag=5, polDegree=1)
 
def setMaxMu (self, maxMu)
 
def setMaxMuElectrons (self, maxMuEl)
 
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 getMaskVar (self)
 
def setAandB (self, a, b)
 
def chi2 (self)
 
def wres (self, params=None)
 
def weightedRes (self, params=None)
 
def fitFullModel (self, pInit=None, nSigma=5)
 
def ndof (self)
 
def getNormalizedFitData (self, i, j, divideByMu=False)
 
def __call__ (self, params)
 

Public Attributes

 mu
 
 sqrtW
 
 r
 
 cov
 
 vcov
 
 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
For the time being it uses as input a numpy recarray (tuple with named tags) which
contains one row per covariance and per pair: see the routine makeCovArray.

Parameters
----------
inputTuple: `numpy.recarray`
    Tuple 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.

Definition at line 211 of file astierCovPtcFit.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.cp.pipe.astierCovPtcFit.CovFit.__init__ (   self,
  inputTuple,
  maxRangeFromTuple = 8 
)

Definition at line 236 of file astierCovPtcFit.py.

Member Function Documentation

◆ __call__()

def lsst.cp.pipe.astierCovPtcFit.CovFit.__call__ (   self,
  params 
)

Definition at line 656 of file astierCovPtcFit.py.

◆ chi2()

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

Definition at line 511 of file astierCovPtcFit.py.

◆ copy()

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

Definition at line 293 of file astierCovPtcFit.py.

◆ evalCovModel()

def lsst.cp.pipe.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 351 of file astierCovPtcFit.py.

◆ fitFullModel()

def lsst.cp.pipe.astierCovPtcFit.CovFit.fitFullModel (   self,
  pInit = None,
  nSigma = 5 
)
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.

nSigma : `int`
    Sigma cut to get rid of outliers.

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 534 of file astierCovPtcFit.py.

◆ getA()

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

Definition at line 417 of file astierCovPtcFit.py.

◆ getACov()

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

Definition at line 437 of file astierCovPtcFit.py.

◆ getASig()

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

Definition at line 442 of file astierCovPtcFit.py.

◆ getB()

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

Definition at line 421 of file astierCovPtcFit.py.

◆ getBCov()

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

Definition at line 447 of file astierCovPtcFit.py.

◆ getC()

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

Definition at line 425 of file astierCovPtcFit.py.

◆ getCCov()

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

Definition at line 457 of file astierCovPtcFit.py.

◆ getGain()

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

Definition at line 480 of file astierCovPtcFit.py.

◆ getGainErr()

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

Definition at line 462 of file astierCovPtcFit.py.

◆ getMaskVar()

def lsst.cp.pipe.astierCovPtcFit.CovFit.getMaskVar (   self)
Get mask of var = cov[0,0]

Definition at line 498 of file astierCovPtcFit.py.

◆ getNoise()

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

Definition at line 494 of file astierCovPtcFit.py.

◆ getNoiseCov()

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

Definition at line 470 of file astierCovPtcFit.py.

◆ getNoiseSig()

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

Definition at line 475 of file astierCovPtcFit.py.

◆ getNormalizedFitData()

def lsst.cp.pipe.astierCovPtcFit.CovFit.getNormalizedFitData (   self,
  i,
  j,
  divideByMu = False 
)
Get measured signal and covariance, cov model and wigths

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

j: `int`
    Lag for covariance

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

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

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

model: `numpy.array`
    Covariance model(model*gain**2)

weights: `numpy.array`
    Weights(self.sqrtW/gain**2)

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

Definition at line 602 of file astierCovPtcFit.py.

◆ getParamValues()

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

Definition at line 342 of file astierCovPtcFit.py.

◆ getRon()

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

Definition at line 484 of file astierCovPtcFit.py.

◆ getRonErr()

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

Definition at line 488 of file astierCovPtcFit.py.

◆ initFit()

def lsst.cp.pipe.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 301 of file astierCovPtcFit.py.

◆ ndof()

def lsst.cp.pipe.astierCovPtcFit.CovFit.ndof (   self)
Number of degrees of freedom

Returns
-------
mask.sum() - len(self.params.free): `int`
    Number of usable pixels - number of parameters of fit.

Definition at line 590 of file astierCovPtcFit.py.

◆ setAandB()

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

Definition at line 505 of file astierCovPtcFit.py.

◆ setMaxMu()

def lsst.cp.pipe.astierCovPtcFit.CovFit.setMaxMu (   self,
  maxMu 
)
Select signal level based on max average signal in ADU

Definition at line 273 of file astierCovPtcFit.py.

◆ setMaxMuElectrons()

def lsst.cp.pipe.astierCovPtcFit.CovFit.setMaxMuElectrons (   self,
  maxMuEl 
)
Select signal level based on max average signal in electrons

Definition at line 285 of file astierCovPtcFit.py.

◆ setParamValues()

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

Definition at line 346 of file astierCovPtcFit.py.

◆ subtractDistantOffset()

def lsst.cp.pipe.astierCovPtcFit.CovFit.subtractDistantOffset (   self,
  maxLag = 8,
  startLag = 5,
  polDegree = 1 
)
Subtract a background/offset to the measured covariances.

Parameters
---------
maxLag: `int`
    Maximum lag considered

startLag: `int`
    First lag from where to start the offset subtraction.

polDegree: `int`
    Degree of 2D polynomial to fit to covariance to define offse to be subtracted.

Definition at line 241 of file astierCovPtcFit.py.

◆ weightedRes()

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

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

Definition at line 522 of file astierCovPtcFit.py.

◆ wres()

def lsst.cp.pipe.astierCovPtcFit.CovFit.wres (   self,
  params = None 
)
To be used in weightedRes

Definition at line 515 of file astierCovPtcFit.py.

Member Data Documentation

◆ cov

lsst.cp.pipe.astierCovPtcFit.CovFit.cov

Definition at line 267 of file astierCovPtcFit.py.

◆ covParams

lsst.cp.pipe.astierCovPtcFit.CovFit.covParams

Definition at line 586 of file astierCovPtcFit.py.

◆ mu

lsst.cp.pipe.astierCovPtcFit.CovFit.mu

Definition at line 237 of file astierCovPtcFit.py.

◆ params

lsst.cp.pipe.astierCovPtcFit.CovFit.params

Definition at line 308 of file astierCovPtcFit.py.

◆ r

lsst.cp.pipe.astierCovPtcFit.CovFit.r

Definition at line 239 of file astierCovPtcFit.py.

◆ sqrtW

lsst.cp.pipe.astierCovPtcFit.CovFit.sqrtW

Definition at line 238 of file astierCovPtcFit.py.

◆ vcov

lsst.cp.pipe.astierCovPtcFit.CovFit.vcov

Definition at line 268 of file astierCovPtcFit.py.


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