Plotting

The matplotlib figures need using PythonPlot; the _makie figures need a Makie backend.

FunctionDescription
uvplot(data)Plot UV coverage
plot_v2(data)Plot squared visibilities vs baseline
plot_t3phi(data)Plot closure phases vs baseline
plot_t3amp(data)Plot triple amplitudes vs baseline
plot_visamp(data)Plot visibility amplitudes
plot_visphi(data)Plot visibility phases
plot_diffphi(data)Plot differential phases
plot_flux(data)Plot flux vs wavelength
plot_obs(data; obs, ...)Multi-panel figure with shared x-axis and legend (alias plot_multi)
plot_v2_residuals(data, v2_model)Plot V² residuals against a model
plot_t3phi_residuals(data, t3phi_model)Plot closure-phase residuals
plot_t3amp_residuals(data, t3amp_model)Plot triple-amplitude residuals
plot_visamp_residuals(data, visamp_model)Plot visibility-amplitude residuals
plot_visphi_residuals(data, visphi_model)Plot visibility-phase residuals
plot_residuals(data, obs)Combined residual plot for all observables
plot_v2_multifile(data_vec)Overlay V² from multiple datasets
plot_facility(facility)Plot telescope positions from a FacilityConfig
imdisp(image; pixsize, ...)Display a single image
imdisp_multi(cube; labels, ...)Display multiple images side by side
set_oiplot_defaults()Apply matplotlib style settings
plot_ultranest_corner(result)Corner plot of an UltraNest result
OITOOLS.set_oiplot_defaults — Function
set_oiplot_defaults(; compact=oiplot_compact)

Apply consistent matplotlib style settings. When compact=true, all sizes are reduced for stacking multiple plots in a single figure. Calling without arguments preserves the current compact state.

The plotting functions install these once, on the first plot of a session. After that your own matplotlib.rcParams edits are left alone, so you can restyle freely:

using OITOOLS, PythonCall
plot_v2(data)                                        # style installed here
pyimport("matplotlib").rcParams["font.family"] = ["serif"]
plot_v2(data)                                        # serif is honoured

Call this function directly to reapply the OITOOLS style and discard such overrides.

source
OITOOLS.uvplot — Function
uvplot(data; kwargs...)

Plot the UV coverage for one or more OIdata bins. Conjugate baselines (-u, -v) are always shown. Accepts a single OIdata, a vector, or the 2-D array returned by readoifits (flattened automatically).

Keyword arguments

  • color — colouring scheme:
    • "baseline" (default) — one colour per baseline pair, labelled legend
    • "wav" / "wavelength" — coloured by λ (μm) with a horizontal colorbar
    • "mjd" / "time" — coloured by MJD with a horizontal colorbar
    • any other string — all points black
  • figsize — figure size tuple. Default: (10, 10).
  • minuv, maxuv — axis limits in Mλ when square=true.
  • square — force equal axis limits. Default: true.
  • legend_below — place the baseline legend below the plot. Default: true.
  • figtitle — plot title string.
  • cmap — matplotlib colormap for wav / mjd modes. Default: "Spectral_r".
  • flipx — invert the x-axis (East to the right). Default: false.
  • filename — save to file if non-empty.
source
OITOOLS.plot_v2 — Function
plot_v2(data; kwargs...)

Plot squared visibilities V² vs baseline length (Mλ). Accepts a single OIdata, vector, or 2-D array.

Keyword arguments

  • color — "baseline" (default), "wav", "mjd", or an explicit colour string.
  • logplot — logarithmic y-axis. Default: false.
  • figsize — figure size. Default: (12, 6).
  • figtitle — prefix for the figure window title.
  • markopt — use distinct marker shapes per baseline. Default: false.
  • legend_below — place legend below the plot. Default: false.
source
OITOOLS.plot_t3phi — Function
plot_t3phi(data; kwargs...)

Plot closure phases T3φ (degrees) vs a representative baseline length (Mλ). Accepts a single OIdata, vector, or 2-D array.

Keyword arguments

  • t3base — x-axis baseline: "geom" (default, geometric mean) or "max" (longest side).
  • color — "baseline" (default), "wav", "mjd", or explicit colour string.
  • figsize — figure size. Default: (12, 6).
  • figtitle — prefix for the figure window title.
  • markopt — use distinct marker shapes. Default: false.
  • legend_below — place legend below the plot. Default: false.
source
OITOOLS.plot_t3amp — Function
plot_t3amp(data; kwargs...)

