Commit 758a5daf authored by myron's avatar myron
Browse files

esynth for the ant

parent 36a80a7d
......@@ -388,9 +388,6 @@ def tools_sequencer( peaks_shifts = None,
selected_rois = None,
scalar_products_target_file = None,
volume_retrieval_beta = None,
volume_retrieval_niter = None ,
energy_custom_grid = None,
custom_components_file = None ,
interpolation_infos_file = None,
......
......@@ -20,7 +20,7 @@ def main():
monitor_column = "izero/0.000001"
first_scan_num = 651
Ydim = 25
Ydim = None # not used. it is the scan lenght , it is given by the data, contained in the scan
Zdim = 10
Edim = 7
......@@ -42,10 +42,10 @@ def main():
["beta_optical" , 0.1],
["niter_global" , 3 ]
])
resynth_z_square = 0
selected_rois = list(range(0,72))
volume_retrieval_beta = 6.0e-20
volume_retrieval_niter = 100
steps_to_do = {
"do_step_make_roi": False,
......@@ -83,22 +83,24 @@ def main():
###### peaks_shifts = h5py.File("../peaks_positions_for_analysers.h5","r")["peaks_positions"][()]
###### assert( len(peaks_shifts) == 72)
roiob = xrs_rois.roi_object()
roiob.loadH5( roi_target_path )
elastic = xrs_read.Hydra( datadir )
elastic.set_roiObj( roiob )
elastic.get_compensation_factor( elastic_scan_for_peaks_shifts , method='sum')
el_dict = elastic.cenom_dict
Enominal = np.median( list( el_dict.values() ) )
peaks_shifts = np.array([ el_dict["ROI%02d"%i] if ("ROI%02d"%i) in el_dict else nan for i in range( 72) ] )
peaks_shifts-= Enominal
if steps_to_do["do_step_interpolation_coefficients"]:
roiob = xrs_rois.roi_object()
roiob.loadH5( roi_target_path )
elastic = xrs_read.Hydra( datadir )
elastic.set_roiObj( roiob )
elastic.get_compensation_factor( elastic_scan_for_peaks_shifts , method='sum')
el_dict = elastic.cenom_dict
Enominal = np.median( list( el_dict.values() ) )
peaks_shifts = np.array([ el_dict["ROI%02d"%i] if ("ROI%02d"%i) in el_dict else nan for i in range( 72) ] )
peaks_shifts -= Enominal
else:
peaks_shifts = None
##############################################################
##########################################################################
tools_sequencer_esynth.tools_sequencer( peaks_shifts = peaks_shifts ,
tools_sequencer_esynth.tools_sequencer(
peaks_shifts = peaks_shifts ,
datadir = datadir ,
filter_path = filter_path ,
roi_scan_num = roi_scan_num ,
......@@ -122,14 +124,12 @@ def main():
response_fit_options = response_fit_options,
resynthetised_reference_and_roi_target_file = resynthetised_reference_and_roi_target_file,
resynth_z_square = resynth_z_square,
selected_rois = selected_rois,
scalar_products_target_file = scalar_products_target_file ,
volume_retrieval_beta = volume_retrieval_beta ,
volume_retrieval_niter = volume_retrieval_niter ,
energy_custom_grid = energy_custom_grid,
custom_components_file = custom_components_file,
interpolation_infos_file = interpolation_infos_file
......
import numpy as np
import h5py
import glob
import json
import os
import h5py
import math
from XRStools import tools_sequencer_esynth
from XRStools import xrs_read, xrs_rois
import os
def main():
filter_path = None
# filter_path = "mask.h5:/FILTER_MASK/filter"
roi_scan_num = list(range(592,600))
reference_scan_list = list(range(592,600))
monitor_column = "izero/0.000001"
first_scan_num = 464
Ydim = None # not used, it is the scan lenght , it is given by the data, contained in the scang
Zdim = 2
Edim = 62
elastic_scan_for_peaks_shifts = 38
energy_custom_grid = 9.96595 + np.arange(72)*0.0005
### custom_components_file = "abc.h5"
custom_components_file = None
datadir = "/data/id20/inhouse/data/run5_17/run7_ihr/"
# If reference_clip is not None, then a smaller part of the reference scan is considered
# This may be usefule to obtain smaller volumes containing the interesting part
# The used reference scan will the correspond to the positions from reference_clip[0] to reference_clip[1]-1 included
###########
reference_clip = None
# reference_clip = [ 90, 180 ]
## in the reference scan for each position there is a spot with a maximum. We set zero the background which is further than
## such radius from the maximum
isolate_spot_by = 7
#### For the fit of the response function based on reference scans
response_fit_options = dict( [
["niter_optical" , 40],
["beta_optical" , 0.1],
["niter_global" , 1 ]
])
resynth_z_square = 0
selected_rois = list(range(0,24)) + list( range(36,60) )
steps_to_do = {
"do_step_make_roi": False,
"do_step_sample_extraction": False,
"do_step_extract_reference_scan": False,
"do_step_fit_reference_response": False,
"do_step_resynthetise_reference": False,
"do_step_scalars" : False,
"do_step_interpolation_coefficients": True,
"do_step_finalise_for_fit": False
}
os.system("mkdir results")
scalar_products_target_file = "results/scalar_products_target_file.h5"
roi_target_path = "results/myrois.h5:/ROIS"
signals_target_file = "results/signals.h5"
extracted_reference_target_file = "results/reference.h5"
response_target_file = "results/response.h5"
resynthetised_reference_and_roi_target_file = "results/resynthetised_roi_and_scan.h5"
interpolation_infos_file = "interpolation_infos.json"
###########################################################################################
###### LOADING PEAKS SHIFTS
###### peaks_shifts = h5py.File("../peaks_positions_for_analysers.h5","r")["peaks_positions"][()]
###### assert( len(peaks_shifts) == 72)
if steps_to_do["do_step_interpolation_coefficients"]:
## in this case peaks shifts are needed. They are passed
# to tools_sequencer which calculates the coefficients
roiob = xrs_rois.roi_object()
roiob.loadH5( roi_target_path )
elastic = xrs_read.Hydra( datadir )
elastic.set_roiObj( roiob )
elastic.get_compensation_factor( elastic_scan_for_peaks_shifts , method='sum')
el_dict = elastic.cenom_dict
Enominal = np.median( list( el_dict.values() ) )
peaks_shifts = np.array([ el_dict["ROI%02d"%i] if ("ROI%02d"%i) in el_dict else nan for i in range( 72) ] )
peaks_shifts -= Enominal
else:
peaks_shifts = None
##############################################################
##########################################################################
tools_sequencer_esynth.tools_sequencer(peaks_shifts = peaks_shifts ,
datadir = datadir ,
filter_path = filter_path ,
roi_scan_num = roi_scan_num ,
roi_target_path = roi_target_path ,
steps_to_do = steps_to_do,
first_scan_num = first_scan_num,
Ydim = Ydim , # not used
Zdim = Zdim ,
Edim = Edim ,
monitor_column = monitor_column,
signals_target_file = signals_target_file,
reference_scan_list = reference_scan_list,
reference_clip = reference_clip,
extracted_reference_target_file = extracted_reference_target_file ,
isolate_spot_by = isolate_spot_by,
response_target_file = response_target_file,
response_fit_options = response_fit_options,
resynthetised_reference_and_roi_target_file = resynthetised_reference_and_roi_target_file,
resynth_z_square = resynth_z_square,
selected_rois = selected_rois,
scalar_products_target_file = scalar_products_target_file ,
energy_custom_grid = energy_custom_grid,
custom_components_file = custom_components_file,
interpolation_infos_file = interpolation_infos_file
)
main()
......@@ -30,7 +30,6 @@ def main():
Zdim = 2
Edim = 62
rois_are_ready = True
elastic_scan_for_peaks_shifts = 38
datadir = "/data/id20/inhouse/data/run5_17/run7_ihr/"
......@@ -110,10 +109,7 @@ def main():
el_dict = elastic.cenom_dict
Enominal = np.median( list( el_dict.values() ) )
peaks_shifts = np.array([ el_dict["ROI%02d"%i] if ("ROI%02d"%i) in el_dict else nan for i in range( 72) ] )
Enominal = np.median(peaks_shifts)
peaks_shifts-= Enominal
else:
peaks_shifts = None
......
......@@ -37,6 +37,8 @@ def main():
["niter_global" , 3 ]
])
resynth_z_square = 0
selected_rois = list(range(0,24)) + list( range(36,60) )
scal_prod_use_optional_solution = True
......@@ -119,6 +121,7 @@ def main():
response_fit_options = response_fit_options,
resynthetised_reference_and_roi_target_file = resynthetised_reference_and_roi_target_file,
resynth_z_square = 0
selected_rois = selected_rois,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment