Пример #1
0
    def get_detector_par(self, hdu, det):
        """
        Return metadata for the selected detector.

        Args:
            hdu (`astropy.io.fits.HDUList`_):
                The open fits file with the raw image of interest.
            det (:obj:`int`):
                1-indexed detector number.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        # Detector 1
        detector_dict = dict(
            binning='1,1',
            det=1,
            dataext=0,
            specaxis=0,
            specflip=False,
            spatflip=False,
            platescale=0.15,
            darkcurr=0.01,
            saturation=
            320000.,  #32000 for low gain, I set to a higher value to keep data in K-band
            nonlinear=0.875,
            mincounts=-1e10,
            numamplifiers=1,
            gain=np.atleast_1d(3.8),
            ronoise=np.atleast_1d(6.0),  # SUTR readout mode with exposure~600s
            datasec=np.atleast_1d('[5:2044, 900:1250]'),
            oscansec=np.atleast_1d('[:5, 900:1250]'))
        return detector_container.DetectorContainer(**detector_dict)
Пример #2
0
    def get_detector_par(self, hdu, det):
        """
        Return metadata for the selected detector.

        Args:
            hdu (`astropy.io.fits.HDUList`_):
                The open fits file with the raw image of interest.
            det (:obj:`int`):
                1-indexed detector number.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        detector_dict = dict(
            det=1,
            binning         ='1,1',  # No binning allowed
            dataext         = 0,
            specaxis        = 0,
            specflip        = False,
            spatflip        = False,
            platescale      = 0.193,
            darkcurr        = 0.8,
            saturation      = 100000.,
            nonlinear       = 1.00,  # docs say linear to 90,000 but our flats are usually higher
            numamplifiers   = 1,
            mincounts       = -1e10,
            gain            = np.atleast_1d(5.8),
            ronoise         = np.atleast_1d(23.),
            datasec         = np.atleast_1d('[:,:]'),
            oscansec        = np.atleast_1d('[:,:]')
            )
        return detector_container.DetectorContainer(**detector_dict)
Пример #3
0
    def get_detector_par(self, hdu, det):
        """
        Return a DectectorContainer for the current image

        Args:
            hdu (`astropy.io.fits.HDUList`):
                HDUList of the image of interest.
                Ought to be the raw file, or else..
            det (int):

        Returns:
            :class:`pypeit.images.detector_container.DetectorContainer`:

        """
        # Detector 1
        detector_dict = dict(
            binning         = '1,1',
            det             = 1,
            dataext         = 0,
            specaxis        = 1,
            specflip        = False,
            spatflip        = False,
            platescale      = 0.1798,
            darkcurr        = 0.8,
            saturation      = 1e9, # ADU, this is hacked for now
            nonlinear       = 1.00,  # docs say linear to 90,000 but our flats are usually higher
            numamplifiers   = 1,
            mincounts       = -1e10,
            gain            = np.atleast_1d(2.15),  # Taken from MOSFIRE detector webpage
            ronoise         = np.atleast_1d(5.8), # This is for 16 non-destructuve reads, the default readout mode
            datasec         = np.atleast_1d('[:,:]'),
            oscansec        = np.atleast_1d('[:,:]')
        )
        return detector_container.DetectorContainer(**detector_dict)
Пример #4
0
    def get_detector_par(self, hdu, det):
        """
        Return metadata for the selected detector.

        Args:
            hdu (`astropy.io.fits.HDUList`_):
                The open fits file with the raw image of interest.
            det (:obj:`int`):
                1-indexed detector number.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        # Detector 1
        detector_dict = dict(
            binning         = '1,1',
            det             = 1,
            dataext         = 0,
            specaxis        = 1,
            specflip        = False,
            spatflip        = False,
            platescale      = 0.1798,
            darkcurr        = 0.8,
            saturation      = 1e9, # ADU, this is hacked for now
            nonlinear       = 1.00,  # docs say linear to 90,000 but our flats are usually higher
            numamplifiers   = 1,
            mincounts       = -1e10,
            gain            = np.atleast_1d(2.15),  # Taken from MOSFIRE detector webpage
            ronoise         = np.atleast_1d(5.8), # This is for 16 non-destructuve reads, the default readout mode
            datasec         = np.atleast_1d('[:,:]'),
            oscansec        = np.atleast_1d('[:,:]')
        )
        return detector_container.DetectorContainer(**detector_dict)
Пример #5
0
def test_io():
    detector = detector_container.DetectorContainer(**def_det)
    detector.to_file(data_path('tmp_detector.fits'), overwrite=True)

    _new_detector = detector.from_file(data_path('tmp_detector.fits'))

    os.remove(data_path('tmp_detector.fits'))
Пример #6
0
    def get_detector_par(self, hdu, det):
        """
        Return metadata for the selected detector.

        Args:
            hdu (`astropy.io.fits.HDUList`_):
                The open fits file with the raw image of interest.
            det (:obj:`int`):
                1-indexed detector number.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        # Detector 1
        detector_dict = dict(
            binning='1,1',
            det=1,
            dataext=1,
            specaxis=0,
            specflip=False,
            spatflip=False,
            platescale=0.2012,
            darkcurr=0.01,
            saturation=700000.,  #155400.,
            nonlinear=1.0,
            mincounts=-1e10,
            numamplifiers=1,
            gain=np.atleast_1d(0.95),
            ronoise=np.atleast_1d(3.14),
            datasec=np.atleast_1d('[:,:]'),
            oscansec=np.atleast_1d('[:,:]'))
        return detector_container.DetectorContainer(**detector_dict)
