distroi.data.oi_container module#

Contains a class to store optical interferometric (OI) observables and additional functions to take radiative transfer (RT) model images and convert them to interferometric observables at the spatial frequencies of data stored in the OIFITS format. Currently supports the following combinations of observables: Squared visibilities - Closure phases; Visibilities - Closure phases; Correlated fluxes (formally stored as visibilities) - Closure phases.

class distroi.data.oi_container.OIContainer(dictionary: dict[str, ndarray], fcorr: bool = False)#

Bases: object

Class to contain optical interferometry observables, where each observable is stored in the form of raveled 1D numpy arrays. Based on the Data class in ReadOIFITS.py, where the observables are stored per OIFITS table, but the raveled form makes calculations easier and less prone to error. Currently supports visibilities (both in normalized and correlated flux form), squared visibilities and closure phases. In this format this class and the methods below can be expanded to accommodate for different kinds of observables (i.e. addition of differential visibilities). Can contain observables either related to astronomical observations or model RT images.

Parameters:
  • dictionary (dict) – Dictionary containing keys and values representing all instance variables described below (excluding fcorr).

  • fcorr (bool, optional) – Set to True if the visibilities are to be stored as correlated fluxes in Jy.

vis_in_fcorr#

Whether visibilities are stored in correlated flux or not.

Type:

bool

v_uf#

u-axis spatial freqs in 1/rad for visibility data.

Type:

np.ndarray

v_vf#

v-axis spatial freqs in 1/rad for visibility data.

Type:

np.ndarray

v_wave#

Wavelengths in micron for visibility data.

Type:

np.ndarray

v#

Visibilities, either normalized visibilities or correlated flux in Jansky.

Type:

np.ndarray

v_err#

Error on visibilities.

Type:

np.ndarray

v_base#

Baseline length in MegaLambda for visibility data.

Type:

np.ndarray

v2_uf#

u-axis spatial freqs in 1/rad for squared visibility data.

Type:

np.ndarray

v2_vf#

v-axis spatial freqs in 1/rad for squared visibility data.

Type:

np.ndarray

v2_wave#

Wavelengths in micron for squared visibility data.

Type:

np.ndarray

v2#

Squared visibilities.

Type:

np.ndarray

v2_err#

Error on squared visibilities.

Type:

np.ndarray

v2_base#

Baseline length in MegaLambda for squared visibility data.

Type:

np.ndarray

t3_uf1#

u-axis spatial freqs in 1/rad for the 1st projected baseline along the closure triangle.

Type:

np.ndarray

t3_vf1#

v-axis spatial freqs in 1/rad for the 1st projected baseline along the closure triangle.

Type:

np.ndarray

t3_uf2#

u-axis spatial freqs in 1/rad for the 2nd projected baseline along the closure triangle.

Type:

np.ndarray

t3_vf2#

v-axis spatial freqs in 1/rad for the 2nd projected baseline along the closure triangle.

Type:

np.ndarray

t3_uf3#

u-axis spatial freqs in 1/rad for the 3rd projected baseline along the closure triangle.

Type:

np.ndarray

t3_vf3#

v-axis spatial freqs in 1/rad for the 3rd projected baseline along the closure triangle.

Type:

np.ndarray

t3_wave#

Wavelengths in micron for closure phase data.

Type:

np.ndarray

t3phi#

Closure phases in degrees.

Type:

np.ndarray

t3phi_err#

Error on closure phases.

Type:

np.ndarray

t3_bmax#

Maximum baseline length along the closure triangle in units of MegaLambda.

Type:

np.ndarray

plot_data(fig_dir: str | None = None, log_plotv: bool = False, plot_vistype: Literal['vis2', 'vis', 'fcorr'] = 'vis2', show_plots: bool = True, data_figsize: tuple = (10, 5)) None#

Plots the data included in the OIContainer instance. Currently, plots uv coverage, a (squared) visibility curve and closure phases.

Parameters:
  • fig_dir (str, optional) – Directory to store plots in.

  • log_plotv (bool, optional) – Set to True for a logarithmic y-scale in the (squared) visibility plot.

  • plot_vistype ({'vis2', 'vis', 'fcorr'}, optional) – Sets the type of visibility to be plotted. ‘vis2’ for squared visibilities or ‘vis’ for visibilities (either normalized or correlated flux in Jy, as implied by the OIContainer objects).

  • show_plots (bool, optional) – Set to False if you do not want the plots to be shown during your python instance. Note that if True, this freezes further code execution until the plot windows are closed.

