pypeit.display.display module

Module for ginga routines. Mainly for debugging

pypeit.display.display.clear_all(allow_new=False)[source]

Clear all of the ginga canvasses.

Parameters:

allow_new (bool, optional) – Allow a subprocess to be called to execute a new ginga viewer if one is not already running. See connect_to_ginga().

pypeit.display.display.clear_canvas(cname)[source]

Clear the ginga canvas

Parameters:

cname (str) – Channel name

pypeit.display.display.connect_to_ginga(host='localhost', port=9000, raise_err=False, allow_new=False)[source]

Connect to a RC Ginga.

Parameters:
  • host (str, optional) – Host name.

  • port (int, optional) – Probably should remain at 9000

  • raise_err (bool, optional) – Raise an error if no connection is made, otherwise just raise a warning and continue

  • allow_new (bool, optional) – Allow a subprocess to be called to execute a new ginga viewer if one is not already running.

Returns:

connection to ginga viewer.

Return type:

ginga.RemoteClient

pypeit.display.display.show_image(inp, chname='Image', waveimg=None, mask=None, exten=0, cuts=None, clear=False, wcs_match=False)[source]

Display an image using Ginga.

Todo

  • implement instrument specific reading

  • use the mask as a boolean mask if bitmask is not provided.

Parameters:
  • inp (str, numpy.ndarray) – The image to view. If a string is provided, it must be the name of a fits image that can be read by astropy.io.fits.

  • chname (str, optional) – The name of the ginga channel to use.

  • waveimg (numpy.ndarray, optional) – Wavelength image

  • mask (ImageBitMaskArray, optional) – A bitmask array that designates a pixel as being masked. Currently this is only used when displaying the spectral extraction result.

  • exten (int, optional) – The extension of the fits file with the image to show. This is only used if the input is a file name.

  • cuts (array-like, optional) – Initial cut levels to apply when displaying the image. This object must have a length of 2 with the lower and upper levels, respectively.

  • clear (bool, optional) – Clear any existing ginga viewer and its channels.

  • wcs_match (bool, optional) – Use this as a reference image for the WCS and match all image in other channels to it.

Returns:

The ginga remote client object and the channel object with the displayed image.

Return type:

tuple

Raises:

ValueError – Raised if cuts is provided and does not have two elements.

pypeit.display.display.show_points(viewer, ch, spec, spat, color='cyan', legend=None, legend_spec=None, legend_spat=None)[source]

Plot points in a ginga viewer

Parameters:
  • viewer (ginga.RemoteClient) – Ginga RC viewer

  • ch (ginga.util.grc._channel_proxy) – Ginga channel

  • spec (list) – List of spectral positions on image to plot

  • spat (list) – List of spatial positions on image to plot

  • color (str) – Color for points

  • legend (str) – Label for a legend

  • legend_spec (float) – Spectral pixel loation for legend

  • legend_spat (float) – Pixel loation for legend

pypeit.display.display.show_scattered_light(image_list, slits=None, wcs_match=True)[source]

Interface to ginga to show the quality of the Scattered Light subtraction

Parameters:
  • image_list (zip) – A zip of the images to show, their names, and the scales

  • slits (SlitTraceSet, optional) – The current slit traces

  • wcs_match (bool, optional) – Use a reference image for the WCS and match all image in other channels to it.

pypeit.display.display.show_slits(viewer, ch, left, right, slit_ids=None, left_ids=None, right_ids=None, maskdef_ids=None, spec_vals=None, rotate=False, pstep=50, clear=False, synced=True)[source]

Overplot slits on the image in Ginga in the given channel

