Exemple #1
0
    def setUp(self):
        _file_path = os.path.dirname(__file__)
        self.folder = os.path.abspath(
            os.path.join(_file_path, '../../ResoFit/data/_mock_data_for_test'))
        self.data_file = os.path.join(self.folder,
                                      '_data_calibration_fitting_test.txt')
        self.spectra_file = os.path.join(
            self.folder, '_spectra_calibration_fitting_test.txt')

        energy_min = 7
        energy_max = 150
        energy_step = 0.01

        layer_1 = 'U'
        thickness_1 = 0.075
        density_1 = None
        layer = Layer()
        layer.add_layer(layer=layer_1,
                        thickness_mm=thickness_1,
                        density_gcm3=density_1)

        self.calibration = Calibration(data_file=self.data_file,
                                       spectra_file=self.spectra_file,
                                       layer=layer,
                                       energy_min=energy_min,
                                       energy_max=energy_max,
                                       energy_step=energy_step,
                                       folder=self.folder,
                                       database=self.database)
image_end = 2700  # Can be omitted or =None
# norm_to_file = 'ob_1.csv'  #'Ag.csv'
# norm_to_file = 'Ag.csv'
norm_to_file = 'ob_all.csv'
baseline = False
each_step = False

norm_factor = 1.2
source_to_detector_m = 16.126845685903064  # 16#16.445359069030175#16.447496101100739
offset_us = -12112.431834715671  # 0#2.7120797253959119#2.7355447625559037

# Calibrate the peak positions
calibration = Calibration(data_file=data_file,
                          spectra_file=spectra_file,
                          layer=layers,
                          energy_min=energy_min,
                          energy_max=energy_max,
                          energy_step=energy_step,
                          folder=folder,
                          baseline=baseline)

calibration.experiment.norm_to(norm_to_file, norm_factor=norm_factor)
calibration.experiment.slice(start=image_start, end=image_end)

calibrate_result = calibration.calibrate(
    source_to_detector_m=source_to_detector_m,
    offset_us=offset_us,
    vary='all',
    each_step=each_step)
calibration.index_peak(thres_exp=0.05,
                       min_dist_exp=2,
                       min_dist_map=5,
Exemple #3
0
image_start = None  # Can be omitted or =None
image_end = None  # Can be omitted or =None
norm_to_file = 'run_33_resonance_ob.txt'  #None  # 'sphere_background_1.csv'
baseline = True
each_step = False

repeat = 1
source_to_detector_m = 15.4318  # 16#16.445359069030175#16.447496101100739
offset_us = 2.7  # 0#2.7120797253959119#2.7355447625559037

# Calibrate the peak positions
calibration = Calibration(data_file=data_file,
                          spectra_file=spectra_file,
                          layer=layer,
                          energy_min=energy_min,
                          energy_max=energy_max,
                          energy_step=energy_step,
                          norm_factor=repeat,
                          folder=folder,
                          baseline=baseline)

calibration.norm_to(norm_to_file)
calibration.slice(slice_start=image_start, slice_end=image_end)

calibrate_result = calibration.calibrate(
    source_to_detector_m=source_to_detector_m,
    offset_us=offset_us,
    vary='all',
    each_step=each_step)
calibration.plot()
Exemple #4
0
# experiment.slice(start=image_start)
# experiment.find_peak(x_type=x_type, y_type=y_type, thres=0.07, min_dist=50)
# experiment.plot(x_type=x_type, y_type=y_type, plot_with_baseline=True)
# print(experiment.o_peak)
# plt.xlim(left=0, right=300)
# plt.show()

# Calibrate the peak positions
calibration = Calibration(data_file=data_file,
                          spectra_file=spectra_file,
                          layer=layers,
                          energy_min=energy_min,
                          energy_max=energy_max,
                          energy_step=energy_step,
                          folder=folder,
                          exp_source_to_detector_m=source_to_detector_m,
                          exp_offset_us=offset_us,
                          database=database,
                          baseline=baseline,
                          baseline_deg=baseline_deg,
                          x_type=x_type,
                          y_type=y_type
                          )

calibration.experiment.norm_to(norm_to_file, norm_factor=norm_factor)
calibration.experiment.slice(start=image_start, end=image_end)
calibrate_result = calibration.calibrate(source_to_detector_m=source_to_detector_m,
                                         offset_us=offset_us,
                                         vary='source_to_detector',
                                         # vary='all',
                                         each_step=each_step)
Exemple #5
0
# x_type = 'lambda'
# x_type = 'energy'
x_type = 'number'
# x_type = 'time'
# y_type = 'transmission'
y_type = 'attenuation'

# Calibrate the peak positions
calibration = Calibration(data_file=data_file,
                          spectra_file=spectra_file,
                          layer=layers,
                          energy_min=energy_min,
                          energy_max=energy_max,
                          energy_step=energy_step,
                          folder=folder,
                          exp_source_to_detector_m=source_to_detector_m,
                          exp_offset_us=offset_us,
                          database=database,
                          baseline=baseline,
                          baseline_deg=baseline_deg,
                          x_type=x_type,
                          y_type=y_type)

calibration.experiment.norm_to(file=norm_to_file, norm_factor=norm_factor)
calibration.experiment.slice(start=image_start, end=image_end)

calibrate_result = calibration.calibrate(
    source_to_detector_m=source_to_detector_m,
    offset_us=offset_us,
    vary='all',
    each_step=each_step)
image_end = 2720  # Can be omitted or =None
# norm_to_file = 'ob_1.csv'  #'Ag.csv'
# norm_to_file = 'Ag.csv'
norm_to_file = 'ob_all.csv'
baseline = False
each_step = True

repeat = 1.2
source_to_detector_m = 16.126845685903064  # 16#16.445359069030175#16.447496101100739
offset_us = -12112.431834715671  # 0#2.7120797253959119#2.7355447625559037

# Calibrate the peak positions
calibration = Calibration(data_file=data_file,
                          spectra_file=spectra_file,
                          layer=layers,
                          energy_min=energy_min,
                          energy_max=energy_max,
                          energy_step=energy_step,
                          folder=folder,
                          baseline=baseline)

calibration.experiment.norm_to(norm_to_file)
calibration.experiment.slice(start=image_start, end=image_end)

calibration.experiment.plot(
    x_type='energy',
    source_to_detector_m=source_to_detector_m,
    offset_us=offset_us,
    logx=True,
)
# calibrate_result = calibration.calibrate(source_to_detector_m=source_to_detector_m,
#                                          offset_us=offset_us,