LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Public Attributes | List of all members
lsst.jointcal.check_logged_chi2.LogParser Class Reference

Public Member Functions

def __init__ (self, plot=True, verbose=True)
 
def __call__ (self, logfile)
 

Public Attributes

 matcher
 
 plot
 
 verbose
 
 fig
 
 section_start
 
 section_end
 

Detailed Description

Parse a jointcal logfile to extract chi2 values and plot them.

Call the instance with the path to a file to check it for anamolous chi2
and output plots to your current directory.

Parameters
----------
plot : `bool`
    Make plots for each file (saved to the current working directory)?
verbose : `bool`
    Print extra updates during processing?

Definition at line 76 of file check_logged_chi2.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.jointcal.check_logged_chi2.LogParser.__init__ (   self,
  plot = True,
  verbose = True 
)

Definition at line 89 of file check_logged_chi2.py.

89  def __init__(self, plot=True, verbose=True):
90  # This regular expression extracts the chi2 values, and the "kind" of
91  # chi2 (e.g. "Initial", "Fit iteration").
92  # Chi2 values in the log look like this, for example:
93  # jointcal INFO: Initial chi2/ndof : 2.50373e+16/532674=4.7003e+10
94  chi2_re = "jointcal INFO: (?P<kind>.+) chi2/ndof : (?P<chi2>.+)/(?P<ndof>.+)=(?P<reduced_chi2>.+)"
95  self.matcher = re.compile(chi2_re)
96  self.plot = plot
97  self.verbose = verbose
98 
99  # Reuse the Figure to speed up plotting and save memory.
100  self.fig = plt.figure(figsize=(15, 8))
101 
102  # How to find the beginning and end of the relevant parts of the log
103  # to scan for chi2 values.
104  self.section_start = {"astrometry": "Starting astrometric fitting...",
105  "photometry": "Starting photometric fitting..."}
106  self.section_end = {"astrometry": "Updating WCS for visit:",
107  "photometry": "Updating PhotoCalib for visit:"}
108 

Member Function Documentation

◆ __call__()

def lsst.jointcal.check_logged_chi2.LogParser.__call__ (   self,
  logfile 
)
Parse logfile to extract chi2 values and generate and save plots.

The plot output is written to the current directory, with the name
derived from the basename of ``logfile``.

Parameters
----------
logfile : `str`
    The filename of the jointcal log to process.

Definition at line 109 of file check_logged_chi2.py.

109  def __call__(self, logfile):
110  """Parse logfile to extract chi2 values and generate and save plots.
111 
112  The plot output is written to the current directory, with the name
113  derived from the basename of ``logfile``.
114 
115  Parameters
116  ----------
117  logfile : `str`
118  The filename of the jointcal log to process.
119  """
120  title = os.path.basename(logfile)
121  if self.verbose:
122  print("Processing:", title)
123 
124  with open(logfile) as opened_log:
125  # Astrometry is always run first, so we can scan for that until the
126  # end of that section, and then continue scanning for photometry.
127  astrometry = self._extract_chi2(opened_log, "astrometry")
128  increased = self._find_chi2_increase(astrometry, title, "astrometry")
129  photometry = self._extract_chi2(opened_log, "photometry")
130  increased |= self._find_chi2_increase(photometry, title, "photometry")
131 
132  if astrometry is None and photometry is None and self.verbose:
133  print(f"WARNING: No chi2 values found in {logfile}.")
134 
135  if increased or self.plot:
136  self._plot(astrometry, photometry, title)
137  plotfile = f"{os.path.splitext(title)[0]}.png"
138  plt.savefig(plotfile, bbox_inches="tight")
139  print("Saved plot:", plotfile)
140 

Member Data Documentation

◆ fig

lsst.jointcal.check_logged_chi2.LogParser.fig

Definition at line 100 of file check_logged_chi2.py.

◆ matcher

lsst.jointcal.check_logged_chi2.LogParser.matcher

Definition at line 95 of file check_logged_chi2.py.

◆ plot

lsst.jointcal.check_logged_chi2.LogParser.plot

Definition at line 96 of file check_logged_chi2.py.

◆ section_end

lsst.jointcal.check_logged_chi2.LogParser.section_end

Definition at line 106 of file check_logged_chi2.py.

◆ section_start

lsst.jointcal.check_logged_chi2.LogParser.section_start

Definition at line 104 of file check_logged_chi2.py.

◆ verbose

lsst.jointcal.check_logged_chi2.LogParser.verbose

Definition at line 97 of file check_logged_chi2.py.


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