Parameters ---------- run_id_uid: int or str int - run ID (e.g. -1, 45326), str - run UID
(self, run_id_uid)
| 186 | return msg |
| 187 | |
| 188 | def load_run_from_db(self, run_id_uid): |
| 189 | """ |
| 190 | Parameters |
| 191 | ---------- |
| 192 | run_id_uid: int or str |
| 193 | int - run ID (e.g. -1, 45326), str - run UID |
| 194 | """ |
| 195 | |
| 196 | # Copy value to 'runid' field ('runid' field should not change |
| 197 | # during processing unless new data is loaded) |
| 198 | self.io_model.data_ready = False |
| 199 | |
| 200 | def _update_data(): |
| 201 | self.fit_model.fit_img = {} # clear dict in fitmodel to rm old results |
| 202 | # This will draw empty (hidden) preview plot, since no channels are selected. |
| 203 | self.plot_model.update_preview_spectrum_plot() |
| 204 | self.plot_model.update_total_count_map_preview(new_plot=True) |
| 205 | |
| 206 | try: |
| 207 | self.io_model.load_data_runid(run_id_uid) |
| 208 | |
| 209 | except Exception as ex: |
| 210 | _update_data() |
| 211 | self.fitting_parameters_changed() |
| 212 | |
| 213 | # For plotting purposes, otherwise plot will not update |
| 214 | self.plot_model.plot_exp_opt = False |
| 215 | self.plot_model.show_fit_opt = False |
| 216 | |
| 217 | logger.info(f"Failed to load the run #{run_id_uid}.") |
| 218 | logger.exception(ex) |
| 219 | |
| 220 | # Clear file name or scan id from window title. This does not update |
| 221 | # the displayed title. |
| 222 | self.io_model.window_title_clear() |
| 223 | raise |
| 224 | |
| 225 | else: |
| 226 | _update_data() |
| 227 | self.fitting_parameters_changed() |
| 228 | |
| 229 | # For plotting purposes, otherwise plot will not update |
| 230 | self.plot_model.plot_exp_opt = False |
| 231 | self.plot_model.plot_exp_opt = True |
| 232 | self.plot_model.show_fit_opt = False |
| 233 | self.plot_model.show_fit_opt = True |
| 234 | |
| 235 | # Change window title (include file name). This does not update the visible title, |
| 236 | # only the text attribute of 'io_model' class. |
| 237 | self.io_model.window_title_set_run_id(self.io_model.runid) |
| 238 | |
| 239 | file_name = self.io_model.file_path |
| 240 | msg = "" |
| 241 | |
| 242 | logger.info("Loading of the run is completed") |
| 243 | |
| 244 | return msg, file_name |
| 245 |
no test coverage detected