Scattering

ehtim.scattering.stochastic_optics.MakeEpsilonScreen(Nx, Ny, rngseed=0)[source]

Create a standardized Fourier representation of a scattering screen

Parameters
  • Nx (int) – Number of pixels in the x direction

  • Ny (int) – Number of pixels in the y direction

  • rngseed (int) – Seed for the random number generator

Returns

A 2D numpy ndarray.

Return type

epsilon

class ehtim.scattering.stochastic_optics.ScatteringModel(model='dipole', scatt_alpha=1.38, observer_screen_distance=8.702519999999999e+21, source_screen_distance=1.706558e+22, theta_maj_mas_ref=1.38, theta_min_mas_ref=0.703, POS_ANG=81.9, wavelength_reference_cm=1.0, r_in=80000000.0, r_out=1e+20)[source]

A scattering model based on a thin-screen approximation.

Models include:
(‘von_Mises’, ‘boxcar’, ‘dipole’): These scattering models are motivated by observations of Sgr A*.

Each gives a Gaussian at long wavelengths that matches the model defined by {theta_maj_mas_ref, theta_min_mas_ref, POS_ANG} at the reference wavelength wavelength_reference_cm with a lambda^2 scaling. The source sizes {theta_maj, theta_min} are the image FWHM in milliarcseconds at the reference wavelength. Note that this may not match the ensemble-average kernel at the reference wavelength, if the reference wavelength is short enough to be beyond the lambda^2 regime! This model also includes an inner and outer scale and will thus transition to scattering with scatt_alpha at shorter wavelengths Note: This model requires a finite inner scale

‘power-law’: This scattering model gives a pure power law at all wavelengths. There is no inner scale, but there can be an outer scale.

The ensemble-average image is given by {theta_maj_mas_ref, theta_min_mas_ref, POS_ANG} at the reference wavelength wavelength_reference_cm. The ensemble-average image size is proportional to wavelength^(1+2/scatt_alpha) = wavelength^(11/5) for Kolmogorov

model

The type of scattering model (determined by the power spectrum of phase fluctuations).

Type

string

scatt_alpha

The power-law index of the phase fluctuations (Kolmogorov is 5/3).

Type

float

observer_screen_distance

The distance from the observer to the scattering screen in cm.

Type

float

source_screen_distance

The distance from the source to the scattering screen in cm.

Type

float

theta_maj_mas_ref

FWHM in mas of the major axis angular broadening at the specified reference wavelength.

Type

float

theta_min_mas_ref

FWHM in mas of the minor axis angular broadening at the specified reference wavelength.

Type

float

POS_ANG

The position angle of the major axis of the scattering.

Type

float

wavelength_reference_cm

The reference wavelength for the scattering model in cm.

Type

float

r_in

The inner scale of the scattering screen in cm.

Type

float

r_out

The outer scale of the scattering screen in cm.

Type

float

rF[source]

The Fresnel scale of the scattering screen at the specific wavelength.

Type

function

Deblur_obs(obs, use_approximate_form=True)[source]

Deblurs the observation obs by dividing visibilities by the ensemble-average scattering kernel. See Fish et al. (2014): arXiv:1409.4690.

Parameters

obs (Obsdata) – The observervation data (including scattering).

Returns

The deblurred observation.

Return type

obsdeblur (Obsdata)

Ensemble_Average_Blur(im, wavelength_cm=None, ker=None, use_approximate_form=True)[source]

Blurs an input Image with the ensemble-average scattering kernel.

Parameters
  • im (Image) – The unscattered image.

  • wavelength_cm (float) – The observing wavelength for the scattering kernel in cm. If unspecified, this will default to the wavelength of the input image.

  • ker (2D ndarray) – The user can optionally pass a pre-computed ensemble-average blurring kernel.

Returns

The ensemble-average scattered image.

Return type

out (Image)

Ensemble_Average_Kernel(Reference_Image, wavelength_cm=None, use_approximate_form=True)[source]

The ensemble-average convolution kernel for images; returns a 2D array corresponding to the image dimensions of the reference image

Parameters
  • Reference_Image (Image) – Reference image to determine image and pixel dimensions and wavelength.

  • wavelength_cm (float) – The observing wavelength for the scattering kernel in cm. If unspecified, this will default to the wavelength of the Reference image.