Пример #7
0
    def get_detector_par(self, hdu, det):
        """
        Return a DectectorContainer for the current image

        Args:
            hdu (`astropy.io.fits.HDUList`):
                HDUList of the image of interest.
                Ought to be the raw file, or else..
            det (int):

        Returns:
            :class:`pypeit.images.detector_container.DetectorContainer`:

        """
        detector_dict = dict(
            det=1,
            binning='1,1',  # No binning allowed
            dataext=0,
            specaxis=0,
            specflip=False,
            spatflip=False,
            platescale=0.193,
            darkcurr=0.8,
            saturation=100000.,
            nonlinear=
            1.00,  # docs say linear to 90,000 but our flats are usually higher
            numamplifiers=1,
            mincounts=-1e10,
            gain=np.atleast_1d(5.8),
            ronoise=np.atleast_1d(23.),
            datasec=np.atleast_1d('[:,:]'),
            oscansec=np.atleast_1d('[:,:]'))
        return detector_container.DetectorContainer(**detector_dict)
Пример #8
0
    def get_detector_par(self, hdu, det):
        # Binning
        xbin = hdu[0].header['CCDXBIN']
        ybin = hdu[0].header['CCDYBIN']
        binning = '{:},{:}'.format(xbin, ybin)

        # Detector 1
        detector_dict = dict(binning=binning,
                             det=1,
                             dataext=0,
                             specaxis=0,
                             specflip=False,
                             spatflip=False,
                             platescale=0.120,
                             darkcurr=0.5,
                             saturation=65535.,
                             nonlinear=0.99,
                             mincounts=-1e10,
                             numamplifiers=4,
                             gain=np.atleast_1d([1.99, 2.06, 1.96, 2.01]),
                             ronoise=np.atleast_1d([3.66, 3.62, 3.72, 3.64]),
                             datasec=np.atleast_1d('[:,:]'),
                             oscansec=np.atleast_1d('[:,:]'))
        detector = detector_container.DetectorContainer(**detector_dict)
        return detector
Пример #9
0
    def get_detector_par(self, hdu, det):
        """
        Return a DectectorContainer for the current image

        Args:
            hdu (`astropy.io.fits.HDUList`):
                HDUList of the image of interest.
                Ought to be the raw file, or else..
            det (int):

        Returns:
            :class:`pypeit.images.detector_container.DetectorContainer`:

        """

        # Detector 1
        detector_dict = dict(
            binning='1,1',
            det=1,
            dataext=0,
            specaxis=0,
            specflip=False,
            spatflip=False,
            platescale=0.15,
            darkcurr=0.01,
            saturation=
            320000.,  #32000 for low gain, I set to a higher value to keep data in K-band
            nonlinear=0.875,
            mincounts=-1e10,
            numamplifiers=1,
            gain=np.atleast_1d(3.8),
            ronoise=np.atleast_1d(6.0),  # SUTR readout mode with exposure~600s
            datasec=np.atleast_1d('[5:2044, 900:1250]'),
            oscansec=np.atleast_1d('[:5, 900:1250]'))
        return detector_container.DetectorContainer(**detector_dict)
Пример #10
0
    def get_detector_par(self, hdu, det):
        """
        Return a DectectorContainer for the current image

        Args:
            hdu (`astropy.io.fits.HDUList`):
                HDUList of the image of interest.
                Ought to be the raw file, or else..
            det (int):

        Returns:
            :class:`pypeit.images.detector_container.DetectorContainer`:

        """
        # Detector 1
        detector_dict = dict(
            binning         = '1,1',
            det             = 1,
            dataext         = 1,
            specaxis        = 0,
            specflip=True,
            spatflip=True,
            platescale      = 0.15,
            darkcurr        = 0.15,
            saturation      = 150000.,
            nonlinear       = 0.71,
            mincounts       = -1e10,
            numamplifiers   = 1,
            gain            = np.atleast_1d(13.5),
            ronoise         = np.atleast_1d(7.0),
            datasec         = np.atleast_1d('[:,:]'),#'[1:1024,1:1022]',
            oscansec        = np.atleast_1d('[:,:]'),#'[1:1024,1:1022]'
        )

        return detector_container.DetectorContainer(**detector_dict)
