How to use the ehtim.array function in ehtim

To help you get started, we’ve selected a few ehtim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github achael / eht-imaging / examples / example_model.py View on Github external
# Note: this is an example sequence of commands to run in ipython
# The matplotlib windows may not open/close properly if you run this directly as a script

from __future__ import division
from __future__ import print_function

import matplotlib.pyplot as plt
import numpy as np
import ehtim as eh

# Load a sample array
eht = eh.array.load_txt('../arrays/EHT2019.txt')

# Make a ring model
mod = eh.model.Model()
mod = mod.add_mring(1.5, 40.*eh.RADPERUAS, beta_list=[0.1+0.2j])

# View the model
mod.display()

# View the model after blurring with a circular Gaussian
mod.blur_circ(5.*eh.RADPERUAS).display()

# Add another model component
mod = mod.add_circ_gauss(1., 20.*eh.RADPERUAS, x0=-15.*eh.RADPERUAS, y0=20.*eh.RADPERUAS)
mod.blur_circ(5.*eh.RADPERUAS).display()

# Make an image of the model
github achael / eht-imaging / examples / example_scattering.py View on Github external
# Note: must import ehtim outside the ehtim directory
# either in parent eht-imaging directory or after installing with setuptools

import numpy as np
import ehtim as eh
import ehtim.scattering as so
import ehtim.plotting as pl

# Load the image and the array
im = eh.image.load_txt('../models/avery_sgra_eofn.txt')
eht = eh.array.load_txt('../arrays/EHT2017.txt')

# If the image has an even number of pixels, make it odd
#if im.xdim%2 == 0:
#	newim = im.imvec.reshape(im.ydim, im.xdim)
#	newim = newim[:-1,:-1]
#	im = eh.image.Image(newim, im.psize, im.ra, im.dec, rf=im.rf, source=im.source, mjd=im.mjd)


# Create a ScatteringModel; this defaults to parameters appropriate for Sgr A*
sm = so.ScatteringModel()

# Scatter the image; display the result
im_scatt = sm.Scatter(im,DisplayImage=True)

# Compare visibilities of the unscattered, scattered, and deblurred images
obs_unscatt = im.observe(eht, tint=300., tadv = 300, tstart = 22., tstop = 28., bw = 16e9, add_th_noise=False, sgrscat=False, ampcal=True, phasecal=True, timetype = 'GMST')
github achael / eht-imaging / examples / example.py View on Github external
# Note: this is an example sequence of commands to run in ipython
# The matplotlib windows may not open/close properly if you run this directly as a script

from __future__ import division
from __future__ import print_function

import matplotlib.pyplot as plt
import numpy as np
import ehtim as eh
from   ehtim.calibrating import self_cal as sc
#from  ehtim.plotting import self_cal as sc

# Load the image and the array
im = eh.image.load_txt('../models/avery_sgra_eofn.txt')
eht = eh.array.load_txt('../arrays/EHT2017.txt')

# Look at the image
im.display()

# Observe the image
# tint_sec is the integration time in seconds, and tadv_sec is the advance time between scans
# tstart_hr is the GMST time of the start of the observation and tstop_hr is the GMST time of the end
# bw_hz is the  bandwidth in Hz
# sgrscat=True blurs the visibilities with the Sgr A* scattering kernel for the appropriate image frequency
# ampcal and phasecal determine if gain variations and phase errors are included
tint_sec = 5
tadv_sec = 600
tstart_hr = 0
tstop_hr = 24
bw_hz = 4e9
obs = im.observe(eht, tint_sec, tadv_sec, tstart_hr, tstop_hr, bw_hz,
github achael / eht-imaging / examples / example_calibration.py View on Github external
import ehtim as eh

# Load the image and the array
im = eh.image.load_txt('../models/avery_sgra_eofn.txt')
eht = eh.array.load_txt('../arrays/EHT2017.txt')

# Observe the image
tint_sec = 30
tadv_sec = 1200*3
tstart_hr = 0
tstop_hr = 24
bw_hz = 4e9
obs = im.observe(eht, tint_sec, tadv_sec, tstart_hr, tstop_hr, bw_hz,
                 sgrscat=False, ampcal=False, phasecal=False)

# Test without multiprocessing
obs_nc = eh.calibrating.network_cal.network_cal(obs, im.total_flux(), processes=-1,msgtype='bh')
obs_sc = eh.calibrating.self_cal.self_cal(obs, im, processes=-1)

eh.comp_plots.plot_bl_obs_im_compare([obs,obs_nc,obs_sc],im,'SMA','ALMA','amp')
eh.comp_plots.plotall_obs_im_compare([obs,obs_nc,obs_sc],im,'uvdist','amp')
github achael / eht-imaging / scripts / verify_gradients.py View on Github external
# This is a rough script to verify the consistency of Fourier transform types and to check gradients of the various image regularization options

from __future__ import division
from __future__ import print_function

import numpy as np
import ehtim as eh

im = eh.image.load_txt('../models/avery_sgra_eofn.txt')
eht = eh.array.load_txt('../arrays/EHT2017.txt')

tint_sec = 5
tadv_sec = 600
tstart_hr = 0
tstop_hr = 24
bw_hz = 4e9
obs_dft = im.observe(eht, tint_sec, tadv_sec, tstart_hr, tstop_hr, bw_hz, sgrscat=False, ampcal=True, phasecal=True, ttype='direct', add_th_noise=False)
obs_nfft = im.observe(eht, tint_sec, tadv_sec, tstart_hr, tstop_hr, bw_hz, sgrscat=False, ampcal=True, phasecal=True, ttype='nfft', add_th_noise=False)

prior = im.copy()
im2 = im.copy() # This is our test image

# Add random noise to the image
for j in range(len(im2.imvec)):
    im2.imvec[j] *= (1.0 + (np.random.rand()-0.5)/10.0)
    im2.imvec[j] += (1.0 + (np.random.rand()-0.5)/10.0) * np.mean(im2.imvec)
github achael / eht-imaging / examples / example_dd_clean.py View on Github external
#example script for running data domain clean

import ehtim as eh
from ehtim.imaging.clean import *

#################################################################
# Data domain clean with complex visibilities
im = eh.image.load_txt('./models/avery_sgra_eofn.txt')
arr = eh.array.load_txt('./arrays/EHT2017.txt') 
#arr = eh.array.load_txt('./arrays/EHT2025.txt')
obs = im.observe(arr, 1000, 600, 0, 24., 4.e10, add_th_noise=False, phasecal=True)
prior = eh.image.make_square(obs, 128, 1.5*im.fovx())

# data domain clean with visibilities
outvis = dd_clean_vis(obs, prior, niter=100, loop_gain=0.1, method='min_chisq',weighting='uniform')

#################################################################
# Data domain clean directly with bispectrum
# trial image 2 -- 2 Gaussians
im2 = eh.image.make_square(obs, 256, 3*im.fovx())
im2 = im2.add_gauss(1., (1*eh.RADPERUAS, 1*eh.RADPERUAS, 0, 0, 0))
im2 = im2.add_gauss(.7, (1*eh.RADPERUAS, 1*eh.RADPERUAS, 0, -75*eh.RADPERUAS, 30*eh.RADPERUAS))
obs2 = im2.observe(arr, 600, 600, 0, 24., 4.e9, add_th_noise=False, phasecal=False)
prior = eh.image.make_square(obs, 50, 3*im.fovx())