Returns

The ensemble-average scattering kernel in the image domain.

Return type

ker (2D ndarray)

Ensemble_Average_Kernel_Visibility(u, v, wavelength_cm, use_approximate_form=True)[source]

The ensemble-average multiplicative scattering kernel for visibilities at a particular {u,v} coordinate

Parameters
  • u (float) – u baseline coordinate (dimensionless)

  • v (float) – v baseline coordinate (dimensionless)

  • wavelength_cm (float) – The observing wavelength for the scattering kernel in cm.

Returns

The ensemble-average kernel at the specified {u,v} point and observing wavelength.

Return type

float

Mag()[source]

Returns the effective magnification the scattering screen: (observer-screen distance)/(source-screen distance).

Returns

The effective magnification of the scattering screen.

Return type

M (float)

MakePhaseScreen(EpsilonScreen, Reference_Image, obs_frequency_Hz=0.0, Vx_km_per_s=50.0, Vy_km_per_s=0.0, t_hr=0.0, sqrtQ_init=None)[source]

Create a refractive phase screen from standardized Fourier components (the EpsilonScreen). All lengths should be specified in centimeters If the observing frequency (obs_frequency_Hz) is not specified, then it will be taken to be equal to the frequency of the Reference_Image Note: an odd image dimension is required!

Parameters
  • EpsilonScreen (2D ndarray) – Optionally, the scattering screen can be specified. If none is given, a random one will be generated.

  • Reference_Image (Image) – The reference image.

  • obs_frequency_Hz (float) – The observing frequency, in Hz. By default, it will be taken to be equal to the frequency of the Unscattered_Image.

  • Vx_km_per_s (float) – Velocity of the scattering screen in the x direction (toward East) in km/s.

  • Vy_km_per_s (float) – Velocity of the scattering screen in the y direction (toward North) in km/s.

  • t_hr (float) – The current time of the scattering in hours.

  • ea_ker (2D ndarray) – The used can optionally pass a precomputed array of the ensemble-average blurring kernel.

  • sqrtQ_init (2D ndarray) – The used can optionally pass a precomputed array of the square root of the power spectrum.

Returns

The phase screen.

Return type

phi_Image (Image)

Q(qx, qy)[source]

Computes the power spectrum of the scattering model at a wavenumber {qx,qy} (in 1/cm). The power spectrum is part of what defines the scattering model (along with Dphi). Q(qx,qy) is independent of the observing wavelength.

Parameters
  • qx (float) – x coordinate of the wavenumber in 1/cm.

  • qy (float) – y coordinate of the wavenumber in 1/cm.

Returns

The power spectrum Q(qx,qy)

Return type

(float)

Scatter(Unscattered_Image, Epsilon_Screen=array([], dtype=float64), obs_frequency_Hz=0.0, Vx_km_per_s=50.0, Vy_km_per_s=0.0, t_hr=0.0, ea_ker=None, sqrtQ=None, Linearized_Approximation=False, DisplayImage=False, Force_Positivity=False, use_approximate_form=True)[source]

Scatter an image using the specified epsilon screen. All lengths should be specified in centimeters If the observing frequency (obs_frequency_Hz) is not specified, then it will be taken to be equal to the frequency of the Unscattered_Image Note: an odd image dimension is required!

Parameters
  • Unscattered_Image (Image) – The unscattered image.

  • Epsilon_Screen (2D ndarray) – Optionally, the scattering screen can be specified. If none is given, a random one will be generated.

  • obs_frequency_Hz (float) – The observing frequency, in Hz. By default, it will be taken to be equal to the frequency of the Unscattered_Image.

  • Vx_km_per_s (float) – Velocity of the scattering screen in the x direction (toward East) in km/s.

  • Vy_km_per_s (float) – Velocity of the scattering screen in the y direction (toward North) in km/s.

  • t_hr (float) – The current time of the scattering in hours.

  • ea_ker (2D ndarray) – The used can optionally pass a precomputed array of the ensemble-average blurring kernel.

  • sqrtQ (2D ndarray) – The used can optionally pass a precomputed array of the square root of the power spectrum.

  • Linearized_Approximation (bool) – If True, uses a linearized approximation for the scattering (Eq. 10 of Johnson & Narayan 2016). If False, uses Eq. 9 of that paper.

  • DisplayImage (bool) – If True, show a plot of the unscattered, ensemble-average, and scattered images as well as the phase screen.

  • Force_Positivity (bool) – If True, eliminates negative flux from the scattered image from the linearized approximation.

  • Return_Image_List (bool) – If True, returns a list of the scattered frames. If False, returns a movie object.

