Пример #1
0
def test_save(filepath):
    hdu = fits.open(filepath)
    cube = hdu[0].data
    hdu.close()
    params_ami = {
        "peakmethod": 'fft',
        "bs_multi_tri": False,
        "maskname": "g7",
        "fw_splodge": 0.7,
    }
    bs = amical.extract_bs(cube,
                           filepath,
                           targetname='test',
                           **params_ami,
                           display=False)
    cal = amical.calibrate(bs, bs)
    assert isinstance(cal, munch.Munch)

    dic, savefile = amical.save(cal, oifits_file='test.oifits', fake_obj=True)
    v2 = dic['OI_VIS2']['VIS2DATA']
    cp = dic['OI_T3']['T3PHI']

    assert isinstance(dic, dict)
    assert isinstance(savefile, str)
    assert (isinstance(v2, np.ndarray))
    assert (isinstance(cp, np.ndarray))
    assert (len(v2) == 21)
    assert (len(cp) == 35)
Пример #2
0
def _extract_bs_ifile(f, args, ami_param):
    """Extract the bispectrum on individial file (f) and save them as hdf5."""
    hdu = fits.open(f)
    cube = hdu[0].data
    hdu.close()

    # Extract the bispectrum
    bs = amical.extract_bs(cube, f, **ami_param, save_to=args.save_to)

    bs_file = os.path.join(args.outdir, Path(f).stem + "_bispectrum")
    amical.save_bs_hdf5(bs, bs_file)
    return 0
Пример #3
0
def example_cal_fft(global_datadir):
    fits_file = global_datadir / "test.fits"
    with fits.open(fits_file) as fh:
        cube = fh[0].data
    bs = amical.extract_bs(
        cube,
        fits_file,
        targetname="test",
        bs_multi_tri=False,
        maskname="g7",
        fw_splodge=0.7,
        display=False,
        peakmethod="fft",
    )
    return amical.calibrate(bs, bs)
Пример #4
0
def test_cal_phscorr(global_datadir):
    fits_file = global_datadir / "test.fits"
    with fits.open(fits_file) as fh:
        cube = fh[0].data
    bs = amical.extract_bs(
        cube,
        fits_file,
        targetname="test",
        bs_multi_tri=False,
        maskname="g7",
        fw_splodge=0.7,
        display=False,
        peakmethod="fft",
    )
    cal = amical.calibrate(bs, bs, apply_atmcorr=True)
    assert isinstance(cal, munch.Munch)
Пример #5
0
def test_extract(peakmethod, global_datadir):
    fits_file = global_datadir / "test.fits"
    with fits.open(fits_file) as fh:
        cube = fh[0].data
    bs = amical.extract_bs(
        cube,
        fits_file,
        targetname="test",
        bs_multi_tri=False,
        maskname="g7",
        fw_splodge=0.7,
        display=False,
        peakmethod=peakmethod,
    )
    bs_keys = list(bs.keys())
    assert isinstance(bs, munch.Munch)
    assert len(bs_keys) == 13
Пример #6
0
def test_show(filepath):
    hdu = fits.open(filepath)
    cube = hdu[0].data
    hdu.close()
    params_ami = {
        "peakmethod": 'fft',
        "bs_multi_tri": False,
        "maskname": "g7",
        "fw_splodge": 0.7,
    }
    bs = amical.extract_bs(cube,
                           filepath,
                           targetname='test',
                           **params_ami,
                           display=False)
    cal = amical.calibrate(bs, bs)
    amical.show(cal)
Пример #7
0
def example_bss(global_datadir):
    fits_file = global_datadir / "test.fits"
    with fits.open(fits_file) as fh:
        cube = fh[0].data
    bss = {}
    for peakmethod in peakmethods:
        bss[peakmethod] = amical.extract_bs(
            cube,
            fits_file,
            targetname='test',
            bs_multi_tri=False,
            maskname="g7",
            fw_splodge=0.7,
            display=False,
            peakmethod=peakmethod
        )
    return bss
