Commit 36a80a7d authored by myron's avatar myron
Browse files

finished with the ant in interpolation

parent bb162b0b
......@@ -2849,9 +2849,12 @@ def superR_scal_deltaXimages(mydata):
solution = None
else:
solution_filename, solution_groupname = split_hdf5_address(solution_address)
solution = h5py.File(solution_filename,"r")
solution = solution[solution_groupname][:]
try:
solution = h5py.File(solution_filename,"r")
solution = solution[solution_groupname][:]
except:
raise ValueError("You asked for the utilisation of the optional solution to fix factors but could not read file %s groupname %s "%(solution_filename, solution_groupname) )
roi_keys = filterRoiList(h5.keys(),prefix="")
......@@ -3905,14 +3908,16 @@ def superR_recreate_rois(mydata):
# not necessary of old_scan_address contains also the ROI
original_roi_path : None
resynth_z_square : None
"""
allowed_keys = ["old_scan_address","original_roi_path","responsefilename","nex","target_filename","filter_rois","recenterings_refined","filter_path",]
allowed_keys = ["old_scan_address","original_roi_path","responsefilename","nex","target_filename","filter_rois","recenterings_refined","filter_path","resynth_z_square"]
check_allowed_keys(mydata, allowed_keys)
foil_scan_address = mydata["old_scan_address"]
foil_filename ,foil_groupname = split_hdf5_address(foil_scan_address)
tmp_groupname = foil_groupname
newscanstarget = ""
for i in range(2):
......@@ -3927,11 +3932,6 @@ def superR_recreate_rois(mydata):
else:
roi_filename ,roisgroupname = split_hdf5_address(mydata["original_roi_path"])
responsefilename= mydata["responsefilename"]
responsefilename, responsepath = split_hdf5_address( responsefilename)
......@@ -3941,8 +3941,6 @@ def superR_recreate_rois(mydata):
newscanstarget = newscanstarget[1:]
# if os.path.exists(target_filename):
# sys.stdout.write("Error : file %s exists already. Remove it yourself\n"%target_filename)
# sys.stderr.write("Error : file %s exists already. Remove it yourself\n"%target_filename)
......@@ -3954,6 +3952,12 @@ def superR_recreate_rois(mydata):
filter_rois = 1
if ("resynth_z_square" in mydata and mydata["resynth_z_square"] != "None" ) :
resynth_z_square = mydata["resynth_z_square"]
else:
resynth_z_square = None
if "recenterings_refined" in mydata :
......@@ -3991,6 +3995,7 @@ def superR_recreate_rois(mydata):
roisgroupname_target = roisgroupname_target ,
newscanstarget = newscanstarget,
responsefilename = responsefilename,
resynth_z_square = resynth_z_square,
responsepath = responsepath,
nex = nex, filter_rois=filter_rois, recenterings= recenterings ,
filterMask = filterMask)
......
......@@ -6,6 +6,7 @@ import math
import scipy
import scipy.stats
import scipy.ndimage.filters as filt
from scipy.ndimage import gaussian_filter
import sys
import pickle
import os
......@@ -1217,6 +1218,7 @@ def DOROIS(filename = "../nonregressions/demo_imaging.hdf5" , groupname = "ROI_B
roisgroupname_target = "ROI_B_FIT8/",
newscanstarget = "scanXX/scans/Scan273",
responsefilename = "responses.h5",
resynth_z_square = None,
responsepath = "fit",
nex = 3,
filter_rois=1,
......@@ -1244,13 +1246,16 @@ def DOROIS(filename = "../nonregressions/demo_imaging.hdf5" , groupname = "ROI_B
h5group = h5[name]
print( name, "data")
solution = h5group["data"][:]
solution = h5group["data"][()]
trajectory = Trajectory()
trajectory.X.intercept = h5group["Xintercept"][()]
trajectory.X.slope = h5group["Xslope"][()]
trajectory.Y.intercept = h5group["Yintercept"][()]
trajectory.Y.slope = h5group["Yslope"][()]
nref = h5group["nref"][()]
if resynth_z_square is not None:
solution = gaussian_filter( solution, [ nref*resynth_z_square , 0 ])
trajectory.N = O_spots.shape[0]
if recenterings is not None:
......
......@@ -194,7 +194,8 @@ def resynthetise_scan(
old_scan_address= None,
response_file = None ,
target_address = None,
original_roi_path = None
original_roi_path = None,
resynth_z_square = None
):
......@@ -216,8 +217,16 @@ def resynthetise_scan(
filter_rois : 0
original_roi_path : {original_roi_path}
resynth_z_square : {resynth_z_square}
"""
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")
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",
resynth_z_square = resynth_z_square)
process_input( s , exploit_slurm_mpi = 0, stop_omp = True)
......@@ -384,7 +393,8 @@ def tools_sequencer( peaks_shifts = None,
energy_custom_grid = None,
custom_components_file = None ,
interpolation_infos_file = None
interpolation_infos_file = None,
resynth_z_square = None
) :
......@@ -467,7 +477,8 @@ def tools_sequencer( peaks_shifts = None,
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
original_roi_path = roi_path,
resynth_z_square = resynth_z_square
)
......
......@@ -293,13 +293,13 @@ def synthetise_response(scan_address=None, target_address=None, resp
process_input( s , exploit_slurm_mpi = 1, stop_omp = True)
def resynthetise_scan(
def resynthetise_scan(
old_scan_address= None,
response_file = None ,
target_address = None,
original_roi_path = None
):
original_roi_path = None,
resynth_z_square = None
):
input_string = """
superR_recreate_rois :
......@@ -319,8 +319,15 @@ def resynthetise_scan(
filter_rois : 0
original_roi_path : {original_roi_path}
resynth_z_square : {resynth_z_square}
"""
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")
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",
resynth_z_square = resynth_z_square
)
process_input( s , exploit_slurm_mpi = 0, stop_omp = True)
......@@ -462,7 +469,9 @@ def tools_sequencer( peaks_shifts = None,
response_target_file = None,
response_fit_options = None,
resynthetised_reference_and_roi_target_file = None,
resynth_z_square = None,
selected_rois = None,
scal_prod_use_optional_solution= False,
scalar_products_and_volume_target_file = None,
......@@ -556,7 +565,8 @@ def tools_sequencer( peaks_shifts = None,
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
original_roi_path = roi_path,
resynth_z_square = resynth_z_square
)
......
......@@ -48,19 +48,20 @@ def main():
#### For the fit of the response function based on reference scans
response_fit_options = dict( [
["niter_optical" , 100],
["niter_optical" , 40],
["beta_optical" , 0.1],
["niter_global" , 3 ]
["niter_global" , 1 ]
])
resynth_z_square = 8
selected_rois = list(range(0,24)) + list( range(36,60) )
scal_prod_use_optional_solution = True
scal_prod_use_optional_solution = False
volume_retrieval_beta = 6.0e-20
volume_retrieval_beta = 0.12
volume_retrieval_niter = 100
......@@ -70,10 +71,11 @@ def main():
"do_step_interpolation": False,
"do_step_extract_reference_scan": False,
"do_step_fit_reference_response": True,
"do_step_fit_reference_response": False,
"do_step_resynthetise_reference": False,
"do_step_scalars" : False,
"do_step_volume_retrieval" : False,
"do_step_put_all_in_one_stack" : True
}
......@@ -99,7 +101,7 @@ def main():
###### peaks_shifts = h5py.File("../peaks_positions_for_analysers.h5","r")["peaks_positions"][()]
###### assert( len(peaks_shifts) == 72)
if rois_are_ready:
if steps_to_do["do_step_interpolation"]:
roiob = xrs_rois.roi_object()
roiob.loadH5( roi_target_path )
elastic = xrs_read.Hydra( datadir )
......@@ -143,7 +145,8 @@ 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,
scal_prod_use_optional_solution = scal_prod_use_optional_solution ,
......@@ -153,7 +156,27 @@ def main():
volume_retrieval_niter = volume_retrieval_niter
)
if steps_to_do["do_step_put_all_in_one_stack"] :
volumefile = scalar_products_and_volume_target_file
h5file_root = h5py.File( volumefile ,"r+" )
scankeys = list( h5file_root.keys())
scankeys.sort()
volumes = []
for k in scankeys:
if k[:1]!="_":
continue
print( k)
if "volume" in h5file_root[k]:
volumes.append( h5file_root[k]["volume"] )
# volume = np.concatenate(volumes,axis=0)
volume = np.array(volumes)
h5py.File("concatenated_volume.h5","w")["volume"] = volume
h5file_root.close()
......
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