Movie

class ehtim.movie.Movie(frames, times, psize, ra, dec, rf=230000000000.0, polrep='stokes', pol_prim=None, pulse=<function trianglePulse2D>, source='SgrA', mjd=51544, bounds_error=True, interp='linear')[source]

A polarimetric movie (in units of Jy/pixel).

pulse

The function convolved with the pixel values for continuous image

Type

function

psize

The pixel dimension in radians

Type

float

xdim

The number of pixels along the x dimension

Type

int

ydim

The number of pixels along the y dimension

Type

int

mjd

The integer MJD of the image

Type

int

source

The astrophysical source name

Type

str

ra

The source Right Ascension in fractional hours

Type

float

dec

The source declination in fractional degrees

Type

float

rf

The image frequency in Hz

Type

float

polrep

polarization representation, either ‘stokes’ or ‘circ’

Type

str

pol_prim

The default image: I,Q,U or V for Stokes, or RR,LL,LR,RL for Circular

Type

str

interp

Interpolation method, for scipy.interpolate.interp1d ‘kind’ keyword (e.g. ‘linear’, ‘nearest’, ‘quadratic’, ‘cubic’, ‘previous’, ‘next’…)

Type

str

bounds_error

if False, return nearest frame when outside [start_hr, stop_hr]

Type

bool

times

The list of frame time stamps in hours

Type

list

_movdict

The dictionary with the lists of frames

Type

dict

add_pol_movie(movie, pol)[source]

Add another movie polarization.

Parameters
  • movie (list) – list of 2D frames (possibly complex) in a Jy/pixel array

  • pol (str) – The image type: ‘I’,’Q’,’U’,’V’ for stokes, ‘RR’,’LL’,’RL’,’LR’ for circ

add_qu(qmovie, umovie)[source]

Add Stokes Q and U movies. self.polrep must be ‘stokes’

Parameters
  • qmovie (list) – list of 2D Stokes Q frames in Jy/pixel array

  • umovie (list) – list of 2D Stokes U frames in Jy/pixel array

Returns:

add_v(vmovie)[source]

Add Stokes V movie. self.polrep must be ‘stokes’

Parameters

vmovie (list) – list of 2D Stokes Q frames in Jy/pixel array

Returns:

avg_frame()[source]

Coherently Average the movie frames into a single image.

Returns

averaged image of all frames

Return type

(Image)

blur_circ(fwhm_x, fwhm_t, fwhm_x_pol=0)[source]

Apply a Gaussian filter to a list of images.

Parameters
  • fwhm_x (float) – circular beam size for spatial blurring in radians

  • fwhm_t (float) – temporal blurring in frames

  • fwhm_x_pol (float) – circular beam size for Stokes Q,U,V spatial blurring in radians

Returns

output image list

Return type

(Image)

circ_polfrac_curve()[source]

Return the (signed) total fractional circular polarized flux over time

Args:

Returns

image fractional circular polarized flux per frame

Return type

(numpy.ndarray)

copy()[source]

Return a copy of the Movie object.

Args:

Returns

copy of the Image.

Return type

(Movie)

export_mp4(out='movie.mp4', fps=10, dpi=120, interp='gaussian', scale='lin', dynamic_range=1000.0, cfun='afmhot', nvec=20, pcut=0.01, plotp=False, gamma=0.5, frame_pad_factor=1, label_time=False, verbose=False)[source]

Save the Movie to an mp4 file

fovx()[source]

Return the movie fov in x direction in radians.

Args:

Returns

movie fov in x direction (radian)

Return type

(float)

fovy()[source]

Returns the movie fov in y direction in radians.

Args:

Returns

movie fov in y direction (radian)

Return type

(float)

get_frame(n)[source]

Return an Image of the nth frame

Parameters

n (int) – the frame number

Returns

the Image object of the nth frame

Return type

(Image)

get_image(time)[source]

Return an Image at time

Parameters

time (float) – the time in hours

Returns

the Image object at the given time

Return type

(Image)

im_list()[source]

Return a list of the movie frames

Args:

Returns

list of Image objects

Return type

(list)

property lightcurve

Return the total flux over time of the image in Jy.

Args:

Returns

image total flux (Jy) over time

Return type

(numpy.Array)