Returns

The scattered image.

Return type

AI_Image (Image)

Scatter2(args, kwargs)[source]

Call self.Scatter with expanded args and kwargs.

Scatter_Movie(Unscattered_Movie, Epsilon_Screen=array([], dtype=float64), obs_frequency_Hz=0.0, Vx_km_per_s=50.0, Vy_km_per_s=0.0, framedur_sec=None, N_frames=None, ea_ker=None, sqrtQ=None, Linearized_Approximation=False, Force_Positivity=False, Return_Image_List=False, processes=0)[source]

Scatter a movie using the specified epsilon screen. The movie can either be a movie object, an image list, or a static image If scattering a list of images or static image, the frame duration in seconds (framedur_sec) must be specified If scattering a static image, the total number of frames must be specified (N_frames) All lengths should be specified in centimeters If the observing frequency (obs_frequency_Hz) is not specified, then it will be taken to be equal to the frequency of the Unscattered_Movie Note: an odd image dimension is required!

Parameters
  • Unscattered_Movie – This can be a movie object, an image list, or a static image

  • Epsilon_Screen (2D ndarray) – Optionally, the scattering screen can be specified. If none is given, a random one will be generated.

  • obs_frequency_Hz (float) – The observing frequency, in Hz. By default, it will be taken to be equal to the frequency of the Unscattered_Movie.

  • Vx_km_per_s (float) – Velocity of the scattering screen in the x direction (toward East) in km/s.

  • Vy_km_per_s (float) – Velocity of the scattering screen in the y direction (toward North) in km/s.

  • framedur_sec (float) – Duration of each frame, in seconds. Only needed if Unscattered_Movie is not a movie object.

  • N_frames (int) – Total number of frames. Only needed if Unscattered_Movie is a static image object.

  • ea_ker (2D ndarray) – The used can optionally pass a precomputed array of the ensemble-average blurring kernel.

  • sqrtQ (2D ndarray) – The used can optionally pass a precomputed array of the square root of the power spectrum.

  • Linearized_Approximation (bool) – If True, uses a linearized approximation for the scattering (Eq. 10 of Johnson & Narayan 2016). If False, uses Eq. 9 of that paper.

  • Force_Positivity (bool) – If True, eliminates negative flux from the scattered image from the linearized approximation.

  • Return_Image_List (bool) – If True, returns a list of the scattered frames. If False, returns a movie object.

  • processes (int) – Number of cores to use in multiprocessing. Default value (0) means no multiprocessing. Uses all available cores if processes < 0.

Returns

Either a movie object or a list of images, depending on the flag Return_Image_List.

Return type

Scattered_Movie

dDphi_dz(r, phi, phi_q, wavelength)[source]

differential contribution to the phase structure function

rF(wavelength)[source]

Returns the Fresnel scale [cm] of the scattering screen at the specified wavelength [cm].

Parameters

wavelength (float) – The desired wavelength [cm]

Returns

The Fresnel scale [cm]

Return type

rF (float)

sqrtQ_Matrix(Reference_Image, Vx_km_per_s=50.0, Vy_km_per_s=0.0, t_hr=0.0)[source]

Computes the square root of the power spectrum on a discrete grid. Because translation of the screen is done most conveniently in Fourier space, a screen translation can also be included.

Parameters
  • Reference_Image (Image) – Reference image to determine image and pixel dimensions and wavelength.

  • Vx_km_per_s (float) – Velocity of the scattering screen in the x direction (toward East) in km/s.

  • Vy_km_per_s (float) – Velocity of the scattering screen in the y direction (toward North) in km/s.

  • t_hr (float) – The current time of the scattering in hours.

Returns

The square root of the power spectrum of the screen with an additional phase for rotation of the screen.

Return type

sqrtQ (2D complex ndarray)