meafs_code package

Subpackages

Submodules

meafs_code.gui module

MEAFS GUI
Matheus J. Castro
This is the main file. Here it is included all MEAFS features and the GUI.
class meafs_code.gui.MEAFS(parent=None)[source]

Bases: QMainWindow, Ui_MEAFS

Main class that define the properties of the GUI.

LineAddRemove(uiobject, add, islinelist=False)[source]

Add new or removes lines from a QT table.

Parameters:
  • uiobject – the QT table widget to change.

  • add – true: add a line; false: remove a line.

  • islinelist – if it is a line-list table, also calls the function to generate the checkboxes.

argument_resolve(fastcheck=False)[source]

Resolve the arguments passed in the commandline.

Parameters:

fastcheck – if true, only check for the help and version arguments.

auto_save()[source]

Save the session by the auto_save.plk file name or the name previously chosen by the user.

auto_set_output()[source]

Try to find the synthetic spectrum output file name automatic by looking in the configuration file

static browse(uiobject, caption, direc=None)[source]

Show a File Dialog to select some file.

Parameters:
  • uiobject – the QT widget that shows the file path.

  • caption – the caption in File Dialog.

  • direc – the first directory that File Dialog should show.

static browse_dir_out(uiobject, caption, direc=None)[source]

Show a File Dialog to select some directory.

Parameters:
  • uiobject – the QT widget that shows the file path.

  • caption – the caption in File Dialog.

  • direc – the first directory that File Dialog should show.

centralize_child_window(wind)[source]

Centralize child windows in respect of the main window.

Parameters:

wind – the new window widget to be centralized.

checkLinelistElements()[source]

Check or uncheck all checkboxes in the line-list table.

checkLineliststate()[source]

Count the number of checked checkboxes in the line-list table, update the progress total value accordingly and also check or uncheck the “Select All” element.

check_output_folder()[source]

Check if the output folder location is written.

Returns:

true if it is present, otherwise false.

checkmethod()[source]

Check which methods tab is selected and disable the other ones.

checktabshels()[source]

Modify the behaviour of some UI elements to guide the user through the creation of the final plots for the abundances.

clear_scale(show_msg=True)[source]

Resets the fixed scale to show images in the final plots area, allowing resizing the GUI into smaller sizes.

Parameters:

show_msg – Option to pop up a message saying that the scale was cleared.

clear_spectrum_plot()[source]

Clear all plots in the Spectrum Plot tab, except the spectra themselves.

clearstd()[source]

Clear the QT Widget that receive the stdout and stderr messages.

closeEvent(event)[source]

Handles the close button event and trigger an “are you sure?” message.

Parameters:

event – the event itself.

datatableconfig(load=False, loaddata=None)[source]

Configure the button to show the spectrum file name and the tooltip to show the full path in the data QT table.

Parameters:
  • load – if it is to load or to clear the spectrum data.

  • loaddata – the data containing the file names.

datatableselect()[source]

Configure the data QT table with the buttons to select spectra or clear them.

dict_to_qtable(qtable, dict_table, checkboxes=None, tooltip=False)[source]

Transform a QT Table in a dictionary.

Parameters:
  • qtable – the QT Table to be written.

  • dict_table – the dictionary to read the data.

  • checkboxes – the index of checkboxes, if exists.

  • tooltip – write the item or the tooltip (for spectrum data table)

enable_auto_save()[source]

Enable or disable the timed auto-save and the close auto-save capability and write this setting in to the settings file.

fitparWindow()[source]

Call and get the values of the Fit Parameters window.

full_spec_plot_range()[source]

Apply the total maximum and minimum values of the current plot and change the range to it.

get_delimiter(error_msg=None)[source]

Get the current set delimiter type in MEAFS GUI.

Parameters:

error_msg – Custom error message to show.

Returns:

the delimiter, None (for auto-detect) or -1 (for error).

graymethods(metharray)[source]

Gray the tabs of the methods that are not selected.

Parameters:

metharray – the pattern that should be grayed.

gui_hold(value)[source]

Froozen some widgets in the GUI so they can not be modified while running the fit.

Parameters:

value – if it is to hold or not the GUI

loadData()[source]

Load the data present in the QT table and call the function to plot the spectra in the GUI.

loadLinelist()[source]

Load a line-list file with element and wavelength in the proper QT table.

loadRefer()[source]

Load the abundance reference file containing the elements and their abundances in the QT table.

load_session(direc=None, list_save=None, loadprev=False)[source]

Load a previously saved session, or a list with all session-variables.

Parameters:
  • direc – the directory where the File Dialog should first open.

  • list_save – a list with all session-variable. If it is different from None, the prompt to choose a file will not be shown.

  • loadprev – if true, the path of the file needs to be written in the self.filepath variable.

static make_jupyter_widget_with_kernel()[source]

Create and configure the Jupyter QT Widget.

Returns:

the widget itself.

new_session()[source]

