Commit 3326acdd authored by myron's avatar myron
Browse files

restructured the reference resynthesis

parent 3a7e1658
...@@ -3923,17 +3923,35 @@ def superR_recreate_rois(mydata): ...@@ -3923,17 +3923,35 @@ def superR_recreate_rois(mydata):
## simple statistical criteria which is har coded in file reponse_percussionelle.py ## simple statistical criteria which is har coded in file reponse_percussionelle.py
## routine get_spots_list ## routine get_spots_list
filter_rois : 1 filter_rois : 1
# not necessary of old_scan_address contains also the ROI
original_roi_path : None
""" """
foil_scan_address = mydata["old_scan_address"] foil_scan_address = mydata["old_scan_address"]
foil_filename ,foil_groupname = split_hdf5_address(foil_scan_address) foil_filename ,foil_groupname = split_hdf5_address(foil_scan_address)
roisgroupname = foil_groupname
tmp_groupname = foil_groupname
newscanstarget = "" newscanstarget = ""
for i in range(2): for i in range(2):
pos = roisgroupname.rfind("/") pos = tmp_groupname.rfind("/")
newscanstarget = roisgroupname[pos:]+ newscanstarget newscanstarget = tmp_groupname[pos:]+ newscanstarget
roisgroupname=roisgroupname[:pos] tmp_groupname=tmp_groupname[:pos]
if "original_roi_path" not in mydata or mydata["original_roi_path"] in ["None", None]:
roisgroupname = tmp_groupname
roi_filename = foil_filename
else:
roi_filename ,roisgroupname = split_hdf5_address(mydata["original_roi_path"])
responsefilename= mydata["responsefilename"] responsefilename= mydata["responsefilename"]
responsefilename, responsepath = split_hdf5_address( responsefilename) responsefilename, responsepath = split_hdf5_address( responsefilename)
...@@ -3957,16 +3975,6 @@ def superR_recreate_rois(mydata): ...@@ -3957,16 +3975,6 @@ def superR_recreate_rois(mydata):
print( "LANCIO ")
dic = {"filename" : foil_filename , "groupname" : foil_groupname,
"roisgroupname" : roisgroupname,
"target_filename":target_filename,
"roisgroupname_target" : roisgroupname_target ,
"newscanstarget" : newscanstarget,
"responsefilename" : responsefilename,
"responsepath" : responsepath,
"nex" : nex, "filter_rois":filter_rois}
print( dic)
if "recenterings_refined" in mydata : if "recenterings_refined" in mydata :
recenterings_refined = mydata["recenterings_refined"] recenterings_refined = mydata["recenterings_refined"]
...@@ -3994,9 +4002,10 @@ def superR_recreate_rois(mydata): ...@@ -3994,9 +4002,10 @@ def superR_recreate_rois(mydata):
filterMask = h5f[dataname][:] filterMask = h5f[dataname][:]
reponse_percussionelle.DOROIS(filename = foil_filename , groupname = foil_groupname, reponse_percussionelle.DOROIS(filename = foil_filename ,
groupname = foil_groupname,
roi_filename = roi_filename,
roisgroupname = roisgroupname, roisgroupname = roisgroupname,
target_filename=target_filename, target_filename=target_filename,
roisgroupname_target = roisgroupname_target , roisgroupname_target = roisgroupname_target ,
......
...@@ -1211,6 +1211,7 @@ def reload_trajectories(trajectory_file, nomi_rois) : ### , trajectory_file_grou ...@@ -1211,6 +1211,7 @@ def reload_trajectories(trajectory_file, nomi_rois) : ### , trajectory_file_grou
def DOROIS(filename = "../nonregressions/demo_imaging.hdf5" , groupname = "ROI_B/foil_scanXX/scans/Scan273/", def DOROIS(filename = "../nonregressions/demo_imaging.hdf5" , groupname = "ROI_B/foil_scanXX/scans/Scan273/",
roi_filename = None,
roisgroupname = "ROI_B/", roisgroupname = "ROI_B/",
target_filename="newscan.h5", target_filename="newscan.h5",
roisgroupname_target = "ROI_B_FIT8/", roisgroupname_target = "ROI_B_FIT8/",
...@@ -1221,7 +1222,10 @@ def DOROIS(filename = "../nonregressions/demo_imaging.hdf5" , groupname = "ROI_B ...@@ -1221,7 +1222,10 @@ def DOROIS(filename = "../nonregressions/demo_imaging.hdf5" , groupname = "ROI_B
filter_rois=1, filter_rois=1,
recenterings= None, recenterings= None,
filterMask = None): filterMask = None):
if roi_filename is None:
roi_filename = filename
O_spots_list, nomi_rois, stats , origini, rois, xscales, energy= get_spots_list( filename, groupname , filter_rois= filter_rois ) O_spots_list, nomi_rois, stats , origini, rois, xscales, energy= get_spots_list( filename, groupname , filter_rois= filter_rois )
trajectory_list = [] trajectory_list = []
...@@ -1305,10 +1309,10 @@ def DOROIS(filename = "../nonregressions/demo_imaging.hdf5" , groupname = "ROI_B ...@@ -1305,10 +1309,10 @@ def DOROIS(filename = "../nonregressions/demo_imaging.hdf5" , groupname = "ROI_B
# print( filename) # print( filename)
# print( roisgroupname+ "/rois_definition/image") # print( roisgroupname+ "/rois_definition/image")
h5f = h5py.File(filename,"r") h5f = h5py.File( roi_filename,"r")
# imagealldect = h5f [roisgroupname+ "/rois_definition/image"][:] # imagealldect = h5f [roisgroupname+ "/rois_definition/image"][:]
print( filename) print( roi_filename)
print( roisgroupname+ "/image" ) print( roisgroupname+ "/image" )
imagealldect = h5f [roisgroupname+ "/image"][:] imagealldect = h5f [roisgroupname+ "/image"][:]
......
...@@ -58,10 +58,10 @@ def main(): ...@@ -58,10 +58,10 @@ def main():
"do_step_make_roi": False, "do_step_make_roi": False,
"do_step_sample_extraction": False, "do_step_sample_extraction": False,
"do_step_interpolation": False, "do_step_interpolation": False,
"do_extract_reference_scan": False, "do_step_extract_reference_scan": False,
"do_fit_reference_response": False, "do_step_fit_reference_response": False,
"do_resynthetise_reference": False, "do_step_resynthetise_reference": True,
"do_step_finalise_for_fit": False "do_step_finalise_for_fit": False
} }
...@@ -78,7 +78,7 @@ def main(): ...@@ -78,7 +78,7 @@ def main():
response_target_file = "results/response.h5" response_target_file = "results/response.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 ,
datadir = datadir , datadir = datadir ,
...@@ -102,8 +102,9 @@ def main(): ...@@ -102,8 +102,9 @@ def main():
extracted_reference_target_file = extracted_reference_target_file , extracted_reference_target_file = extracted_reference_target_file ,
isolate_spot_by = isolate_spot_by, isolate_spot_by = isolate_spot_by,
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
) )
...@@ -389,7 +390,40 @@ def synthetise_response(scan_address=None, target_address=None, resp ...@@ -389,7 +390,40 @@ def synthetise_response(scan_address=None, target_address=None, resp
niter_global=response_fit_options["niter_global"] niter_global=response_fit_options["niter_global"]
) )
process_input( s , exploit_slurm_mpi = 1, stop_omp = True) process_input( s , exploit_slurm_mpi = 1, stop_omp = True)
def resynthetise_scan(
old_scan_address= None,
response_file = None ,
target_address = None,
original_roi_path = None
):
inputstring = """
superR_recreate_rois :
### we have calculated the responses in responsefilename
### and we want to enlarge the scan by a margin of 3 times
### the original scan on the right and on the left
### ( so for a total of a 7 expansion factor )
responsefilename : {response_file}
nex : 0
## the old scan covered by the old rois
old_scan_address : {old_scan_address}
## where new rois and bnew scan are written
target_filename : {target_address}
filter_rois : 0
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")
process_input( s , exploit_slurm_mpi = 0, stop_omp = True)
def tools_sequencer( peaks_shifts = None, def tools_sequencer( peaks_shifts = None,
datadir = None, datadir = None,
filter_path = None, filter_path = None,
...@@ -418,8 +452,8 @@ def tools_sequencer( peaks_shifts = None, ...@@ -418,8 +452,8 @@ def tools_sequencer( peaks_shifts = None,
reference_scan_list = None, reference_scan_list = 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
) : ) :
if roi_path is None: if roi_path is None:
...@@ -452,7 +486,7 @@ def tools_sequencer( peaks_shifts = None, ...@@ -452,7 +486,7 @@ def tools_sequencer( peaks_shifts = None,
interpolate( peaks_shifts , signals_file , interpolated_signals_target_file ) interpolate( peaks_shifts , signals_file , interpolated_signals_target_file )
if(steps_to_do["do_extract_reference_scan"]): # of course we need the REFERENCE SCAN if(steps_to_do["do_step_extract_reference_scan"]): # of course we need the REFERENCE SCAN
get_reference( datadir = datadir, get_reference( datadir = datadir,
roi_path = roi_path, roi_path = roi_path,
...@@ -494,7 +528,7 @@ def tools_sequencer( peaks_shifts = None, ...@@ -494,7 +528,7 @@ def tools_sequencer( peaks_shifts = None,
ftarget.close() ftarget.close()
if(steps_to_do["do_fit_reference_response"]): # of course we need the REFERENCE SCAN if(steps_to_do["do_step_fit_reference_response"]):
synthetise_response( synthetise_response(
scan_address= extracted_reference_target_file +":references/scans/ScansSum" , scan_address= extracted_reference_target_file +":references/scans/ScansSum" ,
target_address = response_target_file +":/FIT", target_address = response_target_file +":/FIT",
...@@ -502,8 +536,13 @@ def tools_sequencer( peaks_shifts = None, ...@@ -502,8 +536,13 @@ def tools_sequencer( peaks_shifts = None,
) )
if(steps_to_do["do_step_resynthetise_reference"]):
resynthetise_scan(
old_scan_address= extracted_reference_target_file +":references/scans/ScansSum" ,
response_file = response_target_file +":/FIT",
target_address = resynthetised_reference_and_roi_target_file + ":/rois_and_reference",
original_roi_path = roi_path
)
......
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