MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / open_data_file

Method open_data_file

pyxrf/gui_support/gpc_class.py:111–186  ·  view source on GitHub ↗
(self, file_path)

Source from the content-addressed store, hash-verified

109 return self.io_model.is_databroker_available()
110
111 def open_data_file(self, file_path):
112 self.io_model.data_ready = False
113 # only load one file
114 # 'temp' is used to reload the same file, otherwise file_name will not update
115 self.io_model.file_path = "temp"
116 f_path = file_path
117
118 def _update_data():
119 self.fit_model.fit_img = {} # clear dict in fitmodel to rm old results
120 # This will draw empty (hidden) preview plot, since no channels are selected.
121 self.plot_model.update_preview_spectrum_plot()
122 self.plot_model.update_total_count_map_preview(new_plot=True)
123
124 # The following statement initiates file loading. It may raise exceptions
125 try:
126 self.io_model.file_path = file_path
127
128 except Exception:
129 _update_data()
130 self.fitting_parameters_changed()
131
132 # For plotting purposes, otherwise plot will not update
133 self.plot_model.plot_exp_opt = False
134
135 self.plot_model.show_fit_opt = False
136
137 logger.info(f"Failed to load the file '{f_path}'.")
138 # Clear file name or scan id from window title. This does not update
139 # the displayed title.
140 self.io_model.window_title_clear()
141 raise
142 else:
143 _update_data()
144 self.fitting_parameters_changed()
145
146 # For plotting purposes, otherwise plot will not update
147 try:
148 # TODO: permanent fix for the following issue is needed
149 # Suppress Matplotlib exception.
150 # draw_glyph_to_bitmap: glyph num is out of range
151 # This is a temporary fix, proper debugging is needed so that try..except
152 # could be removed
153 self.plot_model.plot_exp_opt = False
154 except Exception as ex:
155 logger.error(f"Exception was raised while removing experimental data plot: {str(ex)}")
156 try:
157 self.plot_model.plot_exp_opt = True
158 except Exception as ex:
159 logger.error(f"Exception was raised while plotting experimental data: {str(ex)}")
160 try:
161 self.plot_model.show_fit_opt = False
162 except Exception as ex:
163 logger.error(f"Exception was raised while removing fitted data plot: {str(ex)}")
164 try:
165 self.plot_model.show_fit_opt = True
166 except Exception as ex:
167 logger.error(f"Exception was raised while plotting fitted data: {str(ex)}")
168

Callers 1

cbMethod · 0.80

Calls 3

window_title_clearMethod · 0.80

Tested by

no test coverage detected