Parameters:
  • viewer (ginga.RemoteClient) – Ginga RC viewer

  • ch (ginga.util.grc._channel_proxy) – Ginga channel

  • left (numpy.ndarray) – Array with spatial position of left slit edges. Shape must be \((N_{\rm spec},)\) or \((N_{\rm spec}, N_{\rm l-edge})\), and can be different from right unless synced is True.

  • right (numpy.ndarray) – Array with spatial position of right slit edges. Shape must be \((N_{\rm spec},)\) or \((N_{\rm spec}, N_{\rm r-edge})\), and can be different from left unless synced is True.

  • spec_vals (numpy.ndarray, optional) – Array with spectral position of left and right slit edges. Shape must be \((N_{\rm spec},)\) or \((N_{\rm spec}, N_{\rm r-edge})\). Currently it is only possible to input a single set of spec_vals for both left and right edges, but not possible to pass distinct spec_vals for left and right. If not passed in the default of np.arange(\((N_{\rm spec},)\)) will be used.

  • slit_ids (int, array-like, optional) – PypeIt ID numbers for the slits. If None, IDs run from -1 to \(-N_{\rm slits}\). If not None, shape must be \((N_{\rm slits},)\). These are only used if synced is True.

  • left_ids (int, array-like, optional) – ID numbers for the left edges. If None, IDs run from -1 to \(-N_{\rm l-edge}\). If not None, shape must be \((N_{\rm l-edge},)\). These are only used if synced is False.

  • right_ids (int, array-like, optional) – ID numbers for the right edges. If None, IDs run from -1 to \(-N_{\rm r-edge}\). If not None, shape must be \((N_{\rm r-edge},)\). These are only used if synced is False.

  • maskdef_ids (int, array-like, optional) – slitmask IDs assigned to each slits. If None, IDs will not be shown. If not None, shape must be \((N_{\rm slits},)\). These are only used if synced is True.

  • rotate (bool, optional) – Rotate the image?

  • pstep (bool, optional) – Show every pstep point of the edges as opposed to every point, recommended for speed.

  • clear (bool, optional) – Clear the canvas?

  • synced (bool, optional) – Flag the left and right traces are synced into slits. Otherwise, the edges are treated separately. If True, the number of left and right edges must be the same and left_ids and right_ids are ignored.

pypeit.display.display.show_tilts(viewer, ch, tilt_traces, yoff=0.0, xoff=0.0, points=True, nspec=None, pstep=3, clear_canvas=False)[source]

Show the arc tilts on the input channel

Parameters:
  • viewer (ginga.RemoteClient) – Ginga RC viewer

  • ch (ginga.util.grc._channel_proxy) – Ginga channel

  • tilt_traces (astropy.table.Table) – Table containing the traced and fitted tilts

  • yoff (float, optional) – Offset tilts by this amount

  • xoff (float, optional) – Offset tilts by this amount

  • points (bool, optional) – Plot the Gaussian-weighted tilt centers

  • nspec (int, optional) – Number of spectral pixels in the TiltImage

  • pstep (int, optional) – Show every pstep point of the tilts as opposed to every point, recommended for speed.

  • clear_canvas (bool, optional) – Clear the canvas first?

pypeit.display.display.show_trace(viewer, ch, trace, trc_name=None, maskdef_extr=None, manual_extr=None, clear=False, rotate=False, pstep=3, yval=None, color='blue')[source]
Parameters:
  • viewer (ginga.RemoteClient) – Ginga RC viewer.

  • ch (ginga.util.grc._channel_proxy) – Ginga channel.

  • trace (numpy.ndarray) – Array with spatial position of the object traces on the detector. Shape must be \((N_{\rm spec},)\) or \((N_{\rm spec}, N_{\rm trace})\).

  • trc_name (numpy.ndarray, optional) – Array with Trace names. Shape must be \((N_{\rm trace},)\).

  • maskdef_extr (numpy.ndarray, optional) – Array with the maskdef extraction flags. Shape must be \((N_{\rm trace},)\).

  • manual_extr (numpy.ndarray, optional) – Array with the manual extraction flags. Shape must be \((N_{\rm trace},)\).

  • clear (bool, optional) – Clear the canvas?

  • rotate (bool, optional) – Rotate the image?

  • pstep (bool, optional) – Show every pstep point of the edges as opposed to every point, recommended for speed.

  • yval (numpy.ndarray, optional) – Array with spectral position of the object traces. Shape must be \((N_{\rm spec},)\) or \((N_{\rm spec}, N_{\rm trace})\). If not passed in, the default of np.arange(\((N_{\rm spec},)\)) will be used.

  • color (str, optional) – Color for the trace