How to use the gwpy.version.version function in gwpy

To help you get started, we’ve selected a few gwpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gwpy / gwpy / gwpy / sources / transient.py View on Github external
# You should have received a copy of the GNU General Public License
# along with GWpy.  If not, see .

"""Representation of a transient GW source
"""

from astropy import units as aunits

from .. import (version, detector)
from ..time import Time
from ..data import Series

from .core import (Source, SourceList)

__author__ = "Duncan Macleod "
__version__ = version.version

class TransientSource(Source):
    """Generic short-duration (transient) source object.
        
    This class is designed to be sub-classed for specific sources
    """
    def __init__(self, time=None, coordinates=None, ra=None, dec=None):
        if time is not None:
            if not isinstance(time, Time):
                time = Time(time, format='gps')
            self.time = time
        if coordinates:
            if ra is not None or dec is not None:
                 raise ValueError("'ra' and/or 'dec' should not be given if "
                                  "'coordinates' is given, and vice-versa.")
            self.coordinates = coordinates
github gwpy / gwpy / bin / gwpy-ldvw.py View on Github external
# (at your option) any later version.
#
# GWpy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GWpy.  If not, see .
#
"""Command line interface to GWpy plotting functions
"""
from gwpy import version
__author__ = 'joseph areeda'
__email__ = 'joseph.areeda@ligo.org'
__version__ = version.version

VERBOSE = 3 # 0 = errors only, 1 = Warnings, 2 = INFO, >2 DEBUG >=5 ALL

# each Product calls a function in this file to instantiate the objject that creates the plot
def coherence(args):
    if VERBOSE > 1:
        print 'coherence called'
    from gwpy.cli.coherence import Coherence

    plotObj = Coherence()
    plotObj.makePlot(args)
    return

def timeseries(args):
    if VERBOSE > 1:
        print 'timeseries called'
github gwpy / gwpy / gwpy / spectrum / psd.py View on Github external
Each of these methods utilises an existing method provided by the
LIGO Algorithm Library, wrapped into python as part of the `lal.spectrum`
module.
"""

import numpy
from matplotlib import mlab
from scipy import signal

from astropy import units

from .core import Spectrum

from .. import version
__author__ = "Duncan Macleod "
__version__ = version.version

__all__ = ['bartlett', 'welch', 'median_mean', 'median', 'spectrogram']

# cache windows internally
LAL_WINDOWS = {}
LAL_FFTPLANS = {}
LAL_FFTPLAN_LEVEL = 1


def bartlett(timeseries, segmentlength, window=None, plan=None):
    """Calculate the power spectral density of the given `TimeSeries`
    using the Bartlett average method.

    This method divides the data into chunks of length `segmentlength`,
    a periodogram calculated for each, and the bin-by-bin mean returned.
github gwpy / gwpy / gwpy / io / ligolw / connect.py View on Github external
"""Test converter for LIGO_LW tables to ATpy
"""

import re
import numpy

from glue.ligolw import (utils as ligolw_utils, table as ligolw_table,
                         lsctables)

from astropy.table import Table
from astropy.io import registry

from ... import version

__author__ = "Duncan Macleod "
__version__ = version.version

def read_ligolw(filepath, table_name, columns=None):
    from . import utils
    # read table into GLUE LIGO_LW
    if columns:
        TableType = lsctables.TableByName[table_name]
        _oldcols = TableType.loadcolumns
        TableType.loadcolumns = columns
    if isinstance(filepath, basestring):
        xmldoc = ligolw_utils.load_filename(filepath)
    else:
        xmldoc,_ = ligolw_utils.load_fileobj(filepath)
    out = ligolw_table.get_table(xmldoc, table_name)
    if columns:
        TableType.loadcolumns = _oldcols
    return utils.to_table(out, columns=columns)
github gwpy / gwpy / gwpy / io / auth.py View on Github external
"""This module provides LIGO.ORG authenticated HTML queries
"""

import os
import sys
import stat
import urllib2
import cookielib
import warnings

from glue.auth.saml import HTTPNegotiateAuthHandler

from .. import version

__author__ = "Duncan Macleod "
__version__ = version.version

COOKIE_JAR = '/tmp/%s_cookies' % os.getenv('USER')
LIGO_LOGIN_URL = 'login.ligo.org'