Пример #8
0
def test_extraction(filepath):
    hdu = fits.open(filepath)
    cube = hdu[0].data
    hdu.close()
    method = ['fft', 'gauss', 'square']
    for m in method:
        params_ami = {
            "peakmethod": m,
            "bs_multi_tri": False,
            "maskname": "g7",
            "fw_splodge": 0.7,
        }
        bs = amical.extract_bs(cube,
                               filepath,
                               targetname='test',
                               **params_ami,
                               display=False)
        assert isinstance(bs, munch.Munch)
Пример #9
0
def test_extract_multitri(global_datadir, tmp_path):
    fits_file = global_datadir / "test.fits"
    with fits.open(fits_file) as fh:
        cube = fh[0].data
    bs = amical.extract_bs(
        cube,
        fits_file,
        targetname="test",
        bs_multi_tri=True,
        maskname="g7",
        fw_splodge=0.7,
        display=True,
        expert_plot=True,
        naive_err=True,
        verbose=True,
        save_to=str(tmp_path),
        peakmethod="fft",
    )
    bs_keys = list(bs.keys())
    assert isinstance(bs, munch.Munch)
    assert len(bs_keys) == 13
Пример #10
0
def test_quiet_mode(global_datadir, capsys):
    fits_file = global_datadir / "test.fits"
    with fits.open(fits_file) as fh:
        cube = fh[0].data
    bs = amical.extract_bs(
        cube,
        fits_file,
        targetname="test",
        bs_multi_tri=False,
        maskname="g7",
        fw_splodge=0.7,
        display=False,
        peakmethod="fft",
        verbose=False,
    )
    captured = capsys.readouterr()
    bs_keys = list(bs.keys())
    assert isinstance(bs, munch.Munch)
    assert len(bs_keys) == 13
    assert captured.out == ""
    assert captured.err == ""
Пример #11
0
# Check example_SPHERE.py for more details.
# ----------------------------------

#  AMI parameters (refer to the docstrings of `extract_bs` for details)
params_ami = {
    "peakmethod": "fft",
    "bs_multi_tri": False,
    "maskname": "g7",
    "fw_splodge": 0.7,
}

# Extract raw complex observables for the target and the calibrator:
# It's the core of the pipeline (amical/mf_pipeline/bispect.py)
bs_t = amical.extract_bs(cube_t,
                         file_t,
                         targetname="fakebinary",
                         **params_ami,
                         display=True)
bs_c = amical.extract_bs(cube_c,
                         file_c,
                         targetname="fakepsf",
                         **params_ami,
                         display=False)

# Calibrate the raw data to get calibrated V2 and CP.
# bs_c can be a single calibrator result or a list of calibrators.
# (see amical/calibration.py for details).
cal = amical.calibrate(bs_t, bs_c)

# Display and save the results as oifits
amical.show(cal)
Пример #12
0
cube_c = amical.select_clean_data(file_c, clip=True,
                                  **clean_param, display=True)

#  AMI parameters (refer to the docstrings of `extract_bs` for details)
params_ami = {"peakmethod": 'fft',
              "bs_multi_tri": False,
              "maskname": "g7",
              "fw_splodge": 0.7,
              "filtname": 'K1'
              }


# # Extract raw complex observables for the target and the calibrator:
# # It's the core of the pipeline (amical/mf_pipeline/bispect.py)
bs_t = amical.extract_bs(cube_t, file_t, targetname='HD142527',
                         **params_ami, display=True)
bs_c = amical.extract_bs(cube_c, file_c, targetname='HD142695',
                         **params_ami, display=False)

# (from amical.tools import check_seeing_cond, plot_seeing_cond)
# In case of multiple files for a same target, you can
# check the seeing condition and select only the good ones.
# cond_t = check_seeing_cond([bs_t])
# cond_c = check_seeing_cond([bs_c])
# plot_seeing_cond([cond_t, cond_c], lim_seeing=1)


# Calibrate the raw data to get get calibrated V2 and CP
# bs_c can be a single calibrator result or a list of calibrator.
# (see amical/core.py for details).
cal = amical.calibrate(bs_t, bs_c)