From 1e939b9e867b19dcf4715de1e786d78c29e79604 Mon Sep 17 00:00:00 2001 From: Ulrich Noebauer Date: Fri, 6 Oct 2017 14:46:07 +0200 Subject: [PATCH] Force deactivate LaTeX in GUI --- tardis/gui/widgets.py | 248 +++++++++++++++++++++--------------------- 1 file changed, 126 insertions(+), 122 deletions(-) diff --git a/tardis/gui/widgets.py b/tardis/gui/widgets.py index fe13b70a122..e819af68c6a 100644 --- a/tardis/gui/widgets.py +++ b/tardis/gui/widgets.py @@ -26,6 +26,10 @@ class MatplotlibWidget(FigureCanvas): def __init__(self, tablecreator, parent, fig=None): """Create the canvas. Add toolbar depending on the parent.""" + + # Force-deactivate LaTeX + plt.rcParams["text.usetex"] = False + self.tablecreator = tablecreator self.parent = parent self.figure = Figure()#(frameon=False,facecolor=(1,1,1)) @@ -40,20 +44,20 @@ def __init__(self, tablecreator, parent, fig=None): self.span = None super(MatplotlibWidget, self).__init__(self.figure) - super(MatplotlibWidget, self).setSizePolicy(QtGui.QSizePolicy.Expanding, + super(MatplotlibWidget, self).setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) super(MatplotlibWidget, self).updateGeometry() if fig != 'model': self.toolbar = NavigationToolbar(self, parent) - self.cid[0] = self.figure.canvas.mpl_connect('pick_event', + self.cid[0] = self.figure.canvas.mpl_connect('pick_event', self.on_span_pick) else: - self.cid[0] = self.figure.canvas.mpl_connect('pick_event', + self.cid[0] = self.figure.canvas.mpl_connect('pick_event', self.on_shell_pick) def show_line_info(self): """Show line info for span selected region.""" - self.parent.line_info.append(LineInfo(self.parent, self.span.xy[0][0], + self.parent.line_info.append(LineInfo(self.parent, self.span.xy[0][0], self.span.xy[2][0], self.tablecreator)) def show_span(self, garbage=0, left=5000, right=10000): @@ -63,7 +67,7 @@ def show_span(self, garbage=0, left=5000, right=10000): """ if self.parent.spectrum_span_button.text() == 'Show Wavelength Range': if not self.span: - self.span = self.ax.axvspan(left, right, color='r', alpha=0.3, + self.span = self.ax.axvspan(left, right, color='r', alpha=0.3, picker=self.span_picker) else: self.span.set_visible(True) @@ -82,12 +86,12 @@ def on_span_pick(self, event): self.span.set_linewidth(5) self.draw() if event.edge == 'left': - self.cid[1] = self.figure.canvas.mpl_connect('motion_notify_event', + self.cid[1] = self.figure.canvas.mpl_connect('motion_notify_event', self.on_span_left_motion) elif event.edge == 'right': - self.cid[1] = self.figure.canvas.mpl_connect('motion_notify_event', + self.cid[1] = self.figure.canvas.mpl_connect('motion_notify_event', self.on_span_right_motion) - self.cid[2] = self.figure.canvas.mpl_connect('button_press_event', + self.cid[2] = self.figure.canvas.mpl_connect('button_press_event', self.on_span_resized) def on_span_left_motion(self, mouseevent): @@ -115,7 +119,7 @@ def on_span_resized(self, mouseevent): """Redraw the red rectangle to currently selected span.""" self.figure.canvas.mpl_disconnect(self.cid[1]) self.figure.canvas.mpl_disconnect(self.cid[2]) - self.cid[0] = self.figure.canvas.mpl_connect('pick_event', + self.cid[0] = self.figure.canvas.mpl_connect('pick_event', self.on_span_pick) self.span.set_edgecolor('r') self.span.set_linewidth(1) @@ -165,12 +169,12 @@ def span_picker(self, span, mouseevent, tolerance=5): return False, event_attributes class Shell(matplotlib.patches.Wedge): - """A data holder to store measurements of shells that will be drawn in + """A data holder to store measurements of shells that will be drawn in the plot. """ def __init__(self, index, center, r_inner, r_outer, **kwargs): - super(Shell, self).__init__(center, r_outer, 0, 90, + super(Shell, self).__init__(center, r_outer, 0, 90, width=r_outer - r_inner, **kwargs) self.index = index self.center = center @@ -179,27 +183,27 @@ def __init__(self, index, center, r_inner, r_outer, **kwargs): self.width = r_outer - r_inner class ConfigEditor(QtGui.QWidget): - """The configuration editor widget. + """The configuration editor widget. + + This widget is added to the stacked widget that is the central widget of + the main top level window created by Tardis. + """ - This widget is added to the stacked widget that is the central widget of - the main top level window created by Tardis. - """ - def __init__(self, yamlconfigfile, parent=None): """Create and return the configuration widget. Parameters ---------- - yamlconfigfile: string + yamlconfigfile: string File name of the yaml configuration file. parent: None - Set to None. The parent is changed when the widget is + Set to None. The parent is changed when the widget is appended to the layout of its parent. """ super(ConfigEditor, self).__init__(parent) - - #Configurations from the input and template + + #Configurations from the input and template configDict = yaml.load(open(yamlconfigfile)) templatedictionary ={'tardis_config_version':[True, 'v1.0'], 'supernova':{ 'luminosity_requested':[True, '1 solLum'], @@ -224,7 +228,7 @@ def __init__(self, yamlconfigfile, parent=None): } }, 'model':{ 'structure':{'type':[True, ['file|_:_|filename|_:_|' - 'filetype|_:_|v_inner_boundary|_:_|v_outer_boundary', + 'filetype|_:_|v_inner_boundary|_:_|v_outer_boundary', 'specific|_:_|velocity|_:_|density']], 'filename':[True, None], 'filetype':[True, None], @@ -241,9 +245,9 @@ def __init__(self, yamlconfigfile, parent=None): 'w7_v_0': [False, '1 km/s'], 'time_0':[True, None], 'rho_0':[True, None], - 'v_0': [True, None], + 'v_0': [True, None], 'exponent': [True, None], - 'value':[True, None] + 'value':[True, None] } }, 'abundances':{ 'type':[True, ['file|_:_|filetype|_:_|' @@ -264,7 +268,7 @@ def __init__(self, yamlconfigfile, parent=None): 'no_of_virtual_packets':[False, 0], 'enable_reflective_inner_boundary':[False, False], 'inner_boundary_albedo':[False, 0.0], - 'convergence_strategy':{ 'type':[True, + 'convergence_strategy':{ 'type':[True, ['damped|_:_|damping_constant|_:_|t_inner|_:_|' 't_rad|_:_|w|_:_|lock_t_inner_cycles|_:_|' 't_inner_update_exponent','specific|_:_|threshold' @@ -299,7 +303,7 @@ def __init__(self, yamlconfigfile, parent=None): self.colView = QtGui.QColumnView() self.colView.setModel(self.trmodel) #Five columns of width 256 each can be visible at once - self.colView.setFixedWidth(256*5) + self.colView.setFixedWidth(256*5) self.colView.setItemDelegate(TreeDelegate(self)) self.layout.addWidget(self.colView) @@ -307,7 +311,7 @@ def __init__(self, yamlconfigfile, parent=None): button = QtGui.QPushButton('Recalculate') button.setFixedWidth(90) self.layout.addWidget(button) - button.clicked.connect(self.recalculate) + button.clicked.connect(self.recalculate) #Finally put them all in self.setLayout(self.layout) @@ -316,14 +320,14 @@ def match_dicts(self, dict1, dict2): #dict1<=dict2 """Compare and combine two dictionaries. If there are new keys in `dict1` then they are appended to `dict2`. - The `dict2` stores the values for the keys in `dict1` but it - first modifies them by taking the value and appending to a - list whose first item is either True or False, indicating if + The `dict2` stores the values for the keys in `dict1` but it + first modifies them by taking the value and appending to a + list whose first item is either True or False, indicating if that key is mandatory or not. The goal of this method is to - perform validation by inserting user provided values into the - template dictionary. After inserting user given values into the - template dictionary, all the keys have either default or user - provided values. Then it can be used to build a tree to be + perform validation by inserting user provided values into the + template dictionary. After inserting user given values into the + template dictionary, all the keys have either default or user + provided values. Then it can be used to build a tree to be shown in the ConfigEditor. Parameters @@ -331,13 +335,13 @@ def match_dicts(self, dict1, dict2): #dict1<=dict2 dict1: dictionary The dictionary of user provided configuration. dict2: dictionary - The template dictionary with all default values set. This + The template dictionary with all default values set. This one may have some keys missing that are present in the `dict1`. Such keys will be appended. Raises ------ IOError - If the configuration file has an invalid value for a + If the configuration file has an invalid value for a key that can only take values from a predefined list, then this error is raised. @@ -349,8 +353,8 @@ def match_dicts(self, dict1, dict2): #dict1<=dict2 elif isinstance(dict2[key], list): if isinstance(dict2[key][1], list): - - #options = dict2[key][1] #This is passed by reference. + + #options = dict2[key][1] #This is passed by reference. #So copy the list manually. options = [dict2[key][1][i] for i in range( len(dict2[key][1]))] @@ -363,11 +367,11 @@ def match_dicts(self, dict1, dict2): #dict1<=dict2 if optionselected in options: indexofselected = options.index(optionselected) temp = dict2[key][1][0] - + dict2[key][1][0] = dict2[key][1][indexofselected] dict2[key][1][indexofselected] = temp - - + + else: print 'The selected and available options' print optionselected @@ -388,16 +392,16 @@ def recalculate(self): pass class ModelViewer(QtGui.QWidget): - """The widget that holds all the plots and tables that visualize - the data in the tardis model. This is also appended to the stacked + """The widget that holds all the plots and tables that visualize + the data in the tardis model. This is also appended to the stacked widget in the top level window. """ - + def __init__(self, tablecreator, parent=None): """Create all widgets that are children of ModelViewer.""" QtGui.QWidget.__init__(self, parent) - + #Data structures self.model = None self.shell_info = {} @@ -408,7 +412,7 @@ def __init__(self, tablecreator, parent=None): #Shells widget self.shellWidget = self.make_shell_widget() - + #Spectrum widget self.spectrumWidget = self.make_spectrum_widget() @@ -422,15 +426,15 @@ def __init__(self, tablecreator, parent=None): (1, 0)) self.tableview = QtGui.QTableView() self.tableview.setMinimumWidth(200) - self.tableview.connect(self.tableview.verticalHeader(), + self.tableview.connect(self.tableview.verticalHeader(), QtCore.SIGNAL('sectionClicked(int)'), self.graph.highlight_shell) - self.tableview.connect(self.tableview.verticalHeader(), + self.tableview.connect(self.tableview.verticalHeader(), QtCore.SIGNAL('sectionDoubleClicked(int)'), self.on_header_double_clicked) #Label for text output self.outputLabel = QtGui.QLabel() - self.outputLabel.setFrameStyle(QtGui.QFrame.StyledPanel | + self.outputLabel.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Sunken) self.outputLabel.setStyleSheet("QLabel{background-color:white;}") @@ -458,11 +462,11 @@ def __init__(self, tablecreator, parent=None): textntablelayout.addWidget(textsBox) textntablelayout.addWidget(tableBox) - self.layout.addLayout(textntablelayout) + self.layout.addLayout(textntablelayout) self.setLayout(self.layout) def fill_output_label(self): - """Read some data from tardis model and display on the label for + """Read some data from tardis model and display on the label for quick user access. """ @@ -470,19 +474,19 @@ def fill_output_label(self): Model converged : {}
Simulation Time : {} s
\ Inner Temperature : {} K
Number of packets : {}
\ Inner Luminosity : {}'\ - .format(self.model.iterations, + .format(self.model.iterations, self.model.iterations_executed, - 'True' if - self.model.converged else - 'False', + 'True' if + self.model.converged else + 'False', self.model.runner.time_of_simulation.value, - self.model.model.t_inner.value, + self.model.model.t_inner.value, self.model.last_no_of_packets, self.model.runner.calculate_luminosity_inner(self.model.model)) self.outputLabel.setText(labeltext) def make_shell_widget(self): - """Create the plot of the the shells and place it inside a + """Create the plot of the the shells and place it inside a container widget. Return the container widget. """ @@ -581,7 +585,7 @@ def change_spectrum_to_spec_virtual_flux_angstrom(self): self.change_spectrum(luminosity_density_lambda, 'spec_flux_angstrom') def change_spectrum_to_spec_flux_angstrom(self): - """Change spectrum data back from virtual spectrum. (See the + """Change spectrum data back from virtual spectrum. (See the method above).""" if self.model.runner.spectrum.luminosity_density_lambda is None: luminosity_density_lambda = np.zeros_like( @@ -616,7 +620,7 @@ def plot_spectrum(self): luminosity_density_lambda =\ self.model.runner.spectrum.luminosity_density_lambda.value - self.spectrum.dataplot = self.spectrum.ax.plot(wavelength, + self.spectrum.dataplot = self.spectrum.ax.plot(wavelength, luminosity_density_lambda, label='b') self.spectrum.draw() @@ -649,7 +653,7 @@ def change_graph(self, data, name, unit): self.graph.draw() def plot_model(self): - """Plot the two graphs, the shell model and the line plot + """Plot the two graphs, the shell model and the line plot both showing the radiation temperature and set labels. """ @@ -669,7 +673,7 @@ def plot_model(self): self.shells = [] t_rad_normalizer = colors.Normalize(vmin=self.model.model.t_rad.value.min(), vmax=self.model.model.t_rad.value.max()) - t_rad_color_map = plt.cm.ScalarMappable(norm=t_rad_normalizer, + t_rad_color_map = plt.cm.ScalarMappable(norm=t_rad_normalizer, cmap=plt.cm.jet) t_rad_color_map.set_array(self.model.model.t_rad.value) if self.graph.cb: @@ -680,25 +684,25 @@ def plot_model(self): self.graph.cb = self.graph.figure.colorbar(t_rad_color_map) self.graph.cb.set_label('T (K)') self.graph.normalizing_factor = 0.2 * ( - self.model.model.r_outer.value[-1] - + self.model.model.r_outer.value[-1] - self.model.model.r_inner.value[0]) / ( self.model.model.r_inner.value[0]) #self.graph.normalizing_factor = 8e-16 for i, t_rad in enumerate(self.model.model.t_rad.value): - r_inner = (self.model.model.r_inner.value[i] * + r_inner = (self.model.model.r_inner.value[i] * self.graph.normalizing_factor) - r_outer = (self.model.model.r_outer.value[i] * + r_outer = (self.model.model.r_outer.value[i] * self.graph.normalizing_factor) - self.shells.append(Shell(i, (0,0), r_inner, r_outer, + self.shells.append(Shell(i, (0,0), r_inner, r_outer, facecolor=t_rad_color_map.to_rgba(t_rad), picker=self.graph.shell_picker)) self.graph.ax2.add_patch(self.shells[i]) - self.graph.ax2.set_xlim(0, - self.model.model.r_outer.value[-1] * + self.graph.ax2.set_xlim(0, + self.model.model.r_outer.value[-1] * self.graph.normalizing_factor) - self.graph.ax2.set_ylim(0, - self.model.model.r_outer.value[-1] * + self.graph.ax2.set_ylim(0, + self.model.model.r_outer.value[-1] * self.graph.normalizing_factor) self.graph.figure.tight_layout() self.graph.draw() @@ -722,7 +726,7 @@ def __init__(self, index, tablecreator, parent=None): self.atomstable = QtGui.QTableView() self.ionstable = QtGui.QTableView() self.levelstable = QtGui.QTableView() - self.atomstable.connect(self.atomstable.verticalHeader(), + self.atomstable.connect(self.atomstable.verticalHeader(), QtCore.SIGNAL('sectionClicked(int)'), self.on_atom_header_double_clicked) @@ -730,7 +734,7 @@ def __init__(self, index, tablecreator, parent=None): self.table1_data = self.parent.model.plasma.abundance[ self.shell_index] self.atomsdata = self.createTable([['Z = '], ['Count (Shell %d)' % ( - self.shell_index + 1)]], iterate_header=(2, 0), + self.shell_index + 1)]], iterate_header=(2, 0), index_info=self.table1_data.index.values.tolist()) self.ionsdata = None self.levelsdata = None @@ -747,14 +751,14 @@ def __init__(self, index, tablecreator, parent=None): self.show() def on_atom_header_double_clicked(self, index): - """Called when a header in the first column is clicked to show + """Called when a header in the first column is clicked to show ion populations.""" self.current_atom_index = self.table1_data.index.values.tolist()[index] self.table2_data = self.parent.model.plasma.ion_number_density[ self.shell_index].ix[self.current_atom_index] - self.ionsdata = self.createTable([['Ion: '], - ['Count (Z = %d)' % self.current_atom_index]], - iterate_header=(2, 0), + self.ionsdata = self.createTable([['Ion: '], + ['Count (Z = %d)' % self.current_atom_index]], + iterate_header=(2, 0), index_info=self.table2_data.index.values.tolist()) normalized_data = [] for item in self.table2_data.values: @@ -778,13 +782,13 @@ def on_ion_header_double_clicked(self, index): self.current_ion_index = self.table2_data.index.values.tolist()[index] self.table3_data = self.parent.model.plasma.level_number_density[ self.shell_index].ix[self.current_atom_index, self.current_ion_index] - self.levelsdata = self.createTable([['Level: '], - ['Count (Ion %d)' % self.current_ion_index]], - iterate_header=(2, 0), + self.levelsdata = self.createTable([['Level: '], + ['Count (Ion %d)' % self.current_ion_index]], + iterate_header=(2, 0), index_info=self.table3_data.index.values.tolist()) normalized_data = [] for item in self.table3_data.values.tolist(): - normalized_data.append(float(item / + normalized_data.append(float(item / self.table2_data.ix[self.current_ion_index])) self.levelsdata.add_data(normalized_data) self.levelstable.setModel(self.levelsdata) @@ -809,7 +813,7 @@ def update_tables(self): class LineInfo(QtGui.QDialog): """Dialog to show the line info used by spectrum widget.""" def __init__(self, parent, wavelength_start, wavelength_end, tablecreator): - """Create the dialog and set data in it from the model. + """Create the dialog and set data in it from the model. Show widget.""" super(LineInfo, self).__init__(parent) self.createTable = tablecreator @@ -823,7 +827,7 @@ def __init__(self, parent, wavelength_start, wavelength_end, tablecreator): packet_nu_line_interaction.packet_filter_mode = 'packet_nu' packet_nu_line_interaction.wavelength_start = wavelength_start * u.angstrom packet_nu_line_interaction.wavelength_end = wavelength_end * u.angstrom - + line_in_nu_line_interaction = analysis.LastLineInteraction.from_model( self.parent.model) line_in_nu_line_interaction.packet_filter_mode = 'line_in_nu' @@ -831,18 +835,18 @@ def __init__(self, parent, wavelength_start, wavelength_end, tablecreator): line_in_nu_line_interaction.wavelength_end = wavelength_end * u.angstrom - self.layout.addWidget(LineInteractionTables(packet_nu_line_interaction, - self.parent.model.plasma.atomic_data.atom_data, self.parent.model.plasma.lines, 'filtered by frequency of packet', + self.layout.addWidget(LineInteractionTables(packet_nu_line_interaction, + self.parent.model.plasma.atomic_data.atom_data, self.parent.model.plasma.lines, 'filtered by frequency of packet', self.createTable)) - self.layout.addWidget(LineInteractionTables(line_in_nu_line_interaction, - self.parent.model.plasma.atomic_data.atom_data, self.parent.model.plasma.lines, + self.layout.addWidget(LineInteractionTables(line_in_nu_line_interaction, + self.parent.model.plasma.atomic_data.atom_data, self.parent.model.plasma.lines, 'filtered by frequency of line interaction', self.createTable)) self.setLayout(self.layout) self.show() def get_data(self, wavelength_start, wavelength_end): - """Fetch line info data for the specified wavelength range + """Fetch line info data for the specified wavelength range from the model and create ionstable. """ @@ -851,17 +855,17 @@ def get_data(self, wavelength_start, wavelength_end): last_line_in_ids, last_line_out_ids = analysis.get_last_line_interaction( self.wavelength_start, self.wavelength_end, self.parent.model) self.last_line_in, self.last_line_out = ( - self.parent.model.atom_data.lines.ix[last_line_in_ids], + self.parent.model.atom_data.lines.ix[last_line_in_ids], self.parent.model.atom_data.lines.ix[last_line_out_ids]) self.grouped_lines_in, self.grouped_lines_out = (self.last_line_in.groupby( - ['atomic_number', 'ion_number']), + ['atomic_number', 'ion_number']), self.last_line_out.groupby(['atomic_number', 'ion_number'])) - self.ions_in, self.ions_out = (self.grouped_lines_in.groups.keys(), + self.ions_in, self.ions_out = (self.grouped_lines_in.groups.keys(), self.grouped_lines_out.groups.keys()) self.ions_in.sort() self.ions_out.sort() self.header_list = [] - self.ion_table = (self.grouped_lines_in.wavelength.count().astype(float) / + self.ion_table = (self.grouped_lines_in.wavelength.count().astype(float) / self.grouped_lines_in.wavelength.count().sum()).values.tolist() for z, ion in self.ions_in: self.header_list.append('Z = %d: Ion %d' % (z, ion)) @@ -875,7 +879,7 @@ def get_transition_table(self, lines, atom, ion): transitions_with_duplicates = lines.ix[grouped.groups[(atom, ion)] ].groupby(['level_number_lower', 'level_number_upper']).groups transitions = lines.ix[grouped.groups[(atom, ion)] - ].drop_duplicates().groupby(['level_number_lower', + ].drop_duplicates().groupby(['level_number_lower', 'level_number_upper']).groups transitions_count = [] transitions_parsed = [] @@ -890,7 +894,7 @@ def get_transition_table(self, lines, atom, ion): for index in range(len(transitions_count)): transitions_count[index] /= float(s) for key, value in transitions.items(): - transitions_parsed.append("%d-%d (%.2f A)" % (key[0], key[1], + transitions_parsed.append("%d-%d (%.2f A)" % (key[0], key[1], self.parent.model.atom_data.lines.ix[value[0]]['wavelength'])) return transitions_parsed, transitions_count @@ -900,14 +904,14 @@ def on_atom_clicked(self, index): """ self.transitionsin_parsed, self.transitionsin_count = ( - self.get_transition_table(self.last_line_in, + self.get_transition_table(self.last_line_in, self.ions_in[index][0], self.ions_in[index][1])) self.transitionsout_parsed, self.transitionsout_count = ( - self.get_transition_table(self.last_line_out, + self.get_transition_table(self.last_line_out, self.ions_out[index][0], self.ions_out[index][1])) - self.transitionsindata = self.createTable([self.transitionsin_parsed, + self.transitionsindata = self.createTable([self.transitionsin_parsed, ['Lines In']]) - self.transitionsoutdata = self.createTable([self.transitionsout_parsed, + self.transitionsoutdata = self.createTable([self.transitionsout_parsed, ['Lines Out']]) self.transitionsindata.add_data(self.transitionsin_count) self.transitionsoutdata.add_data(self.transitionsout_count) @@ -924,12 +928,12 @@ def on_atom_clicked2(self, index): """ self.transitionsin_parsed, self.transitionsin_count = ( - self.get_transition_table(self.last_line_in, self.ions_in[index][0], + self.get_transition_table(self.last_line_in, self.ions_in[index][0], self.ions_in[index][1])) self.transitionsout_parsed, self.transitionsout_count = ( - self.get_transition_table(self.last_line_out, + self.get_transition_table(self.last_line_out, self.ions_out[index][0], self.ions_out[index][1])) - self.transitionsindata = self.createTable([self.transitionsin_parsed, + self.transitionsindata = self.createTable([self.transitionsin_parsed, ['Lines In']]) self.transitionsoutdata = self.createTable([self.transitionsout_parsed, ['Lines Out']]) @@ -943,12 +947,12 @@ def on_atom_clicked2(self, index): self.show() class LineInteractionTables(QtGui.QWidget): - """Widget to hold the line interaction tables used by + """Widget to hold the line interaction tables used by LineInfo which in turn is used by spectrum widget. """ - def __init__(self, line_interaction_analysis, atom_data, lines_data, description, + def __init__(self, line_interaction_analysis, atom_data, lines_data, description, tablecreator): """Create the widget and set data.""" super(LineInteractionTables, self).__init__() @@ -961,7 +965,7 @@ def __init__(self, line_interaction_analysis, atom_data, lines_data, description self.atom_data = atom_data self.lines_data = lines_data.reset_index().set_index('line_id') line_interaction_species_group = \ - line_interaction_analysis.last_line_in.groupby(['atomic_number', + line_interaction_analysis.last_line_in.groupby(['atomic_number', 'ion_number']) self.species_selected = sorted( line_interaction_species_group.groups.keys()) @@ -977,7 +981,7 @@ def __init__(self, line_interaction_analysis, atom_data, lines_data, description line_interaction_species_group.wavelength.count() self.layout.addWidget(self.text_description) self.layout.addWidget(self.species_table) - self.species_table.connect(self.species_table.verticalHeader(), + self.species_table.connect(self.species_table.verticalHeader(), QtCore.SIGNAL('sectionClicked(int)'), self.on_species_clicked) self.layout.addWidget(self.transitions_table) @@ -1027,24 +1031,24 @@ def on_species_clicked(self, index): self.transitions_table.setModel(last_line_in_model) class Tardis(QtGui.QMainWindow): - """Create the top level window for the GUI and wait for call to + """Create the top level window for the GUI and wait for call to display data. """ - + def __init__(self, tablemodel, config=None, atom_data=None, parent=None): """Create the top level window and all widgets it contains. When called with no arguments it initializes the GUI in passive - mode. When a yaml config file and atom data are provided the + mode. When a yaml config file and atom data are provided the GUI starts in the active mode. Parameters --------- parent: None - Set to None by default and shouldn't be changed unless + Set to None by default and shouldn't be changed unless you are developing something new. - config: string + config: string yaml file with configuration information for TARDIS. atom_data: string hdf file that has the atom data. @@ -1052,12 +1056,12 @@ def __init__(self, tablemodel, config=None, atom_data=None, parent=None): Raises ------ TemporarilyUnavaliable - Raised when an attempt is made to start the active mode. + Raised when an attempt is made to start the active mode. This will be removed when active mode is developed. """ - #assumes that qt has already been initialized by starting IPython + #assumes that qt has already been initialized by starting IPython #with the flag "--pylab=qt" # app = QtCore.QCoreApplication.instance() # if app is None: @@ -1071,7 +1075,7 @@ def __init__(self, tablemodel, config=None, atom_data=None, parent=None): QtGui.QMainWindow.__init__(self, parent) #path to icons folder - self.path = os.path.join(tardis.__path__[0],'gui','images') + self.path = os.path.join(tardis.__path__[0],'gui','images') #Check if configuration file was provided self.mode = 'passive' @@ -1088,14 +1092,14 @@ def __init__(self, tablemodel, config=None, atom_data=None, parent=None): self.modeLabel = QtGui.QLabel('Passive mode') statusbr.addPermanentWidget(self.modeLabel) statusbr.showMessage(self.mode, 5000) - statusbr.showMessage("Ready", 5000) + statusbr.showMessage("Ready", 5000) #Actions quitAction = QtGui.QAction("&Quit", self) - quitAction.setIcon(QtGui.QIcon(os.path.join(self.path, + quitAction.setIcon(QtGui.QIcon(os.path.join(self.path, 'closeicon.png'))) quitAction.triggered.connect(self.close) - + self.viewMdv = QtGui.QAction("View &Model", self) self.viewMdv.setIcon(QtGui.QIcon(os.path.join(self.path, 'mdvswitch.png'))) @@ -1103,7 +1107,7 @@ def __init__(self, tablemodel, config=None, atom_data=None, parent=None): self.viewMdv.setChecked(True) self.viewMdv.setEnabled(False) self.viewMdv.triggered.connect(self.switch_to_mdv) - + self.viewForm = QtGui.QAction("&Edit Model", self) self.viewForm.setIcon(QtGui.QIcon(os.path.join(self.path, 'formswitch.png'))) @@ -1121,7 +1125,7 @@ def __init__(self, tablemodel, config=None, atom_data=None, parent=None): #Toolbar fileToolbar = self.addToolBar("File") - fileToolbar.setObjectName("FileToolBar") + fileToolbar.setObjectName("FileToolBar") fileToolbar.addAction(quitAction) viewToolbar = self.addToolBar("View") @@ -1131,9 +1135,9 @@ def __init__(self, tablemodel, config=None, atom_data=None, parent=None): #Central Widget self.stackedWidget = QtGui.QStackedWidget() - self.mdv = ModelViewer(tablemodel) + self.mdv = ModelViewer(tablemodel) self.stackedWidget.addWidget(self.mdv) - + #In case of active mode if self.mode == 'active': #Disabled currently @@ -1146,7 +1150,7 @@ def __init__(self, tablemodel, config=None, atom_data=None, parent=None): # self.viewMdv.setEnabled(True) # model = run_tardis(config, atom_data) # self.show_model(model) - raise TemporarilyUnavaliable("The active mode is under" + raise TemporarilyUnavaliable("The active mode is under" "development. Please use the passive mode for now.") self.setCentralWidget(self.stackedWidget) @@ -1156,7 +1160,7 @@ def show_model(self, model=None): Parameters ---------- - model: TARDIS model object + model: TARDIS model object A keyword argument that takes the tardis model object. """ @@ -1172,7 +1176,7 @@ def show_model(self, model=None): self.mdv.plot_model() self.mdv.plot_spectrum() self.showMaximized() - + def switch_to_mdv(self): """Switch the cental stacked widget to show the modelviewer.""" @@ -1186,9 +1190,9 @@ def switch_to_form(self): class TemporarilyUnavaliable(Exception): """Exception raised when creation of active mode of tardis is attempted.""" - + def __init__(self, value): self.value = value - + def __str__(self): return repr(self.value)