analyzer_plots#

arte.dataelab.analyzer_plots.modalplot(residual_modes_vector, pol_modes_vector, unit=None, overplot=False, plot_to=None, title=None, xlabel='Mode index', ylabel='wavefront rms', add_unit_to_ylabel=True, res_label='residual modes', res_color='red', pol_label='POL modes', pol_color='black')#

Plot modal coefficients comparison for adaptive optics analysis.

Creates a plot comparing residual modal coefficients against POL (or other reference) modes. Typically used to visualize loop performance by plotting closed-loop residuals vs. open-loop measurements.

Parameters:
  • residual_modes_vector (array_like or astropy.units.Quantity) – Residual mode coefficients (typically RMS or std dev per mode)

  • pol_modes_vector (array_like or astropy.units.Quantity) – Reference mode coefficients (typically POL modes or open-loop)

  • unit (astropy.units.Unit, optional) – Target unit for both vectors. If specified, both inputs will be converted to this unit

  • overplot (bool, optional) – If True, add to existing plot. If False, clear plot first (default: False)

  • plot_to (matplotlib.pyplot or matplotlib.axes.Axes, optional) – Matplotlib object to plot to. If None, uses pyplot (default: None)

  • title (str, optional) – Plot title. Required when overplot=False

  • xlabel (str, optional) – X-axis label (default: ‘Mode index’)

  • ylabel (str, optional) – Y-axis label (default: ‘wavefront rms’)

  • add_unit_to_ylabel (bool, optional) – If True, append unit to ylabel (default: True)

  • res_label (str, optional) – Legend label for residual modes (default: ‘residual modes’)

  • res_color (str, optional) – Color for residual modes plot (default: ‘red’)

  • pol_label (str, optional) – Legend label for POL modes (default: ‘POL modes’)

  • pol_color (str, optional) – Color for POL modes plot (default: ‘black’)

Returns:

The axes object containing the plot

Return type:

matplotlib.axes.Axes

Examples

>>> # Basic usage
>>> modalplot(residuals, pol_modes, title='AO Performance')
>>> # Apply optical gain and specify units
>>> modalplot(
...     analyzer.residual_modes.time_std() * 2,
...     analyzer.pol_modes.time_std() * 2,
...     unit=u.nm,
...     title='Performance with 2x optical gain'
... )
>>> # Overplot multiple datasets
>>> modalplot(res1, pol1, title='Comparison')
>>> modalplot(res2, pol2, overplot=True,
...          res_label='residual modes 2', res_color='blue')

Notes

  • Automatically handles astropy units and NotAvailable values

  • When overplotting, title parameter is ignored

  • Legend is automatically generated from labels