def request(url, debug=False):
    """Request the given URL using LIGO.ORG SAML authentication.

    This requires an active Kerberos ticket for the user, to get one:

    >>> kinit albert.einstein@LIGO.ORG

    Parameters
    ----------
    url : `str`
        URL path for request
    debug : `bool`, optional
github gwpy / gwpy / gwpy / sources / core.py View on Github external
#
# GWpy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GWpy.  If not, see .

"""This core module provides basic Source and SourceList types
designed to be sub-classes for specific sources
"""

from .. import version
__author__ = "Duncan Macleod "
__version__ = version.version


class Source(object):
    """Generic gravitational-wave source object.

    This class is designed to be sub-classed for specific sources
    """
    pass


class SourceList(list):
    """Generic gravitational-wave source list.

    This class is designed to be sub-classed for specific sources
    """
    def __isub__(self, other):
github gwpy / gwpy / gwpy / sources / grb.py View on Github external
# along with GWpy.  If not, see .

"""Representation of the gamma-ray burst
"""

from math import log10
from scipy import stats

from astropy import units as aunits, coordinates as acoords

from .. import (time, version, detector)

from .transient import (TransientSource, TransientSourceList)

__author__ = "Duncan Macleod "
__version__ = version.version

# long/short GRB distributions (log t90)  source: astro-ph/0205004
SHORT_GRB_DIST = stats.norm(scale=0.61, loc=-0.11)
LONG_GRB_DIST = stats.norm(scale=0.43, loc=1.54)


class GammaRayBurst(TransientSource):
    __slots__ = ['name', 'detector', 'time', 'coordinates',
                 'error', 'distance', 't90', 't1', 't2', 'fluence', 'url',
                 'trig_id']

    @classmethod
    def query(cls, name, detector=None, source='grbview'):
        grbs = GammaRayBurstList(name, detector=detector, source=source)
        if len(grbs) > 1:
            raise ValueError("Multiple records found for this GRB name."
github gwpy / gwpy / gwpy / data / nddata.py View on Github external
# along with GWpy.  If not, see .

"""This module provides an extension to the NDData class from astropy
with dynamic access to metadata as class attributes
"""

import numpy

from astropy.nddata import NDData as AstroData
from astropy.units import Quantity
from astropy.io import registry as io_registry

from .. import version

__author__ = "Duncan Macleod "
__version__ = version.version


class NDData(AstroData):
    """A subclass of the numpy array with added metadata access
    """
    def __init__(self, data, name=None, **kwargs):
        kwargs.setdefault('mask', None)
        super(NDData, self).__init__(numpy.asarray(data), **kwargs)
        if isinstance(data, self.__class__):
            name = name or data.name
        self.name = name

    def copy(self):
        """Make a copy of this series

        Returns
github gwpy / gwpy / gwpy / plotter / layer.py View on Github external
"""Layers for GWpy Plot objects

Each layer represents a data set added to a plot, e.g. a line or some
scatter points. The LayerCollection is attached to the plot to allow
recording and extraction of individual layers in complex plots.
"""

from .. import version
__author__ = "Duncan Macleod "
__version__ = version.version

from matplotlib.lines import Line2D
from matplotlib.collections import Collection
from matplotlib.image import AxesImage

try:
    from collections import OrderedDict
except ImportError:
    from astropy.utils import OrderedDict


class LayerCollection(OrderedDict):
    """Object recording the plotting layers on a figure
    """
    LAYER_TYPES = [Line2D.__class__.__name__, Collection.__class__.__name__,
                   AxesImage.__class__.__name__]
github gwpy / gwpy / gwpy / io / nds.py View on Github external
"""Wrapper to the nds2-client package, providing network access
to LIGO data.
"""


from math import (floor, ceil)

import nds2

from .. import (version, detector)
from ..detector import Channel
from ..time import Time
from ..timeseries import TimeSeries

__author__ = "Duncan Macleod "
__version__ = version.version


try:
    from collections import OrderedDict
except ImportError:
    from astropy.utils import OrderedDict
finally:
    DEFAULT_HOSTS = OrderedDict([
                    (None,('nds.ligo.caltech.edu', 31200)),
                    (detector.LHO_4k.prefix,('nds.ligo-wa.caltech.edu', 31200)),
                    (detector.LLO_4k.prefix,('nds.ligo-la.caltech.edu', 31200)),
                    (detector.CIT_40.prefix,('nds40.ligo.caltech.edu', 31200))])


class NDSConnection(object):