def translate_filter(self, md): """Extract the filter name. Translate a full filter description into a mere filter name. Return "unknown" if the keyword FILTER does not exist in the header, which can happen for some valid Community Pipeline products. Parameters ---------- md : `lsst.daf.base.PropertySet` FITS header metadata. Returns ------- filter : `str` The name of the filter to use in the calib registry. """ if "FILTER" in md: if "OBSTYPE" in md: obstype = md["OBSTYPE"].strip().lower() if "zero" in obstype or "bias" in obstype: return "NONE" filterName = CalibsParseTask.translate_filter(self, md) # TODO (DM-24514): remove workaround if/else if filterName == '_unknown_' and "CALIB_ID" in md: return self._translateFromCalibId("filter", md) else: return CalibsParseTask.translate_filter(self, md) elif "CALIB_ID" in md: return self._translateFromCalibId("filter", md) else: return "unknown"
def getInfo(self, filename): """Retrieve path, calib_hdu, and possibly calibDate. Parameters ---------- filename: `str` Calibration file to inspect. Returns ------- phuInfo : `dict` Primary header unit info. infoList : `list` of `dict` List of file properties to use for each extension. """ phuInfo, infoList = CalibsParseTask.getInfo(self, filename) # In practice, this returns an empty dict # and a list containing an empty dict. for item in infoList: item['path'] = filename try: item['calib_hdu'] = item['hdu'] except KeyError: # calib_hdu is required for the calib registry item['calib_hdu'] = 1 # Try to fetch a date from filename # and use as the calibration dates if not already set found = re.search(r'(\d\d\d\d-\d\d-\d\d)', filename) if found: date = found.group(1) for info in infoList: if 'calibDate' not in info or info['calibDate'] == "unknown": info['calibDate'] = date return phuInfo, infoList
def getInfo(self, filename): """Get information about the image from the filename and/or its contents @param filename: Name of file to inspect @return File properties; list of file properties for each extension """ phuInfo, infoList = CalibsParseTask.getInfo(self, filename) # Single-extension fits without EXTNAME can be a valid CP calibration product # Use info of primary header unit if not infoList: infoList.append(phuInfo) return phuInfo, infoList
def translate_filter(self, md): """Extract the filter name Translate a full filter description into a mere filter name. Return "unknown" if the keyword FILTER does not exist in the header, which can happen for some valid Community Pipeline products. @param md (PropertySet) FITS header metadata """ if not md.exists("FILTER"): return "unknown" return CalibsParseTask.translate_filter(self, md)
def translate_filter(self, md): """Extract the filter name Translate a full filter description into a mere filter name. Return "unknown" if the keyword FILTER does not exist in the header, which can happen for some valid Community Pipeline products. @param md (PropertySet) FITS header metadata """ if md.exists("FILTER"): if md.exists("OBSTYPE") and "zero" in md.get("OBSTYPE").strip().lower(): return "NONE" return CalibsParseTask.translate_filter(self, md) elif md.exists("CALIB_ID"): return self._translateFromCalibId("filter", md) else: return "unknown"
def getInfo(self, filename): """Get information about the image from the filename and/or its contents @param filename: Name of file to inspect @return File properties; list of file properties for each extension """ phuInfo, infoList = CalibsParseTask.getInfo(self, filename) # Single-extension fits without EXTNAME can be a valid CP calibration product # Use info of primary header unit if not infoList: infoList.append(phuInfo) for info in infoList: info['path'] = filename # Try to fetch a date from filename # and use as the calibration dates if not already set found = re.search('(\d\d\d\d-\d\d-\d\d)', filename) if not found: return phuInfo, infoList date = found.group(1) for info in infoList: if 'calibDate' not in info or info['calibDate'] == "unknown": info['calibDate'] = date return phuInfo, infoList
def getInfo(self, filename): """Get information about the image from the filename and/or its contents. Parameters ---------- filename: `str` Name of file to inspect. Returns ------- phuInfo : `dict` Primary header unit info. infoList : `list` of `dict` File properties; list of file properties for each extension. """ phuInfo, infoList = CalibsParseTask.getInfo(self, filename) # Single-extension fits without EXTNAME can be a valid CP calibration product # Use info of primary header unit if not infoList: infoList.append(phuInfo) for info in infoList: info['path'] = filename # Try to fetch a date from filename # and use as the calibration dates if not already set found = re.search(r'(\d\d\d\d-\d\d-\d\d)', filename) for item in infoList: try: item['calib_hdu'] = item['hdu'] except KeyError: # workaround for pre- DM-19730 defect ingestion item['calib_hdu'] = 1 if not found: return phuInfo, infoList date = found.group(1) for info in infoList: if 'calibDate' not in info or info['calibDate'] == "unknown": info['calibDate'] = date return phuInfo, infoList