Skip to content
Snippets Groups Projects
Commit fb7aa8c4 authored by Loïc Le Guyader's avatar Loïc Le Guyader
Browse files

Rename np_mean to np_mean_sk in BOZ analysis

parent ea810a73
No related branches found
No related tags found
1 merge request!294BOZ improvements and additional documentation
Pipeline #138901 passed
...@@ -1459,7 +1459,7 @@ def ff_refine_crit_sk(p, alpha, params, arr_dark, arr, tid, rois, ...@@ -1459,7 +1459,7 @@ def ff_refine_crit_sk(p, alpha, params, arr_dark, arr, tid, rois,
# drop saturated shots # drop saturated shots
d = data.where(data['sat_sat'] == False, drop=True) d = data.where(data['sat_sat'] == False, drop=True)
r = xas(d, 40, Iokey='np_mean', Itkey='0', nrjkey='0', fluorescence=True) r = xas(d, 40, Iokey='np_mean_sk', Itkey='0', nrjkey='0', fluorescence=True)
err_sigma = np.nansum(r['sigmaA']) err_sigma = np.nansum(r['sigmaA'])
err_mean = (1.0 - np.nanmean(r['muA']))**2 err_mean = (1.0 - np.nanmean(r['muA']))**2
...@@ -1650,7 +1650,7 @@ def nl_crit_sk(p, domain, alpha, arr_dark, arr, tid, rois, mask, flat_field, ...@@ -1650,7 +1650,7 @@ def nl_crit_sk(p, domain, alpha, arr_dark, arr, tid, rois, mask, flat_field,
# drop saturated shots # drop saturated shots
d = data.where(data['sat_sat'] == False, drop=True) d = data.where(data['sat_sat'] == False, drop=True)
v = snr(d['np_mean'].values.flatten(), d['0'].values.flatten(), v = snr(d['np_mean_sk'].values.flatten(), d['0'].values.flatten(),
methods=['weighted']) methods=['weighted'])
err = 1e8*v['weighted']['s']**2 err = 1e8*v['weighted']['s']**2
...@@ -2014,7 +2014,7 @@ def inspect_correction_sk(params, ff, gain=None): ...@@ -2014,7 +2014,7 @@ def inspect_correction_sk(params, ff, gain=None):
scale = 1e-6 scale = 1e-6
f, axs = plt.subplots(1, 3, figsize=(8, 2), sharex=True) f, axs = plt.subplots(1, 3, figsize=(8, 2.5), sharex=True)
# nbins = np.linspace(0.01, 1.0, 100) # nbins = np.linspace(0.01, 1.0, 100)
...@@ -2029,16 +2029,13 @@ def inspect_correction_sk(params, ff, gain=None): ...@@ -2029,16 +2029,13 @@ def inspect_correction_sk(params, ff, gain=None):
good_d = d.where(d['sat_sat'] == False, drop=True) good_d = d.where(d['sat_sat'] == False, drop=True)
sat_d = d.where(d['sat_sat'], drop=True) sat_d = d.where(d['sat_sat'], drop=True)
good_d['np_mean'] = 0.5*(good_d['n']+good_d['p']) snr_v = snr(good_d['np_mean_sk'].values.flatten(),
sat_d['np_mean'] = 0.5*(sat_d['n']+sat_d['p'])
snr_v = snr(good_d['np_mean'].values.flatten(),
good_d['0'].values.flatten(), verbose=True) good_d['0'].values.flatten(), verbose=True)
m = snr_v['direct']['mu'] m = snr_v['direct']['mu']
h, xedges, yedges, img = axs[k].hist2d( h, xedges, yedges, img = axs[k].hist2d(
g*scale*good_d['0'].values.flatten(), g*scale*good_d['0'].values.flatten(),
good_d['np_mean'].values.flatten()/good_d['0'].values.flatten(), good_d['np_mean_sk'].values.flatten()/good_d['0'].values.flatten(),
[photon_scale, np.linspace(0.95, 1.05, 150)*m], [photon_scale, np.linspace(0.95, 1.05, 150)*m],
cmap='Blues', cmap='Blues',
norm=LogNorm(vmin=0.2, vmax=200), norm=LogNorm(vmin=0.2, vmax=200),
...@@ -2046,7 +2043,7 @@ def inspect_correction_sk(params, ff, gain=None): ...@@ -2046,7 +2043,7 @@ def inspect_correction_sk(params, ff, gain=None):
) )
h, xedges, yedges, img2 = axs[k].hist2d( h, xedges, yedges, img2 = axs[k].hist2d(
g*scale*sat_d['0'].values.flatten(), g*scale*sat_d['0'].values.flatten(),
sat_d['np_mean'].values.flatten()/sat_d['0'].values.flatten(), sat_d['np_mean_sk'].values.flatten()/sat_d['0'].values.flatten(),
[photon_scale, np.linspace(0.95, 1.05, 150)*m], [photon_scale, np.linspace(0.95, 1.05, 150)*m],
cmap='Reds', cmap='Reds',
norm=LogNorm(vmin=0.2, vmax=200), norm=LogNorm(vmin=0.2, vmax=200),
...@@ -2288,7 +2285,7 @@ def process_module(arr, tid, dark, rois, mask=None, sat_level=511, ...@@ -2288,7 +2285,7 @@ def process_module(arr, tid, dark, rois, mask=None, sat_level=511,
# np_mean roi where we normalize the sum of flat_field # np_mean roi where we normalize the sum of flat_field
np_mean = (r['n'] + r['p'])/(ff['n'] + ff['p']) np_mean = (r['n'] + r['p'])/(ff['n'] + ff['p'])
v['np_mean'] = np_mean.sum(axis=(2,3)) v['np_mean_sk'] = np_mean.sum(axis=(2,3))
res = xr.Dataset() res = xr.Dataset()
...@@ -2298,9 +2295,9 @@ def process_module(arr, tid, dark, rois, mask=None, sat_level=511, ...@@ -2298,9 +2295,9 @@ def process_module(arr, tid, dark, rois, mask=None, sat_level=511,
res[n] = xr.DataArray(ensure_on_host(v[n]), coords=r_coords, dims=dims) res[n] = xr.DataArray(ensure_on_host(v[n]), coords=r_coords, dims=dims)
res[n + '_sat'] = xr.DataArray(ensure_on_host(r_sat[n][:, :]), res[n + '_sat'] = xr.DataArray(ensure_on_host(r_sat[n][:, :]),
coords=r_coords, dims=dims) coords=r_coords, dims=dims)
res['np_mean'] = xr.DataArray(ensure_on_host(v['np_mean']), res['np_mean_sk'] = xr.DataArray(ensure_on_host(v['np_mean_sk']),
coords=r_coords, dims=dims) coords=r_coords, dims=dims)
res['np_mean_sat'] = res['n_sat'] + res['p_sat'] res['np_mean_sk_sat'] = res['n_sat'] + res['p_sat']
for n in rois.keys(): for n in rois.keys():
roi = rois[n] roi = rois[n]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment