Esempio n. 1
0
def test_origin_type(cal, tmpdir):
    og = [50.0]
    with pytest.raises(TypeError, match="origin should be a str or None"):
        amical.save(
            cal,
            oifits_file="test_origin.oifits",
            datadir=tmpdir,
            fake_obj=True,
            origin=og,
        )
Esempio n. 2
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)
Esempio n. 3
0
def test_save_origin(cal, tmpdir):
    og = "allo"
    _dic, savefile = amical.save(
        cal,
        oifits_file="test_origin.oifits",
        datadir=tmpdir,
        fake_obj=True,
        origin=og,
    )
    hdr = fits.getheader(savefile)
    assert hdr["ORIGIN"] == og
Esempio n. 4
0
def perform_calibrate(args):
    """Calibrate the data with AMICAL (save calibrated oifits files)"""

    sciname, calname = _select_association_file(args)
    bs_t = amical.load_bs_hdf5(sciname)

    bs_c = []
    for x in calname:
        bs_c = amical.load_bs_hdf5(x)

    display = len(bs_c) > 1
    cal = amical.calibrate(
        bs_t,
        bs_c,
        clip=args.clip,
        normalize_err_indep=args.norm,
        apply_atmcorr=args.atmcorr,
        apply_phscorr=args.phscorr,
        display=display,
    )

    # Position angle from North to East
    pa = bs_t.infos.pa

    cprint("\nPosition angle computed for the data: pa = %2.3f deg" % pa,
           "cyan")

    # Display and save the results as oifits
    if args.plot:
        amical.show(cal, true_flag_t3=False, cmax=180, pa=pa)
        plt.show()

    oifits_file = Path(bs_t.infos.filename).stem + "_calibrated.fits"

    amical.save(cal, oifits_file=oifits_file, datadir=args.outdir)
    return 0
Esempio n. 5
0
def test_save(bss, tmpdir):
    bs = bss["fft"]
    cal = amical.calibrate(bs, bs)
    assert isinstance(cal, munch.Munch)

    dic, savefile = amical.save(cal, oifits_file='test.oifits', 
                                datadir=tmpdir, 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)
Esempio n. 6
0
def test_save_cal(cal, tmpdir):
    dic, savefile = amical.save(cal,
                                oifits_file="test_cal.oifits",
                                datadir=tmpdir,
                                fake_obj=True)

    assert isinstance(dic, dict)
    assert isinstance(savefile, str)

    hdr = fits.getheader(savefile)
    v2 = dic["OI_VIS2"]["VIS2DATA"]
    cp = dic["OI_T3"]["T3PHI"]

    assert isinstance(v2, np.ndarray)
    assert isinstance(cp, np.ndarray)
    assert len(v2) == 21
    assert len(cp) == 35
    assert hdr["ORIGIN"] == "Sydney University"
Esempio n. 7
0
    "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)
dic = amical.save(cal,
                  oifits_file="example_fakebinary_NIRISS.oifits",
                  fake_obj=True)

plt.show(block=True)