Plot triple amplitudes T3amp vs a representative baseline length (Mλ). Accepts a single OIdata, vector, or 2-D array.

Keyword arguments

  • t3base — x-axis baseline: "geom" (default, geometric mean) or "max" (longest side).
  • color — "baseline" (default), "wav", "mjd", or explicit colour string.
  • logplot — use logarithmic y-axis. Default: false.
  • figsize — figure size. Default: (12, 6).
  • figtitle — prefix for the figure window title.
  • markopt — use distinct marker shapes. Default: false.
  • legend_below — place legend below the plot. Default: false.
source
OITOOLS.plot_visamp — Function
plot_visamp(data; kwargs...)

Plot visibility amplitudes vs baseline length (Mλ). Accepts a single OIdata, vector, or 2-D array. The title and y-label adapt to the AMPTYP header stored in data.amptyp ("absolute", "differential", "correlated flux", or generic).

Keyword arguments

  • color — "baseline" (default), "wav", "mjd", or explicit colour string.
  • logplot — use logarithmic y-axis. Default: false.
  • figsize — figure size. Default: (12, 6).
  • figtitle — prefix for the figure window title.
  • markopt — use distinct marker shapes. Default: false.
  • legend_below — place legend below the plot. Default: false.
source
OITOOLS.plot_visphi — Function
plot_visphi(data; kwargs...)

Plot visibility phases (degrees). The layout is chosen automatically from the PHITYP header stored in data.phityp:

  • differential (phityp is "differential", matched case-insensitively) — one subplot per baseline with wavelength (nm) on the x-axis.
  • absolute (default) — single panel with spatial frequency (Mλ) on the x-axis, coloured by baseline, wavelength, or MJD.

Accepts a single OIdata, vector, or 2-D array.

Keyword arguments

  • color — "baseline" (default), "wav", "mjd", or explicit colour string (ignored for differential layout).
  • figsize — figure size. Default: (12, 6).
  • figtitle — prefix for the figure window title.
  • markopt — use distinct marker shapes. Default: false.
  • legend_below — place legend below the plot. Default: false.
source
OITOOLS.plot_diffphi — Function
plot_diffphi(data; kwargs...)

Deprecated — use plot_visphi instead, which auto-detects differential phases from data.phityp.

source
OITOOLS.plot_flux — Function
plot_flux(data; kwargs...)

Plot flux spectra vs wavelength (μm). Accepts a single OIdata, vector, or 2-D array.