Пример #11
0
    def get_detector_par(self, det, hdu=None):
        """
        Return metadata for the selected detector.

        Args:
            det (:obj:`int`):
                1-indexed detector number.
            hdu (`astropy.io.fits.HDUList`_, optional):
                The open fits file with the raw image of interest.  If not
                provided, frame-dependent parameters are set to a default.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        # Detector 1
        detector_dict = dict(
            binning='1,1',
            det=1,
            dataext=1,
            specaxis=0,
            specflip=True,
            spatflip=True,
            platescale=0.15,
            darkcurr=0.15,
            saturation=150000.,
            nonlinear=0.71,
            mincounts=-1e10,
            numamplifiers=1,
            gain=np.atleast_1d(13.5),
            ronoise=np.atleast_1d(7.0),
            datasec=np.atleast_1d('[:,:]'),
            oscansec=None,
        )
        return detector_container.DetectorContainer(**detector_dict)
Пример #12
0
    def get_detector_par(self, det, hdu=None):
        """
        Return metadata for the selected detector.

        .. warning::

            Many of the necessary detector parameters are read from the file
            header, meaning the ``hdu`` argument is effectively **required** for
            LTD/DeVeny.  The optional use of ``hdu`` is only viable for
            automatically generated documentation.

        Args:
            det (:obj:`int`):
                1-indexed detector number.
            hdu (`astropy.io.fits.HDUList`_, optional):
                The open fits file with the raw image of interest.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        if hdu is None:
            binning = '1,1'  # Most common use mode
            gain = np.atleast_1d(1.52)  # Hardcoded in the header
            ronoise = np.atleast_1d(4.9)  # Hardcoded in the header
            datasec = np.atleast_1d('[5:512,53:2095]')  # For 1x1 binning
            oscansec = np.atleast_1d('[5:512,5:48]')  # For 1x1 binning
        else:
            binning = self.get_meta_value(self.get_headarr(hdu), 'binning')
            gain = np.atleast_1d(hdu[0].header['GAIN'])
            ronoise = np.atleast_1d(hdu[0].header['RDNOISE'])
            datasec = self.rotate_trimsections(hdu[0].header['TRIMSEC'],
                                               hdu[0].header['NAXIS1'])
            oscansec = self.rotate_trimsections(hdu[0].header['BIASSEC'],
                                                hdu[0].header['NAXIS1'])

        # Detector
        detector_dict = dict(
            binning=binning,
            det=1,
            dataext=0,
            specaxis=1,  # Native spectrum is along the x-axis
            specflip=True,  # DeVeny CCD has blue at the right
            spatflip=False,
            platescale=0.34,  # Arcsec / pixel
            darkcurr=4.5,  # Electrons per hour
            saturation=65535.,  # 16-bit ADC
            nonlinear=0.97,  # Linear to ~97% of saturation
            mincounts=-1e10,
            numamplifiers=1,
            gain=gain,  # See above
            ronoise=ronoise,  # See above
            # Data & Overscan Sections -- Edge tracing can handle slit edges
            datasec=datasec,  # See above
            oscansec=oscansec  # See above
        )
        return detector_container.DetectorContainer(**detector_dict)
Пример #13
0
    def get_detector_par(self, hdu, det):
        # Binning
        binning = self.get_meta_value(
            self.get_headarr(hdu),
            'binning')  # Could this be detector dependent??

        # Detector 1
        detector_dict1 = dict(
            binning=binning,
            det=1,
            dataext=1,
            specaxis=0,
            specflip=False,
            spatflip=False,
            platescale=0.135,
            darkcurr=0.0,
            saturation=65535.,
            nonlinear=0.76,
            mincounts=-1e10,
            numamplifiers=2,
            gain=np.atleast_1d([1.255, 1.18]),
            ronoise=np.atleast_1d([4.64, 4.76]),
        )
        # Detector 2
        detector_dict2 = detector_dict1.copy()
        detector_dict2.update(
            dict(det=2,
                 dataext=2,
                 gain=np.atleast_1d([1.191, 1.162]),
                 ronoise=np.atleast_1d([4.54, 4.62])))

        # Instantiate
        detector_dicts = [detector_dict1, detector_dict2]
        detector = detector_container.DetectorContainer(**detector_dicts[det])

        # Deal with number of amps
        namps = hdu[0].header['NUMAMPS']
        # The website does not give values for single amp per detector so we take the mean
        #   of the values provided
        if namps == 2:
            detector.numamplifiers = 1
            # Long silt mode
            if hdu[0].header['AMPPSIZE'] == '[1:1024,1:4096]':
                idx = 0 if det == 1 else 1  # Vid1 for det=1, Vid4 for det=2
                detector.gain = np.atleast_1d(detector.gain[idx])
                detector.ronoise = np.atleast_1d(detector.ronoise[idx])
            else:
                detector.gain = np.atleast_1d(np.mean(detector.gain))
                detector.ronoise = np.atleast_1d(np.mean(detector.ronoise))
        elif namps == 4:
            pass
        else:
            msgs.error("Did not see this namps coming..")

        # Return
        return detector
