Newer
Older
[](https://git.ligo.org/gwinc/pygwinc/commits/master)

This is a collection of mostly analytic noise calculations (e.g. quantum, thermal)
## basic usage
`pygwinc` creates noise budgets based on detector descriptions
provided in either .yml or .mat files (see below). Once the detector
description is loaded, the noise budget can be calculated and plotted:
```python
>>> import gwinc
>>> import numpy as np
>>> freq = np.logspace(1, 3, 1000)
>>> Budget, ifo, freq_, plot_style = gwinc.load_ifo('aLIGO')
>>> ifo = gwinc.precompIFO(freq, ifo)
>>> traces = Budget(freq, ifo=ifo).calc_trace()
>>> fig = gwinc.plot_noise(freq, traces, **plot_style)
>>> fig.show()
## command line interface
You can make gwinc plots directly from the command line by executing
the package directly:
```shell
`pygwinc` can load detector descriptions in different formats: the new
YAML .yaml format, the original MATLAB gwinc .mat format, or even from
a MATLAB .m file. `pygwinc` includes .yaml detector descriptions for
various detectors:
* [aLIGO.yaml](https://git.ligo.org/gwinc/pygwinc/blob/master/gwinc/ifo/aLIGO.yaml)
* [A+.yaml](https://git.ligo.org/gwinc/pygwinc/blob/master/gwinc/ifo/A+.yaml)
* [Voyager.yaml](https://git.ligo.org/gwinc/pygwinc/blob/master/gwinc/ifo/Voyager.yaml)
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
## noise budgets
GWINC provides an `nb` package for defining arbitrary noise budgets:
```python
import numpy as np
from gwinc import nb
from gwinc import noise
class ExcessGas(nb.Noise):
"""Excess gas"""
style = dict(
label='Excess Gas',
color='#ad900d',
linestyle='--',
)
def calc(self):
return noise.residualgas.gas(self.freq, self.ifo)
class MeasuredNoise(nb.Noise):
"""My measured noise"""
style = dict(
label='Measured Noise,
color='#838209,
linestyle='-',
)
def load(self):
psd, freq = np.loadtxt('/path/to/measured/psd.txt')
self.data = self.interpolate(f, psd)
def calc(self):
return self.data
class MyBudget(nb.Budget):
noises = [
ExcessGas,
MeasuredNoise,
]
```
## comparison with MATLAB gwinc
`pygwinc` includes the ability use MATLAB gwinc directly via the
MATLAB python interface (see the CLI '--matlab' option above). This
also allows for easy direct comparison between the pygwinc and
matgwinc noise budgets.
If you have a local checkout of matgwinc (at e.g. /path/to/gwinc) and
a local installation of MATLAB and it's python interface (at
e.g. /opt/matlab/python/lib/python3.6/site-packages) you can run the
comparison as so:
```shell
$ export GWINCPATH=/path/to/matgwinc
$ export PYTHONPATH=/opt/matlab/python/lib/python3.6/site-packages
$ python3 -m gwinc.test -p aLIGO
```
This will produce a summary page of the various noise spectra that
differ between matgwinc and pygwinc.
Latest comparison plots from continuous integration:
* [aLIGO comparison](https://gwinc.docs.ligo.org/pygwinc/aLIGO_test.png)
* [A+ comparison](https://gwinc.docs.ligo.org/pygwinc/A+_test.png)