Load data according to runID number. requires databroker
(self, run_id_uid)
| 478 | self.fname_from_db = "scan2D_" + str(self.runid) |
| 479 | |
| 480 | def load_data_runid(self, run_id_uid): |
| 481 | """ |
| 482 | Load data according to runID number. |
| 483 | |
| 484 | requires databroker |
| 485 | """ |
| 486 | # Clear data. If reading the file fails, then old data should not be kept. |
| 487 | self.file_channel_list = [] |
| 488 | self.clear() |
| 489 | |
| 490 | if db is None: |
| 491 | raise RuntimeError("Databroker is not installed. The scan cannot be loaded.") |
| 492 | |
| 493 | s = f"ID {run_id_uid}" if isinstance(run_id_uid, int) else f"UID '{run_id_uid}'" |
| 494 | logger.info(f"Loading scan with {s}") |
| 495 | |
| 496 | # Use 'current_working_directory' for all new files |
| 497 | self.file_directory = self.current_working_directory |
| 498 | |
| 499 | rv = render_data_to_gui( |
| 500 | run_id_uid, |
| 501 | create_each_det=self.load_each_channel, |
| 502 | working_directory=self.file_directory, |
| 503 | file_overwrite_existing=self.file_overwrite_existing, |
| 504 | ) |
| 505 | |
| 506 | if rv is None: |
| 507 | logger.error(f"Data from scan #{self.runid} was not loaded") |
| 508 | return |
| 509 | |
| 510 | img_dict, self.data_sets, fname, detector_name, self.scan_metadata = rv |
| 511 | |
| 512 | # Process metadata |
| 513 | self._metadata_update_program_state() |
| 514 | |
| 515 | # Replace relative scan ID with true scan ID. |
| 516 | if "scan_id" in self.scan_metadata: |
| 517 | self.runid = int(self.scan_metadata["scan_id"]) |
| 518 | if "scan_uid" in self.scan_metadata: |
| 519 | self.runuid = self.scan_metadata["scan_uid"] |
| 520 | |
| 521 | # Change file name without rereading the file |
| 522 | self.file_path_silent_change = True |
| 523 | self.file_path = fname |
| 524 | logger.info(f"Data loading: complete dataset for the detector '{detector_name}' was loaded successfully.") |
| 525 | |
| 526 | self.file_channel_list = list(self.data_sets.keys()) |
| 527 | |
| 528 | self.img_dict = img_dict |
| 529 | |
| 530 | self.data_ready = True |
| 531 | |
| 532 | default_channel = 0 # Use summed data as default |
| 533 | self.file_opt = default_channel |
| 534 | if self.file_channel_list and self.data_sets: |
| 535 | self.data_sets[self.file_channel_list[default_channel]].selected_for_preview = True |
| 536 | |
| 537 | self.update_data_set_buffers() |
no test coverage detected