" list](https://sympa.esrf.fr/sympa/info/fame-data-analysis) to be kept updated\n",
" about bug fixes and new features\n",
"- Report bugs and features requests in the [famewoks issues tracker](https://gitlab.esrf.fr/F-CRG/fames/famewoks/-/issues) or by directly sending an email to [mauro.rovezzi@esrf.fr](mailto:mauro.rovezzi@esrf.fr)\n",
"- To run this notebook at BM16:\n",
" - (production/stable) go to [http://jade:8000](http://jade:8000) and run the notebook with the `sloth (v2312)` kernel\n",
" - (development) go to [http://bm16ctrl:8000](http://bm16ctrl:8000) and run the notebook with the `sloth` kernel\n"
"- To run this notebook at BM16: go to [http://jade:8000](http://jade:8000) and run the notebook with the `sloth (v2312)` kernel"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First set main imports and global settings for the experiment (session)"
"First set main imports and global settings for the experiment (session). **NOTE** to restart the notebook, you need to restart the underlying kenel process. Simply closing the notebook window/tab does not reload it."
]
},
{
...
...
@@ -89,8 +87,8 @@
"metadata": {},
"outputs": [],
"source": [
"# define the counters names or use those already defined for BM16: CNTS_FLUO_XMAP, CNTS_FLUO, CNTS_CAS\n",
"CNTS_CAS_XPAD = ExpCounters(\n",
"# you can define your own counters names or use those already defined for BM16: CNTS_FLUO_XMAP, CNTS_FLUO, CNTS_CAS\n",
"Search for the samples names available in the given experimental session.\n",
"Here the whole data reduction and evaluation workflow currently implemented is explained in details. You may take (copy/paste somewhere) only those cells of interest for you."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Search samples and datasets\n",
"\n",
"It is possible to use the parameter `ignore_names = [\"list\", \"of\", \"strings\"]` to ignore those samples names containing such words."
"Search for the samples names available in the given experimental session. It is possible to use the parameter `ignore_names = [\"list\", \"of\", \"strings\"]` to ignore those samples names containing such words."
]
},
{
...
...
@@ -224,7 +323,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load data\n",
"### Load data\n",
"\n",
"Select a dataset and load the scan data into the session (e.g. load from disk to memory).\n",
"\n",
...
...
@@ -264,7 +363,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data plotter\n",
"### Data plotter\n",
"\n",
"Plot the data loaded in the dataset\n",
"\n",
...
...
@@ -313,7 +412,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Energy alignment\n",
"### Energy alignment\n",
"\n",
"First set a reference group for the energy alignment"
]
...
...
@@ -365,7 +464,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data cleaning\n",
"### Data cleaning\n",
"\n",
"Set bad scans. The `scans` variable can be a list of integers or a string that is interpreted (*NOTE* always put spaces after commas). If `scans=None`, all scans are enabled."
]
...
...
@@ -402,14 +501,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Merge data\n",
"\n",
"Merge the scans in the dataset\n",
"### Merge data\n",
"\n",
"(*NOTE* `pre_edge` and `rebin_xafs` are applied on the merged group),\n",
"\n",
"*Default parameters for Larch `rebin_xafs()` function* : \n",
"Merge the scans in the dataset. `pre_edge` and `rebin_xafs` are applied on the merged group\n",
"\n",
"*Default parameters for Larch `rebin_xafs()` function*: \n",
"Save the data to an Athena project file (*NOTE*: the files are overwritten each time). To save the rebinned spectra, use the option `save_rebinned=True`. The data channel should be specified, e.g. `data = [\"fluo\", \"ref\", \"trans\"]`. An Athena project for each data channel is created. If you want to change the scans saved in the Athena project, simply use the `set_bad_scans()` function (first enable all scans and then select those to export, see example below)."
]
...
...
@@ -569,48 +665,11 @@
"source": [
"exp.session.samples[2].datasets[3].scans[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Sandbox\n",
"\n",
"This section is simply a sandbox (messy area) for testing/development or add your own workflow."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "sloth2411",
"display_name": "sloth",
"language": "python",
"name": "python3"
},
...
...
%% Cell type:markdown id: tags:
# Data reduction and evaluation workflow
- This notebook is based on a **work in progress project**, called `famewoks` and may be affected by bugs
-`famewoks` is publicly available at [https://gitlab.esrf.fr/F-CRG/fames/famewoks](https://gitlab.esrf.fr/F-CRG/fames/famewoks)
- Subscribe to the [`fame-data-analysis@esrf.fr` mailing
list](https://sympa.esrf.fr/sympa/info/fame-data-analysis) to be kept updated
about bug fixes and new features
- Report bugs and features requests in the [famewoks issues tracker](https://gitlab.esrf.fr/F-CRG/fames/famewoks/-/issues) or by directly sending an email to [mauro.rovezzi@esrf.fr](mailto:mauro.rovezzi@esrf.fr)
- To run this notebook at BM16:
- (production/stable) go to [http://jade:8000](http://jade:8000) and run the notebook with the `sloth (v2312)` kernel
- (development) go to [http://bm16ctrl:8000](http://bm16ctrl:8000) and run the notebook with the `sloth` kernel
- To run this notebook at BM16: go to [http://jade:8000](http://jade:8000) and run the notebook with the `sloth (v2312)` kernel
%% Cell type:markdown id: tags:
First set main imports and global settings for the experiment (session)
First set main imports and global settings for the experiment (session). **NOTE** to restart the notebook, you need to restart the underlying kenel process. Simply closing the notebook window/tab does not reload it.
%% Cell type:code id: tags:
``` python
%load_extautoreload
%autoreload2
# Uncomment the following two lines if the plots do not show in the notebook
Here the whole data reduction and evaluation workflow currently implemented is explained in details. You may take (copy/paste somewhere) only those cells of interest for you.
Search for the samples names available in the given experimental session.
%% Cell type:markdown id: tags:
It is possible to use the parameter `ignore_names = ["list", "of", "strings"]` to ignore those samples names containing such words.
### Search samples and datasets
Search for the samples names available in the given experimental session. It is possible to use the parameter `ignore_names = ["list", "of", "strings"]` to ignore those samples names containing such words.
it is also possible to search/load the datasets for all samples
%% Cell type:code id: tags:
``` python
session = search_datasets(session, verbose=False)
```
%% Cell type:markdown id: tags:
## Load data
### Load data
Select a dataset and load the scan data into the session (e.g. load from disk to memory).
**Parameters for `load_data()`**
- `skip_scans`: the scans that are not going to be loaded (e.g. bad scans), it can be a list of numbers `[1,2,3]` or a string `"1:4, 7"`
- `use_fluo_corr`: if True, it uses the dead-time corrected fluorescence channel (**NOTE** this correction usually fails at low count rates, check with/without correction so see which is the lower noise configuration)
- `iskip`: the index of the initial data points to skip (None)
- `istrip`: the relative index with respect to the last data points to strip (None)
- `merge`: to automatically merge the scans in a dataset (True)
- `calc_eshift`: fit the energy shift using the first scan of the dataset as reference (*NOTE* this slows down the loading)
%% Cell type:code id: tags:
``` python
sel_dataset = 0
dataset = datasets[sel_dataset]
load_data(
session,
dataset,
use_fluo_corr=False,
iskip=1, #: ignore the first point
istrip=1, #: ignore the last point
calc_eshift=True,
merge=True,
skip_scans=[],
)
```
%% Cell type:markdown id: tags:
## Data plotter
### Data plotter
Plot the data loaded in the dataset
**Parameters for `plot_data()`**
- `data` can be:
- `"fluos"`: to show all fluorescence channels
- `"fluo"`: sum of active fluorescence channels (use `set_bad_fluo_channels()` for excluding bad ones)
- `"trans"`: sample transmission (*muT1*)
- `"ref"`: reference "foil" transmission (*muT2*)
- `ynorm`: *None*, `area` (shows y data normalized by their area), `flat` (show flattened) or *True* (show normalized)
- `show_slide`: if True shows one scan at time with a slider
- `show_i0`: *True* shows I0 signal (*NOTE* for `data = "ref"` it is I1 signal)
- `show_e0`: *True* shows E0 (as found by the `pre_edge()` function of Larch)
- `show_deriv`: *True* shows the derivative of the signal
- `show_merge`: *True* shows the merged signal (sum of the channels for the current scan)
- if `"rebin"` it shows the rebinned version of the merge (*NOTE* the single scans are never rebinned, as they are meant to be merged (and then rebinned))
%% Cell type:code id: tags:
``` python
fig = plot_data(
dataset,
data="fluo",
ynorm="area",
show_slide=True,
show_i0=False,
show_e0=False,
show_deriv=False,
show_merge=False,
)
```
%% Cell type:markdown id: tags:
The plot function permits digging into the whole data for a single dataset. The following functions permits acting on the data (you may go back in the workflow and plot the data again)
%% Cell type:markdown id: tags:
## Energy alignment
### Energy alignment
First set a reference group for the energy alignment
Set bad scans. The `scans` variable can be a list of integers or a string that is interpreted (*NOTE* always put spaces after commas). If `scans=None`, all scans are enabled.
%% Cell type:code id: tags:
``` python
set_bad_scans(dataset, scans="1, 10")
#set_bad_scans(dataset, scans=None) #: all marked as good
```
%% Cell type:markdown id: tags:
To exclude the bad channels. If `scan=None` it will exclude the `channels` for all scans
(*NOTE*`pre_edge` and `rebin_xafs` are applied on the merged group),
### Merge data
*Default parameters for Larch `rebin_xafs()` function* :
Merge the scans in the dataset. `pre_edge` and `rebin_xafs` are applied on the merged group
*Default parameters for Larch `rebin_xafs()` function*:
- `pre1`: pre_step*int((min(energy)-e0)/pre_step)
- `pre2` : -30
- `pre_step`: 2
- `exafs1` :-15
- `exafs2` : max(energy)-e0
- `xanes_step` : e0/25000 , round down to 0.05
- `method` : centroid
%% Cell type:code id: tags:
``` python
merge_data(dataset)
```
%% Cell type:markdown id: tags:
## Save data
### Save data
Save the data to an Athena project file (*NOTE*: the files are overwritten each time). To save the rebinned spectra, use the option `save_rebinned=True`. The data channel should be specified, e.g. `data = ["fluo", "ref", "trans"]`. An Athena project for each data channel is created. If you want to change the scans saved in the Athena project, simply use the `set_bad_scans()` function (first enable all scans and then select those to export, see example below).
%% Cell type:code id: tags:
``` python
set_bad_scans(dataset, scans=None) #: all marked as good
once everything is loaded into the session, it is possible to perform grouped actions faster (no need to relaod the data in memory). For example, to plot I0 with fluorescence sum