Keyword arguments

  • color — colouring scheme:
    • "wav" (default) — coloured by wavelength with a horizontal colorbar.
    • "station" — one colour per station; OIFLUX entries with CALSTAT=C (i.e. `fluxsta_index == 0) are labelled"Calibrated"`.
    • "mjd" / "time" — scatter coloured by MJD with a horizontal colorbar.
    • any other string — treated as a matplotlib colour applied uniformly.
  • figsize — figure size. Default: (12, 6).
  • figtitle — prefix for the figure window title.
  • markopt — use black markers with distinct shapes. Default: false.
  • legend_below — place legend below the plot. Default: false.
source
OITOOLS.plot_obs — Function
plot_obs(data; obs=["V2","T3PHI","T3AMP"], color="baseline",
                 logplot=false, figsize=nothing, figtitle="", markopt=false)

Multi-panel figure with one subplot per observable, sharing the x-axis and a single legend. Panels are stacked vertically; only the bottom panel gets an x-axis label.

obs is a vector of spec keys from OBS_PLOT_SPECS (e.g. "V2", "T3PHI", "T3AMP", "VISAMP", "VISPHI", "FLUX"). Panels whose data is empty are skipped automatically.

When logplot=true, amplitude-like panels (V², T3amp, Visamp) use a log y-axis; phase panels are unaffected.

source
OITOOLS.plot_residuals — Function
plot_residuals(data, obs; color="baseline", figsize=(14,10))

Plot data vs model and normalised residuals for all observable types present in data. obs is a NamedTuple from image_to_obs or model_to_obs.

Also accepts image-domain plot_residuals(x, ft, data) or model-domain plot_residuals(model, x, data) signatures.

source
OITOOLS.imdisp — Function
imdisp(image; kwargs...)

Display a 2-D reconstructed image. The image is normalised to its maximum and oriented with East left and North up. Accepts a flat vector (square image assumed) or a 2-D matrix.

Keyword arguments

  • pixsize — pixel scale in mas. When -1 (default) the axes show pixel indices.
  • colormap — matplotlib colormap. Default: "gist_heat".
  • figtitle — figure window title. Default: "OITOOLS image".
  • tickinterval — minor-tick spacing in mas. Default: 0.5; auto-scaled for large images.
  • use_colorbar — show a right-side colorbar. Default: false.
  • beamsize — if > 0, draw a filled white circle of this diameter (mas) to indicate the PSF.
  • beamlocation — [fx, fy] fractional position of the beam circle. Default: [0.8, 0.8].
source
OITOOLS.imdisp_multi — Function
imdisp_multi(cube; kwargs...)

Display a 3-D stack of images (e.g. polychromatic channels or multi-temporal epochs) in a grid of subplots, one panel per slice. Each slice is normalised independently and rendered with the same formatting as imdisp.

cube is an (nx, nx, nslices) array.

Keyword arguments

  • labels — vector of strings for subplot titles. Default: "1", "2", ….
  • pixsize — pixel scale in mas (-1 = pixel indices).
  • colormap — matplotlib colormap name. Default: "gist_heat".
  • figtitle — figure window title. Default: "OITOOLS images".
  • tickinterval — minor-tick spacing (auto-adjusted for large fields of view).
  • use_colorbar — show a colour bar beside each panel.
  • beamsize — if > 0, draw a beam circle on each panel.
  • beamlocation — [x, y] fractional position for the beam circle.
source

Makie plotting

The same figures drawn with Makie, without Python: CairoMakie for files, GLMakie for a window. The GUI and the compiled application use these.

FunctionDescription
uvplot_makie(data)uv coverage, every sampled spatial frequency
plot_v2_makie(data)V² against baseline; also plot_t3phi_makie, plot_t3amp_makie, plot_visamp_makie, plot_visphi_makie, plot_flux_makie, plot_diffphi_makie
plot_observable_makie(data, kind)the same, the observable given by kind, a key of OBS_SPECS
imdisp_makie(image)one image, East left and North up
imdisp_multi_makie(cube)a stack of images as a grid
plot_residuals_makie(model, x, data)data over model, normalised residuals below
plot_obs_makie(data)several observables stacked on a shared x axis
plot_v2_multifile_makie(datasets)V² from several files, one legend entry per baseline
plot_facility_makie(facility)telescope positions to scale
plot_corner_makie(posterior, names)corner plot of posterior samples (any sampler); needs using PairPlots

Each name is the matplotlib one with _makie appended. Each returns a PlotData, whose figure field can be passed to Makie.save:

using OITOOLS, CairoMakie
data = readoifits("data.oifits")[1, 1]
Makie.save("uv.pdf", uvplot_makie(data).figure)
Makie.save("v2.pdf", plot_v2_makie(data; logscale = true).figure)

Colours, groupings and axis labels match the matplotlib figures: OBS_SPECS holds the values of OBS_PLOT_SPECS, both use the oiplot_colors palette, and test/gui/plotport.jl compares the two backends' figures.

No Makie version: set_oiplot_defaults (matplotlib rcParams), the per-observable plot_*_residuals functions (plot_residuals_makie draws all observables) and plot_ultranest_corner (use plot_corner_makie).

OITOOLS.uvplot_makie — Function
uvplot_makie(data; color = :baseline, conjugate = true) -> PlotData

uv coverage in a new figure: every uv point, V² baselines and closure-triangle legs, as uvplot.

source
OITOOLS.plot_observable_makie — Function
plot_observable_makie(data, which; color = nothing, logscale = false) -> PlotData

An observable against its x axis (baseline, or wavelength for flux), in a new figure. which is any key of OBS_SPECS. color = nothing uses that observable's own oiplot default.

source
OITOOLS.plot_v2_makie — Function
plot_v2_makie(data; kwargs...) -> PlotData

v2 against its natural x axis, in Makie — the counterpart of plot_v2.

A thin wrapper over plot_observable_makie, which takes any key of OBS_SPECS and is what to reach for when the observable is chosen at run time.

source
OITOOLS.plot_t3phi_makie — Function
plot_t3phi_makie(data; kwargs...) -> PlotData

t3phi against its natural x axis, in Makie — the counterpart of plot_t3phi.

A thin wrapper over plot_observable_makie, which takes any key of OBS_SPECS and is what to reach for when the observable is chosen at run time.

source
OITOOLS.plot_t3amp_makie — Function
plot_t3amp_makie(data; kwargs...) -> PlotData

t3amp against its natural x axis, in Makie — the counterpart of plot_t3amp.

A thin wrapper over plot_observable_makie, which takes any key of OBS_SPECS and is what to reach for when the observable is chosen at run time.

source
OITOOLS.plot_visamp_makie — Function
plot_visamp_makie(data; kwargs...) -> PlotData

visamp against its natural x axis, in Makie — the counterpart of plot_visamp.

A thin wrapper over plot_observable_makie, which takes any key of OBS_SPECS and is what to reach for when the observable is chosen at run time.

source
OITOOLS.plot_visphi_makie — Function
plot_visphi_makie(data; kwargs...) -> PlotData

visphi against its natural x axis, in Makie — the counterpart of plot_visphi.

A thin wrapper over plot_observable_makie, which takes any key of OBS_SPECS and is what to reach for when the observable is chosen at run time.

source
OITOOLS.plot_flux_makie — Function
plot_flux_makie(data; kwargs...) -> PlotData

flux against its natural x axis, in Makie — the counterpart of plot_flux.

A thin wrapper over plot_observable_makie, which takes any key of OBS_SPECS and is what to reach for when the observable is chosen at run time.

source
OITOOLS.plot_diffphi_makie — Function
plot_diffphi_makie(data; kwargs...) -> PlotData

diffphi against its natural x axis, in Makie — the counterpart of plot_diffphi.

A thin wrapper over plot_observable_makie, which takes any key of OBS_SPECS and is what to reach for when the observable is chosen at run time.

source
OITOOLS.imdisp_makie — Function
imdisp_makie(image; pixsize = -1, kwargs...) -> PlotData

One image, East left and North up, normalised to its own maximum.

image may be a matrix or a flat vector of nx² pixels. pixsize is in mas; -1 labels the axes in pixels instead.

keyworddefaultmeaning
colormap:gist_heatany Makie colormap; imdisp's default is the same ramp
title""axis title
colorbarfalsedraw a colour bar beside the image
beamsize-1if positive, draw a beam circle of this diameter (mas)
beamlocation(0.8, 0.8)fractional position of that circle

An image whose maximum is below 1e-20 is drawn unnormalised, with a warning.

source
OITOOLS.imdisp_multi_makie — Function
imdisp_multi_makie(cube; labels = nothing, kwargs...) -> PlotData

A stack of images as a grid of panels, one per slice of an (nx, ny, nslices) array.

Each panel is normalised to its own maximum, as in imdisp_multi; shared_scale = true uses one normalisation for the whole cube.

Keywords otherwise as imdisp_makie; labels titles the panels and defaults to the slice number.

source
OITOOLS.plot_residuals_makie — Function
plot_residuals_makie(data, obs; color = :baseline, logscale = false) -> PlotData
plot_residuals_makie(model::FlatModel, x, data; kwargs...)
plot_residuals_makie(x, ft, data; kwargs...)

Data against model, with normalised residuals beneath, for every observable present.

obs is the NamedTuple model_to_obs or image_to_obs returns; the two convenience methods build it. Each observable gets a tall panel of data and model together and a short one of (model − data) / σ under it, sharing an x axis — the 3:1 split plot_residuals uses.

Phase differences are wrapped to ±180° before dividing by σ.

color is :baseline, :wav or :mjd, as everywhere else.

source
OITOOLS.plot_obs_makie — Function
plot_obs_makie(data; kinds = nothing, color = :baseline, logscale = false) -> PlotData

Several observables stacked on a shared x axis, as plot_obs. kinds defaults to every observable present in the data, in the order of OBS_SPECS. Only the bottom panel has x labels.

source
OITOOLS.plot_v2_multifile_makie — Function
plot_v2_multifile_makie(datasets; logscale = false) -> PlotData

V² from several datasets on one axis, as plot_v2_multifile, with one colour and one legend entry per baseline across all datasets.

source
OITOOLS.plot_facility_makie — Function
plot_facility_makie(facility) -> PlotData

Telescope positions of a FacilityConfig, labelled, with equal axes, as plot_facility.

source
OITOOLS.plot_corner_makie — Function
plot_corner_makie(posterior, names; truth = nothing, kwargs...)
plot_corner_makie(result; kwargs...)

Corner plot of a posterior sample matrix, (n_samples, n_params), with one label per column; truth, one value per column, is marked on every panel. result is a BootstrapResult (its kept replicates) or a NestedResult (its posterior).

Needs using PairPlots and a Makie backend.

source
OITOOLS.plot_ultranest_corner — Function
plot_ultranest_corner(result; font_size = 8, histogram_color = "black",
                      contour_colors = ["#0072B2", "#56B4E9", "#009E73", "#F0E442"])

Draw UltraNest's corner plot for a completed nested-sampling result.

result is UltraNest's Python result object (NestedResult.result under :ultranest). The UltraNest backend of fit_model_nested(…; cornerplot = true) calls this when PythonPlot is loaded. The default contour colours are the Okabe-Ito palette.

source
OITOOLS.PlotData — Type
PlotData(figure, axis, points, info)

A built figure plus what a click needs. points is the Makie plot object Makie.pick will return; info[i] describes point i of it.

source

Graphical interface

oitoolsgui launches the GUI (see The GUI); the other functions are the steps it runs.

OITOOLS.oitoolsgui — Function
oitoolsgui(files...; optional = true, verbose = true)

Open the GUI, loading everything it needs on the way.

From the REPL: using OITOOLS; oitoolsgui(), optionally with OIFITS files to open. bin/oitoolsgui.jl calls it with the files on its command line.

GLMakie, QMLMakie and QML must be installed in the active environment (or use --project=bin). GLFW_jll (native Wayland), Nautilus (nested sampling), Pigeons (tempering) and PairPlots (corner plots) are loaded when installed, and listed in one message when not; optional = false skips them. The Python extensions are not loaded.

Call it before using GLMakie: it sets the Mesa, GLFW and Qt platform variables, then loads those packages. If GLMakie is already loaded it prints a warning.

source
OITOOLS.gui — Function
gui()
gui(session)

Open the OITOOLS window (Exploring, Observing, Modeling, Imaging and Tools over one session). It needs the GUI packages loaded:

using OITOOLS, GLMakie, QMLMakie, QML
gui()

With no argument it builds its own session; bin/oitoolsgui.jl passes one holding the files named on its command line. oitoolsgui loads the packages and opens the window.

source
OITOOLS.configure_graphics! — Function
configure_graphics!(; verbose = true) -> NamedTuple

Set the Mesa driver variables needed on WSL; elsewhere, do nothing.

Returns (applied, reason, vars): whether anything was set, a one-line reason, and the variables set. Call it before the first OpenGL context exists: oitoolsgui calls it before loading GLMakie, and gui calls it again. Variables already set are left alone, so any of these takes precedence:

OITOOLSGUI_NO_GPU_SETUP=1     # skip all of it
GALLIUM_DRIVER=llvmpipe       # or any other explicit choice
LIBGL_ALWAYS_SOFTWARE=1       # compare against software rendering

With QSG_INFO=1 Qt prints the GL vendor and renderer.

source
OITOOLS.configure_qt_platform! — Function
configure_qt_platform!(; match_x11 = false, verbose = true) -> (; applied, reason, vars)

Keep Qt on the same windowing system as GLMakie.

Qt follows the session (Wayland or X11) on its own. With match_x11 = true, set when GLMakie could not use Wayland, this sets QT_QPA_PLATFORM=xcb so that Qt uses X11 too. oitoolsgui passes match_x11 = !prefer_native_wayland!().applied, which is true when $FORCE_X11 is set or GLFW was already initialised (as in a PackageCompiler sysimage). An explicit QT_QPA_PLATFORM is left alone.

source
OITOOLS.configure_qt_scale! — Function
configure_qt_scale!(; verbose = true) -> (; applied, reason, vars)

Scale all of Qt on Linux, through QT_SCALE_FACTOR, when the desktop does not.

Qt draws the controls' padding, borders and indicators at the desktop's scale. On X11 at 100% a dense panel gets them at one device pixel per point while the window's own scale enlarges the text, so text crowds its fields; Windows at 150% draws the same panel's controls at 1.5. This sets the factor window_scale_for gives the panel's EDID density, divided by what X11 already applies (Xft.dpi). Under WSL, whose WSLg gives Qt a scale of 1, the density is wsl_panel_dpi, from Windows' display scale (AppliedDPI in the registry).

window_scale in gui_settings_file() wins when positive (1 turns it off). Left alone: any of QT_SCALE_VARS already set; a Wayland session other than WSLg, whose compositor gives Qt its scale; WSL when the registry cannot be read; displays that disagree in density or have no EDID. Must run before QML is loaded, which creates the QGuiApplication; app/launcher.sh does the same for the bundle.

source
OITOOLS.resource_dir — Function
resource_dir() -> String or nothing

The directory holding the shipped resources, or nothing if there is none.

The first existing one of:

  1. $OITOOLS_RESOURCE_DIR;
  2. <Sys.BINDIR>/../share/oitools, in an application bundle;
  3. pkgdir(OITOOLS), a development checkout.
source