Skip to content
Snippets Groups Projects
Forked from gwinc / pygwinc
436 commits behind the upstream repository.
user avatar
Jameson Graef Rollins authored
This patch provides a new nb sub-module that defines classes for managing
and calculating noise budgets.  It provides the following overridable
classes:

nb.Calibration  A noise calibration
nb.Noise        A noise source
nb.Budget       A budget of noises

The Budget class includes a calc_trace() method that will return a traces
dictionary that includes data and trace plot styling for every noise term
in the budget recursively.

The existing included interferometers are updated to define their budgets
using this new interface, and the plot_noises function is updated to
accept the new traces dictionary.

An HDF5_SCHEMA describes how trace dictionaries are encoded into HDF5 files.
The new io module includes functions for writing traces to HDF5 files, and
for reading traces stored in this format.

The command line interface is updated to handle this new structure.
39d430dd
History

pipeline status

Python port of GW Interferometer Noise Calculator

gwinc

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:

>>> 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:

$ python3 -m gwinc aLIGO

detector description files

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:

noise budgets

GWINC provides an nb package for defining arbitrary noise budgets:

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:

$ 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: