Beispiel #1
0
def test_deproject():

    uvtable_filename = "/tmp/uvtable.txt"
    uvtable, wle = create_sample_uvtable(uvtable_filename)

    uv = UVTable(filename=uvtable_filename, wle=wle)

    inc = np.radians(30)
    uv_30 = uv.deproject(inc, inplace=False)

    assert_allclose(uv_30.u, uv.u * np.cos(inc))

    uv.deproject(inc)  # inplace=True by default
    assert_allclose(uv_30.u, uv.u)
Beispiel #2
0
def test_uvcut():

    uvtable_filename = "/tmp/uvtable.txt"
    uvtable, wle = create_sample_uvtable(uvtable_filename)

    uv = UVTable(filename=uvtable_filename, wle=wle, columns=COLUMNS_V0)

    maxuv = 5e3
    uvt = uv.uvcut(maxuv)

    # manual uvcut
    uvcut = uv.uvdist <= maxuv

    assert_allclose(uvt.u, uv.u[uvcut])
    assert_allclose(uvt.v, uv.v[uvcut])
    assert_allclose(uvt.re, uv.re[uvcut])
    assert_allclose(uvt.im, uv.im[uvcut])
    assert_allclose(uvt.weights, uv.weights[uvcut])
Beispiel #3
0
def test_init_uvtable():

    uvtable_filename = "/tmp/uvtable.txt"
    uvtable, wle = create_sample_uvtable(uvtable_filename)
    u, v, re, im, w = uvtable

    # test reading from file
    # format='uvtable'
    uvt_file = UVTable(filename=uvtable_filename, wle=wle)

    # test providing uvtable tuple
    # takes u, v in units of observing wavelength
    uvt_uvtable1 = UVTable(uvtable=(u, v, re, im, w), wle=wle)
    uvt_uvtable2 = UVTable(uvtable=(u / wle, v / wle, re, im, w))

    reference = np.hypot(u / wle, v / wle)

    assert_allclose(uvt_uvtable1.uvdist, reference, atol=0, rtol=1e-16)
    assert_allclose(uvt_uvtable2.uvdist, reference, atol=0, rtol=1e-16)
    assert_allclose(uvt_file.uvdist, reference, atol=0, rtol=1e-16)
Beispiel #4
0
    pa_b *= deg
    dra_a *= arcsec
    dra_b *= arcsec
    ddec_a *= arcsec
    ddec_b *= arcsec
    f_a = GaussianProfile(f0_a, sigma_a, rmin, dr, nr)
    f_b = GaussianProfile(f0_b, sigma_b, rmin, dr, nr)
    vis_mod_a = g_double.sampleProfile(f_a[0], rmin, dr, nxy, dxy, np.ascontiguousarray(u), np.ascontiguousarray(v), inc=inc_a, PA=pa_a, dRA=dra_a, dDec=ddec_a)   
    vis_mod_b = g_double.sampleProfile(f_b[0], rmin, dr, nxy, dxy, np.ascontiguousarray(u), np.ascontiguousarray(v), inc=inc_b, PA=pa_b, dRA=dra_b, dDec=ddec_b)
    vis_mod = vis_mod_a + vis_mod_b 
np.savetxt(os.path.join(args.outdir, args.targname + '_uvtable_mod.txt'), np.stack([u * args.wavelength, v * args.wavelength, vis_mod.real, vis_mod.imag, w], axis=-1))


### GET VISIBILITIES OF DATA OF DATA
print("\nCreating UV plot of best-fit model...")
uv = UVTable(filename=args.uvtable, wle=args.wavelength)
if args.binary == False:
    uv.apply_phase(-dra, -ddec)
    uv.deproject(inc, pa)
else:
    uv.apply_phase(-dra_a, -ddec_a,)
    uv.deproject(inc_a, pa_a,)

### GET VISIBILITIES OF BEST-FIT MODEL
uv_mod = UVTable(filename=os.path.join(args.outdir, args.targname + '_uvtable_mod.txt'), wle=args.wavelength)
if args.binary == False:
    uv_mod.apply_phase(-dra, -ddec)
    uv_mod.deproject(inc, pa)
else:
    uv_mod.apply_phase(-dra_a, -ddec_a)
    uv_mod.deproject(inc_a, pa_a)
Beispiel #5
0
from __future__ import (division, print_function, absolute_import,
                        unicode_literals)

import numpy as np
from uvplot import UVTable, arcsec

wle = 0.88e-3  # Observing wavelength         [m]

dRA = 0.3 * arcsec  # Delta Right Ascension offset [rad]
dDec = 0.07 * arcsec  # Delta Declination     offset [rad]
inc = np.radians(73.)  # Inclination    [rad]
PA = np.radians(59)  # Position Angle [rad]

uvbin_size = 30e3  # uv-distance bin [wle]

uv = UVTable(filename='uvtable.txt', wle=wle)
uv.apply_phase(dRA, dDec)
uv.deproject(inc, PA)

uv_mod = UVTable(filename='uvtable_mod.txt', wle=wle)
uv_mod.apply_phase(dRA=dRA, dDec=dDec)
uv_mod.deproject(inc=inc, PA=PA)

axes = uv.plot(label='Data', uvbin_size=uvbin_size)
uv_mod.plot(label='Model',
            uvbin_size=uvbin_size,
            axes=axes,
            yerr=False,
            linestyle='-',
            color='r')