Exemple #1
0
def test_lris_red_multi_run():
    # Perform the setup
    file_list = glob.glob(
        os.path.join(os.environ['PYPEIT_DEV'], 'RAW_DATA', 'Keck_LRIS_red',
                     'multi*', '*.fits*'))
    cfg_lines = [
        '[rdx]', 'spectrograph = keck_lris_red', '[calibrations]',
        '[[pixelflatframe]]', 'number = 3', '[[standardframe]]', 'number = 0'
    ]
    ps = PypeItSetup(file_list, cfg_lines=cfg_lines)
    ps.run(setup_only=True)

    # Test
    #assert len(ps.setup_dict) == 2, 'Should find two setups'
    assert len(ps.fitstbl) >= 40, 'Should find 40+ files'
    arcs = ps.fitstbl['filename'][ps.fitstbl.find_frames('arc')]
    assert len(arcs) >= 2, 'Should find two or more arcs'
    assert 'r170320_2017.fits.gz' in arcs, \
            'Should have identified r170320_2017.fits.gz as an arc'
    assert 'r170816_0057.fits' in ps.fitstbl['filename'][ps.fitstbl.find_frames('science')], \
            'Should have identified r170816_0057.fits as a science frame'

    # Clean-up
    #os.remove('keck_lris_red.lst')
    #os.remove('keck_lris_red.setups')
    os.remove('keck_lris_red.sorted')
Exemple #2
0
def setup(file_list: List[str], output_path: str,
          spectrograph: str) -> Tuple[PypeItSetup, str]:
    """
    Does PypeIt setup, without writing the .pypeit file
    """

    # Get the output directory
    output_path = os.getcwd() if output_path is None else output_path
    sort_dir = os.path.join(output_path, 'setup_files')
    os.makedirs(sort_dir, exist_ok=True)

    # Initialize PypeItSetup based on the arguments
    cfg_lines = ['[rdx]', f'spectrograph = {spectrograph}']
    fname = os.path.join(
        sort_dir,
        f'{spectrograph}_{datetime.date.today().strftime("%Y-%m-%d")}.pypeit')
    ps = PypeItSetup(file_list,
                     setups=[],
                     cfg_lines=cfg_lines,
                     pypeit_file=fname)

    # Run the setup
    ps.run(setup_only=True, sort_dir=sort_dir)

    table = ps.fitstbl.table
    table.sort('filename')
    table.add_index('filename')

    # Make the target field accept long names
    table['target'] = table['target'].astype('U255')

    # now we guess the calib ids
    set_calibs(table)

    return (ps, output_path)