예제 #1
0
def test_gen_sensfunc():
    # Load a random spectrum for the sensitivity function
    sfile = data_path('spec1d_J0025-0312_KASTr_2015Jan23T025323.85.fits')
    specobjs = arload.load_specobj(sfile)
    # Settings, etc.
    arutils.dummy_settings()
    settings.argflag['run']['spectrograph'] = 'shane_kast_blue'
    settings.argflag['reduce']['masters']['setup'] = 'C_01_aa'
    settings.spect['arc'] = {}
    settings.spect['arc']['index'] = [[0]]
    fitsdict = arutils.dummy_fitsdict()
    slf = arutils.dummy_self()
    slf._msstd[0]['RA'] = '05:06:36.6'
    slf._msstd[0]['DEC'] = '52:52:01.0'
    # Generate
    slf._sensfunc = arflx.generate_sensfunc(slf, 4, [specobjs], fitsdict)
    # Save
    try:
        os.mkdir('MF_shane_kast_blue')
    except FileExistsError:
        pass
    armasters.save_sensfunc(slf, 'C_01_aa')
    # Test
    assert isinstance(slf._sensfunc, dict)
    assert isinstance(slf._sensfunc['wave_min'], Quantity)
예제 #2
0
def test_save1d_hdf5():
    """ save1d to FITS and HDF5
    """
    # Dummy self
    slf = arut.dummy_self()
    fitsdict = arut.dummy_fitsdict(nfile=1, spectrograph='none')
    # specobj
    slf._specobjs = []
    slf._specobjs.append([])
    slf._specobjs[0].append([mk_specobj(objid=455), mk_specobj(flux=3., objid=555)])
    # Write to HDF5
    arsv.save_1d_spectra_hdf5(slf, fitsdict)
예제 #3
0
def test_save1d_fits():
    """ save1d to FITS and HDF5
    """
    arut.dummy_settings()
    fitsdict = arut.dummy_fitsdict(nfile=10, spectrograph='shane_kast_blue', directory=data_path(''))
    # Dummy self
    slf = arut.dummy_self()
    slf._specobjs = []
    slf._specobjs.append([])
    slf._specobjs[0].append([mk_specobj()])
    # Write to FITS
    arsv.save_1d_spectra_fits(slf, fitsdict)
예제 #4
0
def test_setup_param():
    """ Run the parameter setup script
    Returns
    -------

    """
    # Initialize some settings
    arut.dummy_settings()
    # Load Dummy self
    slf = arut.dummy_self()
    settings.argflag['run']['spectrograph'] = 'shane_kast_blue'
    settings.spect['arc'] = {}
    settings.spect['arc']['index'] = [[0]]
    fitsdict = arut.dummy_fitsdict()
    # Run
    arcparm = pyarc.setup_param(slf, 0, 1, fitsdict)
    for key in ['llist', 'disp', 'wvmnx']:
        assert key in arcparm
예제 #5
0
def test_save2d_fits():
    arut.dummy_settings()
    # Dummy self
    slf = arut.dummy_self()
    fitsdict = arut.dummy_fitsdict(nfile=1, spectrograph='none', directory=data_path(''))
    fitsdict['filename'] = np.array(['b1.fits.gz'])
    # Settings
    settings.argflag['run']['directory']['science'] = data_path('')
    settings.argflag['reduce']['masters']['setup'] = 'A_01_aa'
    # Fill with dummy images
    dum = np.ones((100,100))
    slf._sciframe[0] = dum
    slf._modelvarframe[0] = dum * 2
    slf._bgframe[0] = dum + 0.1
    slf._basename = 'test'
    slf._idx_sci[0] = 0
    # Call
    arsv.save_2d_images(slf, fitsdict)
    # Read and test
    head0 = pyfits.getheader(data_path('spec2d_test.fits'))
    assert head0['PYPCNFIG'] == 'A'
    assert head0['PYPCALIB'] == 'aa'
    assert 'PYPIT' in head0['PIPELINE']
예제 #6
0
def fitsdict():
    return arutils.dummy_fitsdict()