Example #1
0
    def default_pypeit_par():
        """
        Set default parameters for  LBT/LUCI reductions.

        OLD CODE from LBT MODS
        """
        par = pypeitpar.PypeItPar()
        # Scienceimage default parameters
        par['reduce'] = pypeitpar.ReducePar()
        # Always flux calibrate, starting with default parameters
        par['fluxcalib'] = pypeitpar.FluxCalibratePar()
        # Always correct for flexure, starting with default parameters
        par['flexure'] = pypeitpar.FlexurePar()
        # Set the default exposure time ranges for the frame typing
        par['calibrations']['biasframe']['exprng'] = [None, 1]
        par['calibrations']['darkframe']['exprng'] = [999999,
                                                      None]  # No dark frames
        par['calibrations']['pinholeframe']['exprng'] = [999999, None
                                                         ]  # No pinhole frames
        par['calibrations']['pixelflatframe']['exprng'] = [0, None]
        par['calibrations']['traceframe']['exprng'] = [0, None]
        par['calibrations']['arcframe']['exprng'] = [None, 60]
        par['calibrations']['standardframe']['exprng'] = [1, 200]
        par['scienceframe']['exprng'] = [200, None]
        return par
Example #2
0
    def default_pypeit_par(self):
        """
        Set default parameters for the reductions.
        """
        par = pypeitpar.PypeItPar()
        par['rdx']['spectrograph'] = 'gemini_flamingos2'
        # No overscan
        for key in par['calibrations'].keys():
            if 'frame' in key:
                par['calibrations'][key]['process']['overscan'] = 'none'
        # Wavelengths
        # 1D wavelength solution with arc lines
        par['calibrations']['wavelengths']['rms_threshold'] = 0.5
        par['calibrations']['wavelengths']['sigdetect']=5
        par['calibrations']['wavelengths']['fwhm'] = 5
        par['calibrations']['wavelengths']['n_first']=2
        par['calibrations']['wavelengths']['n_final']=4
        par['calibrations']['wavelengths']['lamps'] = ['OH_NIRES']
        par['calibrations']['wavelengths']['nonlinear_counts'] = self.detector[0]['nonlinear'] * self.detector[0]['saturation']
        #par['calibrations']['wavelengths']['method'] = 'reidentify'
        #par['calibrations']['wavelengths']['method'] = 'full_template'
        #par['calibrations']['wavelengths']['reid_arxiv'] = 'magellan_fire_long.fits'
        par['calibrations']['wavelengths']['match_toler']=5.0

        # Set slits and tilts parameters
        par['calibrations']['tilts']['tracethresh'] = 5
        par['calibrations']['tilts']['spat_order'] = 4
        par['calibrations']['slitedges']['trace_thresh'] = 10.
        par['calibrations']['slitedges']['edge_thresh'] = 200.
        #par['calibrations']['slitedges']['det_min_spec_length'] = 0.3
        par['calibrations']['slitedges']['fit_min_spec_length'] = 0.4
        par['calibrations']['slitedges']['sync_predict'] = 'nearest'

        # Overscan but not bias
        #  This seems like a kludge of sorts
        par['calibrations']['biasframe']['useframe'] = 'none'
        # No overscan
        par['scienceframe']['process']['overscan'] ='none'
        for key in par['calibrations'].keys():
            if 'frame' in key:
                par['calibrations'][key]['process']['overscan'] = 'none'

        # Set the default exposure time ranges for the frame typing
        par['calibrations']['standardframe']['exprng'] = [None, 30]
        par['calibrations']['tiltframe']['exprng'] = [50, None]
        par['calibrations']['arcframe']['exprng'] = [50, None]
        par['calibrations']['darkframe']['exprng'] = [20, None]
        par['scienceframe']['exprng'] = [20, None]

        # Scienceimage parameters
        #par['reduce']['sig_thresh'] = 5
        #par['reduce']['maxnumber'] = 2
        par['reduce']['skysub']['sky_sigrej'] = 5.0
        par['reduce']['findobj']['find_trim_edge'] = [10,10]
        # Always flux calibrate, starting with default parameters
        par['fluxcalib'] = pypeitpar.FluxCalibratePar()
        # Do not correct for flexure
        par['flexure'] = None

        return par