Пример #14
0
    def get_detector_par(self, det, hdu=None):
        """
        Return metadata for the selected detector.

        Args:
            det (:obj:`int`):
                1-indexed detector number.
            hdu (`astropy.io.fits.HDUList`_, optional):
                The open fits file with the raw image of interest.  If not
                provided, frame-dependent parameters are set to a default.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        # Detector 1
        detector_dict = dict(
            binning         = '1,1',
            det             = 1,
            dataext         = 0,
            specaxis        = 1,
            specflip        = False,
            spatflip        = False,
            platescale      = 0.25,
            # Dark current nominally is < 360 electrons per hours
            # but the dark subtraction will effectively bring this to 0
            darkcurr        = 0.0,
            # Saturation is 55000, but will be set to dummy value for
            # now
            saturation      = 1e+8,
            # NIR detectors are non-linear even in lower percentages
            # of the full well, thus for precision measurements one
            # should take into account a general non-linearity
            # correction.
            nonlinear       = 0.80,
            mincounts       = -1e10,
            # In fact there are 32 amplifiers, which gain and ronoise
            # are extremely similar to each other, thus it will be
            # mimicked as 1
            numamplifiers   = 1,
            # The readout noise for LUCI are different for
            # different readout modes. The LIR mode values will be
            # commented in and the MER values will be uncommented:
            gain= np.atleast_1d(2.0),
            # ronoise= 10.3,
            ronoise         = np.atleast_1d(4.61),
            datasec=np.atleast_1d('[5:2044,5:2044]'),
            # For Luci the first 4 pixels on each side can
            # technically be used for as a biassec. This is not
            # included here.
            oscansec= np.atleast_1d('[5:2044,1:4]'),
            )
        return detector_container.DetectorContainer(**detector_dict)
Пример #15
0
    def get_detector_par(self, det: int, hdu: Optional[fits.HDUList] = None):
        """
        Return metadata for the selected detector.

        .. warning::

            Many of the necessary detector parameters are read from the file
            header, meaning the ``hdu`` argument is effectively **required** for
            P200/DBSPr.  The optional use of ``hdu`` is only viable for
            automatically generated documentation.

        Args:
            det (:obj:`int`):
                1-indexed detector number.
            hdu (`astropy.io.fits.HDUList`_, optional):
                The open fits file with the raw image of interest.  If not
                provided, frame-dependent parameters are set to a default.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        if hdu is None:
            binning = '1,1'
            datasec = None
            oscansec = None
        else:
            # TODO: Could this be detector dependent??
            binning = self.get_meta_value(self.get_headarr(hdu), 'binning')
            datasec = np.atleast_1d(flip_fits_slice(hdu[0].header['TSEC1']))
            oscansec = np.atleast_1d(flip_fits_slice(hdu[0].header['BSEC1']))

        # Detector 1
        detector_dict = dict(
            binning         = binning,
            det             = 1,
            dataext         = 0,
            specaxis        = 1,
            specflip        = False,
            spatflip        = False, # check
            platescale      = 0.293,
            darkcurr        = 0.0,
            saturation      = 45000.,
            nonlinear       = 40./45.,
            mincounts       = -1e10, # check
            numamplifiers   = 1,
            gain            = np.atleast_1d(2.8),
            ronoise         = np.atleast_1d(8.5),
            datasec         = datasec,
            oscansec        = oscansec
        )
        return detector_container.DetectorContainer(**detector_dict)
