Commit 8bf57899 authored by myron's avatar myron
Browse files

ants

parent 835241c4
......@@ -119,6 +119,76 @@ def extract_sample_givenrois(
)
process_input(input_string, exploit_slurm_mpi = 0)
def synthetise_response(scan_address=None, target_address=None, response_fit_options = None
):
input_string = """
superR_fit_responses :
foil_scan_address : "{scan_address}"
nref : 7 # the number of subdivision per pixel dimension used to
# represent the optical response function at higher resolution
niter_optical : {niter_optical} # the number of iterations used in the optimisation of the optical
# response
beta_optical : {beta_optical} # The L1 norm factor in the regularisation
# term for the optical functions
pixel_dim : 1 # The pixel response function is represented with a
# pixel_dim**2 array
niter_pixel : 10 # The number of iterations in the pixel response optimisation
# phase. A negative number stands for ISTA, positive for FISTA
beta_pixel : 0.0 # L1 factor for the pixel response regularisation
## The used trajectories are always written whith the calculated response
## They can be reloaded and used as initialization(and freezed with do_refine_trajectory : 0 )
## Uncomment the following line if you want to reload a set of trajectories
## without this options trajectories are initialised from the spots drifts
##
# reload_trajectories_file : "response.h5"
filter_rois : 0
######
## The method first find an estimation of the foil scan trajectory on each roi
## then, based on this, obtain a fit of the optical response function
## assuming a flat pixel response. Finally the pixel response is optimised
##
## There is a final phase where a global optimisation
## is done in niter_global steps.
##
## Each step is composed of optical response fit, followed by a pixel response fit.
## If do_refine_trajectory is different from zero, the trajectory is reoptimised at each step
##
niter_global : {niter_global}
## if do_refine_trajectory=1 the start and end point of the trajectory are free
## if =2 then the start and end point are forced to a trajectory which is obtained
## from a reference scan : the foil scan may be short, then one can use the scan of
## an object to get another one : key *trajectory_reference_scan_address*
##
do_refine_trajectory : 1
## optional: only if do_refine_trajectory = 2
trajectory_reference_scansequence_address : "demo_newrois.h5:/ROI_FOIL/images/scans/"
trajectory_threshold : 0.1
## if the pixel response function is forced to be symmetrical
simmetrizza : 1
## where the found responses are written
target_file : {target_address}
# target_file : "fitted_responses.h5"
"""
s=input_string.format( scan_address=scan_address ,
target_address=target_address,
niter_optical = response_fit_options[ "niter_optical"],
beta_optical=response_fit_options["beta_optical"],
niter_global=response_fit_options["niter_global"]
)
process_input( s , exploit_slurm_mpi = 1, stop_omp = True)
def resynthetise_scan(
old_scan_address= None,
......
......@@ -10,10 +10,8 @@ from XRStools import tools_sequencer_esynth
from XRStools import xrs_read, xrs_rois
import os
def main():
def main():
os.system("xz -dk mask.h5.xz --stdout > mask.h5")
filter_path = "mask.h5:/FILTER_MASK/filter"
roi_scan_num = [245,246,247]
......@@ -32,36 +30,23 @@ def main():
### custom_components_file = "abc.h5"
custom_components_file = None
datadir = "/data/id20/inhouse/data/run3_20/run3_es949"
# 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 = 6
#### For the fit of the response function based on reference scans
response_fit_options = dict( [
["niter_optical" , 100],
["beta_optical" , 0.1],
["niter_global" , 3 ]
])
# selected_rois = list(range(0,24)) + list( range(36,60) )
selected_rois = list( range(24,36) ) + list( range(60,72) )
# selected_rois = list(range(0,72))
selected_rois = list(range(0,72))
volume_retrieval_beta = 6.0e-20
volume_retrieval_niter = 100
steps_to_do = {
"do_step_make_roi": False,
"do_step_sample_extraction": False,
......@@ -69,7 +54,7 @@ def main():
"do_step_fit_reference_response": False,
"do_step_resynthetise_reference": False,
"do_step_scalars" : True,
"do_step_scalars" : False,
"do_step_interpolation_coefficients": True,
......@@ -105,8 +90,7 @@ def main():
elastic.get_compensation_factor( elastic_scan_for_peaks_shifts , method='sum')
el_dict = elastic.cenom_dict
Enominal = np.median( list( el_dict.values() ) )
peaks_shift = 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 = np.array([ el_dict["ROI%02d"%i] if ("ROI%02d"%i) in el_dict else nan for i in range( 72) ] )
peaks_shifts-= Enominal
##############################################################
......
import numpy as np
import h5py
import glob
import json
import os
import h5py
import math
from XRStools import tools_sequencer_interp
import os
def main():
## os.system("xz -dk ../mask.h5.xz --stdout > mask.h5 ")
filter_path = None
# filter_path = "mask.h5:/FILTER_MASK/filter"
roi_scan_num = [592]
reference_scan_list = [245, 246, 247]
monitor_column = "izero/0.000001"
first_scan_num = 651
Ydim = 25
Zdim = 10
Edim = 7
elastic_scan_for_peaks_shifts = 69
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" , 100],
["beta_optical" , 0.1],
["niter_global" , 3 ]
])
selected_rois = list(range(0,24)) + list( range(36,60) )
scal_prod_use_optional_solution = True
volume_retrieval_beta = 6.0e-20
volume_retrieval_niter = 100
rois_are_ready = False
steps_to_do = {
"do_step_make_roi": True,
"do_step_sample_extraction": False,
"do_step_interpolation": False,
"do_step_extract_reference_scan": False,
"do_step_fit_reference_response": False,
"do_step_resynthetise_reference": False,
"do_step_scalars" : False,
"do_step_volume_retrieval" : False,
}
os.system("mkdir results")
scalar_products_and_volume_target_file = "results/scalar_products_and_volume.h5"
roi_target_path = "results/myrois.h5:/ROIS"
signals_target_file = "results/signals.h5"
interpolated_signals_target_file = "results/interpolated_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"
###########################################################################################
###### LOADING PEAKS SHIFTS
###### peaks_shifts = h5py.File("../peaks_positions_for_analysers.h5","r")["peaks_positions"][()]
###### assert( len(peaks_shifts) == 72)
if rois_are_ready:
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_shift = 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
##############################################################
##########################################################################
tools_sequencer_interp.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 ,
Zdim = Zdim ,
Edim = Edim ,
monitor_column = monitor_column,
signals_target_file = signals_target_file,
interpolated_signals_target_file = interpolated_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,
selected_rois = selected_rois,
scal_prod_use_optional_solution = scal_prod_use_optional_solution ,
scalar_products_and_volume_target_file = scalar_products_and_volume_target_file ,
volume_retrieval_beta = volume_retrieval_beta ,
volume_retrieval_niter = volume_retrieval_niter
)
main()
......@@ -5,12 +5,9 @@ import json
import os
import h5py
import math
from XRStools import tools_sequencer_interp
import os
def main():
def main():
os.system("xz -dk ../mask.h5.xz --stdout > mask.h5 ")
filter_path = "mask.h5:/FILTER_MASK/filter"
......@@ -18,7 +15,6 @@ def main():
roi_scan_num = [245,246,247]
reference_scan_list = [245, 246, 247]
monitor_column = "izero/0.000001"
first_scan_num = 651
......@@ -30,36 +26,24 @@ def main():
datadir = "/data/id20/inhouse/data/run3_20/run3_es949"
# 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 = 6
#### For the fit of the response function based on reference scans
response_fit_options = dict( [
["niter_optical" , 100],
["beta_optical" , 0.1],
["niter_global" , 3 ]
])
])
selected_rois = list(range(0,24)) + list( range(36,60) )
scal_prod_use_optional_solution = True
volume_retrieval_beta = 6.0e-20
volume_retrieval_niter = 100
steps_to_do = {
"do_step_make_roi": False,
......
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