Example #3
0
def test_flux(monkeypatch):
    def mock_get_header(file):
        if file == "fail_grating.fits":
            return {"DISPNAME": "Unknown"}
        else:
            return {"DISPNAME": "600ZD"}

    def mock_get_flux_calib_instance(spec1d_files, sens_files, par):
        if spec1d_files[0] == "fail_flux.fits":
            raise PypeItError("Test failure")
        else:
            # The collate_1d caller doesn't use the output, it just
            # depends on the side effect of fluxing
            return None

    # Test success
    with monkeypatch.context() as m:
        monkeypatch.setattr(fits, "getheader", mock_get_header)
        monkeypatch.setattr(fluxcalibrate.FluxCalibrate, "get_instance",
                            mock_get_flux_calib_instance)

        spectrograph = load_spectrograph('keck_deimos')
        # This could break if we start supporting it
        unsupported_spectrograph = load_spectrograph('shane_kast_red')

        par = pypeitpar.PypeItPar()
        par['fluxcalib'] = pypeitpar.FluxCalibratePar()

        # Test success
        failed_messages = []
        flux(par, spectrograph, ["no_fail.fits"], failed_messages)

        assert len(failed_messages) == 0

        # Test failure due to no archived sensfunc
        flux(par, spectrograph, ["fail_grating.fits"], failed_messages)
        assert failed_messages[
            0] == "Could not find archived sensfunc to flux fail_grating.fits, skipping it."

        failed_messages = []

        # Test failure in fluxing
        flux(par, spectrograph, ["fail_flux.fits"], failed_messages)
        assert failed_messages[
            0] == "Failed to flux calibrate fail_flux.fits, skipping it."

        # Test failure due to unsupported spectrograph
        with pytest.raises(PypeItError):
            flux(par, unsupported_spectrograph, ["600ZD_file.fits"],
                 failed_messages)
Example #4
0
    def default_pypeit_par(self):
        """
        Set default parameters.
        """
        par = pypeitpar.PypeItPar()
        par['rdx']['spectrograph'] = 'magellan_fire_long'

        # No overscan
        for key in par['calibrations'].keys():
            if 'frame' in key:
                par['calibrations'][key]['process']['overscan'] = 'none'
        # Wavelengths
        # 1D wavelength solution with arc lines
        par['calibrations']['wavelengths']['rms_threshold'] = 1.0
        par['calibrations']['wavelengths']['sigdetect'] = 3
        par['calibrations']['wavelengths']['fwhm'] = 20
        par['calibrations']['wavelengths']['n_first'] = 2
        par['calibrations']['wavelengths']['n_final'] = 4
        par['calibrations']['wavelengths']['lamps'] = [
            'ArI', 'ArII', 'ThAr', 'NeI'
        ]
        par['calibrations']['wavelengths']['nonlinear_counts'] = self.detector[
            0]['nonlinear'] * self.detector[0]['saturation']
        par['calibrations']['wavelengths']['method'] = 'full_template'
        par['calibrations']['wavelengths'][
            'reid_arxiv'] = 'magellan_fire_long.fits'
        par['calibrations']['wavelengths']['match_toler'] = 5.0

        # Set slits and tilts parameters
        par['calibrations']['tilts']['tracethresh'] = 5
        par['calibrations']['slitedges']['trace_thresh'] = 10.
        par['calibrations']['slitedges']['sync_predict'] = 'nearest'

        # Scienceimage parameters
        par['reduce']['findobj']['sig_thresh'] = 5
        #par['reduce']['maxnumber'] = 2
        par['reduce']['findobj']['find_trim_edge'] = [50, 50]
        # Always flux calibrate, starting with default parameters
        par['fluxcalib'] = pypeitpar.FluxCalibratePar()
        # Do not correct for flexure
        par['flexure'] = None
        # Set the default exposure time ranges for the frame typing
        par['calibrations']['standardframe']['exprng'] = [None, 60]
        par['calibrations']['arcframe']['exprng'] = [1, 50]
        par['calibrations']['darkframe']['exprng'] = [20, None]
        par['scienceframe']['exprng'] = [20, None]
        return par
Example #5
0
def test_fluxcalibrate():
    pypeitpar.FluxCalibratePar()
Example #6
0
    # Read the baseline file that is not changed and must be edited by
    # the person building the documentation as necessary.
    pypeit_root = os.path.dirname(resource_filename('pypeit', ''))
    input_base = os.path.join(pypeit_root, 'doc', 'scripts',
                              'base_par_rst.txt')
    with open(input_base, 'r') as f:
        lines = [l.replace('\n', '') for l in f.readlines()]
    lines += ['']

    # Start to append the automatically generated documentation
    lines += ['Current PypeItPar Parameter Hierarchy']
    lines += ['+++++++++++++++++++++++++++++++++++++']
    lines += ['']

    p = pypeitpar.PypeItPar(flexure=pypeitpar.FlexurePar(),
                            fluxcalib=pypeitpar.FluxCalibratePar())

    lines += par_hierarchy(p)
    lines += ['']
    lines += ['----']
    lines += ['']

    lines += p.to_rst_table()
    lines += ['']

    lines += [' .. _instr_par:']
    lines += ['']

    lines += ['Instrument-Specific Default Configuration']
    lines += ['+++++++++++++++++++++++++++++++++++++++++']
    lines += ['']