Пример #16
0
    def get_detector_par(self, hdu, det):
        """
        Return metadata for the selected detector.

        Args:
            hdu (`astropy.io.fits.HDUList`_):
                The open fits file with the raw image of interest.
            det (:obj:`int`):
                1-indexed detector number.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        # Binning
        binning = self.get_meta_value(self.get_headarr(hdu), 'binning')

        # Detector 1
        detector_dict1 = dict(
            binning=binning,
            det=1,
            dataext=1,
            specaxis=0,
            specflip=False,
            spatflip=False,
            xgap=0.,
            ygap=0.,
            ysize=1.,
            platescale=0.24,
            darkcurr=3.0,  #ToDO: To Be update
            saturation=65535.,
            nonlinear=0.95,  #ToDO: To Be update
            mincounts=-1e10,
            numamplifiers=4,
            gain=np.atleast_1d([1.085, 1.046, 1.042, 0.975]),
            ronoise=np.atleast_1d([3.2, 3.2, 3.2, 3.2]),
        )
        # Detector 2
        detector_dict2 = detector_dict1.copy()
        detector_dict2.update(
            dict(
                det=2,
                dataext=2,
                gain=np.atleast_1d(
                    [1.028, 1.115, 1.047, 1.045]
                ),  #ToDo: FW measures 1.115 for amp2 but 1.163 in IDL pipeline
                ronoise=np.atleast_1d([3.6, 3.6, 3.6, 3.6])))

        # Instantiate
        detector_dicts = [detector_dict1, detector_dict2]
        return detector_container.DetectorContainer(**detector_dicts[det])
Пример #17
0
    def get_detector_par(self, hdu, det):
        """
        Return a DectectorContainer for the current image

        Args:
            hdu (`astropy.io.fits.HDUList`):
                HDUList of the image of interest.
                Ought to be the raw file, or else..
            det (int):

        Returns:
            :class:`pypeit.images.detector_container.DetectorContainer`:

        """
        # Some properties of the image
        head0 = hdu[0].header
        binning = self.compound_meta(self.get_headarr(hdu), "binning")
        numamps = head0['NVIDINP']
        specflip = True if head0['AMPID1'] == 2 else False
        gainmul, gainarr = head0['GAINMUL'], np.zeros(numamps)
        ronarr = np.ones(numamps) * 2.7
        dsecarr = np.array([''] * numamps)

        for ii in range(numamps):
            # Assign the gain for this amplifier
            gainarr[ii] = head0["GAIN{0:1d}".format(ii + 1)] * gainmul

        detector = dict(
            det=det,
            binning=binning,
            dataext=0,
            specaxis=0,
            specflip=specflip,
            spatflip=False,
            xgap=0.,
            ygap=0.,
            ysize=1.,
            platescale=0.147,  # arcsec/pixel
            darkcurr=None,  # <-- TODO : Need to set this
            mincounts=-1e10,
            saturation=65535.,
            nonlinear=0.95,  # For lack of a better number!
            numamplifiers=numamps,
            gain=gainarr,
            ronoise=ronarr,  # <-- TODO : Need to set this for other setups
            datasec=dsecarr.copy(),  # <-- This is provided in the header
            oscansec=dsecarr.copy(),  # <-- This is provided in the header
        )
        # Return
        return detector_container.DetectorContainer(**detector)
Пример #18
0
    def get_detector_par(self, hdu, det):
        # Binning
        binning = self.get_meta_value(
            self.get_headarr(hdu),
            'binning')  # Could this be detector dependent??

        # Detector 1
        detector_dict1 = dict(
            binning=binning,
            det=1,
            dataext=1,
            specaxis=0,
            specflip=False,
            spatflip=False,
            platescale=0.135,
            darkcurr=0.0,
            saturation=65535.,
            nonlinear=0.86,
            mincounts=-1e10,
            numamplifiers=2,
            gain=np.atleast_1d([1.55, 1.56]),
            ronoise=np.atleast_1d([3.9, 4.2]),
        )
        # Detector 2
        detector_dict2 = detector_dict1.copy()
        detector_dict2.update(
            dict(det=2,
                 dataext=2,
                 gain=np.atleast_1d([1.63, 1.70]),
                 ronoise=np.atleast_1d([3.6, 3.6])))

        # Instantiate
        detector_dicts = [detector_dict1, detector_dict2]
        detector = detector_container.DetectorContainer(**detector_dicts[det])

        # Deal with number of amps
        namps = hdu[0].header['NUMAMPS']
        # The website does not give values for single amp per detector so we take the mean
        #   of the values provided
        if namps == 2:
            detector.numamplifiers = 1
            detector.gain = np.atleast_1d(np.mean(detector.gain))
            detector.ronoise = np.atleast_1d(np.mean(detector.ronoise))
        elif namps == 4:
            pass
        else:
            msgs.error("Did not see this namps coming..")

        # Return
        return detector
Пример #19
0
    def get_detector_par(self, hdu, det):
        """
        Return metadata for the selected detector.

        Args:
            hdu (`astropy.io.fits.HDUList`_):
                The open fits file with the raw image of interest.
            det (:obj:`int`):
                1-indexed detector number.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        # Some properties of the image
        head0 = hdu[0].header
        binning = self.compound_meta(self.get_headarr(hdu), "binning")
        numamps = head0['NVIDINP']
        specflip = True if head0['AMPID1'] == 2 else False
        gainmul, gainarr = head0['GAINMUL'], np.zeros(numamps)
        ronarr = np.zeros(
            numamps
        )  # Set this to zero (determine the readout noise from the overscan regions)
        dsecarr = np.array([''] * numamps)

        for ii in range(numamps):
            # Assign the gain for this amplifier
            gainarr[ii] = head0["GAIN{0:1d}".format(ii + 1)]  # * gainmul

        detector = dict(
            det=det,
            binning=binning,
            dataext=0,
            specaxis=0,
            specflip=specflip,
            spatflip=False,
            platescale=0.145728,  # arcsec/pixel
            darkcurr=None,  # <-- TODO : Need to set this
            mincounts=-1e10,
            saturation=65535.,
            nonlinear=0.95,  # For lack of a better number!
            numamplifiers=numamps,
            gain=gainarr,
            ronoise=ronarr,
            datasec=dsecarr.copy(),  # <-- This is provided in the header
            oscansec=dsecarr.copy(),  # <-- This is provided in the header
        )
        # Return
        return detector_container.DetectorContainer(**detector)
