LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
Public Member Functions | Static Public Attributes | List of all members
lsst.pipe.tasks.ingestCalibs.CalibsRegisterTask Class Reference
Inheritance diagram for lsst.pipe.tasks.ingestCalibs.CalibsRegisterTask:
lsst.pipe.tasks.ingest.RegisterTask

Public Member Functions

def openRegistry (self, directory, create=False, dryrun=False, name="calibRegistry.sqlite3")
 
def createTable (self, conn, forceCreateTables=False)
 
def addRow (self, conn, info, *args, **kwargs)
 
def updateValidityRanges (self, conn, validity, tables=None)
 
def fixSubsetValidity (self, conn, table, detectorData, validity)
 

Static Public Attributes

 ConfigClass = CalibsRegisterConfig
 

Detailed Description

Task that will generate the calibration registry for the Mapper

Definition at line 102 of file ingestCalibs.py.

Member Function Documentation

◆ addRow()

def lsst.pipe.tasks.ingestCalibs.CalibsRegisterTask.addRow (   self,
  conn,
  info,
args,
**  kwargs 
)
Add a row to the file table

Reimplemented from lsst.pipe.tasks.ingest.RegisterTask.

Definition at line 115 of file ingestCalibs.py.

115 def addRow(self, conn, info, *args, **kwargs):
116 """Add a row to the file table"""
117 info[self.config.validStart] = None
118 info[self.config.validEnd] = None
119 RegisterTask.addRow(self, conn, info, *args, **kwargs)
120

◆ createTable()

def lsst.pipe.tasks.ingestCalibs.CalibsRegisterTask.createTable (   self,
  conn,
  forceCreateTables = False 
)
Create the registry tables

Reimplemented from lsst.pipe.tasks.ingest.RegisterTask.

Definition at line 110 of file ingestCalibs.py.

110 def createTable(self, conn, forceCreateTables=False):
111 """Create the registry tables"""
112 for table in self.config.tables:
113 RegisterTask.createTable(self, conn, table=table, forceCreateTables=forceCreateTables)
114

◆ fixSubsetValidity()

def lsst.pipe.tasks.ingestCalibs.CalibsRegisterTask.fixSubsetValidity (   self,
  conn,
  table,
  detectorData,
  validity 
)
Update the validity ranges among selected rows in the registry.

For defects and qe_curve, the products are valid from their start date until
they are superseded by subsequent defect data.
For other calibration products, the validity ranges are checked and
if there are overlaps, a midpoint is used to fix the overlaps,
so that the calibration data with whose date is nearest the date
of the observation is used.

DM generated calibrations contain a CALIB_ID header
keyword. These calibrations likely require the
incrementValidEnd configuration option set to True.  Other
calibrations generate the calibDate via the DATE-OBS header
keyword, and likely require incrementValidEnd=False.

@param conn: Database connection
@param table: Name of table to be selected
@param detectorData: Values identifying a detector (from columns in self.config.detector)
@param validity: Validity range (days)

Definition at line 139 of file ingestCalibs.py.