lin_polfrac_curve()[source]

Return the total fractional linear polarized flux over time

Args:

Returns

image fractional linear polarized flux per frame

Return type

(numpy.ndarray)

movie_args()[source]

“Copy arguments for making a new Movie into a list and dictonary

observe(array, tint, tadv, tstart, tstop, bw, repeat=False, mjd=None, timetype='UTC', polrep_obs=None, elevmin=10.0, elevmax=85.0, no_elevcut_space=False, ttype='nfft', fft_pad_factor=2, fix_theta_GMST=False, sgrscat=False, add_th_noise=True, jones=False, inv_jones=False, opacitycal=True, ampcal=True, phasecal=True, frcal=True, dcal=True, rlgaincal=True, stabilize_scan_phase=False, stabilize_scan_amp=False, neggains=False, tau=0.1, taup=0.1, gain_offset=0.1, gainp=0.1, dterm_offset=0.05, rlratio_std=0.0, rlphase_std=0.0, caltable_path=None, seed=False, sigmat=None, verbose=True)[source]

Generate baselines from an array object and observe the movie.

Parameters
  • array (Array) – an array object containing sites with which to generate baselines

  • tint (float) – the scan integration time in seconds

  • tadv (float) – the uniform cadence between scans in seconds

  • tstart (float) – the start time of the observation in hours

  • tstop (float) – the end time of the observation in hours

  • bw (float) – the observing bandwidth in Hz

  • repeat (bool) – if True, repeat the movie to fill up the observation interval

  • mjd (int) – the mjd of the observation, if set as different from the image mjd

  • timetype (str) – how to interpret tstart and tstop; either ‘GMST’ or ‘UTC’

  • polrep_obs (str) – ‘stokes’ or ‘circ’ sets the data polarimetric representation

  • elevmin (float) – station minimum elevation in degrees

  • elevmax (float) – station maximum elevation in degrees

  • no_elevcut_space (bool) – if True, do not apply elevation cut to orbiters

  • ttype (str) – “fast”, “nfft” or “dtft”

  • fft_pad_factor (float) – zero pad the image to fft_pad_factor * image size in the FFT

  • fix_theta_GMST (bool) – if True, stops earth rotation to sample fixed u,v

  • sgrscat (bool) – if True, the visibilites will be blurred by the Sgr A* kernel

  • add_th_noise (bool) – if True, baseline-dependent thermal noise is added

  • jones (bool) – if True, uses Jones matrix to apply mis-calibration effects otherwise uses old formalism without D-terms

  • inv_jones (bool) – if True, applies estimated inverse Jones matrix (not including random terms) to calibrate data

  • opacitycal (bool) – if False, time-dependent gaussian errors are added to opacities

  • ampcal (bool) – if False, time-dependent gaussian errors are added to station gains

  • phasecal (bool) – if False, time-dependent station-based random phases are added

  • frcal (bool) – if False, feed rotation angle terms are added to Jones matrix.

  • dcal (bool) – if False, time-dependent gaussian errors added to Jones matrix D-terms.

  • rlgaincal (bool) – if False, time-dependent gains are not equal for R and L pol

  • stabilize_scan_phase (bool) – if True, random phase errors are constant over scans

  • stabilize_scan_amp (bool) – if True, random amplitude errors are constant over scans

  • neggains (bool) – if True, force the applied gains to be <1

  • tau (float) – the base opacity at all sites, or a dict giving one opacity per site

  • taup (float) – the fractional std. dev. of the random error on the opacities

  • gainp (float) – the fractional std. dev. of the random error on the gains or a dict giving one std. dev. per site

  • gain_offset (float) – the base gain offset at all sites, or a dict giving one gain offset per site

  • dterm_offset (float) – the base std. dev. of random additive error at all sites, or a dict giving one std. dev. per site

  • rlratio_std (float) – the fractional std. dev. of the R/L gain offset or a dict giving one std. dev. per site

  • rlphase_std (float) – std. dev. of R/L phase offset, or a dict giving one std. dev. per site a negative value samples from uniform

  • caltable_path (string) – If not None, path and prefix for saving the applied caltable

  • seed (int) – seeds the random component of the noise terms. DO NOT set to 0!

  • sigmat (float) – temporal std for a Gaussian Process used to generate gain noise. if sigmat=None then an iid gain noise is applied.

  • verbose (bool) – print updates and warnings