Пример #20
0
def test_io():
    detector = detector_container.DetectorContainer(**def_det)
    detector.to_file(data_path('tmp_detector.fits'), overwrite=True)

    _new_detector = detector.from_file(data_path('tmp_detector.fits'))

    # Check a few attributes are equal
    assert detector['dataext'] == _new_detector['dataext'], 'Bad read dataext'
    assert np.array_equal(detector['gain'],
                          _new_detector['gain']), 'Bad read gain'
    assert detector['binning'] == _new_detector['binning'], 'Bad read binning'
    assert np.array_equal(detector['datasec'],
                          _new_detector['datasec']), 'Bad read datasec'

    os.remove(data_path('tmp_detector.fits'))
Пример #21
0
    def get_detector_par(self, hdu, det):
        """
        Return metadata for the selected detector.

        Detector data from `here
        <http://www.not.iac.es/instruments/detectors/CCD14/>`__.

        Args:
            hdu (`astropy.io.fits.HDUList`_):
                The open fits file with the raw image of interest.
            det (:obj:`int`):
                1-indexed detector number.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        # http://www.not.iac.es/instruments/detectors/CCD14/

        # Detector 1
        detector_dict = dict(
            binning=self.get_meta_value(self.get_headarr(hdu), 'binning'),
            det=1,
            dataext=1,
            specaxis=0,
            specflip=True,
            spatflip=False,
            xgap=0.,
            ygap=0.,
            ysize=1.,
            platescale=0.2138,
            mincounts=-1e10,
            darkcurr=1.3,  # e-/pix/hr
            saturation=700000.,  # ADU
            nonlinear=0.86,
            datasec=np.atleast_1d('[:,{}:{}]'.format(1, 2062)),  # Unbinned
            oscansec=None,
            numamplifiers=1,
        )

        # Parse datasec, oscancsec from the header
        head1 = hdu[1].header
        detector_dict['gain'] = np.atleast_1d(head1['GAIN'])  # e-/ADU
        detector_dict['ronoise'] = np.atleast_1d(head1['RDNOISE'])  # e-

        # Return
        return detector_container.DetectorContainer(**detector_dict)
Пример #22
0
    def get_detector_par(self, det, hdu=None):
        """
        Return metadata for the selected detector.

        Args:
            det (:obj:`int`):
                1-indexed detector number.
            hdu (`astropy.io.fits.HDUList`_, optional):
                The open fits file with the raw image of interest.  If not
                provided, frame-dependent parameters are set to a default.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        # Binning
        # TODO: Could this be detector dependent??
        binning = '1,1' if hdu is None else self.get_meta_value(
            self.get_headarr(hdu), 'binning')

        # Detector 1
        detector_dict = dict(
            binning=binning,
            det=1,
            dataext=0,
            specaxis=1,
            specflip=True,
            spatflip=False,
            # plate scale in arcsec/pixel
            platescale=0.3,
            # electrons/pixel/hour. From: http://www.lco.cl/telescopes-information/magellan/instruments/mage/the-mage-spectrograph-user-manual
            darkcurr=1.00,
            saturation=65535.,
            # CCD is linear to better than 0.5 per cent up to digital saturation (65,536 DN including bias) in the Fast readout mode.
            nonlinear=0.99,
            mincounts=-1e10,
            numamplifiers=1,
            gain=np.atleast_1d(1.02),  # depends on the readout
            ronoise=np.atleast_1d(2.9),  # depends on the readout
            datasec=np.atleast_1d('[1:1024, 1:2048]'),
            oscansec=np.atleast_1d('[1:1024, 2049:2176]'),
        )
        # Taken from the MASE paper: https://arxiv.org/pdf/0910.1834.pdf
        #self.norders = 15
        # 20-6
        return detector_container.DetectorContainer(**detector_dict)
Пример #23
0
    def get_detector_par(self, det, hdu=None):
        """
        Return metadata for the selected detector.

        Args:
            det (:obj:`int`):
                1-indexed detector number.
            hdu (`astropy.io.fits.HDUList`_, optional):
                The open fits file with the raw image of interest.  If not
                provided, frame-dependent parameters are set to a default.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        # Detector 1
        detector_dict = dict(
            binning='1,1' if hdu is None else self.get_meta_value(
                self.get_headarr(hdu), 'binning'),
            det=1,
            dataext=0,
            specaxis=1,
            specflip=True,
            spatflip=False,
            xgap=0.,
            ygap=0.,
            ysize=1.,
            platescale=0.273,
            mincounts=-1e10,
            darkcurr=0.0,
            saturation=65535.,
            nonlinear=0.86,
            numamplifiers=4,
            gain=np.atleast_1d([2.2, 2.2, 2.2, 2.2]),
            ronoise=np.atleast_1d([5.0, 5.0, 5.0, 5.0]),
            datasec=np.atleast_1d([
                '[9:509,33:2064]', '[509:,33:2064]', '[9:509, 2065:4092',
                '[509:, 2065:4092'
            ]),
            oscansec=np.atleast_1d([
                '[9:509, 1:32]', '[509:, 1:32]', '[9:509, 4098:]',
                '[509:, 4098:]'
            ]),
        )
        # Return
        return detector_container.DetectorContainer(**detector_dict)
Пример #24
0
    def get_detector_par(self, hdu: fits.HDUList, det: int):
        """
        Return metadata for the selected detector.

        Args:
            hdu (`astropy.io.fits.HDUList`_):
                The open fits file with the raw image of interest.
            det (:obj:`int`):
                1-indexed detector number.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        # Binning
        binning = self.get_meta_value(
            self.get_headarr(hdu),
            'binning')  # Could this be detector dependent??

        # Detector 1
        detector_dict = dict(
            binning=binning,
            det=1,
            dataext=0,
            specaxis=1,
            specflip=False,
            spatflip=False,  # check
            platescale=0.293,
            darkcurr=0.0,
            saturation=45000.,
            nonlinear=40. / 45.,
            mincounts=-1e10,  # check
            numamplifiers=1,
            gain=np.atleast_1d(2.8),
            ronoise=np.atleast_1d(8.5))

        header = hdu[0].header

        datasec = header['TSEC1']
        oscansec = header['BSEC1']

        detector_dict['datasec'] = np.atleast_1d(flip_fits_slice(datasec))
        detector_dict['oscansec'] = np.atleast_1d(flip_fits_slice(oscansec))

        return detector_container.DetectorContainer(**detector_dict)