Load a new empty session by overriding all variable to the default values.

norm_trunc_spec()[source]

Call the Normalize and Truncate window

open_prev_results()[source]

Open CSV files with previous runs and load the results, including the available plots (if any).

static qtable_to_dict(qtable, checkboxes=None, tooltip=False)[source]

Transform a QT Table in a dictionary.

Parameters:
  • qtable – the QT Table to be read.

  • checkboxes – the index of checkboxes, if exists.

  • tooltip – get the item or the tooltip (for spectrum data table)

Returns:

the dictionary

quitbtn()[source]

Create an alias to the close button event.

results_show_tab()[source]

Show the results of the selected line in the results table in the results tab and focus the plot in the current line.

run_check_continuum()[source]

Call the Continuum algorithm and draw in the plot the results.

run_erase_continuum()[source]

Erase from the plot the continuum fit line.

run_final_plots(plot_type, single=False)[source]

Run the subroutines to create the final plots.

Parameters:
  • plot_type – type of the final plot to create.

  • single – create a final plot to a single line or for all of them.

run_fit()[source]

Call the fit algorithm.

run_fit_nopars()[source]

Call the fit algorithm only for the abundance, without fitting the Wavelength Shift, Continuum and Convolution.

run_nofit()[source]

Call the fit algorithm without any fit at all, only to generate the plots with the selected values.

save_cur_abund()[source]

Save the results of the fit in a CSV file.

save_session(saveas=False, direc=None, flname=None, getdill=False)[source]

Save a session using dill.

Parameters:
  • saveas – if true, ignore the self.filepath variable.

  • direc – the directory where the File Dialog should first open.

  • flname – file name to save the session. If present, the File Dialog will not be shown.

  • getdill – if true, does not save the session and return the list to be saved.

Returns:

the list to be saved (if getdill is true), true if the session is saved or false if the self.filepath was not properly filled.

show_about()[source]

Create a new window to show info about MEAFS.

show_error(msg)[source]

Show a QT window for some user-input-error message.

Parameters:

msg – the message to be shown.

static show_question(parent, title, message)[source]

Pop-up a question message.

Parameters:
  • parent – the parent window.

  • title – the box title.

  • message – the message.

Returns:

True or False.

show_quit()[source]

Shows the quit message “are you sure?”

Returns:

true or false, depending on the clicked button.

stop_func()[source]

Define if the stop button was precessed during a run.

tablecheckbox(state)[source]

Create a QT Widget with a CheckBox inside to use it in QT tables.

Parameters:

state – if it should be checked or not.

Returns:

the QT widget containing the checkbox.

tablecheckboxindividual()[source]

Check or uncheck a unique checkbox in the line-list table.

turbospec_config_path(init=True, tp=None, onlytext=False)[source]

Check, select and write into the settings the path to the configuration and output files of TurboSpectrum

Parameters:
  • init – if it is only to look if the path in the database exists

  • tp – type of file being called

class meafs_code.gui.Stdredirect(edit, color=None, out=None, showtab=None)[source]

Bases: object

Class that redirect the stdout (outputs) and the stderr (errors) to the GUI and to the terminal, if available.

flush()[source]

Flush function from the sys.flush()

write(text)[source]

Write function that actually writes the output in the GUI and in the terminal (if present).

Parameters:

text – the text message to be printed.

class meafs_code.gui.VerticalNavigationToolbar2QT(canvas, parent=None, coordinates=True)[source]

Bases: NavigationToolbar2QT

Class to create a vertical toolbar for the plot in the matplotlib package.

set_message(s)[source]

Write the mouse pointer coordinates in the toolbar.

Parameters:

s – the message to write (coordinates)

toolitems = [('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous view', 'back', 'back'), ('Forward', 'Forward to next view', 'forward', 'forward'), (None, None, None, None), ('Pan', 'Left button pans, Right button zooms\nx/y fixes axis, CTRL fixes aspect', 'move', 'pan'), ('Zoom', 'Zoom to rectangle\nx/y fixes axis', 'zoom_to_rect', 'zoom'), (None, None, None, None), ('Save', 'Save the figure', 'filesave', 'save_figure')]
meafs_code.gui.exception_hook(exctype, value, traceback)[source]

Function to redirect the errors of the modules to the main module, so the error can be verified.

meafs_code.gui.main()[source]

Main function to run the GUI.

meafs_code.desktop_entry module

MEAFS Desktop Entry Creation
Matheus J. Castro
This file analyse and create aliases in the system to run MEAFS through an entry in the system menu.
meafs_code.desktop_entry.create()[source]

Create the menu entry in the system to run MEAFS.

meafs_code.desktop_entry.get_curr_dir()[source]

Get the current environment running python (like anaconda or system) and the directory where the file is located.

Returns:

the command that activates anaconda environment (if present) and the file absolute path.

meafs_code.desktop_entry.remove()[source]

Remove the menu entry in the system that run MEAFS.