Beispiel #1
0
    def update_record_file(self, exp_number, check_duplicates, scan_list):
        """ update the record file
        it is an option to append file or check and remove duplication.
        duplication can be removed in the record file loading method by checking the time stamp
        :param exp_number:
        :param check_duplicates:
        :param scan_list:
        :return:
        """
        # check inputs
        assert len(self._scanNumbersProcessed
                   ) > 0, 'Processed scan number set cannot be empty!'

        # get calibration information
        det_sample_distance = self._myController.get_calibrated_det_sample_distance(
            exp_number=exp_number)
        det_center_x, det_center_y = self._myController.get_calibrated_det_center(
            exp_number)
        user_wave_length = self._myController.get_calibrated_wave_length(
            exp_number)

        record_file_name = fourcircle_utility.pre_processed_record_file(
            exp_number, self._outputDir)
        if os.path.exists(record_file_name):
            write_header = False
        else:
            write_header = True

        with open(record_file_name, 'a') as csvfile:
            fieldnames = fourcircle_utility.pre_processed_record_header()
            writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

            # write header for the first time
            if write_header:
                writer.writeheader()

            for scan_number in scan_list:
                record = fourcircle_utility.pre_processed_record_make(
                    scan_number, self._mdFileDict[scan_number],
                    det_sample_distance, det_center_x, det_center_y,
                    user_wave_length)
                writer.writerow(record)
    def update_record_file(self, exp_number, check_duplicates, scan_list):
        """ update the record file
        it is an option to append file or check and remove duplication.
        duplication can be removed in the record file loading method by checking the time stamp
        :param exp_number:
        :param check_duplicates:
        :param scan_list:
        :return:
        """
        # check inputs
        assert len(self._scanNumbersProcessed) > 0, 'Processed scan number set cannot be empty!'

        # get calibration information
        det_sample_distance = self._myController.get_calibrated_det_sample_distance(exp_number=exp_number)
        det_center_x, det_center_y = self._myController.get_calibrated_det_center(exp_number)
        user_wave_length = self._myController.get_calibrated_wave_length(exp_number)

        record_file_name = fourcircle_utility.pre_processed_record_file(exp_number, self._outputDir)
        if os.path.exists(record_file_name):
            write_header = False
        else:
            write_header = True

        with open(record_file_name, 'a') as csvfile:
            fieldnames = fourcircle_utility.pre_processed_record_header()
            writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

            # write header for the first time
            if write_header:
                writer.writeheader()

            for scan_number in scan_list:
                record = fourcircle_utility.pre_processed_record_make(scan_number, self._mdFileDict[scan_number],
                                                                      det_sample_distance,
                                                                      det_center_x, det_center_y, user_wave_length)
                writer.writerow(record)