# Path: gwsumm/data/spectral.py
# @use_segmentlist
# def get_spectrum(channel, segments, config=None, cache=None,
#                  query=True, nds=None, format='power', return_=True,
#                  frametype=None, nproc=1, datafind_error='raise',
#                  **fftparams):
#     """Retrieve the time-series and generate a spectrogram of the given
#     channel
#     """
#     channel = get_channel(channel)
#     if isinstance(segments, DataQualityFlag):
#         name = ','.join([channel.ndsname, segments.name])
#         segments = segments.active
#     else:
#         name = channel.ndsname
#     name += ',%s' % format
# 
#     # read data for all sub-channels
#     specs = []
#     channels = list(parse_math_definition(str(channel))[0])
#     if len(channels) == 0:
#         channels = [channel]
#     for c in channels:
#         specs.append(_get_spectrum(c, segments, config=config, cache=cache,
#                                    query=query, nds=nds, format=format,
#                                    return_=return_, frametype=frametype,
#                                    nproc=nproc,
#                                    datafind_error=datafind_error,
#                                    **fftparams))
#     if return_ and len(channels) == 1:
#         return specs[0]
#     elif return_:
#         return [get_with_math(
#                     channel, segments, _get_spectrum, _get_spectrum,
#                     config=config, format=format, return_=True,
#                     which=which)[0] for which in ['mean', 'min', 'max']]


import re
import numpy
from gwpy.segments import SegmentList
from gwdetchar.plot import texify
from ..data import get_spectrum
from .registry import (get_plot, register_plot)
        """Load all data, and generate this `SpectrumDataPlot`
        """
        plot = self.init_plot()
        ax = plot.gca()
        ax.grid(b=True, axis='both', which='both')

        if self.state:
            self.pargs.setdefault(
                'suptitle',
                '[%s-%s, state: %s]' % (self.span[0], self.span[1],
                                        texify(str(self.state))))
        suptitle = self.pargs.pop('suptitle', None)
        if suptitle:
            plot.suptitle(suptitle, y=0.993, va='top')

        # get spectrum format: 'amplitude' or 'power'
        sdform = self.pargs.pop('format')

        # parse plotting arguments
        plotargs = self.parse_plot_kwargs()
        legendargs = self.parse_legend_kwargs()

        # add data
        sumdata = []
        for i, (channel, pargs) in enumerate(zip(self.channels, plotargs)):
            if self.state and not self.all_data:
                valid = self.state
            else:
                valid = SegmentList([self.span])


# Path: gwsumm/data/spectral.py
# @use_segmentlist
# def get_spectrum(channel, segments, config=None, cache=None,
#                  query=True, nds=None, format='power', return_=True,
#                  frametype=None, nproc=1, datafind_error='raise',
#                  **fftparams):
#     """Retrieve the time-series and generate a spectrogram of the given
#     channel
#     """
#     channel = get_channel(channel)
#     if isinstance(segments, DataQualityFlag):
#         name = ','.join([channel.ndsname, segments.name])
#         segments = segments.active
#     else:
#         name = channel.ndsname
#     name += ',%s' % format
# 
#     # read data for all sub-channels
#     specs = []
#     channels = list(parse_math_definition(str(channel))[0])
#     if len(channels) == 0:
#         channels = [channel]
#     for c in channels:
#         specs.append(_get_spectrum(c, segments, config=config, cache=cache,
#                                    query=query, nds=nds, format=format,
#                                    return_=return_, frametype=frametype,
#                                    nproc=nproc,
#                                    datafind_error=datafind_error,
#                                    **fftparams))
#     if return_ and len(channels) == 1:
#         return specs[0]
#     elif return_:
#         return [get_with_math(
#                     channel, segments, _get_spectrum, _get_spectrum,
#                     config=config, format=format, return_=True,
#                     which=which)[0] for which in ['mean', 'min', 'max']]


# Path: gwsumm/plot/noisebudget.py
import re
import numpy
from gwpy.segments import SegmentList
from gwdetchar.plot import texify
from ..data import get_spectrum
from .registry import (get_plot, register_plot)

        """Load all data, and generate this `SpectrumDataPlot`
        """
        plot = self.init_plot()
        ax = plot.gca()
        ax.grid(b=True, axis='both', which='both')

        if self.state:
            self.pargs.setdefault(
                'suptitle',
                '[%s-%s, state: %s]' % (self.span[0], self.span[1],
                                        texify(str(self.state))))
        suptitle = self.pargs.pop('suptitle', None)
        if suptitle:
            plot.suptitle(suptitle, y=0.993, va='top')

        # get spectrum format: 'amplitude' or 'power'
        sdform = self.pargs.pop('format')

        # parse plotting arguments
        plotargs = self.parse_plot_kwargs()
        legendargs = self.parse_legend_kwargs()

        # add data
        sumdata = []
        for i, (channel, pargs) in enumerate(zip(self.channels, plotargs)):
            if self.state and not self.all_data:
                valid = self.state
            else:
                valid = SegmentList([self.span])


            data = get_spectrum(str(channel), valid, query=False,