Пример #25
0
    def get_detector_par(self, hdu, det):
        """
        Return a DectectorContainer for the current image

        Args:
            hdu (`astropy.io.fits.HDUList`):
                HDUList of the image of interest.
                Ought to be the raw file, or else..
            det (int):

        Returns:
            :class:`pypeit.images.detector_container.DetectorContainer`:

        """
        # Binning
        binning = self.get_meta_value(
            self.get_headarr(hdu),
            'binning')  # Could this be detector dependent??

        # Detector 1
        detector_dict = dict(
            binning=binning,
            det=1,
            dataext=0,
            specaxis=1,
            specflip=True,
            spatflip=False,
            # plate scale in arcsec/pixel
            platescale=0.3,
            # electrons/pixel/hour. From: http://www.lco.cl/telescopes-information/magellan/instruments/mage/the-mage-spectrograph-user-manual
            darkcurr=1.00,
            saturation=65535.,
            # CCD is linear to better than 0.5 per cent up to digital saturation (65,536 DN including bias) in the Fast readout mode.
            nonlinear=0.99,
            mincounts=-1e10,
            numamplifiers=1,
            gain=np.atleast_1d(1.02),  # depends on the readout
            ronoise=np.atleast_1d(2.9),  # depends on the readout
            datasec=np.atleast_1d('[1:1024, 1:2048]'),
            oscansec=np.atleast_1d('[1:1024, 2049:2176]'),
        )
        # Taken from the MASE paper: https://arxiv.org/pdf/0910.1834.pdf
        #self.norders = 15
        # 20-6
        return detector_container.DetectorContainer(**detector_dict)
Пример #26
0
    def get_detector_par(self, hdu, det):
        """

        Args:
            hdu (`astropy.io.fits.HDUList`):
                HDUList of the image of interest.
                Ought to be the raw file, or else..
            det (int):
                Ignored.  Must be 1

        Returns:
            :class:`pypeit.images.detector_container.DetectorContainer`:

        """
        # Binning
        binning = self.get_meta_value(
            self.get_headarr(hdu),
            'binning')  # Could this be detector dependent??

        # Detector 1
        detector_dict1 = dict(
            binning=binning,
            det=1,
            dataext=1,
            specaxis=1,
            specflip=False,
            spatflip=False,
            platescale=0.135,  # TO BE UPDATED!!
            darkcurr=0.0,
            saturation=65535.,
            nonlinear=0.76,
            mincounts=-1e10,
            numamplifiers=2,
            gain=np.atleast_1d([1.98, 2.17]),  # TAKEN FROM LOWREDUX
            ronoise=np.atleast_1d([6.1, 6.3]),  # TAKEN FROM LOWREDUX
        )
        # Instantiate
        detector = detector_container.DetectorContainer(**detector_dict1)

        # Deal with number of amps
        if hdu[0].header['NUMAMPS'] != 2:
            msgs.error("Did not see this namps coming..")

        # Return
        return detector
Пример #27
0
    def get_detector_par(self, hdu, det):
        """
        Return a DectectorContainer for the current image

        Args:
            hdu (`astropy.io.fits.HDUList`):
                HDUList of the image of interest.
                Ought to be the raw file, or else..
            det (int):

        Returns:
            :class:`pypeit.images.detector_container.DetectorContainer`:

        """

        # http://www.not.iac.es/instruments/detectors/CCD14/

        # Detector 1
        detector_dict = dict(
            binning=self.get_meta_value(self.get_headarr(hdu), 'binning'),
            det=1,
            dataext=1,
            specaxis=0,
            specflip=True,
            spatflip=False,
            xgap=0.,
            ygap=0.,
            ysize=1.,
            platescale=0.2138,
            mincounts=-1e10,
            darkcurr=1.3,  # e-/pix/hr
            saturation=700000.,  # ADU
            nonlinear=0.86,
            datasec=np.atleast_1d('[:,{}:{}]'.format(1, 2062)),  # Unbinned
            oscansec=None,
            numamplifiers=1,
        )

        # Parse datasec, oscancsec from the header
        head1 = hdu[1].header
        detector_dict['gain'] = np.atleast_1d(head1['GAIN'])  # e-/ADU
        detector_dict['ronoise'] = np.atleast_1d(head1['RDNOISE'])  # e-

        # Return
        return detector_container.DetectorContainer(**detector_dict)