Return type:

None

distroi.data.oi_container.oi_container_calc_image_fft_observables(container_data: OIContainer, img_ffts: list[Image], img_sed: SED | None = None, geom_comps: list[GeomComp] | None = None, geom_comp_flux_fracs: list[float] | None = None, ref_wavelength: float | None = None, interp_method: str = 'linear') OIContainer#

Loads in OI observables from an OIContainer, and calculates corresponding model image observables. The model images are passed along as a list of Image objects.

If this list contains one object, the normalized visibilities will not be interpolated in the wavelength dimension, i.e. the emission morphology is ‘monochromatic’. If the list contains multiple Image objects, interpolation in wavelength is performed. In this case the wavelength coverage of the Image objects needs to exceed that of the OIContainer!

NOTE: This method expects that every Image object in the list has the same pixelscale and amount of pixels (in both x- and y-direction).

Parameters:
  • container_data (OIContainer) – OIContainer at whose spatial frequencies we calculate model observables.

  • img_ffts (list of image.Image) – List of Image objects representing the RT model images at different wavelengths. If containing only one object, no interpolation of the normalized visibilities in the wavelength dimension will be performed.

  • img_sed (sed.SED, optional) – Optional SED to be passed along defining the total flux wavelength dependence of the model Image(s). By default, this is None, and the total flux wavelength dependence will be taken from either the SpecDep property of the Image, in case img_ffts contains a single Image object, or from a linear interpolation between the total fluxes in case img_ffts contains multiple Image objects.

  • geom_comps (list of geom_comp.GeomComp, optional) – Optional list of GeomComp objects, representing geometric components to be added to the complex visibility calculation.

  • geom_comp_flux_fracs (list of float, optional) – Flux fractions of the geometric components. Should add up to less than one. The remainder from the difference with one will be the flux fraction attributed to the model image(s).

  • ref_wavelength (float, optional) – Reference wavelength for the geometric component flux fractions in micron. In case image_ffts contains more than one model image. This wavelength must lie within the wavelength range spanned by the SED (if passed along), or by the model images.

  • interp_method (str, optional) – Interpolation method used by scipy to perform interpolations. Can support ‘linear’, ‘nearest’, ‘slinear’, or ‘cubic’.

Returns:

OIContainer for model image observables.

Return type:

OIContainer

distroi.data.oi_container.oi_container_plot_data_vs_model(container_data: OIContainer, container_mod: OIContainer, fig_dir: str | None = None, log_plotv: bool = False, plot_vistype: Literal['vis2', 'vis', 'fcorr'] = 'vis2', show_plots: bool = True) None#

Plots the data against the model OI observables. Currently, plots uv coverage, a (squared) visibility curve and closure phases. Note that this function shares a name with a similar function in the sed module. Take care with your namespace if you use both functions in the same script.

Parameters:
  • container_data (OIContainer) – Container with data observables.

  • container_mod (OIContainer) – Container with model observables.

  • fig_dir (str, optional) – Directory to store plots in.

  • log_plotv (bool, optional) – Set to True for a logarithmic y-scale in the (squared) visibility plot.

  • plot_vistype ({'vis2', 'vis', 'fcorr'}, optional) – Sets the type of visibility to be plotted. ‘vis2’ for squared visibilities, ‘vis’ for visibilities or ‘fcorr’ for correlated flux in Jy.

  • show_plots (bool, optional) – Set to False if you do not want the plots to be shown during your python instance. Note that if True, this freezes further code execution until the plot windows are closed.

Return type:

None

distroi.data.oi_container.read_oi_container_from_oifits(data_dir: str, data_file: str, wave_lims: tuple[float, float] | None = None, v2lim: float | None = None, fcorr: bool = False) OIContainer#

Retrieve data from (multiple) OIFITS files and return in an OIContainer class instance.

Parameters:
  • data_dir (str) – Path to the directory where the files are stored.

  • data_file (str) – Data filename, including wildcards if needed to read in multiple files at once.

  • wave_lims (tuple[float, float], optional) – The lower and upper wavelength limits in micron used when reading in data.

  • v2lim (float, optional) – Upper limit on the squared visibility used when reading in data.

  • fcorr (bool, optional) – Set to True if visibility data is to be interpreted as correlated fluxes in Jy units.

Returns:

OIContainer with the observables from the OIFITS file.

Return type:

OIContainer