Commit dc3e5ec1 authored by myron's avatar myron
Browse files

xes non regression

parent c3c369fb
......@@ -34,8 +34,9 @@ test:
- /usr/bin/xvfb-run --server-args="-screen 0 1024x768x24" -a python non_reg_testing_XRS.py
- /usr/bin/xvfb-run --server-args="-screen 0 1024x768x24" -a python non_reg_testing_XRS_small.py
- /usr/bin/xvfb-run --server-args="-screen 0 1024x768x24" -a python non_reg_testing_XRS_raman_extraction.py
- cd ../xes
- python xes_analysis.py
- deactivate
after_script:
- pwd
import os
import json
import h5py
import numpy as np
def runit( s , work_dir, filename ) :
open( os.path.join(work_dir, filename) ,"w" ).write(s)
os.system( "cd %s; XRS_swissknife %s ; cd .." % (work_dir, filename) )
def prepare(
work_dir="preparation_run4_16",
data = "/data/id20/inhouse/data/run4_16/run6_ihr/rixs" ,
scan_for_roi= 66 ,
do_roi = True,
do_roi_sample = True,
reference_scan = 66 , # the scan used for the reference
monitorcolumn = "izero",
do_recentering=False,
scan_for_sample_roi = 268 , # Not necessary is recentering is not needed. If not given the rois file is assumed (when needed if needed) to be already there
beta_response = 0
) :
if not os.path.exists(work_dir):
os.makedirs(work_dir)
assert (os.path.exists( work_dir) and os.path.isdir( work_dir) ), "Cannot get work directory %s "%work_dir
assert (os.access(work_dir, os.W_OK | os.X_OK)), " directory %s is not writable"%work_dir
preparation_parameters = {
"work_dir" : work_dir,
"data" : data,
"scan_for_roi" : scan_for_roi,
"reference_scan" : reference_scan,
"monitorcolumn" : monitorcolumn,
"do_recentering" : do_recentering,
"scan_for_sample_roi" : scan_for_sample_roi
}
json.dump(preparation_parameters, open(os.path.join(work_dir, "preparation_parameters.json"),"w") )
if do_roi:
s="""
create_rois:
expdata : "{data_file}"
scans : [{scan_for_roi}]
roiaddress : "roi.h5:/ROI_AS_SELECTED"
""".format( data_file = data, scan_for_roi = scan_for_roi )
runit( s , work_dir, "01_create_roi.yaml" )
if do_recentering and do_roi_sample:
s="""
create_rois:
expdata : "{data_file}"
scans : [{scan_for_roi} ]
roiaddress : roi_sample.h5:/ROI_AS_SELECTED
""".format( data_file = data, scan_for_roi = scan_for_sample_roi )
runit( s , work_dir, "02_create_roi_sample.yaml" )
s="""
loadscan_2Dimages :
expdata : "{data_file}"
roiaddress : roi.h5:/ROI_AS_SELECTED
scan_interval : [{reference_scan},{reference_scan_P1}]
signaladdress : calibration_scan
sumto1D : 0
energycolumn : 'Anal Energy'
monitorcolumn : {monitorcolumn}
save_also_roi : 1
""".format( data_file = data, reference_scan = reference_scan , reference_scan_P1 = reference_scan +1 , monitorcolumn = monitorcolumn )
runit( s , work_dir, "03_load_scan_reference.yaml" )
if do_recentering :
s="""
loadscan_2Dimages :
expdata : "{data_file}"
roiaddress : roi_sample.h5:/ROI_AS_SELECTED
scan_interval : [{scan_for_roi},{scan_for_roi_P1}]
signaladdress : uncentered_sample_scan
sumto1D : 0
energycolumn : 'Anal Energy'
monitorcolumn : {monitorcolumn}
save_also_roi : 1
""".format( data_file = data, scan_for_roi = scan_for_sample_roi , scan_for_roi_P1 = scan_for_sample_roi +1 , monitorcolumn = monitorcolumn )
runit( s , work_dir, "04_load_scan_sample.yaml" )
s="""
calculate_recenterings :
bariA : roi_sample.h5:/ROI_AS_SELECTED/uncentered_sample_scan/scans/Scan%03d/
bariB : roi.h5:/ROI_AS_SELECTED/calibration_scan/scans/Scan%03d/
target : recentering.h5:/recentering
"""%( scan_for_sample_roi, reference_scan )
runit( s , work_dir, "05_setup_recentering.yaml" )
s="""
loadscan_2Dimages :
expdata : {data_file}
roiaddress : roi.h5:/ROI_AS_SELECTED
scan_interval : [{scan_for_roi},{scan_for_roi_P1}]
monitor_column : {monitorcolumn}
recenterings : recentering.h5:/recentering
recenterings_confirmed : recentering.h5:/confirmed_shift
signaladdress : Centered_sample_scans
sumto1D : 0
energycolumn : 'Anal Energy'
monitorcolumn : izero
""".format( data_file = data, scan_for_roi = scan_for_sample_roi , scan_for_roi_P1 = scan_for_sample_roi +1 , monitorcolumn = monitorcolumn )
runit( s , work_dir, "06_calculate_recentering.yaml" )
s="""
superR_fit_responses:
foil_scan_address : roi.h5:/ROI_AS_SELECTED/calibration_scan/scans/Scan%03d
nref : 2
niter_optical : 50
beta_optical : %e
niter_global : 2
pixel_dim : 1
niter_pixel : 0
beta_pixel : 0
do_refine_trajectory : 1
simmetrizza : 1
filter_rois : 0
target_file : fitted_response.h5:/ScanFittedResponse_%03d
MPI_N_PROCS : 1
fit_lines : 1
"""%( reference_scan, beta_response, reference_scan )
runit( s , work_dir, "07_fit.yaml" )
s="""
superR_recreate_rois :
responsefilename : fitted_response.h5:/ScanFittedResponse_%03d
nex : 0
old_scan_address : roi.h5:/ROI_AS_SELECTED/calibration_scan/scans/Scan%03d
filter_rois : 0
recenterings_refines : recentering.h5:/confirmed_shift
target_filename : newscan.h5:/ROI_AS_SELECTED/calibration_scan/scans/ScanReSynth_%03d
"""%( reference_scan, reference_scan, reference_scan )
runit( s , work_dir, "08_resynth.yaml" )
def extract(
work_dir="preparation_run4_16",
scan_interval = [130, 132] ,
target_file = "SPECTRA.h5",
temporary_file = "temporary.h5",
niter = 0,
niterLip = 20,
beta = 0,
) :
assert (os.path.exists( work_dir) and os.path.isdir( work_dir) ), "Cannot get work directory %s "%work_dir
assert (os.access(work_dir, os.W_OK | os.X_OK)), " directory %s is not writable"%work_dir
preparation_parameters = json.load( open(os.path.join(work_dir, "preparation_parameters.json"),"r") )
data = preparation_parameters["data"]
reference_scan = preparation_parameters["reference_scan"]
monitorcolumn = preparation_parameters["monitorcolumn"]
scan_for_roi = preparation_parameters["scan_for_roi"]
start = scan_interval[0]
end = scan_interval[1]
s="""
loadscan_2Dimages :
expdata : {data_file}
roiaddress : newscan.h5:/ROI_AS_SELECTED/calibration_scan/scans/ScanReSynth_{reference_scan:03d}
scan_interval : [{start}, {end}]
signaladdress : ../{temporary_file}:/data_{start}_{end}
sumto1D : 0
energycolumn : 'Anal Energy'
monitorcolumn : {monitorcolumn}
""".format(data_file = data, reference_scan = reference_scan , monitorcolumn = monitorcolumn,
start = start, end = end, temporary_file=temporary_file)
runit( s , work_dir, "31_harvest.yaml" )
s="""
extract_spectra :
reference_address : newscan.h5:/ROI_AS_SELECTED/calibration_scan/scans/ScanReSynth_{reference_scan:03d}
sample_address : ../{temporary_file}:/data_{start}_{end}
roiaddress : newscan.h5:/ROI_AS_SELECTED/calibration_scan/scans/ScanReSynth_{reference_scan:03d}
reference_scan : {reference_scan}
scan_interval : [{start}, {end}]
zmargin : 0
target : ../{result_file}:/fromscans_{start}_{end}
final_plot : PLOT
DE : 0.0
niterLip : {niterLip}
niter : {niter}
beta : {beta}
""".format(reference_scan=reference_scan, start = start, end = end , niterLip = niterLip, niter = niter, beta = beta, result_file = target_file, temporary_file=temporary_file)
runit( s , work_dir, "32_extract_spectra.yaml" )
......@@ -36,7 +36,7 @@ def Fista(solution , problem, niter, niterLip):
x_old = solution
errList=[]
for i in range(1000):
for i in range(niter):
grad, err = problem.calculate_grad(y)
print( "err " , err)
errList.append(err)
......
1.018789699999999903e+04 0.000000000000000000e+00
1.018799699999999939e+04 0.000000000000000000e+00
1.018809699999999975e+04 0.000000000000000000e+00
1.018819699999999830e+04 0.000000000000000000e+00
1.018829699999999866e+04 0.000000000000000000e+00
1.018839699999999903e+04 0.000000000000000000e+00
1.018849699999999939e+04 0.000000000000000000e+00
1.018859699999999975e+04 0.000000000000000000e+00
1.018869699999999830e+04 0.000000000000000000e+00
1.018879699999999866e+04 0.000000000000000000e+00
1.018889699999999903e+04 0.000000000000000000e+00
1.018899699999999939e+04 0.000000000000000000e+00
1.018909699999999975e+04 0.000000000000000000e+00
1.018919699999999830e+04 0.000000000000000000e+00
1.018929699999999866e+04 0.000000000000000000e+00
1.018939699999999903e+04 0.000000000000000000e+00
1.018949699999999939e+04 0.000000000000000000e+00
1.018959699999999975e+04 0.000000000000000000e+00
1.018969699999999830e+04 0.000000000000000000e+00
1.018979699999999866e+04 3.335939576363017647e-03
1.018989699999999903e+04 4.998440329332513345e-03
1.018999699999999939e+04 6.900327537814899756e-03
1.019009699999999975e+04 5.636298655927940091e-03
1.019019699999999830e+04 6.941085726515893069e-03
1.019029699999999866e+04 7.497684698155361767e-03
1.019039699999999903e+04 7.786331901996848374e-03
1.019049699999999939e+04 7.926385804469011573e-03
1.019059699999999975e+04 7.718969289521438945e-03
1.019069699999999830e+04 8.134877751217288455e-03
1.019079699999999866e+04 8.251749944589801405e-03
1.019089699999999903e+04 7.896485772185922805e-03
1.019099699999999939e+04 8.195356318796000877e-03
1.019109699999999975e+04 7.858487279296633501e-03
1.019119699999999830e+04 8.040068889649802653e-03
1.019129699999999866e+04 7.878026263010800417e-03
1.019139699999999903e+04 7.818311236710766970e-03
1.019149699999999939e+04 8.146288359742268753e-03
1.019159699999999975e+04 7.952454747333675272e-03
1.019169699999999830e+04 7.798628148857889714e-03
1.019179699999999866e+04 7.468249846220349590e-03
1.019189699999999903e+04 7.490961621449831673e-03
1.019199699999999939e+04 7.523741477873563226e-03
1.019209699999999975e+04 7.653068749861472245e-03
1.019219699999999830e+04 7.505096183338216299e-03
1.019229699999999866e+04 7.455936455744683992e-03
1.019239699999999903e+04 8.375045967607486555e-03
1.019249699999999939e+04 8.438969081399509686e-03
1.019259699999999975e+04 7.956770255835085917e-03
1.019269699999999830e+04 8.179437010034821404e-03
1.019279699999999866e+04 8.089233711717599279e-03
1.019289699999999903e+04 8.284868643983126293e-03
1.019299699999999939e+04 8.471749699897421909e-03
1.019309699999999975e+04 8.217048832970053410e-03
1.019319699999999830e+04 8.031144370019865919e-03
1.019329699999999866e+04 8.315706063228091999e-03
1.019339699999999903e+04 8.383001912849295453e-03
1.019349699999999939e+04 8.102407484414498803e-03
1.019359699999999975e+04 8.613373822606051541e-03
1.019369699999999830e+04 8.804079835854834377e-03
1.019379699999999866e+04 9.106944799390550779e-03
1.019389699999999903e+04 8.812856719896892954e-03
1.019399699999999939e+04 9.016475435584897502e-03
1.019409699999999975e+04 8.997859120004638583e-03
1.019419699999999830e+04 9.323926780264371952e-03
1.019429699999999866e+04 9.555221399211057468e-03
1.019439699999999903e+04 9.747343144554530131e-03
1.019449699999999939e+04 9.642776886584795634e-03
1.019459699999999975e+04 9.923540664456538193e-03
1.019469699999999830e+04 1.061319512482377346e-02
1.019479699999999866e+04 1.015471794988761535e-02
1.019489699999999903e+04 1.072845264319454567e-02
1.019499699999999939e+04 1.106775013930294538e-02
1.019509699999999975e+04 1.124548766250150524e-02
1.019519700000000012e+04 1.089435130305433860e-02
1.019529699999999866e+04 1.110989256287090235e-02
1.019539699999999903e+04 1.178944474128940101e-02
1.019549699999999939e+04 1.254278167404885257e-02
1.019559699999999975e+04 1.289239139507332432e-02
1.019569700000000012e+04 1.284847749553760972e-02
1.019579699999999866e+04 1.314743560091225470e-02
1.019589699999999903e+04 1.335006625760881693e-02
1.019599699999999939e+04 1.429048971996241778e-02
1.019609699999999975e+04 1.458996508365226381e-02
1.019619700000000012e+04 1.537386500750768416e-02
1.019629699999999866e+04 1.601846386044125659e-02
1.019639699999999903e+04 1.669857325841963419e-02
1.019649699999999939e+04 1.719995120746549075e-02
1.019659699999999975e+04 1.785816007644906722e-02
1.019669700000000012e+04 1.787164476826062429e-02
1.019679699999999866e+04 1.856649804575993823e-02
1.019689699999999903e+04 2.012331971379520065e-02
1.019699699999999939e+04 2.037814729300795047e-02
1.019709699999999975e+04 2.062473207829833982e-02
1.019719700000000012e+04 2.067175987111873753e-02
1.019729699999999866e+04 2.217687380311077552e-02
1.019739699999999903e+04 2.326821715941141538e-02
1.019749699999999939e+04 2.388918129344545435e-02
1.019759699999999975e+04 2.463996787727597282e-02
1.019769700000000012e+04 2.509407931910873080e-02
1.019779699999999866e+04 2.646254531330705442e-02
1.019789699999999903e+04 2.678307605806778957e-02
1.019799699999999939e+04 2.817888115960241052e-02
1.019809699999999975e+04 2.856928463366016288e-02
1.019819700000000012e+04 3.012479014251198337e-02
1.019829699999999866e+04 3.083066892047328297e-02
1.019839699999999903e+04 3.201608844431416689e-02
1.019849699999999939e+04 3.291794730257073531e-02
1.019859699999999975e+04 3.488105398659947787e-02
1.019869700000000012e+04 3.602022842993450602e-02
1.019879699999999866e+04 3.678728135937664456e-02
1.019889699999999903e+04 3.666511832593791903e-02
1.019899699999999939e+04 3.857005701591544738e-02
1.019909699999999975e+04 4.006456687711971998e-02
1.019919700000000012e+04 4.110135889674919329e-02
1.019929699999999866e+04 4.242163205630291450e-02
1.019939699999999903e+04 4.462241234716234767e-02
1.019949699999999939e+04 4.510251197131248668e-02
1.019959699999999975e+04 4.431213319784623600e-02
1.019969700000000012e+04 4.643056272744767315e-02
1.019979699999999866e+04 4.702197941245848944e-02
1.019989699999999903e+04 4.782864072133566347e-02
1.019999699999999939e+04 4.847051168933946136e-02
1.020009699999999975e+04 4.928913899664371517e-02
1.020019700000000012e+04 5.028457840072558110e-02
1.020029699999999866e+04 5.105139308077164678e-02
1.020039699999999903e+04 5.008588854198046253e-02
1.020049699999999939e+04 4.985428360819327276e-02
1.020059699999999975e+04 5.091169729887824041e-02
1.020069700000000012e+04 5.075899958284302294e-02
1.020079699999999866e+04 5.167269383393885418e-02
1.020089699999999903e+04 5.057786856661578706e-02
1.020099699999999939e+04 5.038351671564200024e-02
1.020109699999999975e+04 4.976250954640968477e-02
1.020119700000000012e+04 4.989200114155935284e-02
1.020129699999999866e+04 4.897489639403181105e-02
1.020139699999999903e+04 4.889798650990152817e-02
1.020149699999999939e+04 4.897434534573821829e-02
1.020159699999999975e+04 4.748107049330295426e-02
1.020169700000000012e+04 4.711355514109474840e-02
1.020179699999999866e+04 4.704482948054561353e-02
1.020189699999999903e+04 4.688377723316400347e-02
1.020199699999999939e+04 4.682494040939806645e-02
1.020209699999999975e+04 4.618269293802747255e-02
1.020219700000000012e+04 4.511193194692078579e-02
1.020229699999999866e+04 4.327258441110742870e-02
1.020239699999999903e+04 4.330206783232011525e-02
1.020249699999999939e+04 4.319776509361648170e-02
1.020259699999999975e+04 4.050699506255131532e-02
1.020269700000000012e+04 4.041564989731655233e-02
1.020279699999999866e+04 4.046469562510394274e-02
1.020289699999999903e+04 4.048478640712935978e-02
1.020299699999999939e+04 3.900798430358413948e-02
1.020309699999999975e+04 3.722763919720541159e-02
1.020319700000000012e+04 3.753971828724275706e-02
1.020329699999999866e+04 3.601447714991037885e-02
1.020339699999999903e+04 3.564758812703999746e-02
1.020349699999999939e+04 3.405084258591287161e-02
1.020359699999999975e+04 3.304879149752099066e-02
1.020369700000000012e+04 3.229052800004206247e-02
1.020379699999999866e+04 3.154888150979042599e-02
1.020389699999999903e+04 3.070961941356537342e-02
1.020399699999999939e+04 2.871457656386574436e-02
1.020409699999999975e+04 2.805754055698224392e-02
1.020419700000000012e+04 2.713789885237793617e-02
1.020429699999999866e+04 2.541796564590680096e-02
1.020439699999999903e+04 2.425820472151155385e-02
1.020449699999999939e+04 2.385885582102667893e-02
1.020459699999999975e+04 2.208626539335045713e-02
1.020469700000000012e+04 2.055236607940916227e-02
1.020479699999999866e+04 2.050779436046318294e-02
1.020489699999999903e+04 1.960745338044217120e-02
1.020499699999999939e+04 1.785885900263853299e-02
1.020509699999999975e+04 1.624494739367423474e-02
1.020519700000000012e+04 1.521726651981137289e-02
1.020529699999999866e+04 1.486270636917136519e-02
1.020539699999999903e+04 1.378522880757880598e-02
1.020549699999999939e+04 1.290420245072710845e-02
1.020559699999999975e+04 1.170345589458155616e-02
1.020569700000000012e+04 1.137716300768506009e-02
1.020579699999999866e+04 1.016913512092061135e-02
1.020589699999999903e+04 9.704649848389288597e-03
1.020599699999999939e+04 9.005620930431527602e-03
1.020609699999999975e+04 8.585975113119054952e-03
1.020619700000000012e+04 8.079329476264201365e-03
1.020629699999999866e+04 7.607484028935186139e-03
1.020639699999999903e+04 7.698606948953448138e-03
1.020649699999999939e+04 7.363704963381010812e-03
1.020659699999999975e+04 6.786423397866018538e-03
1.020669700000000012e+04 6.344898206240946054e-03
1.020679699999999866e+04 6.247355113113502514e-03
1.020689699999999903e+04 5.835079445748338374e-03
1.020699699999999939e+04 5.761450786238066397e-03
1.020709699999999975e+04 5.803857153344846309e-03
1.020719700000000012e+04 5.239450282452961724e-03
1.020729699999999866e+04 4.980649816504668752e-03
1.020739699999999903e+04 4.978160591544439004e-03
1.020749699999999939e+04 5.069276237737751524e-03
1.020759699999999975e+04 5.002861789614485716e-03
1.020769700000000012e+04 4.885224905041583854e-03
1.020779699999999866e+04 4.949113944467078974e-03
1.020789699999999903e+04 4.741929002190656273e-03
1.020799699999999939e+04 4.431469759689317910e-03
1.020809699999999975e+04 4.486632154039839858e-03
1.020819700000000012e+04 4.636112439759592849e-03
1.020829699999999866e+04 4.488226522488920726e-03
1.020839699999999903e+04 4.452532997678931154e-03
1.020849699999999939e+04 4.672835740431235604e-03
1.020859699999999975e+04 4.420099585517962490e-03
1.020869700000000012e+04 4.369858890295912415e-03
1.020879699999999866e+04 4.773114640592737018e-03
1.020889699999999903e+04 4.333050474778550425e-03
1.020899699999999939e+04 4.470488894247784221e-03
1.020909699999999975e+04 4.379627365212810167e-03
1.020919700000000012e+04 4.270102536829919505e-03
1.020929700000000048e+04 4.485064046387158415e-03
1.020939699999999903e+04 4.449057150908908818e-03
1.020949699999999939e+04 4.439623624238876048e-03
1.020959699999999975e+04 4.382288372402087274e-03
1.020969700000000012e+04 4.442936323424651404e-03
1.020979700000000048e+04 4.340207095946213220e-03
1.020989699999999903e+04 4.618171241894795769e-03
1.020999699999999939e+04 4.251262662618596720e-03
1.021009699999999975e+04 4.425241636086921747e-03
1.021019700000000012e+04 4.568002310400781293e-03
1.021029700000000048e+04 4.566597849897081028e-03
1.021039699999999903e+04 4.838424947181819979e-03
1.021049699999999939e+04 4.655068927725415640e-03
1.021059699999999975e+04 4.264799588461256827e-03
1.021069700000000012e+04 4.722208608242494006e-03
1.021079700000000048e+04 5.218303739043082465e-03
1.021089699999999903e+04 6.831734916432081160e-03
1.021099699999999939e+04 1.346596188099073027e-02
1.021109699999999975e+04 2.409337165186572344e-02
1.021119700000000012e+04 2.512484397200346817e-02
1.021129700000000048e+04 1.634526261042896014e-02
1.021139699999999903e+04 9.124254604039917088e-03
1.021149699999999939e+04 6.695697508725819737e-03
1.021159699999999975e+04 5.808998184495421657e-03
1.021169700000000012e+04 5.364522530582755723e-03
1.021179700000000048e+04 5.039274542829046306e-03
1.021189699999999903e+04 4.795166157125924263e-03
1.021199699999999939e+04 4.849184760984621111e-03
1.021209699999999975e+04 4.987653995291855755e-03
1.021219700000000012e+04 4.480478535057042487e-03
1.021229700000000048e+04 4.939486643049235265e-03
1.021239699999999903e+04 4.944792038855324277e-03
1.021249699999999939e+04 5.135410126906257179e-03
1.021259699999999975e+04 4.827316155336924645e-03
1.021269700000000012e+04 4.846922079369529214e-03
1.021279700000000048e+04 4.649999778131427494e-03
1.021289699999999903e+04 4.893327189502794800e-03
1.021299699999999939e+04 4.383892880789609127e-03
1.021309699999999975e+04 4.413050913808082981e-03
1.021319700000000012e+04 4.558281939573668833e-03
1.021329700000000048e+04 4.411613660410549156e-03
1.021339699999999903e+04 3.981619690489217496e-03
1.021349699999999939e+04 3.970761714066326636e-03
1.021359699999999975e+04 4.192125447780414849e-03
1.021369700000000012e+04 4.417694313641754716e-03
1.021379700000000048e+04 4.586054571029895242e-03
1.021389699999999903e+04 3.772923245955673004e-03
1.021399699999999939e+04 2.129497574135087289e-03
1.021409699999999975e+04 1.192381165851229188e-03
1.021419700000000012e+04 0.000000000000000000e+00
1.021429700000000048e+04 0.000000000000000000e+00
1.021439699999999903e+04 0.000000000000000000e+00
1.021449699999999939e+04 0.000000000000000000e+00
1.021459699999999975e+04 0.000000000000000000e+00
1.021469700000000012e+04 0.000000000000000000e+00
1.021479700000000048e+04 0.000000000000000000e+00
1.021489699999999903e+04 0.000000000000000000e+00
1.021499699999999939e+04 0.000000000000000000e+00
1.021509699999999975e+04 0.000000000000000000e+00
1.021519700000000012e+04 0.000000000000000000e+00
1.021529700000000048e+04 0.000000000000000000e+00
1.021539699999999903e+04 0.000000000000000000e+00
1.021549699999999939e+04 0.000000000000000000e+00
1.021559699999999975e+04 0.000000000000000000e+00
1.021569700000000012e+04 0.000000000000000000e+00
1.021579700000000048e+04 0.000000000000000000e+00
1.021589699999999903e+04 0.000000000000000000e+00
1.021599699999999939e+04 0.000000000000000000e+00
1.021609699999999975e+04 0.000000000000000000e+00
import os
import json
import h5py
import numpy as np
import XRStools. XES_spectra_extraction as spectra_extraction
if(1):
def runit( s , work_dir, filename ) :
open( os.path.join(work_dir, filename) ,"w" ).write(s)
os.system( "cd %s; XRS_swissknife %s ; cd .." % (work_dir, filename) )
os.system("xs -d --keep preparation_run4_16/ROI.xz ; mv preparation_run4_16/ROI preparation_run4_16/roi.h5" )
def prepare(
work_dir="preparation_run4_16",
data = "/data/id20/inhouse/data/run4_16/run6_ihr/rixs" ,
scan_for_roi= 66 ,
do_roi = True,
do_roi_sample = True,
reference_scan = 66 , # the scan used for the reference
monitorcolumn = "izero",
do_recentering=False,
scan_for_sample_roi = 268 , # Not necessary is recentering is not needed. If not given the rois file is assumed (when needed if needed) to be already there
beta_response = 0
) :
if not os.path.exists(work_dir):
os.makedirs(work_dir)
assert (os.path.exists( work_dir) and os.path.isdir( work_dir) ), "Cannot get work directory %s "%work_dir
assert (os.access(work_dir, os.W_OK | os.X_OK)), " directory %s is not writable"%work_dir
preparation_parameters = {
"work_dir" : work_dir,
"data" : data,
"scan_for_roi" : scan_for_roi,
"reference_scan" : reference_scan,
"monitorcolumn" : monitorcolumn,
"do_recentering" : do_recentering,
"scan_for_sample_roi" : scan_for_sample_roi
}
json.dump(preparation_parameters, open(os.path.join(work_dir, "preparation_parameters.json"),"w") )
if do_roi:
s="""
create_rois:
expdata : "{data_file}"
scans : [{scan_for_roi}]
roiaddress : "roi.h5:/ROI_AS_SELECTED"
""".format( data_file = data, scan_for_roi = scan_for_roi )
runit( s , work_dir, "01_create_roi.yaml" )
if do_recentering and do_roi_sample:
s="""
create_rois:
expdata : "{data_file}"
scans : [{scan_for_roi} ]
roiaddress : roi_sample.h5:/ROI_AS_SELECTED
""".format( data_file = data, scan_for_roi = scan_for_sample_roi )
runit( s , work_dir, "02_create_roi_sample.yaml" )
s="""
loadscan_2Dimages :
expdata : "{data_file}"
roiaddress : roi.h5:/ROI_AS_SELECTED
scan_interval : [{reference_scan},{reference_scan_P1}]
signaladdress : calibration_scan
sumto1D : 0
energycolumn : 'Anal Energy'
monitorcolumn : {monitorcolumn}
save_also_roi : 1
""".format( data_file = data, reference_scan = reference_scan , reference_scan_P1 = reference_scan +1 , monitorcolumn = monitorcolumn )
runit( s , work_dir, "03_load_scan_reference.yaml" )
if do_recentering :
s="""
loadscan_2Dimages :
expdata : "{data_file}"
roiaddress : roi_sample.h5:/ROI_AS_SELECTED
scan_interval : [{scan_for_roi},{scan_for_roi_P1}]
signaladdress : uncentered_sample_scan
sumto1D : 0
energycolumn : 'Anal Energy'
monitorcolumn : {monitorcolumn}
save_also_roi : 1
""".format( data_file = data, scan_for_roi = scan_for_sample_roi , scan_for_roi_P1 = scan_for_sample_roi +1 , monitorcolumn = monitorcolumn )
runit( s , work_dir, "04_load_scan_sample.yaml" )