LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+f5613e8b4f,g1470d8bcf6+190ad2ba91,g14a832a312+311607e4ab,g2079a07aa2+86d27d4dc4,g2305ad1205+a8e3196225,g295015adf3+b67ee847e5,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+a761f810f3,g487adcacf7+17c8fdbcbd,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+65b5bd823e,g5a732f18d5+53520f316c,g64a986408d+f5613e8b4f,g6c1bc301e9+51106c2951,g858d7b2824+f5613e8b4f,g8a8a8dda67+585e252eca,g99cad8db69+6729933424,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+ef4e3a5875,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e9bba80f27,gc120e1dc64+eee469a5e5,gc28159a63d+0e5473021a,gcf0d15dbbd+a761f810f3,gdaeeff99f8+f9a426f77a,ge6526c86ff+d4c1d4bfef,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf1cff7945b+f5613e8b4f,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
lsst.obs.decam.rawFormatter.DarkEnergyCameraRawFormatter Class Reference
Inheritance diagram for lsst.obs.decam.rawFormatter.DarkEnergyCameraRawFormatter:
lsst.obs.decam.rawFormatter.DarkEnergyCameraCPCalibFormatter

Public Member Functions

 getDetector (self, id)
 
 readMetadata (self)
 
 readImage (self)
 

Static Public Attributes

 translatorClass = astro_metadata_translator.DecamTranslator
 
 filterDefinitions = DarkEnergyCamera.filterDefinitions
 
bool wcsFlipX = True
 

Protected Member Functions

 _scanHdus (self, filename, detectorId)
 
 _determineHDU (self, detectorId)
 

Detailed Description

Definition at line 50 of file rawFormatter.py.

Member Function Documentation

◆ _determineHDU()

lsst.obs.decam.rawFormatter.DarkEnergyCameraRawFormatter._determineHDU ( self,
detectorId )
protected
Determine the correct HDU number for a given detector id.

Parameters
----------
detectorId : `int`
    The detector id to search for.

Returns
-------
index : `int`
    The index of the HDU with the requested data.
metadata : `lsst.daf.base.PropertyList`
    The metadata read from the header for that detector id.

Raises
------
ValueError
    Raised if detectorId is not found in any of the file HDUs

Reimplemented in lsst.obs.decam.rawFormatter.DarkEnergyCameraCPCalibFormatter.

Definition at line 98 of file rawFormatter.py.

98 def _determineHDU(self, detectorId):
99 """Determine the correct HDU number for a given detector id.
100
101 Parameters
102 ----------
103 detectorId : `int`
104 The detector id to search for.
105
106 Returns
107 -------
108 index : `int`
109 The index of the HDU with the requested data.
110 metadata : `lsst.daf.base.PropertyList`
111 The metadata read from the header for that detector id.
112
113 Raises
114 ------
115 ValueError
116 Raised if detectorId is not found in any of the file HDUs
117 """
118 filename = self.fileDescriptor.location.path
119 try:
120 index = detector_to_hdu[detectorId]
121 metadata = lsst.afw.fits.readMetadata(filename, index)
122 if metadata['CCDNUM'] != detectorId:
123 # the detector->HDU mapping is different in this file: try scanning
124 return self._scanHdus(filename, detectorId)
125 else:
126 fitsData = lsst.afw.fits.Fits(filename, 'r')
127 fitsData.setHdu(index)
128 return index, metadata
130 # if the file doesn't contain all the HDUs of "normal" files, try scanning
131 return self._scanHdus(filename, detectorId)
132
An exception thrown when problems are found when reading or writing FITS files.
Definition fits.h:36
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition fits.h:308
std::shared_ptr< daf::base::PropertyList > readMetadata(std::string const &fileName, int hdu=DEFAULT_HDU, bool strip=false)
Read FITS header.
Definition fits.cc:1689

◆ _scanHdus()

lsst.obs.decam.rawFormatter.DarkEnergyCameraRawFormatter._scanHdus ( self,
filename,
detectorId )
protected
Scan through a file for the HDU containing data from one detector.

Parameters
----------
filename : `str`
    The file to search through.
detectorId : `int`
    The detector id to search for.

Returns
-------
index : `int`
    The index of the HDU with the requested data.
metadata: `lsst.daf.base.PropertyList`
    The metadata read from the header for that detector id.

Raises
------
ValueError
    Raised if detectorId is not found in any of the file HDUs

Definition at line 62 of file rawFormatter.py.

62 def _scanHdus(self, filename, detectorId):
63 """Scan through a file for the HDU containing data from one detector.
64
65 Parameters
66 ----------
67 filename : `str`
68 The file to search through.
69 detectorId : `int`
70 The detector id to search for.
71
72 Returns
73 -------
74 index : `int`
75 The index of the HDU with the requested data.
76 metadata: `lsst.daf.base.PropertyList`
77 The metadata read from the header for that detector id.
78
79 Raises
80 ------
81 ValueError
82 Raised if detectorId is not found in any of the file HDUs
83 """
84 log = logging.getLogger("lsst.obs.decam.DarkEnergyCameraRawFormatter")
85 log.debug("Did not find detector=%s at expected HDU=%s in %s: scanning through all HDUs.",
86 detectorId, detector_to_hdu[detectorId], filename)
87
88 fitsData = lsst.afw.fits.Fits(filename, 'r')
89 # NOTE: The primary header (HDU=0) does not contain detector data.
90 for i in range(1, fitsData.countHdus()):
91 fitsData.setHdu(i)
92 metadata = fitsData.readMetadata()
93 if metadata['CCDNUM'] == detectorId:
94 return i, metadata
95 else:
96 raise ValueError(f"Did not find detectorId={detectorId} as CCDNUM in any HDU of {filename}.")
97

◆ getDetector()

lsst.obs.decam.rawFormatter.DarkEnergyCameraRawFormatter.getDetector ( self,
id )

Definition at line 59 of file rawFormatter.py.

59 def getDetector(self, id):
60 return DarkEnergyCamera().getCamera()[id]
61

◆ readImage()

lsst.obs.decam.rawFormatter.DarkEnergyCameraRawFormatter.readImage ( self)

Reimplemented in lsst.obs.decam.rawFormatter.DarkEnergyCameraCPCalibFormatter.

Definition at line 138 of file rawFormatter.py.

138 def readImage(self):
139 index, metadata = self._determineHDU(self.dataId['detector'])
140 return lsst.afw.image.ImageI(self.fileDescriptor.location.path, index)
141
142

◆ readMetadata()

lsst.obs.decam.rawFormatter.DarkEnergyCameraRawFormatter.readMetadata ( self)

Definition at line 133 of file rawFormatter.py.

133 def readMetadata(self):
134 index, metadata = self._determineHDU(self.dataId['detector'])
135 astro_metadata_translator.fix_header(metadata)
136 return metadata
137

Member Data Documentation

◆ filterDefinitions

lsst.obs.decam.rawFormatter.DarkEnergyCameraRawFormatter.filterDefinitions = DarkEnergyCamera.filterDefinitions
static

Definition at line 52 of file rawFormatter.py.

◆ translatorClass

lsst.obs.decam.rawFormatter.DarkEnergyCameraRawFormatter.translatorClass = astro_metadata_translator.DecamTranslator
static

Definition at line 51 of file rawFormatter.py.

◆ wcsFlipX

bool lsst.obs.decam.rawFormatter.DarkEnergyCameraRawFormatter.wcsFlipX = True
static

Definition at line 57 of file rawFormatter.py.


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