139 def fixSubsetValidity(self, conn, table, detectorData, validity):
140 """Update the validity ranges among selected rows in the registry.
141
142 For defects and qe_curve, the products are valid from their start date until
143 they are superseded by subsequent defect data.
144 For other calibration products, the validity ranges are checked and
145 if there are overlaps, a midpoint is used to fix the overlaps,
146 so that the calibration data with whose date is nearest the date
147 of the observation is used.
148
149 DM generated calibrations contain a CALIB_ID header
150 keyword. These calibrations likely require the
151 incrementValidEnd configuration option set to True. Other
152 calibrations generate the calibDate via the DATE-OBS header
153 keyword, and likely require incrementValidEnd=False.
154
155 @param conn: Database connection
156 @param table: Name of table to be selected
157 @param detectorData: Values identifying a detector (from columns in self.config.detector)
158 @param validity: Validity range (days)
159 """
160 columns = ", ".join([self.config.calibDate, self.config.validStart, self.config.validEnd])
161 sql = "SELECT id, %s FROM %s" % (columns, table)
162 sql += " WHERE " + " AND ".join(col + "=?" for col in self.config.detector)
163 sql += " ORDER BY " + self.config.calibDate
164 cursor = conn.cursor()
165 cursor.execute(sql, detectorData)
166 rows = cursor.fetchall()
167
168 try:
169 valids = collections.OrderedDict([(_convertToDate(row[self.config.calibDate]), [None, None]) for
170 row in rows])
171 except Exception:
172 det = " ".join("%s=%s" % (k, v) for k, v in zip(self.config.detector, detectorData))
173 self.log.warning("Skipped setting the validity overlaps for %s %s: missing calibration dates",
174 table, det)
175 return
176 dates = list(valids.keys())
177 if table in self.config.validityUntilSuperseded:
178 # A calib is valid until it is superseded
179 for thisDate, nextDate in zip(dates[:-1], dates[1:]):
180 valids[thisDate][0] = thisDate
181 valids[thisDate][1] = nextDate
182 valids[dates[-1]][0] = dates[-1]
183 valids[dates[-1]][1] = _convertToDate("2037-12-31") # End of UNIX time
184 else:
185 # A calib is valid within the validity range (in days) specified.
186 for dd in dates:
187 valids[dd] = [dd - datetime.timedelta(validity), dd + datetime.timedelta(validity)]
188 # Fix the dates so that they do not overlap, which can cause the butler to find a
189 # non-unique calib.
190 midpoints = [t1 + (t2 - t1)//2 for t1, t2 in zip(dates[:-1], dates[1:])]
191 for i, (date, midpoint) in enumerate(zip(dates[:-1], midpoints)):
192 if valids[date][1] > midpoint:
193 nextDate = dates[i + 1]
194 valids[nextDate][0] = midpoint + datetime.timedelta(1)
195 if self.config.incrementValidEnd:
196 valids[date][1] = midpoint + datetime.timedelta(1)
197 else:
198 valids[date][1] = midpoint
199 del midpoints
200 del dates
201 # Update the validity data in the registry
202 for row in rows:
203 calibDate = _convertToDate(row[self.config.calibDate])
204 validStart = valids[calibDate][0].isoformat()
205 validEnd = valids[calibDate][1].isoformat()
206 sql = "UPDATE %s" % table
207 sql += " SET %s=?, %s=?" % (self.config.validStart, self.config.validEnd)
208 sql += " WHERE id=?"
209 conn.execute(sql, (validStart, validEnd, row["id"]))
210
211
daf::base::PropertyList * list
Definition: fits.cc:913

◆ openRegistry()

def lsst.pipe.tasks.ingestCalibs.CalibsRegisterTask.openRegistry (   self,
  directory,
  create = False,
  dryrun = False,
  name = "calibRegistry.sqlite3" 
)
Open the registry and return the connection handle

Reimplemented from lsst.pipe.tasks.ingest.RegisterTask.

Definition at line 106 of file ingestCalibs.py.

106 def openRegistry(self, directory, create=False, dryrun=False, name="calibRegistry.sqlite3"):
107 """Open the registry and return the connection handle"""
108 return RegisterTask.openRegistry(self, directory, create, dryrun, name)
109

◆ updateValidityRanges()

def lsst.pipe.tasks.ingestCalibs.CalibsRegisterTask.updateValidityRanges (   self,
  conn,
  validity,
  tables = None 
)
Loop over all tables, filters, and ccdnums,
and update the validity ranges in the registry.

@param conn: Database connection
@param validity: Validity range (days)

Definition at line 121 of file ingestCalibs.py.

121 def updateValidityRanges(self, conn, validity, tables=None):
122 """Loop over all tables, filters, and ccdnums,
123 and update the validity ranges in the registry.
124
125 @param conn: Database connection
126 @param validity: Validity range (days)
127 """
128 conn.row_factory = sqlite3.Row
129 cursor = conn.cursor()
130 if tables is None:
131 tables = self.config.tables
132 for table in tables:
133 sql = "SELECT DISTINCT %s FROM %s" % (", ".join(self.config.detector), table)
134 cursor.execute(sql)
135 rows = cursor.fetchall()
136 for row in rows:
137 self.fixSubsetValidity(conn, table, row, validity)
138

Member Data Documentation

◆ ConfigClass

lsst.pipe.tasks.ingestCalibs.CalibsRegisterTask.ConfigClass = CalibsRegisterConfig
static

Definition at line 104 of file ingestCalibs.py.


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