gasimulator


Namegasimulator JSON
Version 1.0.3 PyPI version JSON
download
home_page
Summarya gamma simulator
upload_time2024-02-29 10:22:54
maintainer
docs_urlNone
authorChen_zk
requires_python
licenseBSD-3-Clause
keywords python gamma pulse simulate
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
![logo](./fig/logo.png)
# Gamma_simulator
     
This is a gamma pulse simulator jointly developed by [Shamoon College of Engineering(SCE)](https://en.sce.ac.il/) in Israel and [Shanghai Advanced Research Institute](http://www.sari.cas.cn/) in China.Here we will give a brief introduction to our software, including the what and why. For more specific implementation steps of the software, please refer to our [paper](). Of course,**if you are a pure user, please jump directly to [Use](#Use) to see how to use it**.For any questions about the software, you can leave a message or send an email to me, I will reply as soon as possilble

## Introduction
### What is Gamma Simulator?

Gamma simulator is a gamma pulse simulator with parameter customization function, you can specify the type of radioactive source and pulse count rate and other characteristics, generate pulse signals that meet the corresponding characteristics

### Why do we creat it?

The original intention of the gamma simulator was to introduce deep learning into energy spectroscopy in the later stage. The use of deep learning to process pulse signals requires that the collected pulse signals have corresponding labels, which is impossible in commercial energy spectrometer. Therefore, we used the simulator to label the pulse signals while generating them, so as to facilitate the reference of deep learning methods. At the same time, simulators can greatly reduce the manpower, material and financial resources of the signal collection process, and can be used to preliminarily test signal processing methods

## Software structure
### Macrostructure
![mainflow](./fig/mainflow.png)
### Implementation structure
 ![Flow_software](./fig/Flow_software.png)
### Parameter description
Setting Parameters:
|Parameter name  |Parameter description|
| --- | -----------|
| verbose   | Whether to output detailed information   |
| verbose_plots   | Whether images need to be output   |
| source   | The simulated radioactive source   |
| signal_len   | Length of time to simulate sampling(s)   |
| fs   | Analog sampling rate   |
| lambda_value   | Analog pulse count rate(cps)   |
| dict_type    | Shape type model of the simulated pulse   |
| dict_shape_params   | dict shape params   |
| noise_unit   | Unit of noise   |
| noise   | The magnitude of noise in the given unit   |
| dict_size   | Shape dictionary size due to jitter   |
| seed   | The simulated random number seed   |

Shape parameters:
|Parameter name  |Parameter description|
| --- | -----------|
| t_rise   | rise time of the shape   |
| t_fall   | fall time of the shape   |
| shape_len   | length of the shape in samples   |
| shape_len_sec   | length of the shape in seconds   |

Events parameters:
|Parameter name  |Parameter description|
| --- | -----------|
| n_events   | number of events in the signal   |
| times   | arrival times of the events   |
| energies   | energy values for each event   |
| lambda_measured   | actual event rate   |
| shape_param1, shape_param2   | shape parameters for each event   |

Signal parameters:
|Parameter name  |Parameter description|
| --- | -----------|
| signal_len   | length of the signal in samples   |
| signal_len_sec   | length of the signal in seconds   |
| duty_cycle   | duty cycle of the signal  |
| pile_up_stat   | number of the pile-ups in the generated signal   |
| measured_snr   | measured SNR of the generated signal (dB)   |
## Use
### Install
Make sure you have the following libraries in your environment
* numpy
* scipy
* matplotlib
* urllib  
You can use the following command to install the libaries
```bash
pip install numpy scipy matplotlib urllib
```
### Import
```python
from gamma_simulator import gamma_simulator
```

### Run
Step 1.Creat an instance
```python
simulator = gamma_simulator()
```
Step 2.Define parameters
```python
simulator = gamma_simulator(verbose=True,
                            verbose_plots={'shapes': True, 'signal': True},
                            source={'name': 'Co-60', 'weights': 1},
                            signal_len=1,  # "analog" signal of 1 second that are 1e7 samples
                            fs=10e5,
                            lambda_value=1e4,
                            dict_type='gamma',
                            dict_shape_params={'mean1':  1.1,
                                               'std1': 0.001,
                                               'mean2': 1e5,
                                               'std2': 1e3},
                            noise_unit='std',
                            noise=1e-3,
                            dict_size=10,
                            seed=42)
```
Step 3.Creat the signal
```python
signal = simulator.generate_signal()
```


## Notice
### Shape parameter
If you are not familiar with shape parameters, use the following combination of parameters
```python
{dict_type='gamma',
dict_shape_params={'mean1':  1.1,
'std1': 0.001,
'mean2': 1e5,
'std2': 1e3}
```
or
```python
{dict_type='double_exponential',
dict_shape_params={'mean1': 1e-7, 
'std1': 1e-9,
'mean2': 1e-5,
'std2': 1e-7}
```
### Plot setting
Our simulator supports drawing a variety of graphs, including energy, shape, signal and spectrum.
* Energy:Ideal energy spectrum of the drawn signal source (simulator built-in database)
* Shape:Draws a dictionary set of all possible signal shapes
* Signal:When the length of the resulting signal is less than 2000, the generated signal is drawn, and when the length is greater than 2000, the first 2000 sampling points are drawn


The default option is not to draw, if you need to draw, you need to change the specified value in the parameter definition to True
```
verbose_plots={'energy':True, 'shapes': True, 'signal': True}
```
## Examples

```python
from gamma_simulator import gamma_simulator
simulator = gamma_simulator(verbose=True,
                            verbose_plots={'shapes': True, 'signal': True},
                            source={'name': 'Co-60', 'weights': 1},
                            signal_len=1,  # "analog" signal of 1 second that are 1e7 samples
                            fs=10e6,
                            lambda_value=1e4,
                            dict_type='double_exponential',
                            dict_shape_params={'mean1': 1e-7,  # continuous-time parameters measured in seconds
                                               'std1': 1e-9,
                                               'mean2': 1e-5,
                                               'std2': 1e-7},
                            noise_unit='std',
                            noise=1e-3,
                            dict_size=10,
                            seed=42)
signal = simulator.generate_signal()
```

![result1](./fig/Result_for_example1.png)

```python
from gamma_simulator import gamma_simulator
simulator = gamma_simulator(verbose=True,
                            verbose_plots={'energy': True, 'signal': True},
                            source={'name': ['Co-60', 'I-125'], 'weights': [1, 2]},
                            signal_len=1,  # "analog" signal of 1 second that are 1e7 samples
                            fs=10e6,
                            lambda_value=1e4,
                            dict_type='gamma',
                            dict_shape_params={'mean1':  1.1,  # continuous-time parameters measured in seconds
                                               'std1': 0.001,
                                               'mean2': 1e5,
                                               'std2': 1e3},
                            noise_unit='std',
                            noise=1e-3,
                            dict_size=10,
                            seed=42)
signal = simulator.generate_signal()
```

![result2](./fig/Result_for_example2.png)

# version
1.0.1 upload to pypi

1.0.2 add license and install_requires

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "gasimulator",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,gamma,pulse,simulate",
    "author": "Chen_zk",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/20/cf/40ef07f310b1b25531de14d47350a114083024f20a361cb5c0c828404266/gasimulator-1.0.3.tar.gz",
    "platform": null,
    "description": "\r\n![logo](./fig/logo.png)\r\n# Gamma_simulator\r\n     \r\nThis is a gamma pulse simulator jointly developed by [Shamoon College of Engineering(SCE)](https://en.sce.ac.il/) in Israel and [Shanghai Advanced Research Institute](http://www.sari.cas.cn/) in China.Here we will give a brief introduction to our software, including the what and why. For more specific implementation steps of the software, please refer to our [paper](). Of course,**if you are a pure user, please jump directly to [Use](#Use) to see how to use it**.For any questions about the software, you can leave a message or send an email to me, I will reply as soon as possilble\r\n\r\n## Introduction\r\n### What is Gamma Simulator?\r\n\r\nGamma simulator is a gamma pulse simulator with parameter customization function, you can specify the type of radioactive source and pulse count rate and other characteristics, generate pulse signals that meet the corresponding characteristics\r\n\r\n### Why do we creat it?\r\n\r\nThe original intention of the gamma simulator was to introduce deep learning into energy spectroscopy in the later stage. The use of deep learning to process pulse signals requires that the collected pulse signals have corresponding labels, which is impossible in commercial energy spectrometer. Therefore, we used the simulator to label the pulse signals while generating them, so as to facilitate the reference of deep learning methods. At the same time, simulators can greatly reduce the manpower, material and financial resources of the signal collection process, and can be used to preliminarily test signal processing methods\r\n\r\n## Software structure\r\n### Macrostructure\r\n![mainflow](./fig/mainflow.png)\r\n### Implementation structure\r\n ![Flow_software](./fig/Flow_software.png)\r\n### Parameter description\r\nSetting Parameters:\r\n|Parameter name  |Parameter description|\r\n| --- | -----------|\r\n| verbose   | Whether to output detailed information   |\r\n| verbose_plots   | Whether images need to be output   |\r\n| source   | The simulated radioactive source   |\r\n| signal_len   | Length of time to simulate sampling(s)   |\r\n| fs   | Analog sampling rate   |\r\n| lambda_value   | Analog pulse count rate(cps)   |\r\n| dict_type    | Shape type model of the simulated pulse   |\r\n| dict_shape_params   | dict shape params   |\r\n| noise_unit   | Unit of noise   |\r\n| noise   | The magnitude of noise in the given unit   |\r\n| dict_size   | Shape dictionary size due to jitter   |\r\n| seed   | The simulated random number seed   |\r\n\r\nShape parameters:\r\n|Parameter name  |Parameter description|\r\n| --- | -----------|\r\n| t_rise   | rise time of the shape   |\r\n| t_fall   | fall time of the shape   |\r\n| shape_len   | length of the shape in samples   |\r\n| shape_len_sec   | length of the shape in seconds   |\r\n\r\nEvents parameters:\r\n|Parameter name  |Parameter description|\r\n| --- | -----------|\r\n| n_events   | number of events in the signal   |\r\n| times   | arrival times of the events   |\r\n| energies   | energy values for each event   |\r\n| lambda_measured   | actual event rate   |\r\n| shape_param1, shape_param2   | shape parameters for each event   |\r\n\r\nSignal parameters:\r\n|Parameter name  |Parameter description|\r\n| --- | -----------|\r\n| signal_len   | length of the signal in samples   |\r\n| signal_len_sec   | length of the signal in seconds   |\r\n| duty_cycle   | duty cycle of the signal  |\r\n| pile_up_stat   | number of the pile-ups in the generated signal   |\r\n| measured_snr   | measured SNR of the generated signal (dB)   |\r\n## Use\r\n### Install\r\nMake sure you have the following libraries in your environment\r\n* numpy\r\n* scipy\r\n* matplotlib\r\n* urllib  \r\nYou can use the following command to install the libaries\r\n```bash\r\npip install numpy scipy matplotlib urllib\r\n```\r\n### Import\r\n```python\r\nfrom gamma_simulator import gamma_simulator\r\n```\r\n\r\n### Run\r\nStep 1.Creat an instance\r\n```python\r\nsimulator = gamma_simulator()\r\n```\r\nStep 2.Define parameters\r\n```python\r\nsimulator = gamma_simulator(verbose=True,\r\n                            verbose_plots={'shapes': True, 'signal': True},\r\n                            source={'name': 'Co-60', 'weights': 1},\r\n                            signal_len=1,  # \"analog\" signal of 1 second that are 1e7 samples\r\n                            fs=10e5,\r\n                            lambda_value=1e4,\r\n                            dict_type='gamma',\r\n                            dict_shape_params={'mean1':  1.1,\r\n                                               'std1': 0.001,\r\n                                               'mean2': 1e5,\r\n                                               'std2': 1e3},\r\n                            noise_unit='std',\r\n                            noise=1e-3,\r\n                            dict_size=10,\r\n                            seed=42)\r\n```\r\nStep 3.Creat the signal\r\n```python\r\nsignal = simulator.generate_signal()\r\n```\r\n\r\n\r\n## Notice\r\n### Shape parameter\r\nIf you are not familiar with shape parameters, use the following combination of parameters\r\n```python\r\n{dict_type='gamma',\r\ndict_shape_params={'mean1':  1.1,\r\n'std1': 0.001,\r\n'mean2': 1e5,\r\n'std2': 1e3}\r\n```\r\nor\r\n```python\r\n{dict_type='double_exponential',\r\ndict_shape_params={'mean1': 1e-7, \r\n'std1': 1e-9,\r\n'mean2': 1e-5,\r\n'std2': 1e-7}\r\n```\r\n### Plot setting\r\nOur simulator supports drawing a variety of graphs, including energy, shape, signal and spectrum.\r\n* Energy\uff1aIdeal energy spectrum of the drawn signal source (simulator built-in database)\r\n* Shape\uff1aDraws a dictionary set of all possible signal shapes\r\n* Signal\uff1aWhen the length of the resulting signal is less than 2000, the generated signal is drawn, and when the length is greater than 2000, the first 2000 sampling points are drawn\r\n\r\n\r\nThe default option is not to draw, if you need to draw, you need to change the specified value in the parameter definition to True\r\n```\r\nverbose_plots={'energy':True, 'shapes': True, 'signal': True}\r\n```\r\n## Examples\r\n\r\n```python\r\nfrom gamma_simulator import gamma_simulator\r\nsimulator = gamma_simulator(verbose=True,\r\n                            verbose_plots={'shapes': True, 'signal': True},\r\n                            source={'name': 'Co-60', 'weights': 1},\r\n                            signal_len=1,  # \"analog\" signal of 1 second that are 1e7 samples\r\n                            fs=10e6,\r\n                            lambda_value=1e4,\r\n                            dict_type='double_exponential',\r\n                            dict_shape_params={'mean1': 1e-7,  # continuous-time parameters measured in seconds\r\n                                               'std1': 1e-9,\r\n                                               'mean2': 1e-5,\r\n                                               'std2': 1e-7},\r\n                            noise_unit='std',\r\n                            noise=1e-3,\r\n                            dict_size=10,\r\n                            seed=42)\r\nsignal = simulator.generate_signal()\r\n```\r\n\r\n![result1](./fig/Result_for_example1.png)\r\n\r\n```python\r\nfrom gamma_simulator import gamma_simulator\r\nsimulator = gamma_simulator(verbose=True,\r\n                            verbose_plots={'energy': True, 'signal': True},\r\n                            source={'name': ['Co-60', 'I-125'], 'weights': [1, 2]},\r\n                            signal_len=1,  # \"analog\" signal of 1 second that are 1e7 samples\r\n                            fs=10e6,\r\n                            lambda_value=1e4,\r\n                            dict_type='gamma',\r\n                            dict_shape_params={'mean1':  1.1,  # continuous-time parameters measured in seconds\r\n                                               'std1': 0.001,\r\n                                               'mean2': 1e5,\r\n                                               'std2': 1e3},\r\n                            noise_unit='std',\r\n                            noise=1e-3,\r\n                            dict_size=10,\r\n                            seed=42)\r\nsignal = simulator.generate_signal()\r\n```\r\n\r\n![result2](./fig/Result_for_example2.png)\r\n\r\n# version\r\n1.0.1 upload to pypi\r\n\r\n1.0.2 add license and install_requires\r\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "a gamma simulator",
    "version": "1.0.3",
    "project_urls": null,
    "split_keywords": [
        "python",
        "gamma",
        "pulse",
        "simulate"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "20cf40ef07f310b1b25531de14d47350a114083024f20a361cb5c0c828404266",
                "md5": "2badd4acde0b01d6878eeba6b4b27d31",
                "sha256": "05f8ed7a701691c9c475054e431845a574e65221a8d71fd2984f6d617b3dcbbd"
            },
            "downloads": -1,
            "filename": "gasimulator-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "2badd4acde0b01d6878eeba6b4b27d31",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 14917,
            "upload_time": "2024-02-29T10:22:54",
            "upload_time_iso_8601": "2024-02-29T10:22:54.313188Z",
            "url": "https://files.pythonhosted.org/packages/20/cf/40ef07f310b1b25531de14d47350a114083024f20a361cb5c0c828404266/gasimulator-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-29 10:22:54",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "gasimulator"
}
        
Elapsed time: 0.19766s