Skip to content

Commit

Permalink
t0 is now an offset
Browse files Browse the repository at this point in the history
  • Loading branch information
cirelli-c committed May 21, 2024
1 parent 8da5fec commit a5e35eb
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions alvra_tools/XAS_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ def XAS_scanPP_PSEN(scan, TT, channel_delay_motor, diode, Izero, timezero_mm, qu

######################################

def XAS_scanPP_PSEN_bs(scan, TT, channel_delay_motor, diode, Izero, quantile, timezero_mm=None, filterTime=2000, filterAmp=0):
def XAS_scanPP_PSEN_bs(scan, TT, channel_delay_motor, diode, Izero, quantile, timezero_offset=None, filterTime=2000, filterAmp=0):
channels_pp = [channel_Events, diode, Izero, channel_delay_motor] + TT
channels_all = channels_pp

Expand All @@ -777,8 +777,9 @@ def XAS_scanPP_PSEN_bs(scan, TT, channel_delay_motor, diode, Izero, quantile, ti
channel_edges = channel_PSEN126_edges
channel_peaks = channel_PSEN126_peaks

if timezero_mm is None:
timezero_mm = get_timezero_NBS(scan.fname)
timezero_mm = get_timezero_NBS(scan.fname)
if timezero_offset is not None:
timezero_mm = timezero_mm + fs2mm(timezero_offset, 0)

scanvar = scan.readbacks

Expand Down Expand Up @@ -895,7 +896,7 @@ def XAS_scanPP_PSEN_bs(scan, TT, channel_delay_motor, diode, Izero, quantile, ti

######################################

def XAS_scanPP_2diodes_PSEN_bs(scan, TT, channel_delay_motor, diode1, diode2, Izero, quantile, timezero_mm=None, filterTime=2000, filterAmp=0):
def XAS_scanPP_2diodes_PSEN_bs(scan, TT, channel_delay_motor, diode1, diode2, Izero, quantile, timezero_offset=None, filterTime=2000, filterAmp=0):
channels_pp = [channel_Events, diode1, diode2, Izero, channel_delay_motor] + TT
channels_all = channels_pp

Expand All @@ -909,10 +910,11 @@ def XAS_scanPP_2diodes_PSEN_bs(scan, TT, channel_delay_motor, diode1, diode2, Iz
channel_arrTimesAmp = channel_PSEN126_arrTimesAmp
channel_edges = channel_PSEN126_edges
channel_peaks = channel_PSEN126_peaks

if timezero_mm is None:
timezero_mm = get_timezero_NBS(scan.fname)


timezero_mm = get_timezero_NBS(scan.fname)
if timezero_offset is not None:
timezero_mm = timezero_mm + fs2mm(timezero_offset, 0)

scanvar = scan.readbacks

Izero_pump = []
Expand Down Expand Up @@ -1336,10 +1338,10 @@ def save_data_timescans_TT_2diodes(reducedir, run_name, delaymm, delaystage, del
################################################
################################################

def save_reduced_data_1diode(reducedir, run_name, scan, D1p, D1u, PP1, gs1, corr1, t0=None):
if t0 is None:
t0 = get_timezero_NBS(scan.fname)
#t0 = get_timezero_NBS(scan.fname)
def save_reduced_data_1diode(reducedir, run_name, scan, D1p, D1u, PP1, gs1, corr1, t0_offset=None):
t0 = get_timezero_NBS(scan.fname)
if t0_offset is not None:
t0 = t0 + fs2mm(t0_offset, 0)
rdb = scan.readbacks
run_array = {}
run_array[run_name.split('-')[0]] = {"name": run_name,
Expand All @@ -1356,10 +1358,10 @@ def save_reduced_data_1diode(reducedir, run_name, scan, D1p, D1u, PP1, gs1, corr

################################################

def save_reduced_data_1diode_TT(reducedir, run_name, scan, D1p, D1u, PP1, gs1, corr1, PPscan, delayfs, delaycorr, t0=None):
if t0 is None:
t0 = get_timezero_NBS(scan.fname)
#t0 = get_timezero_NBS(scan.fname)
def save_reduced_data_1diode_TT(reducedir, run_name, scan, D1p, D1u, PP1, gs1, corr1, PPscan, delayfs, delaycorr, t0_offset=None):
t0 = get_timezero_NBS(scan.fname)
if t0_offset is not None:
t0 = t0 + fs2mm(t0_offset, 0)
rdb = scan.readbacks
run_array = {}
run_array[run_name.split('-')[0]] = {"name": run_name,
Expand All @@ -1379,10 +1381,10 @@ def save_reduced_data_1diode_TT(reducedir, run_name, scan, D1p, D1u, PP1, gs1, c

################################################

def save_reduced_data_2diodes(reducedir, run_name, scan, D1p, D1u, PP1, gs1, corr1, D2p, D2u, PP2, gs2, corr2, t0=None):
if t0 is None:
t0 = get_timezero_NBS(scan.fname)
#t0 = get_timezero_NBS(scan.fname)
def save_reduced_data_2diodes(reducedir, run_name, scan, D1p, D1u, PP1, gs1, corr1, D2p, D2u, PP2, gs2, corr2, t0_offset=None):
t0 = get_timezero_NBS(scan.fname)
if t0_offset is not None:
t0 = t0 + fs2mm(t0_offset, 0)
rdb = scan.readbacks
run_array = {}
run_array[run_name.split('-')[0]] = {"name": run_name,
Expand All @@ -1404,10 +1406,10 @@ def save_reduced_data_2diodes(reducedir, run_name, scan, D1p, D1u, PP1, gs1, cor

################################################

def save_reduced_data_2diodes_TT(reducedir, run_name, scan, D1p, D1u, PP1, gs1, corr1, PPscan, D2p, D2u, PP2, gs2, corr2, PPscan2, delayfs1, delaycorr1, delayfs2, delaycorr2, t0=None):
if t0 is None:
t0 = get_timezero_NBS(scan.fname)
#t0 = get_timezero_NBS(scan.fname)
def save_reduced_data_2diodes_TT(reducedir, run_name, scan, D1p, D1u, PP1, gs1, corr1, PPscan, D2p, D2u, PP2, gs2, corr2, PPscan2, delayfs1, delaycorr1, delayfs2, delaycorr2, t0_offset=None):
t0 = get_timezero_NBS(scan.fname)
if t0_offset is not None:
t0 = t0 + fs2mm(t0_offset, 0)
rdb = scan.readbacks
run_array = {}
run_array[run_name.split('-')[0]] = {"name": run_name,
Expand Down Expand Up @@ -1455,27 +1457,27 @@ def load_reduced_data(pgroup, loaddir, runlist):

################################################

def LoadTimescansXANES(with_TT, Two_diodes, scan, TT, channel_delay_motor, detector_XAS_1, detector_XAS_2, detector_Izero, quantile_corr, saveflag, reducedir, runname, timezero_mm=None):
def LoadTimescansXANES(with_TT, Two_diodes, scan, TT, channel_delay_motor, detector_XAS_1, detector_XAS_2, detector_Izero, quantile_corr, saveflag, reducedir, runname, timezero_offset=None):
if with_TT:
if Two_diodes:
(Delays_fs_scan, Delays_corr_scan, DataDiode_pump, DataDiode_unpump, Pump_probe_Diode, Pump_probe_scan,
Delays_fs_scan2, Delays_corr_scan2, DataDiode2_pump, DataDiode2_unpump, Pump_probe_Diode2, Pump_probe_scan2,
Izero_pump, Izero_unpump, correlation, correlation2, readbacks, goodshots, goodshots2) = \
XAS_scanPP_2diodes_PSEN_bs(scan, TT, channel_delay_motor, detector_XAS_1, detector_XAS_2, detector_Izero, quantile_corr, timezero_mm)
XAS_scanPP_2diodes_PSEN_bs(scan, TT, channel_delay_motor, detector_XAS_1, detector_XAS_2, detector_Izero, quantile_corr, timezero_offset)
if saveflag:
os.makedirs(reducedir+runname, exist_ok=True)
save_reduced_data_2diodes_TT(reducedir, runname, scan,
DataDiode_pump, DataDiode_unpump, Pump_probe_Diode, goodshots, correlation, Pump_probe_scan,
DataDiode2_pump, DataDiode2_unpump, Pump_probe_Diode2, goodshots2, correlation2, Pump_probe_scan2,
Delays_fs_scan, Delays_corr_scan, Delays_fs_scan2, Delays_corr_scan2, timezero_mm)
Delays_fs_scan, Delays_corr_scan, Delays_fs_scan2, Delays_corr_scan2, timezero_offset)
else:
(Delays_fs_scan, Delays_corr_scan, DataDiode_pump, DataDiode_unpump, Pump_probe_Diode, Pump_probe_scan,
Izero_pump_scan, Izero_unpump_scan, correlation, readbacks, goodshots) = \
XAS_scanPP_PSEN_bs(scan, TT, channel_delay_motor, detector_XAS_1, detector_Izero, quantile_corr, timezero_mm)
XAS_scanPP_PSEN_bs(scan, TT, channel_delay_motor, detector_XAS_1, detector_Izero, quantile_corr, timezero_offset)
if saveflag:
os.makedirs(reducedir+runname, exist_ok=True)
save_reduced_data_1diode_TT(reducedir, runname, scan,
DataDiode_pump, DataDiode_unpump, Pump_probe_Diode, goodshots, correlation, Pump_probe_scan, Delays_fs_scan, Delays_corr_scan, timezero_mm)
DataDiode_pump, DataDiode_unpump, Pump_probe_Diode, goodshots, correlation, Pump_probe_scan, Delays_fs_scan, Delays_corr_scan, timezero_offset)
else:
if Two_diodes:
(DataDiode1_pump, DataDiode1_unpump, Pump_probe_Diode1,
Expand All @@ -1486,7 +1488,7 @@ def LoadTimescansXANES(with_TT, Two_diodes, scan, TT, channel_delay_motor, detec
os.makedirs(reducedir+runname, exist_ok=True)
save_reduced_data_2diodes(reducedir, runname, scan,
DataDiode1_pump, DataDiode1_unpump, Pump_probe_Diode1, goodshots1, correlation1,
DataDiode2_pump, DataDiode2_unpump, Pump_probe_Diode2, goodshots2, correlation2, timezero_mm)
DataDiode2_pump, DataDiode2_unpump, Pump_probe_Diode2, goodshots2, correlation2, timezero_offset)

else:
(DataDiode_pump, DataDiode_unpump, Pump_probe_Diode,
Expand All @@ -1495,7 +1497,7 @@ def LoadTimescansXANES(with_TT, Two_diodes, scan, TT, channel_delay_motor, detec
if saveflag:
os.makedirs(reducedir+runname, exist_ok=True)
save_reduced_data_1diode(reducedir, runname, scan,
DataDiode_pump, DataDiode_unpump, Pump_probe_Diode, goodshots, correlation, timezero_mm)
DataDiode_pump, DataDiode_unpump, Pump_probe_Diode, goodshots, correlation, timezero_offset)

################################################

Expand Down

0 comments on commit a5e35eb

Please sign in to comment.