Exemple #1
0
import emcee
import triangle
import scipy as sp
import numpy as np
from from_fits import create_uvdata_from_fits_file
from components import CGComponent
from model import Model, CCModel
from stats import LnPost

if __name__ == '__main__':
    uv_fname = '1633+382.l22.2010_05_21.uvf'
    map_fname = '1633+382.l22.2010_05_21.icn.fits'
    uvdata = create_uvdata_from_fits_file(uv_fname)
    # Create several components
    cg1 = CGComponent(1.0, 0.0, 0.0, 1.)
    cg1.add_prior(flux=(
        sp.stats.uniform.logpdf,
        [0., 3.],
        dict(),
    ),
                  bmaj=(
                      sp.stats.uniform.logpdf,
                      [0, 10.],
                      dict(),
                  ))
    # Create model
    mdl1 = Model(stokes='I')
    # Add components to model
    mdl1.add_component(cg1)
    # Create posterior for data & model
    lnpost = LnPost(uvdata, mdl1)
Exemple #2
0
import emcee
import triangle
import scipy as sp
from uv_data import UVData
from components import CGComponent
from model import Model
from stats import LnPost


if __name__ == '__main__':
    uvdata = UVData('J0006-0623_X_2008_07_09_pus_vis.fits')
    uv = uvdata.uvw[:, :2]
    # Create several components
    cg1 = CGComponent(2.0, 0.0, 0.0, 0.1)
    # cg2 = CGComponent(1.0, 0.1, -1.05, 1.18)
    cg1.add_prior(flux=(sp.stats.uniform.logpdf, [0., 3.], dict(),),
                  bmaj=(sp.stats.uniform.logpdf, [0, 2.], dict(),))
    # cg2.add_prior(flux=(sp.stats.uniform.logpdf, [0., 0.1], dict(),),
    #                bmaj=(sp.stats.uniform.logpdf, [0, 3.], dict(),))
    # Create model
    mdl1 = Model(stokes='I')
    # Add components to model
    mdl1.add_component(cg1)
    # mdl1.add_component(cg2)
    # Create posterior for data & model
    lnpost = LnPost(uvdata, mdl1)
    # lnpr = LnPrior(mdl1)
    # lnlik = LnLikelihood(uvdata, mdl1)
    # model.uvplot(uv = uv)
    # model.ft(uv=uv)
    ndim = mdl1.size
Exemple #3
0
from mojave import mojave_uv_fits_fname, download_mojave_uv_fits
from spydiff import modelfit_difmap, import_difmap_model
from bootstrap import bootstrap_uvfits_with_difmap_model


source = '1514-241'
epoch = '2006_04_28'
data_dir = '/home/ilya/Dropbox/papers/boot/bias/new/stationary'
# download_mojave_uv_fits(source, epochs=[epoch], bands=['u'],
#                         download_dir=data_dir)

uv_fits_fnames = {freq: mojave_uv_fits_fname(source, freq, epoch) for freq in
                  ('x', 'j', 'u')}
for freq, uv_fits_fname in uv_fits_fnames.items():
    uv_fits_path = os.path.join(data_dir, uv_fits_fname)
    cg1 = CGComponent(2.0, 0., 0., 0.2)
    cg2 = CGComponent(1.0, 0., 0.3, 0.3)
    cg3 = CGComponent(0.5, 0., 1.5, 0.4)
    mdl = Model(stokes='I')
    mdl.add_components(cg1, cg2, cg3)
    uvdata = UVData(uv_fits_path)
    noise = uvdata.noise()
    for i in range(1, 101):
        uvdata = UVData(uv_fits_path)
        uvdata.substitute([mdl])
        uvdata.noise_add(noise)
        art_fits_fname = 'art_{}_{}.fits'.format(freq, i)
        art_fits_path = os.path.join(data_dir, art_fits_fname)
        uvdata.save(art_fits_path)
        modelfit_difmap(art_fits_fname, 'initial.mdl', 'out_{}_{}.mdl'.format(freq, i),
                        niter=100, path=data_dir, mdl_path=data_dir,
Exemple #4
0
              bmaj=(
                  sp.stats.uniform.logpdf,
                  [0, 20.],
                  dict(),
              ),
              e=(
                  sp.stats.uniform.logpdf,
                  [0, 1.],
                  dict(),
              ),
              bpa=(
                  sp.stats.uniform.logpdf,
                  [0, np.pi],
                  dict(),
              ))
cg2 = CGComponent(0.5, 0., -2., 0.55)
cg2.add_prior(flux=(
    sp.stats.uniform.logpdf,
    [0., 5.],
    dict(),
),
              bmaj=(
                  sp.stats.uniform.logpdf,
                  [0, 20.],
                  dict(),
              ))
model = Model(stokes='I')
model.add_components(cg1, cg2)
uvdata.substitute([model])
uvdata.noise_add(noise)
uvdata.save(os.path.join(data_dir, 'fake.uvf'))
Exemple #5
0
import emcee
import triangle
import scipy as sp
import numpy as np
from from_fits import create_uvdata_from_fits_file
from components import CGComponent
from model import Model
from stats import LnPost

if __name__ == '__main__':
    uv_fname = 'J0005+3820_X_1998_06_24_fey_vis.fits'
    map_fname = 'J0005+3820_X_1998_06_24_fey_map.fits'
    uvdata = create_uvdata_from_fits_file(uv_fname)
    # Estimate noise
    # noise = uvdata.noise(average_freq=True, use_V=False)
    # Create some model of couple components 10 mas away
    cg1 = CGComponent(1.0, 0.0, 0.0, 1.5)
    cg2 = CGComponent(0.3, 3.0, 10.0, 3.)
    # Create model
    mdl = Model(stokes='RR')
    # Add components to model
    mdl.add_components(cg1, cg2)
    #uvdata.substitute([mdl])
    #uvdata.noise_add(noise)
    # radplot
    #uvdata.uvplot(stokes='RR')
    # plot image
    mdl_image = mdl.make_image(map_fname)
    # FIXME: doesn't plot component with nonzero coordinates?
    mdl_image.plot(min_rel_level=1.)