Пример #28
0
    def get_detector_par(self, det, hdu=None):
        """
        Return metadata for the selected detector.

        Args:
            det (:obj:`int`):
                1-indexed detector number.
            hdu (`astropy.io.fits.HDUList`_, optional):
                The open fits file with the raw image of interest.  If not
                provided, frame-dependent parameters are set to a default.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        # Detector 1
        detector_dict = dict(
            binning='1,1',  # No binning in near-IR
            det=1,
            dataext=0,
            specaxis=1,
            specflip=False,
            spatflip=False,
            platescale=0.197,  # average between order 11 & 30, see manual
            darkcurr=0.0,
            saturation=
            2.0e5,  # I think saturation may never be a problem here since there are many DITs
            nonlinear=0.86,
            mincounts=-1e10,
            numamplifiers=1,
            gain=np.atleast_1d(2.12),  #
            ronoise=np.atleast_1d(
                8.0
            ),  # ?? more precise value? #TODO the read noise is exposure time  dependent and should be grabbed from header
            datasec=np.atleast_1d(
                '[4:2044,4:]'),  # These are all unbinned pixels
            # EMA: No real overscan for XSHOOTER-NIR:
            # See Table 6 in http://www.eso.org/sci/facilities/paranal/instruments/xshooter/doc/VLT-MAN-ESO-14650-4942_P103v1.pdf
            # The overscan region below contains only zeros
            # ToDo should we just set it as empty?
            #  JXP says yes
            #oscansec        = np.atleast_1d('[4:2044,1:3]'), # These are all unbinned pixels.
        )
        return detector_container.DetectorContainer(**detector_dict)
Пример #29
0
    def get_detector_par(self, hdu, det):
        """
        Return a DectectorContainer for the current image

        Args:
            hdu (`astropy.io.fits.HDUList`):
                HDUList of the image of interest.
                Ought to be the raw file, or else..
            det (int):

        Returns:
            :class:`pypeit.images.detector_container.DetectorContainer`:

        """

        # Detector 1
        detector_dict = dict(
            binning=self.get_meta_value(self.get_headarr(hdu), 'binning'),
            det=1,
            dataext=0,
            specaxis=1,
            specflip=False,
            spatflip=False,
            platescale=0.43,
            saturation=65535.,
            mincounts=-1e10,
            nonlinear=0.76,
            numamplifiers=2,
            gain=np.asarray([1.2, 1.2]),
            ronoise=np.asarray([3.7, 3.7]),
            xgap=0.,
            ygap=0.,
            ysize=1.,
            darkcurr=0.0,
            datasec=np.asarray([
                '[:, 1:1024]', '[:, 1025:2048]'
            ]),  # These are rows, columns on the raw frame, 1-indexed
            oscansec=np.asarray(['[:, 2050:2080]', '[:, 2081:2111]']),
        )
        # suffix='_blue'
        detector = detector_container.DetectorContainer(**detector_dict)

        # Return
        return detector
Пример #30
0
    def get_detector_par(self, det, hdu=None):
        """
        Return metadata for the selected detector.

        Args:
            det (:obj:`int`):
                1-indexed detector number.
            hdu (`astropy.io.fits.HDUList`_, optional):
                The open fits file with the raw image of interest.  If not
                provided, frame-dependent parameters are set to a default.

        Returns:
            :class:`~pypeit.images.detector_container.DetectorContainer`:
            Object with the detector metadata.
        """
        # Binning
        # TODO: Could this be detector dependent??
        binning = '1,1' if hdu is None else self.get_meta_value(
            self.get_headarr(hdu), 'binning')

        # Detector 1
        detector_dict = dict(
            binning=binning,
            det=1,
            dataext=0,
            specaxis=0,
            specflip=False,
            spatflip=False,
            platescale=0.16,  # average from order 17 and order 30, see manual
            darkcurr=0.0,
            saturation=65535.,
            nonlinear=0.86,
            mincounts=-1e10,
            numamplifiers=1,
            gain=np.atleast_1d(
                0.595
            ),  # FITS format is flipped: PrimaryHDU  (2106, 4000) w/respect to Python
            ronoise=np.atleast_1d(
                3.1),  # raw unbinned images are (4000,2106) (spec, spat)
            datasec=np.atleast_1d(
                '[:,11:2058]'),  # pre and oscan are in the spatial direction
            oscansec=np.atleast_1d('[:,2059:2106]'),
        )
        return detector_container.DetectorContainer(**detector_dict)