8 """Read defects for a particular sensor from the standard format at a particular root. 13 Path to the top level of the defects tree. This is expected to hold directories 14 named after the sensor names. They are expected to be lower case. 16 The name of the sensor for which to read defects. 18 The identifier for the sensor in question. 23 A dictionary of `lsst.meas.algorithms.Defects`. 24 The key is the validity start time as a `datetime` object. 26 files = glob.glob(os.path.join(root, chip_name,
'*.ecsv'))
27 parts = os.path.split(root)
28 instrument = os.path.split(parts[0])[1]
31 date_str = os.path.splitext(os.path.basename(f))[0]
32 valid_start = dateutil.parser.parse(date_str)
33 defect_dict[valid_start] = Defects.readText(f)
34 check_metadata(defect_dict[valid_start], valid_start, instrument, chip_id, f)
39 """Check that the metadata is complete and self consistent 43 defects : `lsst.meas.algorithms.Defects` 44 Object to retrieve metadata from in order to compare with 45 metadata inferred from the path. 46 valid_start : datetime 47 Start of the validity range for defects 49 Name of the instrument in question 51 Identifier of the sensor in question 53 Path of the file read to produce ``defects`` 62 If the metadata from the path and the metadata encoded 63 in the path do not match for any reason. 65 md = defects.getMetadata()
66 finst = md.get(
'INSTRUME')
67 fchip_id = md.get(
'DETECTOR')
68 fcalib_date = md.get(
'CALIBDATE')
69 if not (finst.lower(), int(fchip_id), fcalib_date) == (instrument.lower(),
70 chip_id, valid_start.isoformat()):
71 raise ValueError(
"Path and file metadata do not agree:\n" +
72 "Path metadata: %s, %s, %s\n"%(instrument, chip_id, valid_start.isoformat()) +
73 "File metadata: %s, %s, %s\n"%(finst, fchip_id, fcalib_date) +
74 "File read from : %s\n"%(f)
79 """Read all defects from the standard format at a particular root. 84 Path to the top level of the defects tree. This is expected to hold directories 85 named after the sensor names. They are expected to be lower case. 86 camera : `lsst.afw.cameraGeom.Camera` 87 The camera that goes with the defects being read. 92 A dictionary of dictionaries of `lsst.meas.algorithms.Defects`. 93 The first key is the sensor name, and the second is the validity 94 start time as a `datetime` object. 96 root = os.path.normpath(root)
97 dirs = os.listdir(root)
98 dirs = [d
for d
in dirs
if os.path.isdir(os.path.join(root, d))]
100 name_map = {det.getName().lower(): det.getName()
for 103 chip_name = os.path.basename(d)
104 chip_id = camera[name_map[chip_name]].getId()
106 return defects_by_chip
def read_all_defects(root, camera)
def read_defects_one_chip(root, chip_name, chip_id)
Fit spatial kernel using approximate fluxes for candidates, and solving a linear system of equations...
def check_metadata(defects, valid_start, instrument, chip_id, f)