...
  View open merge request
Commits (1)
  • Cyril Guilloud's avatar
    added multi distributions and XCALIBU capacities: · 8342fed4
    Cyril Guilloud authored
    * 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
    8342fed4
This diff is collapsed.
# BLISS simulation devices configuration # BLISS simulation devices configuration
This chapter explains how to configure simulation BLISS devices: This chapter explains how to configure simulation BLISS devices:
...@@ -57,10 +58,9 @@ controller: ...@@ -57,10 +58,9 @@ controller:
## Counter ## Counter
A pretty generic simulation counter is provided by A pretty generic simulation counter is provided by `SimulationCounter` module.
`simulation_counter` module to define a fake counter.
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). scan](scan_default.md).
It returns floats numbers that can be: It returns floats numbers that can be:
...@@ -68,22 +68,25 @@ It returns floats numbers that can be: ...@@ -68,22 +68,25 @@ It returns floats numbers that can be:
* constant * constant
* random * random
* following a gaussian distribution * 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 If included in a scan (except timescan/loopscan without predefined number of
number of points), it returns values according to a user defined points), it returns values according to a user defined distribution:
distribution:
* FLAT (constant value) * FLAT: constant value
* GAUSSIAN * 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. value.
Returned values can be altered by adding a random "noise". Returned values can be altered by adding a random "noise".
### Parameters ### Parameters
* `<distribution>`: 'GAUSSIAN' | 'FLAT' * `<distributions>`: list of distributions
* `<type>`: 'GAUSSIAN' | 'FLAT' | 'XCALIBU'
* `<noise_factor>`: * `<noise_factor>`:
* `>= 0.0` * `>= 0.0`
* add a random noise to the distribution * add a random noise to the distribution
...@@ -98,16 +101,14 @@ Parameters if using GAUSSIAN: ...@@ -98,16 +101,14 @@ Parameters if using GAUSSIAN:
* `<mu_offset>`: shitfs mean value by `<mu_offset> `(X-offset) * `<mu_offset>`: shitfs mean value by `<mu_offset> `(X-offset)
* `<sigma_factor>`: standard deviation adjustement factor. * `<sigma_factor>`: standard deviation adjustement factor.
Parameters if using XCALIBU:
!!! note * `<xcalibu_file>`: name of the file to use. File must be Beacon-accessible (ex:
in `...local/beamline_configuration/`)
TODO: adding an option to be able to furnish to counter a
user-defined array for tests on a deterministic curve.
### Examples ### 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) * centered in 0 (mu = 0.0)
* with a standard deviation (fwhm = ~2.35 * sigma) of 1 (sigma_factor = 1.0) * with a standard deviation (fwhm = ~2.35 * sigma) of 1 (sigma_factor = 1.0)
...@@ -118,10 +119,11 @@ NB: the real height depends also on the sigma value. ...@@ -118,10 +119,11 @@ NB: the real height depends also on the sigma value.
```yaml ```yaml
- -
name: sim_ct_1 name: sim_ct_gauss
plugin: bliss plugin: bliss
class: SimulationCounter class: SimulationCounter
distribution: GAUSSIAN distributions:
- type: GAUSSIAN
mu_offset: 0.0 mu_offset: 0.0
sigma_factor: 1.0 sigma_factor: 1.0
height_factor: 100.0 height_factor: 100.0
...@@ -129,63 +131,103 @@ NB: the real height depends also on the sigma value. ...@@ -129,63 +131,103 @@ NB: the real height depends also on the sigma value.
``` ```
`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) * 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) * scaled in height by 100 ( height_factor: 100.0)
* with a noise factor of 0.1 * with a noise factor of 0.1
```yaml ```yaml
- -
name: sim_ct_2 name: sim_ct_gauss_noise
plugin: bliss plugin: bliss
class: SimulationCounter class: SimulationCounter
distribution: GAUSSIAN distributions:
- type: GAUSSIAN
mu_offset: -1.0 mu_offset: -1.0
sigma_factor: 0.4 sigma_factor: 0.4
height_factor: 100.0 height_factor: 100.0
noise_factor: 0.1 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) * of value 12.0 ( height_factor: 12.0)
* without noise (noise_factor: 0.0) * without noise (noise_factor: 0.0)
```yaml ```yaml
- -
name: sim_ct_3 name: sim_ct_flat_12
plugin: bliss plugin: bliss
class: SimulationCounter class: SimulationCounter
distribution: FLAT distributions:
- type: FLAT
height_factor: 12.0 height_factor: 12.0
noise_factor: 0.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 a base line of 12.0 ( height_factor: 12.0)
* with positive noise (noise_factor: 1.01) * with positive noise (noise_factor: 1.01)
```yaml ```yaml
- -
name: sim_ct_4 name: sim_ct_rand_12
plugin: bliss plugin: bliss
class: SimulationCounter class: SimulationCounter
distribution: FLAT distributions:
- type: FLAT
height_factor: 12.0 height_factor: 12.0
noise_factor: 1.01 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
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 ## MCA
To create a simulation MCA, just use `SimulatedMCA` class: To create a simulation MCA, just use `SimulatedMCA` class:
name: simul_mca ```yaml
module: mca name: simul_mca
class: SimulatedMCA module: mca
plugin: bliss class: SimulatedMCA
plugin: bliss
```
## Lima Device ## Lima Device
......
...@@ -37,3 +37,4 @@ tabulate ...@@ -37,3 +37,4 @@ tabulate
tango >= 9.3.2 tango >= 9.3.2
tmux >= 2.7 tmux >= 2.7
treelib 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 @@ ...@@ -47,9 +47,11 @@
- sample_regulation - sample_regulation
- sensor - sensor
- sim_ct_gauss - sim_ct_gauss
- sim_ct_double_gauss
- sim_ct_gauss_noise - sim_ct_gauss_noise
- sim_ct_flat_12 - sim_ct_flat_12
- sim_ct_rand_12 - sim_ct_rand_12
- sim_ct_xcalibu
- test - test
- test_mg - test_mg
- thermo_sample - thermo_sample
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
name: sim_ct_gauss name: sim_ct_gauss
plugin: bliss plugin: bliss
class: SimulationCounter class: SimulationCounter
distribution: GAUSSIAN distributions:
- type: GAUSSIAN
mu_offset: 0.0 mu_offset: 0.0
sigma_factor: 1.0 sigma_factor: 1.0
height_factor: 100.0 height_factor: 100.0
...@@ -11,22 +12,47 @@ ...@@ -11,22 +12,47 @@
name: sim_ct_gauss_noise name: sim_ct_gauss_noise
plugin: bliss plugin: bliss
class: SimulationCounter class: SimulationCounter
distribution: GAUSSIAN distributions:
- type: GAUSSIAN
mu_offset: -1.0 mu_offset: -1.0
sigma_factor: 0.4 sigma_factor: 0.4
height_factor: 100.0 height_factor: 100.0
noise_factor: 0.1 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 name: sim_ct_flat_12
plugin: bliss plugin: bliss
class: SimulationCounter class: SimulationCounter
distribution: FLAT distributions:
- type: FLAT
height_factor: 12.0 height_factor: 12.0
noise_factor: 0.0 noise_factor: 0.0
- -
name: sim_ct_rand_12 name: sim_ct_rand_12
plugin: bliss plugin: bliss
class: SimulationCounter class: SimulationCounter
distribution: FLAT distributions:
- type: FLAT
height_factor: 12.0 height_factor: 12.0
noise_factor: 1.01 noise_factor: 1.01
-
name: sim_ct_xcalibu
plugin: bliss
class: SimulationCounter
distributions:
- type: XCALIBU
xcalibu_file: "gauss.calib"