Ejemplo n.º 1
0
    def get_tilts(self):
        """
        Load or generate the tilts image

        Requirements:
           mstilt, slits, wv_calib
           det, par, spectrograph

        Returns:
            :class:`pypeit.wavetilts.WaveTilts`:

        """
        # Check for existing data
        #TODO add mstilt_inmask to this list when it gets implemented.
        if not self._chk_objs(['mstilt', 'msbpm', 'slits', 'wv_calib']):
            msgs.warn(
                'dont have all the objects for tilts.  Skipping and may crash down the line..'
            )
            return None

        # Check internals
        self._chk_set(['det', 'calib_ID', 'par'])
        if 'tilt' not in self.master_key_dict.keys():
            msgs.error('Tilt master key not set.  First run get_tiltimage.')

        # Load up?
        masterframe_name = masterframe.construct_file_name(
            wavetilts.WaveTilts,
            self.master_key_dict['tilt'],
            master_dir=self.master_dir)
        if os.path.isfile(masterframe_name) and self.reuse_masters:
            self.wavetilts = wavetilts.WaveTilts.from_file(masterframe_name)
            self.wavetilts.is_synced(self.slits)
            self.slits.mask_wavetilts(self.wavetilts)
        else:  # Build
            # Flexure
            _spat_flexure = self.mstilt.spat_flexure \
                if self.par['tiltframe']['process']['spat_flexure_correct'] else None
            # Instantiate
            buildwaveTilts = wavetilts.BuildWaveTilts(
                self.mstilt,
                self.slits,
                self.spectrograph,
                self.par['tilts'],
                self.par['wavelengths'],
                det=self.det,
                qa_path=self.qa_path,
                master_key=self.master_key_dict['tilt'],
                spat_flexure=_spat_flexure)

            # TODO still need to deal with syntax for LRIS ghosts. Maybe we don't need it
            self.wavetilts = buildwaveTilts.run(doqa=self.write_qa,
                                                show=self.show)
            # Save?
            self.wavetilts.to_master_file(masterframe_name)

        return self.wavetilts
Ejemplo n.º 2
0
def test_run(master_dir):
    # Masters
    spectrograph = load_spectrograph('shane_kast_blue')
    mstilt, edges = load_kast_blue_masters(mstilt=True, edges=True)
    # Instantiate
    #spectrograph.detector[0]['saturation'] = 60000.
    #spectrograph.detector[0]['nonlinear'] = 0.9
    par = pypeitpar.WaveTiltsPar()
    wavepar = pypeitpar.WavelengthSolutionPar()
    slits = edges.get_slits()
    buildwaveTilts = wavetilts.BuildWaveTilts(mstilt, slits, spectrograph, par, wavepar, det=1)
    # Run
    waveTilts = buildwaveTilts.run(doqa=False)
    assert isinstance(waveTilts.fit2tiltimg(slits.slit_img()), np.ndarray)