Commit 912f122a authored by myron's avatar myron
Browse files

restructuring the esynth reconstruction

parent 07373fc5
......@@ -6,13 +6,13 @@ import os
import h5py
import math
BATCH_PARALLELISM = 4
BATCH_PARALLELISM = 1
import os
def main():
os.system("xz -dk mask.h5.xz")
os.system("xz -dk mask.h5.xz --stdout > mask.h5")
filter_path = "mask.h5:/FILTER_MASK/filter"
......@@ -27,7 +27,7 @@ def main():
Zdim = 10
Edim = 7
peaks_shifts = h5py.File("peaks_positions_for_analysers.h5","r")["peaks_positions"][()]
peaks_shifts = h5py.File("../peaks_positions_for_analysers.h5","r")["peaks_positions"][()]
assert( len(peaks_shifts) == 72)
Enominal = np.median(peaks_shifts)
......@@ -54,29 +54,25 @@ def main():
["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
scalar_products_and_volume_target_file = "results/scalar_products_and_volume.h5"
scalar_products_target_file = "results/scalar_products.h5"
steps_to_do = {
"do_step_make_roi": False,
"do_step_sample_extraction": False,
"do_step_interpolation": False,
"do_step_extract_reference_scan": False,
"do_step_extract_reference_scan": False,
"do_step_fit_reference_response": False,
"do_step_resynthetise_reference": False,
"do_step_scalars" : True,
"do_step_volume_retrieval" : False,
"do_step_interpolation_coefficients": False,
"do_step_finalise_for_fit": False
}
......@@ -123,8 +119,7 @@ def main():
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 ,
scalar_products_target_file = scalar_products_target_file ,
volume_retrieval_beta = volume_retrieval_beta ,
volume_retrieval_niter = volume_retrieval_niter
......@@ -219,27 +214,27 @@ def extract_sample_givenrois(
monitor_column = None,
signals_target_file = None,
):
for start in range(Start,End, Thickness):
for iE, start in enumerate(range(Start,End, Thickness)):
end = start+Thickness
signal_path = signals_target_file + ":/_{start}_{end}".format(start=start, end=end)
signal_path = signals_target_file + ":/E{iE}".format(iE=iE)
input_string = """
loadscan_2Dimages :
expdata : {expdata}
roiaddress : {roi_path}
scan_interval : [{start}, {end}]
energy_column : sty
energycolumn : sty
signaladdress : {signal_path}
monitor_column : {monitor_column}
monitorcolumn : {monitor_column}
sumto1D : 0
""".format(
expdata = os.path.join( datadir, "hydra"),
roi_path = roi_path,
start = start,
end = end,
monitor_column = monitor_column,
monitor_column = monitor_column,
signal_path = signal_path
)
process_input(input_string, exploit_slurm_mpi = 1)
......@@ -449,57 +444,27 @@ def resynthetise_scan(
def get_scalars( Start = None, Thickness = None ,
reference_address = None,
signals_file = None,
target_file = None,
use_optional_solution=False,
save_factors = False,
load_factors_from = None,
selected_rois = None,
scal_prod_use_optional_solution= False,
scal_prod_load_factors = False,
scal_prod_load_factors_from = None,
def get_scalars( iE = None,
signals_file = None,
reference_file = None,
target_file = None
):
input_string = """
superR_scal_deltaXimages :
sample_address : {signals_file}:/_{start}_{end}/scans
delta_address : {reference_address}
# roi_keys : [60, 64, 35, 69, 34, 24, 5, 6, 71, 70, 39, 58, 56, 33]
roi_keys : {selected_rois}
nbin : 1
target_address : {target_file}:/_{start}_{end}/scal_prods
"""
if scal_prod_use_optional_solution:
input_string = input_string+"""
optional_solution : {target_file}:/_{start}_{end}/volume
"""
if True:
input_string = input_string+"""
save_factors_on : factors_{start}_{end}.json
"""
if scal_prod_load_factors :
input_string = input_string+"""
load_factors_from : %s
""" % scal_prod_load_factors_from
input_string = input_string .format(start=Start,
end=Start+Thickness ,
signals_file = signals_file ,
reference_address = reference_address,
target_file = target_file,
selected_rois = list(selected_rois)
inputstring = """
superR_scal_deltaXimages_Esynt :
sample_address : {signals_file}:/E{iE}/scans
delta_address : {reference_file}:/rois_and_reference/scans/ScansSum
load_factors_from :
nbin : 1
target_address : {target_file}:/{iE}/scal_prods
""" . format( iE = iE,
signals_file = signals_file ,
reference_file = reference_file ,
target_file = target_file,
)
process_input( input_string, exploit_slurm_mpi = 0)
process_input( inputstring, exploit_slurm_mpi = 0)
def get_volume( Start = None,
Thickness = None,
......@@ -587,8 +552,7 @@ def tools_sequencer( peaks_shifts = None,
resynthetised_reference_and_roi_target_file = None,
selected_rois = None,
scal_prod_use_optional_solution= False,
scalar_products_and_volume_target_file = None,
scalar_products_target_file = None,
volume_retrieval_beta = None,
volume_retrieval_niter = None
......@@ -619,7 +583,7 @@ def tools_sequencer( peaks_shifts = None,
signals_target_file = signals_target_file
)
if(steps_to_do["do_step_interpolation"]):
if(steps_to_do["do_step_interpolation_coefficients"]):
os.system("cp {signals_file} {interpolated_signals_target_file}".format(signals_file=signals_file, interpolated_signals_target_file =interpolated_signals_target_file) )
interpolate( peaks_shifts , signals_file , interpolated_signals_target_file )
......@@ -683,18 +647,15 @@ def tools_sequencer( peaks_shifts = None,
)
if(steps_to_do["do_step_scalars"]):
for start in range( first_scan_num , ( first_scan_num + Edim * Zdim ), Zdim ):
get_scalars( Start = start, Thickness = Zdim ,
reference_address = resynthetised_reference_and_roi_target_file + ":/rois_and_reference/scans/ScansSum" ,
signals_file = interpolated_signals_file ,
target_file = scalar_products_and_volume_target_file,
selected_rois = selected_rois ,
scal_prod_use_optional_solution= scal_prod_use_optional_solution,
scal_prod_load_factors = False,
scal_prod_load_factors_from = None
if(steps_to_do["do_step_scalars"]):
os.system("rm %s"%scalar_products_target_file)
for iE in range(Edim) :
get_scalars( iE = iE,
signals_file = signals_file,
reference_file = resynthetised_reference_and_roi_target_file ,
target_file = scalar_products_target_file
)
if(scal_prod_use_optional_solution):
collect_factors(pattern="factors_*_*.json", newfile="newfactors.json")
......@@ -712,15 +673,6 @@ def tools_sequencer( peaks_shifts = None,
if(steps_to_do["do_step_volume_retrieval"]):
for start in range( first_scan_num , ( first_scan_num + Edim * Zdim ), Zdim ):
get_volume( Start = start,
Thickness = Zdim,
volumes_file = scalar_products_and_volume_target_file,
beta = volume_retrieval_beta ,
niter = volume_retrieval_niter,
)
main()
......
......@@ -44,9 +44,9 @@ def main():
"do_step_make_roi": False,
"do_step_make_reference": False,
"do_step_sample_extraction": False,
"do_step_scalar_products": False,
"do_step_interpolation_coefficients": True,
"do_step_finalise_for_fit": True
"do_step_scalar_products": True,
"do_step_interpolation_coefficients": False,
"do_step_finalise_for_fit": False
}
......@@ -331,8 +331,6 @@ def get_reference( roi_path = None, reference_target_file = None ):
def get_scalars( iE = None,
signals_file = None,
reference_file = None,
......
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