Commit 2a4b7d42 authored by myron's avatar myron
Browse files

reorganised scalar products for volumes

parent 3326acdd
...@@ -54,6 +54,16 @@ def main(): ...@@ -54,6 +54,16 @@ def main():
]) ])
selected_rois = list(range(0,24)) + list( range(36,60) )
scal_prod_use_optional_solution = False
scal_prod_load_factors = False
scal_prod_load_factors_from = "factors.json"
scalar_products_and_volume_target_file = "results/scalar_products_and_volume.h5"
steps_to_do = { steps_to_do = {
"do_step_make_roi": False, "do_step_make_roi": False,
"do_step_sample_extraction": False, "do_step_sample_extraction": False,
...@@ -61,8 +71,8 @@ def main(): ...@@ -61,8 +71,8 @@ def main():
"do_step_extract_reference_scan": False, "do_step_extract_reference_scan": False,
"do_step_fit_reference_response": False, "do_step_fit_reference_response": False,
"do_step_resynthetise_reference": True, "do_step_resynthetise_reference": False,
"do_step_finalise_for_fit": False "do_step_scalars" : True
} }
...@@ -78,6 +88,7 @@ def main(): ...@@ -78,6 +88,7 @@ def main():
response_target_file = "results/response.h5" response_target_file = "results/response.h5"
############# correggi typo
resynthetised_reference_and_roi_target_file = "results/resyntetised_roi_and_scan.h5" resynthetised_reference_and_roi_target_file = "results/resyntetised_roi_and_scan.h5"
tools_sequencer( peaks_shifts = peaks_shifts , tools_sequencer( peaks_shifts = peaks_shifts ,
...@@ -104,8 +115,14 @@ def main(): ...@@ -104,8 +115,14 @@ def main():
response_target_file = response_target_file, response_target_file = response_target_file,
response_fit_options = response_fit_options, response_fit_options = response_fit_options,
resynthetised_reference_and_roi_target_file = resynthetised_reference_and_roi_target_file 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 ,
scal_prod_load_factors = scal_prod_load_factors ,
scal_prod_load_factors_from = scal_prod_load_factors_from ,
scalar_products_and_volume_target_file = scalar_products_and_volume_target_file
) )
...@@ -137,7 +154,7 @@ def select_rois( datadir = None, roi_scan_num=None, roi_target_path = None, fil ...@@ -137,7 +154,7 @@ def select_rois( datadir = None, roi_scan_num=None, roi_target_path = None, fil
else: else:
scans = list(roi_scan_num) scans = list(roi_scan_num)
inputstring = """ input_string = """
create_rois: create_rois:
expdata : {expdata} expdata : {expdata}
scans : {scans} scans : {scans}
...@@ -149,7 +166,7 @@ def select_rois( datadir = None, roi_scan_num=None, roi_target_path = None, fil ...@@ -149,7 +166,7 @@ def select_rois( datadir = None, roi_scan_num=None, roi_target_path = None, fil
roi_target_path = roi_target_path, roi_target_path = roi_target_path,
filter_path = filter_path filter_path = filter_path
) )
process_input( inputstring, exploit_slurm_mpi = 0 ) process_input( input_string, exploit_slurm_mpi = 0 )
def get_reference( roi_path = None, def get_reference( roi_path = None,
...@@ -161,7 +178,7 @@ def get_reference( roi_path = None, ...@@ -161,7 +178,7 @@ def get_reference( roi_path = None,
): ):
signal_path = extracted_reference_target_file + ":/" signal_path = extracted_reference_target_file + ":/"
inputstring = """ input_string = """
loadscan_2Dimages : loadscan_2Dimages :
expdata : {expdata} expdata : {expdata}
roiaddress : {roi_path} roiaddress : {roi_path}
...@@ -174,7 +191,7 @@ def get_reference( roi_path = None, ...@@ -174,7 +191,7 @@ def get_reference( roi_path = None,
sumto1D : 0 sumto1D : 0
energycolumn : 'stx' energycolumn : 'stx'
""" """
s=inputstring.format( s=input_string.format(
expdata = os.path.join( datadir, "hydra"), expdata = os.path.join( datadir, "hydra"),
reference_scan_list = reference_scan_list, reference_scan_list = reference_scan_list,
monitor_column = monitor_column, monitor_column = monitor_column,
...@@ -201,7 +218,7 @@ def extract_sample_givenrois( ...@@ -201,7 +218,7 @@ def extract_sample_givenrois(
signal_path = signals_target_file + ":/_{start}_{end}".format(start=start, end=end) signal_path = signals_target_file + ":/_{start}_{end}".format(start=start, end=end)
inputstring = """ input_string = """
loadscan_2Dimages : loadscan_2Dimages :
expdata : {expdata} expdata : {expdata}
roiaddress : {roi_path} roiaddress : {roi_path}
...@@ -218,7 +235,7 @@ def extract_sample_givenrois( ...@@ -218,7 +235,7 @@ def extract_sample_givenrois(
monitor_column = monitor_column, monitor_column = monitor_column,
signal_path = signal_path signal_path = signal_path
) )
process_input(inputstring, exploit_slurm_mpi = 1) process_input(input_string, exploit_slurm_mpi = 1)
...@@ -322,7 +339,7 @@ def interpolate( peaks_shifts, interp_file_str, interp_file_target_str): ...@@ -322,7 +339,7 @@ def interpolate( peaks_shifts, interp_file_str, interp_file_target_str):
def synthetise_response(scan_address=None, target_address=None, response_fit_options = None def synthetise_response(scan_address=None, target_address=None, response_fit_options = None
): ):
inputstring = """ input_string = """
superR_fit_responses : superR_fit_responses :
foil_scan_address : "{scan_address}" foil_scan_address : "{scan_address}"
nref : 7 # the number of subdivision per pixel dimension used to nref : 7 # the number of subdivision per pixel dimension used to
...@@ -383,7 +400,7 @@ def synthetise_response(scan_address=None, target_address=None, resp ...@@ -383,7 +400,7 @@ def synthetise_response(scan_address=None, target_address=None, resp
# target_file : "fitted_responses.h5" # target_file : "fitted_responses.h5"
""" """
s=inputstring.format( scan_address=scan_address , s=input_string.format( scan_address=scan_address ,
target_address=target_address, target_address=target_address,
niter_optical = response_fit_options[ "niter_optical"], niter_optical = response_fit_options[ "niter_optical"],
beta_optical=response_fit_options["beta_optical"], beta_optical=response_fit_options["beta_optical"],
...@@ -400,7 +417,7 @@ def resynthetise_scan( ...@@ -400,7 +417,7 @@ def resynthetise_scan(
): ):
inputstring = """ input_string = """
superR_recreate_rois : superR_recreate_rois :
### we have calculated the responses in responsefilename ### we have calculated the responses in responsefilename
### and we want to enlarge the scan by a margin of 3 times ### and we want to enlarge the scan by a margin of 3 times
...@@ -419,11 +436,67 @@ def resynthetise_scan( ...@@ -419,11 +436,67 @@ def resynthetise_scan(
original_roi_path : {original_roi_path} original_roi_path : {original_roi_path}
""" """
s=inputstring.format( response_file = response_file , target_address = target_address, old_scan_address=old_scan_address, original_roi_path = original_roi_path +"/rois_definition") s=input_string.format( response_file = response_file , target_address = target_address, old_scan_address=old_scan_address, original_roi_path = original_roi_path +"/rois_definition")
process_input( s , exploit_slurm_mpi = 0, stop_omp = True) process_input( s , exploit_slurm_mpi = 0, stop_omp = True)
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,
):
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)
)
process_input( input_string, exploit_slurm_mpi = 0)
def tools_sequencer( peaks_shifts = None, def tools_sequencer( peaks_shifts = None,
datadir = None, datadir = None,
filter_path = None, filter_path = None,
...@@ -453,7 +526,13 @@ def tools_sequencer( peaks_shifts = None, ...@@ -453,7 +526,13 @@ def tools_sequencer( peaks_shifts = None,
extracted_reference_target_file = None , extracted_reference_target_file = None ,
response_target_file = None, response_target_file = None,
response_fit_options = None, response_fit_options = None,
resynthetised_reference_and_roi_target_file = None resynthetised_reference_and_roi_target_file = None,
selected_rois = None,
scal_prod_use_optional_solution= False,
scal_prod_load_factors = False,
scal_prod_load_factors_from = None,
scalar_products_and_volume_target_file = None
) : ) :
if roi_path is None: if roi_path is None:
...@@ -545,5 +624,20 @@ def tools_sequencer( peaks_shifts = None, ...@@ -545,5 +624,20 @@ 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= False,
scal_prod_load_factors = False,
scal_prod_load_factors_from = None
)
main() main()
Supports Markdown
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