Commit 8342fed4 authored by Cyril Guilloud's avatar Cyril Guilloud

added multi distributions and XCALIBU capacities:

* multi dist: user can define many distributions, they will be sum to create counter data.
* XCALIBU: user can give a calibaration file in config to load TABLE or POLYNOMIAL calib as distribution.
* class name to use: SimulationCounter
parent c8edbb53
Pipeline #11643 failed with stages
in 33 minutes and 40 seconds
This diff is collapsed.
# BLISS simulation devices configuration
This chapter explains how to configure simulation BLISS devices:
......@@ -57,10 +58,9 @@ controller:
## Counter
A pretty generic simulation counter is provided by
`simulation_counter` module to define a fake counter.
A pretty generic simulation counter is provided by `SimulationCounter` module.
This fake counter is usable in a `ct` or in a [default
Such a simulation counter is usable in a `ct` or in a [default
scan](scan_default.md).
It returns floats numbers that can be:
......@@ -68,22 +68,25 @@ It returns floats numbers that can be:
* constant
* random
* following a gaussian distribution
* following a calibration defined by an xcalibu calibration file.
* see: https://gitlab.esrf.fr/bliss/xcalibu
If included in a scan (except timescan/loopscan without predefined
number of points), it returns values according to a user defined
distribution:
If included in a scan (except timescan/loopscan without predefined number of
points), it returns values according to a user defined distribution:
* FLAT (constant value)
* GAUSSIAN
* FLAT: constant value
* GAUSSIAN: gaussian distribution
* XCALIBU: xcalibu calibration defined by polynom or by a table
If included in a `ct` or a `timescan`, it returns either a constant
If included in a `ct` or a `timescan`, it returns either a constant or a random
value.
Returned values can be altered by adding a random "noise".
### Parameters
* `<distribution>`: 'GAUSSIAN' | 'FLAT'
* `<distributions>`: list of distributions
* `<type>`: 'GAUSSIAN' | 'FLAT' | 'XCALIBU'
* `<noise_factor>`:
* `>= 0.0`
* add a random noise to the distribution
......@@ -98,16 +101,14 @@ Parameters if using GAUSSIAN:
* `<mu_offset>`: shitfs mean value by `<mu_offset> `(X-offset)
* `<sigma_factor>`: standard deviation adjustement factor.
!!! note
TODO: adding an option to be able to furnish to counter a
user-defined array for tests on a deterministic curve.
Parameters if using XCALIBU:
* `<xcalibu_file>`: name of the file to use. File must be Beacon-accessible (ex:
in `...local/beamline_configuration/`)
### Examples
`sim_ct_1` counter is configured to generate a gaussian curve:
`sim_ct_gauss` counter is configured to generate a gaussian curve:
* centered in 0 (mu = 0.0)
* with a standard deviation (fwhm = ~2.35 * sigma) of 1 (sigma_factor = 1.0)
......@@ -118,74 +119,115 @@ NB: the real height depends also on the sigma value.
```yaml
-
name: sim_ct_1
name: sim_ct_gauss
plugin: bliss
class: SimulationCounter
distribution: GAUSSIAN
mu_offset: 0.0
sigma_factor: 1.0
height_factor: 100.0
noise_factor: 0.0
distributions:
- type: GAUSSIAN
mu_offset: 0.0
sigma_factor: 1.0
height_factor: 100.0
noise_factor: 0.0
```
`sim_ct_2` counter is configured to generate a noisy gaussian curve:
`sim_ct_gauss_noise` counter is configured to generate a noisy gaussian curve:
* centered in -1 (mu = -1.0)
* with a standard deviation of 0.4 (sigma_factor = 0.4) (narrower than sim_ct_1's curve)
* with a standard deviation of 0.4 (sigma_factor = 0.4) (narrower than sim_ct_gauss's curve)
* scaled in height by 100 ( height_factor: 100.0)
* with a noise factor of 0.1
```yaml
-
name: sim_ct_2
name: sim_ct_gauss_noise
plugin: bliss
class: SimulationCounter
distribution: GAUSSIAN
mu_offset: -1.0
sigma_factor: 0.4
height_factor: 100.0
noise_factor: 0.1
distributions:
- type: GAUSSIAN
mu_offset: -1.0
sigma_factor: 0.4
height_factor: 100.0
noise_factor: 0.1
```
`sim_ct_3` counter is configured to depict a constant value:
`sim_ct_flat_12` counter is configured to depict a constant value:
* of value 12.0 ( height_factor: 12.0)
* without noise (noise_factor: 0.0)
```yaml
-
name: sim_ct_3
name: sim_ct_flat_12
plugin: bliss
class: SimulationCounter
distribution: FLAT
height_factor: 12.0
noise_factor: 0.0
distributions:
- type: FLAT
height_factor: 12.0
noise_factor: 0.0
```
`sim_ct_4` counter is configured to depict a random value:
`sim_ct_rand_12` counter is configured to depict a random value:
* with a base line of 12.0 ( height_factor: 12.0)
* with positive noise (noise_factor: 1.01)
```yaml
-
name: sim_ct_4
name: sim_ct_rand_12
plugin: bliss
class: SimulationCounter
distributions:
- type: FLAT
height_factor: 12.0
noise_factor: 1.01
```
`sim_ct_double_gauss` counter is configured to depict a sum of two gaussian
distributions.
```yaml
-
name: sim_ct_double_gauss
plugin: bliss
class: SimulationCounter
distribution: FLAT
height_factor: 12.0
noise_factor: 1.01
distributions:
- type: GAUSSIAN
mu_offset: 1.0
sigma_factor: 1.0
height_factor: 1.0
noise_factor: 0.0
- type: GAUSSIAN
mu_offset: -8.0
sigma_factor: 1.0
height_factor: 2.0
noise_factor: 0.0
```
`sim_ct_xcalibu` counter is configured to depict a pre-defined distribution
defined as a xcalibu calibration from `gauss.calib` file (located in beacon
configuration directory.
```yaml
-
name: sim_ct_xcalibu
plugin: bliss
class: SimulationCounter
distributions:
- type: XCALIBU
xcalibu_file: "gauss.calib"
```
## MCA
To create a simulation MCA, just use `SimulatedMCA` class:
name: simul_mca
module: mca
class: SimulatedMCA
plugin: bliss
```yaml
name: simul_mca
module: mca
class: SimulatedMCA
plugin: bliss
```
## Lima Device
......
......@@ -37,3 +37,4 @@ tabulate
tango >= 9.3.2
tmux >= 2.7
treelib
xcalibu
# -*- coding: utf-8 -*-
#
# This file is part of the bliss project
#
# Copyright (c) 2015-2019 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import pytest
import os
import time
import numpy
from bliss import setup_globals
from bliss.common import scans
from bliss.scanning import scan, chain
from bliss.scanning.acquisition import timer, calc, motor, counter
from bliss.common import event
def test_sim_count_ascan(session):
"""
Performs aascan with many kind of simulation counters:
* sim_ct_gauss
* sim_ct_gauss_noise
* sim_ct_double_gauss
* sim_ct_flat_12
* sim_ct_rand_12
* sim_ct_xcalibu
"""
robz2 = getattr(setup_globals, "robz2")
simul_ct_gauss = getattr(setup_globals, "sim_ct_gauss")
simul_ct_gauss_noise = getattr(setup_globals, "sim_ct_gauss_noise")
simul_ct_double_gauss = getattr(setup_globals, "sim_ct_double_gauss")
simul_ct_flat_12 = getattr(setup_globals, "sim_ct_flat_12")
simul_ct_rand_12 = getattr(setup_globals, "sim_ct_rand_12")
simul_ct_xcalibu = getattr(setup_globals, "sim_ct_xcalibu")
s = scans.ascan(
robz2,
0,
0.1,
2,
0,
simul_ct_gauss,
simul_ct_gauss_noise,
simul_ct_double_gauss,
simul_ct_flat_12,
simul_ct_rand_12,
simul_ct_xcalibu,
return_scan=True,
save=False,
)
assert robz2.position == 0.1
scan_data = s.get_data()
# TEST calibration
# Type TABLE
# Comments are starting with '#'
# Spaces are mainly ignored.
CALIB_NAME = GAUSS1
CALIB_TYPE = TABLE
CALIB_TIME = 1400081171.300155
CALIB_DESC = "roughly a gaussian..."
GAUSS1[-5] = 1.2
GAUSS1[-4] = 2.3
GAUSS1[-3] = 5.7
GAUSS1[-2] = 12.6
GAUSS1[-1] = 20.9
GAUSS1[0] = 24.9
GAUSS1[1] = 20.9
GAUSS1[2] = 12.6
GAUSS1[3] = 5.7
GAUSS1[4] = 2.3
GAUSS1[5] = 1.2
......@@ -47,9 +47,11 @@
- sample_regulation
- sensor
- sim_ct_gauss
- sim_ct_double_gauss
- sim_ct_gauss_noise
- sim_ct_flat_12
- sim_ct_rand_12
- sim_ct_xcalibu
- test
- test_mg
- thermo_sample
......
......@@ -2,31 +2,57 @@
name: sim_ct_gauss
plugin: bliss
class: SimulationCounter
distribution: GAUSSIAN
mu_offset: 0.0
sigma_factor: 1.0
height_factor: 100.0
noise_factor: 0.0
distributions:
- type: GAUSSIAN
mu_offset: 0.0
sigma_factor: 1.0
height_factor: 100.0
noise_factor: 0.0
-
name: sim_ct_gauss_noise
plugin: bliss
class: SimulationCounter
distribution: GAUSSIAN
mu_offset: -1.0
sigma_factor: 0.4
height_factor: 100.0
noise_factor: 0.1
distributions:
- type: GAUSSIAN
mu_offset: -1.0
sigma_factor: 0.4
height_factor: 100.0
noise_factor: 0.1
-
name: sim_ct_double_gauss
plugin: bliss
class: SimulationCounter
distributions:
- type: GAUSSIAN
mu_offset: 1.0
sigma_factor: 1.0
height_factor: 1.0
noise_factor: 0.0
- type: GAUSSIAN
mu_offset: -8.0
sigma_factor: 1.0
height_factor: 2.0
noise_factor: 0.0
-
name: sim_ct_flat_12
plugin: bliss
class: SimulationCounter
distribution: FLAT
height_factor: 12.0
noise_factor: 0.0
distributions:
- type: FLAT
height_factor: 12.0
noise_factor: 0.0
-
name: sim_ct_rand_12
plugin: bliss
class: SimulationCounter
distribution: FLAT
height_factor: 12.0
noise_factor: 1.01
distributions:
- type: FLAT
height_factor: 12.0
noise_factor: 1.01
-
name: sim_ct_xcalibu
plugin: bliss
class: SimulationCounter
distributions:
- type: XCALIBU
xcalibu_file: "gauss.calib"
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