pypeit.core.gui.object_find module

This script allows the user to add/delete/modify object traces

Todo

Implement color scaling with RMB click+drag

class pypeit.core.gui.object_find.ObjFindGUI(canvas, image, frame, det, sobjs, left, right, obj_trace, trace_models, axes, profdict, slit_ids=None, printout=False, runtime=False)[source]

Bases: object

GUI to interactively identify object traces. The GUI can be run within PypeIt during data reduction, or as a standalone script outside of PypeIt. To initialise the GUI, call the initialise() function in this file.

add_anchor()[source]

Add a manual anchor point

add_object()[source]
button_cont(event)[source]

What to do when the ‘exit and save’ button is clicked

button_exit(event)[source]

What to do when the ‘exit and do not save changes’ button is clicked

button_press_callback(event)[source]

What to do when the mouse button is pressed

Parameters:

event (matplotlib.backend_bases.Event) – Matplotlib event instance containing information about the event

button_release_callback(event)[source]

What to do when the mouse button is released

Parameters:

event (matplotlib.backend_bases.Event) – Matplotlib event instance containing information about the event

delete_object()[source]

Delete an object trace

delete_object_sobj()[source]

Delete a specobj

draw_anchors()[source]

Draw the anchors for manual tracing

draw_callback(event)[source]

Draw callback (i.e. everytime the canvas is being drawn/updated)

Parameters:

event (matplotlib.backend_bases.Event) – A matplotlib event instance

draw_objtraces()[source]

Draw the object traces

draw_profile()[source]

Draw the object profile

empty_mantrace()[source]

Generate an empty dictionary for the manual tracing

fit_anchors()[source]

Fit the manual anchor points

get_axisID(event)[source]

Get the ID of the axis where an event has occurred

Parameters:

event (matplotlib.backend_bases.Event) – Matplotlib event instance containing information about the event

Returns:

Axis where the event has occurred

Return type:

int, None

get_ind_under_point(event)[source]

Get the index of the object trace closest to the cursor

Parameters:

event (matplotlib.backend_bases.Event) – Matplotlib event instance containing information about the event

get_slit()[source]

Find the slit that the mouse is currently in

get_specobjs()[source]

Get the updated version of SpecObjs

Returns:

SpecObjs Class

Return type:

SpecObjs

initialise_menu()[source]

Initialise the menu buttons

key_press_callback(event)[source]

What to do when a key is pressed

Parameters:

event (matplotlib.backend_bases.Event) – Matplotlib event instance containing information about the event

make_objprofile()[source]

Generate an object profile from the traces

mouse_move_callback(event)[source]

Store the locations of mouse as it moves across the canvas

operations(key, axisID)[source]

Canvas operations

Parameters:
  • key (str) – Which key has been pressed

  • axisID (int) – The index of the axis where the key has been pressed (see get_axisID)

print_help()[source]

Print the keys and descriptions that can be used for Identification

print_pypeit_info()[source]

print text that the user should insert into their .pypeit file

radio_meth(label, infobox=True)[source]

Tell the code what to do when a different trace method is selected

Parameters:

label (str) – The label of the radio button that was clicked

recenter()[source]
remove_anchor()[source]

Remove a manual anchor point

replot()[source]

Redraw the entire canvas

set_fwhm(xdata)[source]

Set the FWHM using the available panel

Parameters:

xdata (float) – The x coordinate selected by the user

update_infobox(message="Press '?' to list the available options", yesno=True, default=False)[source]

Send a new message to the information window at the top of the canvas

Parameters:

message (str) – Message to be displayed

class pypeit.core.gui.object_find.ObjectTraces[source]

Bases: object

Simple class to store the object traces

add_object(det, pos_spat, pos_spec, trc_spat, trc_spec, fwhm, addrm=1)[source]

Add an object trace

Parameters:
  • det (int) – Detector to add a slit on

  • pos_spat (float) – patial pixel position

  • pos_spec (float) – Spectral pixel position

  • trc_spat (numpy.ndarray) – Spatial trace of object

  • trc_spec (numpy.ndarray) – Spectral trace of object

  • fwhm (float) – FWHM of the object

  • addrm (int) – Flag to say if an object was been added (1), removed (-1), or was an auto found slit (0)

delete_object(ind)[source]

Delete an object trace

Parameters:

ind (int) – Index of object trace to remove

from_dict(obj_dict, det)[source]

Fill the object traces from a SpecObjs class

Parameters:
  • obj_dict (dict) – A dictionary containing the spatial object traces and FWHM

  • det (int) – Detector to which this applies

from_specobj(sobjs, det)[source]

Fill the object traces from a SpecObjs class

Parameters:
  • sobjs (SpecObjs) – An instance of the SpecObjs class

  • det (int) – Detector to which this applies

get_pypeit_string()[source]

Construct a string that can be placed in the .pypeit file to define new object traces

property nobj
pypeit.core.gui.object_find.initialise(det, frame, left, right, obj_trace, trace_models, sobjs, slit_ids=None, runtime=False, printout=False)[source]

Initialise the ‘ObjFindGUI’ window for interactive object tracing

Parameters:
  • det (int) – 1-indexed detector number

  • frame (numpy.ndarray) – Sky subtracted science image

  • left (numpy.ndarray) – Slit left edges

  • right (numpy.ndarray) – Slit right edges

  • obj_trace (dict) – Result of pypeit.scripts.object_finding.parse_traces().

  • trace_models (dict) – Dictionary with the object, standard star, and slit trace models

  • sobjs (SpecObjs, None) – SpecObjs Class

  • det – Detector index

  • slit_ids (list, None) – List of slit ID numbers

  • runtime (bool) – Is this GUI being launched during a data reduction?

  • printout (bool) – Should the results be printed to screen

Returns:

Returns an instance of the ObjFindGUI class

Return type:

ObjFindGUI