Returns

an observation object

Return type

(Obsdata)

observe_same(obs_in, repeat=False, ttype='nfft', fft_pad_factor=2, sgrscat=False, add_th_noise=True, jones=False, inv_jones=False, opacitycal=True, ampcal=True, phasecal=True, frcal=True, dcal=True, rlgaincal=True, stabilize_scan_phase=False, stabilize_scan_amp=False, neggains=False, taup=0.1, gain_offset=0.1, gainp=0.1, dterm_offset=0.05, rlratio_std=0.0, rlphase_std=0.0, caltable_path=None, seed=False, sigmat=None, verbose=True)[source]

Observe the image on the same baselines as an existing observation object and add noise.

Parameters
  • obs_in (Obsdata) – existing observation with baselines where the FT will be sampled

  • repeat (bool) – if True, repeat the movie to fill up the observation interval

  • ttype (str) – “fast” or “nfft” or “direct”

  • fft_pad_factor (float) – zero pad the image to fft_pad_factor * image size in FFT

  • sgrscat (bool) – if True, the visibilites will be blurred by the Sgr A* kernel

  • add_th_noise (bool) – if True, baseline-dependent thermal noise is added

  • jones (bool) – if True, uses Jones matrix to apply mis-calibration effects

  • inv_jones (bool) – if True, applies estimated inverse Jones matrix (not including random terms) to a priori calibrate data

  • opacitycal (bool) – if False, time-dependent gaussian errors are added to opacities

  • ampcal (bool) – if False, time-dependent gaussian errors are added to station gains

  • phasecal (bool) – if False, time-dependent station-based random phases are added

  • frcal (bool) – if False, feed rotation angle terms are added to Jones matrices.

  • dcal (bool) – if False, time-dependent gaussian errors added to D-terms.

  • rlgaincal (bool) – if False, time-dependent gains are not equal for R and L pol

  • stabilize_scan_phase (bool) – if True, random phase errors are constant over scans

  • stabilize_scan_amp (bool) – if True, random amplitude errors are constant over scans

  • neggains (bool) – if True, force the applied gains to be <1

  • taup (float) – the fractional std. dev. of the random error on the opacities

  • gainp (float) – the fractional std. dev. of the random error on the gains or a dict giving one std. dev. per site

  • gain_offset (float) – the base gain offset at all sites, or a dict giving one gain offset per site

  • dterm_offset (float) – the base std. dev. of random additive error at all sites, or a dict giving one std. dev. per site

  • rlratio_std (float) – the fractional std. dev. of the R/L gain offset or a dict giving one std. dev. per site

  • rlphase_std (float) – std. dev. of R/L phase offset, or a dict giving one std. dev. per site a negative value samples from uniform

  • caltable_path (string) – If not None, path and prefix for saving the applied caltable

  • seed (int) – seeds the random component of the noise terms. DO NOT set to 0!

  • sigmat (float) – temporal std for a Gaussian Process used to generate gain noise. if sigmat=None then an iid gain noise is applied.

  • verbose – print updates and warnings

observe_same_nonoise(obs, repeat=False, sgrscat=False, ttype='nfft', fft_pad_factor=2, zero_empty_pol=True, verbose=True)[source]

Observe the movie on the same baselines as an existing observation without adding noise.

Parameters
  • obs (Obsdata) – existing observation with baselines where the FT will be sampled

  • repeat (bool) – if True, repeat the movie to fill up the observation interval

  • sgrscat (bool) – if True, the visibilites are blurred by the Sgr A* scattering kernel

  • ttype (str) – if “fast”, use FFT to produce visibilities. Else “direct” for DTFT

  • fft_pad_factor (float) – zero pad the image to fft_pad_factor * image size in FFT

  • zero_empty_pol (bool) – if True, returns zero vec if the polarization doesn’t exist. Otherwise return None

  • verbose (bool) – Boolean value controls output prints.

Returns

an observation object

Return type

(Obsdata)

