diff --git a/.gitignore b/.gitignore index 011364833a6dbe9b8c88fd93640d331e547b5141..a36b468f5f401bd9243526b447bb5984734418d6 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ __pycache__/ # Backups *~ +MANIFEST + diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000000000000000000000000000000000000..701f7ec65ae5ae19435971d32221d9ad71bb1611 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,13 @@ +include LICENSE +include README.md +include DISTRIBUTION-README.md +include MANIFEST.in +include setup.cfg +include setup.py +include tox.ini +include CONTRIBUTIONS.md + +recursive-include *.py +recursive-include gwinc *.py +recursive-include matlab *.m +recursive-include docs * diff --git a/README.md b/README.md index 521bade2954165ab2f79d2e8ad92da7445e7a2b2..dbd865860ab5f1b036fcb99c9d9015c92fc7ab38 100644 --- a/README.md +++ b/README.md @@ -9,18 +9,19 @@ `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 with the -`gwinc` command: +description is loaded, the noise budget can be calculated and plotted: ```python >>> import gwinc >>> import numpy as np ->>> ifo = gwinc.load_ifo('aLIGO') >>> freq = np.logspace(1, 3, 1000) ->>> score, data, ifo = gwinc.gwinc(freq, ifo) +>>> ifo = gwinc.load_ifo('aLIGO') +>>> ifo = gwinc.precompIFO(ifo) +>>> noises = gwinc.noise_calc(ifo, freq) +>>> gwinc.plot_noise(ifo, noises) ``` -A convenience function to plot the resulting noise budget is included: +Or the `gwinc` convenience function can be used to handle it all: ``` ->>> gwinc.plot_noise(data) +>>> score, data, ifo = gwinc.gwinc(freq, ifo, plot=True) ``` @@ -71,9 +72,9 @@ YAML .yaml format, the original MATLAB gwinc .mat format, or even from a MATLAB .m file. `pygwinc` includes .yaml detector descriptions for various detectors: - * gwinc/ifo/aLIGO.yaml - * gwinc/ifo/A+.yaml - * gwinc/ifo/Voyager.yaml +* [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) ## comparison with MATLAB gwinc @@ -88,7 +89,14 @@ 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: - $ GWINCPATH=/path/to/gwinc PYTHONPATH=/opt/matlab/python/lib/python3.6/site-packages python3 -m gwinc.test -p aLIGO + $ export GWINCPATH=/path/to/gwinc + $ 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) diff --git a/gwinc/gwinc.py b/gwinc/gwinc.py index e4af794af0db9e041669d7cc89156dbc181f7f98..9227f05321180f034310e3f4e0deb607e5180dc6 100644 --- a/gwinc/gwinc.py +++ b/gwinc/gwinc.py @@ -106,7 +106,7 @@ def noise_calc(ifo, f): return noises -def gwinc(freq, ifoin, source=None, fig=False, PRfixed=True): +def gwinc(freq, ifoin, source=None, plot=False, PRfixed=True): """Calculate strain noise budget for a specified interferometer model. Argument `freq` is the frequency array for which the noises will @@ -117,7 +117,7 @@ def gwinc(freq, ifoin, source=None, fig=False, PRfixed=True): the detector to several potential gravitational wave sources. - If `fig` is specified a plot of the budget will be created. + If `plot` is True a plot of the budget will be created. Returns tuple of (score, noises, ifo) @@ -146,7 +146,7 @@ def gwinc(freq, ifoin, source=None, fig=False, PRfixed=True): # -------------------------------------------------------- # output graphics - if fig: + if plot: # Report input parameters if ifo.Optics.Type == 'DualCarrier_new': #include the case for Dual carrier finesseA = 2*pi/ifo.Optics.ITM.TransmittanceD1 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f575ad345646ced79e7558cde67308de6e282b63 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,13 @@ +[bdist_wheel] +# This flag says that the code is written to work on both Python 2 and Python +# 3. If at all possible, it is good practice to do this. If you cannot, you +# will need to generate wheels for each Python version that you support. +universal=1 + +[aliases] +test=pytest + +[metadata] +description-file = README.rst + + diff --git a/setup.py b/setup.py new file mode 100755 index 0000000000000000000000000000000000000000..b210b4b2b1c25b1ce4ce5bbfecb8471771e5b504 --- /dev/null +++ b/setup.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +from __future__ import division, print_function, unicode_literals +from setuptools import find_packages, setup + + +version = '0.9.5' + + +setup_args = dict( + name = 'GWINC', + version = version, + url = 'https://git.ligo.org/gwinc/pygwinc', + author = 'LIGO Laboratory', + author_email = 'jrollins@ligo.caltech.edu ', + description = "Gravitation Wave Interferometer Noise Calculator", + license = 'Copyright 2017 LIGO Laboratory', + install_requires = [ + 'numpy', + 'scipy', + 'matplotlib', + ], + packages = find_packages( + exclude = ['docs',], + ), + include_package_data = True, + zip_safe = True, + keywords = 'Noise, LIGO, Gravitational Wave,', + classifiers=[ + 'Topic :: Scientific/Engineering', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + ], +) + +if __name__ == "__main__": + setup(**setup_args) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..c227884c0e80908cf5cca9992c113a7bdc5ce171 --- /dev/null +++ b/tox.ini @@ -0,0 +1,22 @@ +# content of: tox.ini , put in same dir as setup.py +[tox] +envlist = + py35 + py36 + py27 + py34 + +[testenv] +setenv = + PYTHONPATH = '' +deps = + pytest + pytest-xdist + pytest-benchmark + matplotlib + numpy + scipy +commands=python -m gwinc.test +pip_pre=True + +