observe_vex(vex, source, synchronize_start=True, t_int=0.0, polrep_obs=None, ttype='nfft', fft_pad_factor=2, fix_theta_GMST=False, sgrscat=False, add_th_noise=True, jones=False, inv_jones=False, opacitycal=True, ampcal=True, phasecal=True, frcal=True, dcal=True, rlgaincal=True, stabilize_scan_phase=False, stabilize_scan_amp=False, neggains=False, tau=0.1, taup=0.1, gain_offset=0.1, gainp=0.1, dterm_offset=0.05, caltable_path=None, seed=False, sigmat=None, verbose=True)[source]

Generate baselines from a vex file and observe the movie.

Parameters
  • vex (Vex) – an vex object containing sites and scan information

  • source (str) – the source to observe

  • synchronize_start (bool) – if True, the start of the movie is defined as the start of the observations

  • t_int (float) – if not zero, overrides the vex scan lengths

  • polrep_obs (str) – ‘stokes’ or ‘circ’ sets the data polarimetric representation

  • ttype (str) – “fast” or “nfft” or “dtft”

  • fft_pad_factor (float) – zero pad the image to fft_pad_factor * image size in FFT

  • fix_theta_GMST (bool) – if True, stops earth rotation to sample fixed u,v

  • sgrscat (bool) – if True, the visibilites will be blurred by the Sgr A* kernel

  • add_th_noise (bool) – if True, baseline-dependent thermal noise is added

  • jones (bool) – if True, uses Jones matrix to apply mis-calibration effects otherwise uses old formalism without D-terms

  • inv_jones (bool) – if True, applies estimated inverse Jones matrix (not including random terms) to calibrate data

  • opacitycal (bool) – if False, time-dependent gaussian errors are added to opacities

  • ampcal (bool) – if False, time-dependent gaussian errors are added to station gains

  • phasecal (bool) – if False, time-dependent station-based random phases are added

  • frcal (bool) – if False, feed rotation angle terms are added to Jones matrix.

  • dcal (bool) – if False, time-dependent gaussian errors added to Jones matrix D-terms.

  • rlgaincal (bool) – if False, time-dependent gains are not equal for R and L pol

  • stabilize_scan_phase (bool) – if True, random phase errors are constant over scans

  • stabilize_scan_amp (bool) – if True, random amplitude errors are constant over scans

  • neggains (bool) – if True, force the applied gains to be <1

  • tau (float) – the base opacity at all sites, or a dict giving one opacity per site

  • taup (float) – the fractional std. dev. of the random error on the opacities

  • gain_offset (float) – the base gain offset at all sites, or a dict giving one gain offset per site

  • gainp (float) – the fractional std. dev. of the random error on the gains

  • dterm_offset (float) – the base dterm offset at all sites, or a dict giving one dterm offset per site

  • caltable_path (string) – If not None, path and prefix for saving the applied caltable

  • seed (int) – seeds the random component of the noise terms. DO NOT set to 0!

  • sigmat (float) – temporal std for a Gaussian Process used to generate gain noise. if sigmat=None then an iid gain noise is applied.

  • verbose (bool) – print updates and warnings

Returns

an observation object

Return type

(Obsdata)

offset_time(t_offset)[source]

Offset the movie in time by t_offset

Parameters

t_offset (float) – offset time in hours

Returns:

orth_chi()[source]

Rotate the EVPA 90 degrees

Args:

Returns

movie with rotated EVPA

Return type

(Image)

reset_interp(interp=None, bounds_error=None)[source]

Reset the movie interpolation function to change the interp. type or change the frames

Parameters
  • interp (str) – Interpolation method, input to scipy.interpolate.interp1d kind keyword

  • bounds_error (bool) – if False, return nearest frame outside [start_hr, stop_hr]

save_fits(fname)[source]

Save the Movie data to individual fits files with filenames basename + 00001, etc.

Parameters

fname (str) – basename of output files

Returns:

save_hdf5(fname)[source]

Save the Movie data to a single hdf5 file.

Parameters

fname (str) – output file name

Returns:

save_txt(fname)[source]

Save the Movie data to individual text files with filenames basename + 00001, etc.

Parameters

fname (str) – basename of output files

Returns:

switch_polrep(polrep_out='stokes', pol_prim_out=None)[source]

Return a new movie with the polarization representation changed

Parameters
  • polrep_out (str) – the polrep of the output data

  • pol_prim_out (str) – The default movie: I,Q,U or V for Stokes, RR,LL,LR,RL for Circular

Returns

new movie object with potentially different polrep

Return type

(Movie)

ehtim.movie.export_multipanel_mp4(input_list, out='movie.mp4', start_hr=None, stop_hr=None, nframes=100, fov=None, npix=None, nrows=1, fps=10, dpi=120, verbose=False, titles=None, panel_size=4.0, common_scale=False, scale='linear', label_type='scale', has_cbar=False, **kwargs)[source]

Export a movie comparing multiple movies in a grid.

Parameters
  • input_list (list) – The list of input Movies or Images

  • out (string) – The output filename

  • start_hr (float) – The start time in hours. If None, defaults to first start time

  • end_hr (float) – The end time in hours. If None, defaults to last start time

  • nframes (int) – The number of frames in the output movie

  • fov (float) – If specified, use this field of view for all panels

  • npix (int) – If specified, use this linear pixel dimension for all panels

  • nrows (int) – Number of rows in movie

  • fps (int) – Frames per second

  • titles (list) – List of panel titles for input_list

  • panel_size (float) – Size of individual panels (inches)

ehtim.movie.load_fits(basename, nframes, framedur=-1, pulse=<function trianglePulse2D>, polrep='stokes', pol_prim=None, zero_pol=True, interp='linear', bounds_error=True)[source]

Read in a movie from fits files and create a Movie object.

Parameters
  • basename (str) – The base name of individual movie frames. Files should have names basename + 00001, etc.

  • nframes (int) – The total number of frames

  • framedur (float) – The frame duration in seconds. if famedur==-1, frame duration taken from file headers

  • pulse (function) – The function convolved with the pixel values for continuous image

  • polrep (str) – polarization representation, either ‘stokes’ or ‘circ’

  • pol_prim (str) – The default image: I,Q,U or V for Stokes, RR,LL,LR,RL for Circular

  • zero_pol (bool) – If True, loads any missing polarizations as zeros

  • interp (str) – Interpolation method, input to scipy.interpolate.interp1d kind keyword

  • bounds_error (bool) – if False, return nearest frame outside interval [start_hr, stop_hr]

Returns

a Movie object

Return type

Movie

ehtim.movie.load_hdf5(file_name, pulse=<function trianglePulse2D>, interp='linear', bounds_error=True)[source]

Read in a movie from an hdf5 file and create a Movie object.

Parameters
  • file_name (str) – The name of the hdf5 file.

  • pulse (function) – The function convolved with the pixel values for continuous image

  • interp (str) – Interpolation method, input to scipy.interpolate.interp1d kind keyword

  • bounds_error (bool) – if False, return nearest frame outside interval [start_hr, stop_hr]

Returns

a Movie object

Return type

Movie

ehtim.movie.load_txt(basename, nframes, framedur=-1, pulse=<function trianglePulse2D>, polrep='stokes', pol_prim=None, zero_pol=True, interp='linear', bounds_error=True)[source]

Read in a movie from text files and create a Movie object.

Parameters
  • basename (str) – The base name of individual movie frames. Files should have names basename + 00001, etc.

  • nframes (int) – The total number of frames

  • framedur (float) – The frame duration in seconds if famedur==-1, frame duration taken from file headers

  • pulse (function) – The function convolved with the pixel values for continuous image

  • polrep (str) – polarization representation, either ‘stokes’ or ‘circ’

  • pol_prim (str) – The default image: I,Q,U or V for Stokes, RR,LL,LR,RL for Circular

  • zero_pol (bool) – If True, loads any missing polarizations as zeros

  • interp (str) – Interpolation method, input to scipy.interpolate.interp1d kind keyword

  • bounds_error (bool) – if False, return nearest frame outside interval [start_hr, stop_hr]

Returns

a Movie object

Return type

Movie

ehtim.movie.merge_im_list(imlist, framedur=- 1, interp='linear', bounds_error=True)[source]

Merge a list of image objects into a movie object.

Parameters
  • imlist (list) – list of Image objects

  • framedur (float) – duration of a movie frame in seconds use to override times in the individual movies

  • interp (str) – Interpolation method, input to scipy.interpolate.interp1d kind keyword

  • bounds_error – if False, return nearest frame outside interval [start_hr, stop_hr]