Package pylal :: Package dq :: Module dqPlotUtils
[hide private]
[frames] | no frames]

Module dqPlotUtils

source code


Author: Duncan Macleod <duncan.macleod@astro.cf.ac.uk>

Classes [hide private]
  PlotSegmentsPlot
Horizontal bar segment plot.
  ScatterPlot
A simple scatter plot, taking x- and y-axis data.
  ColorbarScatterPlot
A scatter plot of x- versus y-data, coloured by z-data.
  DetCharScatterPlot
A 'DetChar' style scatter plot, whereby those triggers under a threshold on the colour column are plotted much smaller than others, allowing line features to be shown easily.
  LineHistogram
A simple line histogram plot.
  VerticalBarHistogram
  DataPlot
Time-series data plot.
  ColorMap
  SkyPositionsPlot
Plot of sky positions plotted onto mpl_toolkits basemap projection.
  ColorbarSkyPositionsPlot
Functions [hide private]
 
set_rcParams()
Customise the figure parameters.
source code
 
set_ticks(ax, calendar_time=False)
Format the x- and y-axis ticks to ensure minor ticks appear when needed and the x-axis is set for spaces of 4 rather than 5.
source code
 
display_name(columnName)
Format the string columnName (e.g.
source code
 
gps2datenum(gpstime)
Convert GPS time into floating in standard python time format (days since Jan 01 0000), don't seem to use properly leap seconds
source code
 
calendar_time_unit(duration) source code
 
time_unit(duration)
Work out renormalisation for the time axis, makes the label more appropriate.
source code
 
getTrigAttribute(trig, col)
Returns the value of trig.col or trig.get_col() for the given string col, and the object trig.
source code
 
add_colorbar(self, mappable, cax=None, clim=None, log=False, base=10, label=None, **kwargs) source code
 
add_hidden_colorbar(self) source code
 
plot_data_series(data, outfile, x_format='time', zero=None, zeroindicator=False, **kwargs)
Plot the time series / spectrum of a given set (or given sets) of data.
source code
 
plot_trigger_hist(triggers, outfile, column='snr', num_bins=1000, color_column=None, color_bins=10, seglist=None, flag='unknown', start=None, end=None, livetime=None, etg=None, **kwargs)
Wrapper for dqPlotUtils.LineHistogram to plot a histogram of the value in any column of the ligolw table triggers.
source code
 
plot_triggers(triggers, outfile, reftriggers=None, xcolumn='time', ycolumn='snr', zcolumn=None, rankcolumn=None, etg=None, start=None, end=None, zero=None, seglist=None, flag=None, **kwargs)
Plots ycolumn against xcolumn for columns in given Sngl{Burst,Inspiral}Table object triggers, coloured by the zcolumn highlighting those entries falling inside one of the entries in the glue.segments.segmentlist object segments, if given.
source code
 
plot_segment_hist(segs, outfile, keys=None, num_bins=100, coltype=int, **kwargs)
segments.
source code
 
plot_trigger_rate(triggers, outfile, average=600, start=None, end=None, zero=None, bincolumn='peak_frequency', bins=[], etg='Unknown', **kwargs)
Plot rate versus time for the given ligolw table triggers, binned by the given bincolumn using the bins list.
source code
 
plot_trigger_rms(triggers, outfile, average=600, start=None, end=None, zero=None, rmscolumn='snr', bincolumn='peak_frequency', bins=[], etg='Unknown', **kwargs)
Plot RMS versus time for the given ligolw table triggers, binned by the given bincolumn using the bins list.
source code
 
plot_segments(segdict, outfile, start=None, end=None, zero=None, keys=None, highlight_segments=None, **kwargs)
Plot the segments contained within the glue.segments.segmentlistdict segdict to the given path string outfile.
source code
 
parse_plot_config(cp, section)
Parse ConfigParser.ConfigParser section for plot parameters.
source code
 
plot_color_map(data, outfile, data_limits=None, x_format='time', y_format='frequency', z_format='amplitude', zero=None, x_range=None, y_range=None, **kwargs)
Plots data in a 2d color map.
source code
 
plot_significance_drop(startsig, endsig, outfile, **kwargs)
Plot significance drop for each channel relative to the application of HVeto round veto segments.
source code
 
plot_sky_positions(skyTable, outfile, format='radians', zcolumn=None, projection=None, centre=None, detectors=[], lines={}, range=[(0,0),(1,1)], **kwargs)
Plot latitude against longitude for the given ligolw table skyTable into the given outfile.
source code
Variables [hide private]
  _display = getenv('DISPLAY', '')
  _backend_warn = """No display detected, moving to 'Agg' backen...
  __date__ = git_version.date
This module provides plotting routines for use in data quality investigations.
Function Details [hide private]

set_ticks(ax, calendar_time=False)

source code 

Format the x- and y-axis ticks to ensure minor ticks appear when needed
and the x-axis is set for spaces of 4 rather than 5.

Arguments:

  ax : matplotlib.axes.AxesSubplot
    Axes object to format

display_name(columnName)

source code 

Format the string columnName (e.g. xml table column) into latex format for 
an axis label.

Examples:

>>> display_name('snr')
'SNR'

>>> display_name('bank_chisq_dof')
'Bank $\chi^2$ DOF'

Arguments:

  columnName : string
    string to format

time_unit(duration)

source code 

Work out renormalisation for the time axis, makes the label more
appropriate. Returns unit (in seconds) and string descriptor

Example:

>>> time_unit(100)
(1, 'seconds')

>>> time_unit(604800)
(86400, 'days')

Arguments:

  duration : float
    plot duration to normalise

getTrigAttribute(trig, col)

source code 

Returns the value of trig.col or trig.get_col() for the given string col,
and the object trig. If col='time' is given, trig.get_peak() is returned for
*Burst* objects, trig.get_end() for *Inspiral* objects and trig.get_start()
for *Ringdown* objects. Raises KeyError if cannot execute.

Arguments:

  trig : [ lsctables.SnglBurst | lscatbles.SnglInspiral |
           lsctables.SnglRingdown ]
    xml table entry from which to extract parameter
  col : string
    glue.ligolw.table column name to extract

plot_data_series(data, outfile, x_format='time', zero=None, zeroindicator=False, **kwargs)

source code 

Plot the time series / spectrum of a given set (or given sets) of data.

Arguments:

  data : list
    list of (ChannelName,x_data,y_data) tuples with channel name (or data 
    source) and time/freq, amplitude arrays for each channel. Channels are
    plotted in the order given.
  outfile : str
    output plot path

Keyword Arguments:

  x_format : [ 'time' | 'frequency' ]
    type of data for x_axis, allows formatting of axes
  zero : [ float | int | LIGOTimeGPS ]
    time around which to centre time series plot
  zeroindicator : [ False | True ]
    indicate zero time with veritcal dashed line, default: False

Unnamed keyword arguments:

  logx : [ True | False ]
    boolean option to display x-axis in log scale.
  logy : [ True | False ]
    boolean option to display y-axis in log scale.
  xlim : tuple
    (xmin, xmax) limits for x-axis
  ylim : tuple
    (ymin, ymax) limits for y-axis
  xlabel : string
    label for x-axis
  ylabel : string
    label for y-axis
  title : string
    title for plot
  subtitle : string
    subtitle for plot

All other given arguments will be passed to matplotlib.axes.Axes.plot.

plot_trigger_hist(triggers, outfile, column='snr', num_bins=1000, color_column=None, color_bins=10, seglist=None, flag='unknown', start=None, end=None, livetime=None, etg=None, **kwargs)

source code 

Wrapper for dqPlotUtils.LineHistogram to plot a histogram of the value in
any column of the ligolw table triggers. If a glue.segments.segmentlist
seglist is given, the histogram is presented before and after removal of
triggers falling inside any segment in the list.

Arguments:

  triggers : glue.ligolw.table.Table
    ligolw table containing triggers
  outfile : string
    string path for output plot

Keyword arguments:

  column : string
    valid column of triggers table to plot as histrogram
  num_bins : int
    number of histogram bins to use
  seglist : glue.segments.segmentlist
    list of segments with which to veto triggers
  flag : string
    display name of segmentlist, normally the name of the DQ flag
  start : [ float | int | LIGOTimeGPS]
    GPS start time (exclude triggers and segments before this time)
  end : [ float | int | LIGOTimeGPS]
    GPS end time (exclude triggers and segments after this time)
  livetime : [ float | int | LIGOTimeGPS ]
    span of time from which triggers and segments are valid, used to
    display histogram counts in terms of rate (Hz) for easy comparisons
  etg : string
    display name of trigger generator, defaults based on triggers tableName

Unnamed keyword arguments:

  cumulative : [ True | False ]
    plot cumulative histogram
  rate : [ True | False ]
    plot rate histogram (normalises with given or calculated livetime)
  fill : [ True | False ]
    fill below the histogram curves, default colors:
        red (vetoed), green (not vetoed).
  logx : [ True | False ]
    boolean option to display x-axis in log scale.
  logy : [ True | False ]
    boolean option to display y-axis in log scale.
  xlim : tuple
    (xmin, xmax) limits for x-axis
  ylim : tuple
    (ymin, ymax) limits for y-axis
  xlabel : string
    label for x-axis
  ylabel : string
    label for y-axis
  title : string
    title for plot
  subtitle : string
    subtitle for plot
  greyscale : [ True | False ]
    use (non-greyscale) colour scheme suitable for greyscale plots

All other given arguments will be passed to matplotlib.axes.Axes.plot and
matplotlib.axes.Axes.fill_between. 

plot_triggers(triggers, outfile, reftriggers=None, xcolumn='time', ycolumn='snr', zcolumn=None, rankcolumn=None, etg=None, start=None, end=None, zero=None, seglist=None, flag=None, **kwargs)

source code 

Plots ycolumn against xcolumn for columns in given
Sngl{Burst,Inspiral}Table object triggers, coloured by the zcolumn
highlighting those entries falling inside one of the entries in the
glue.segments.segmentlist object segments, if given. 

'time' given as a column name is a special case, since s and ns times are
stored separately in the SnglTable structures. In this case the
trigger.get_xxxx() function is called.

Arguments:

  triggers : glue.ligolw.table.Table
    ligolw table containing triggers
  outfile : string
    string path for output plot

Keyword arguments:

  xcolumn : string
    valid column of triggers table to plot on x-axis
  ycolumn : string
    valid column of triggers table to plot on y-axis
  zcolumn : string
    valid column of triggers table to use for colorbar (optional).
  rankcolumn : string
    valid column of triggers table to use for ranking events (optional).
  etg : string
    display name of trigger generator, defaults based on triggers tableName 
  start : [ float | int | LIGOTimeGPS ]
    GPS start time of plot
  end : [ float | int | LIGOTimeGPS ]
    GPS end time of plot
  zero : [ float | int | LIGOTimeGPS ]
    time around which to centre plot
  seglist : glue.segments.segmentlist
    list of segments with which to veto triggers
  flag : string
    display name of segmentlist, normally the name of the DQ flag

Unnamed keyword arguments:

  detchar : [ True | False ]
    use 'DetChar' style for scatter plot with colorbar, triggers below given
    dcthreshold are small with no edges, whilst other triggers are normal
  dcthreshold : float
    threshold below which scatter points are small with no edges when using
    DetChar plotting style
  logx : [ True | False ]
    boolean option to display x-axis in log scale.
  logy : [ True | False ]
    boolean option to display y-axis in log scale.
  logz : [ True | False ]
    boolean option to display z-axis in log scale.
  xlim : tuple
    (xmin, xmax) limits for x-axis. Triggers outside range are removed.
  ylim : tuple
    (ymin, ymax) limits for y-axis. Triggers outside range are removed.
  zlim : tuple
    (zmin, zmax) limits for z-axis. Triggers outside range are removed.
  clim : tuple
    (cmin, cmax) limits for color scale. Triggers outside range are moved
    onto boundary.
  xlabel : string
    label for x-axis
  ylabel : string
    label for y-axis
  zlabel : string
    label for z-axis
  title : string
    title for plot
  subtitle : string
    subtitle for plot
  greyscale : [ True | False ]
    use (non-greyscale) colour scheme suitable for greyscale plots

All other given arguments will be passed to matplotlib.axes.Axes.scatter. 

plot_segment_hist(segs, outfile, keys=None, num_bins=100, coltype=int, **kwargs)

source code 

segments.
Plots a histogram of segment duration for the glue.segments.segmentlist

Arguments:

  segs : [ glue.segments.segmentlist | glue.segments.segmentlistdict ]
    list of segments with which to veto triggers, use dict for multiple
    datasets
  outfile : string 
    string path for output plot

Keyword arguments:

  flag : string
    display name for segments, normally the name of the DQ flag
  logx : [ True | False ]
    boolean option to display x-axis in log scale.
  logy : [ True | False ]
    boolean option to display y-axis in log scale.

plot_trigger_rate(triggers, outfile, average=600, start=None, end=None, zero=None, bincolumn='peak_frequency', bins=[], etg='Unknown', **kwargs)

source code 

Plot rate versus time for the given ligolw table triggers, binned by the
given bincolumn using the bins list.

Arguments:

  triggers : glue.ligolw.table
    LIGOLW table containing a list of triggers
  outfile : string
    string path for output plot

Keyword arguments:

  average : float
    Length (seconds) of rate segment
  start : [ float | int | LIGOTimeGPS ]
    GPS start time
  end : [ float | int | LIGOTimeGPS ]
    GPS end time
  zero : [ float | int | LIGOTimeGPS ]
    GPS time to use for 0 on time axis
  bincolumn : string
    valid column of the trigger table to use for binning
  bins : list
    list of tuples defining the rate bins
  etg : string
    display name of trigger generator
  logy : [ True | False ]
    boolean option to display y-axis in log scale
  ylim : tuple
    (ymin, ymax) limits for rate axis

plot_trigger_rms(triggers, outfile, average=600, start=None, end=None, zero=None, rmscolumn='snr', bincolumn='peak_frequency', bins=[], etg='Unknown', **kwargs)

source code 

Plot RMS versus time for the given ligolw table triggers, binned by the
given bincolumn using the bins list.

Arguments:

  triggers : glue.ligolw.table
    LIGOLW table containing a list of triggers
  outfile : string
    string path for output plot

Keyword arguments:

  average : float
    Length (seconds) of RMS segment
  start : [ float | int | LIGOTimeGPS ]
    GPS start time
  end : [ float | int | LIGOTimeGPS ]
    GPS end time
  zero : [ float | int | LIGOTimeGPS ]
    GPS time to use for 0 on time axis
  rmscolumn : string
    valid column of the trigger table to RMS over
  bincolumn : string
    valid column of the trigger table to use for binning
  bins : list
    list of tuples defining the rate bins
  etg : string
    display name of trigger generator
  logy : [ True | False ]
    boolean option to display y-axis in log scale
  ylim : tuple
    (ymin, ymax) limits for rate axis

plot_segments(segdict, outfile, start=None, end=None, zero=None, keys=None, highlight_segments=None, **kwargs)

source code 

Plot the segments contained within the glue.segments.segmentlistdict
segdict to the given path string outfile. The list keys can be given to
guarantee the order of the segments on the y-axis. x-axis limits can be
controlled using start, end and zero. The glue.segments.segmentlist object
highlight_segments can be given to highlight a number of segments.

Arguments:

  segdict : glue.segments.segmentlistdict

parse_plot_config(cp, section)

source code 

Parse ConfigParser.ConfigParser section for plot parameters. Sections should
be name '[plot xcolumn-ycolumn-zcolumn]' e.g.
'[plot time-peak_frequency-snr]'. Returns a pair of dicts with the
following keys:

columns:

  xcolumn : [ string | None ]
    column string to plot on x-axis
  ycolumn : [ string | None ]
    column string to plot on y-axis
  zcolumn : [ string | None ]
    column string to plot on z-axis

params:

  xlim : list
    [xmin, xmax] pair for x-axis limits
  ylim : list
    [ymin, ymax] pair for y-axis limits
  zlim : list
    [zmin, zmax] pair for z-axis limits
  clim : list
    [cmin, cmax] pair for colorbar limits
  logx : bool
    True / False to plot log scale on x-axis
  logy : bool
    True / False to plot log scale on y-axis
  logz : bool
    True / False to plot log scale on z-axis

plot_sky_positions(skyTable, outfile, format='radians', zcolumn=None, projection=None, centre=None, detectors=[], lines={}, range=[(0,0),(1,1)], **kwargs)

source code 

Plot latitude against longitude for the given ligolw table skyTable into the
given outfile. Uses the mpl_toolkits basemap module to plot the sky sphere 
in a variety of projections, or simply a scatter plot if projection=None.
Can plot lines and detector positions on top if given.

Arguments:

  skyTable : glue.ligolw.table.Table
    ligolw table containing triggers or SkyPosition objects
  outfile : string
    string path for output plot

Keyword arguments:

  zcolumn : string
    valid column of ligolw table to use for colorbar (optional).
  format : [ 'radians' | 'degrees' ]
    str identifying format of longtiude/ra, latitude/dec colums in table.
    Plot is always drawn in degrees.
  projection : str
    type of spherical projection to use, if any. See matplotlib Basemap
    documentation for details, recommended: 'ortho', 'hammer'.
  centre : tuple
    (longitude, latitude) pair on which to centre plot. Latitude centring
    only works for certain projections.
  detectors : list
    list of detector prefixes to plot, e.g. ['H1', 'L1'].
  lines : dict
    dict of name:table pairs from which to plot lines (+ marker) on top of
    points
  range : tuple
    ((xmin, ymin), (xmax, ymax)) tuples for lower left and upper right
    corners, in range 0-1, e.g. (0,0) is full lower left, (1,1) full upper
    right corners for full spherical projection. Only works with certain
    projections.

Unnamed keyword arguments:

  logx : [ True | False ]
    boolean option to display x-axis in log scale. Not applicable when using
    projection.
  logy : [ True | False ]
    boolean option to display y-axis in log scale. Not applicable when using
    projection.
  logz : [ True | False ]
    boolean option to display z-axis in log scale.
  xlim : tuple
    (xmin, xmax) limits for x-axis (longitude). Triggers outside range are
    removed.
  ylim : tuple
    (ymin, ymax) limits for y-axis (latitude). Triggers outside range are
    removed.
  zlim : tuple
    (zmin, zmax) limits for z-axis. Triggers outside range are removed.
  clim : tuple
    (cmin, cmax) limits for color scale. Triggers outside range are moved
    onto boundary.
  xlabel : string
    label for x-axis
  ylabel : string
    label for y-axis
  zlabel : string
    label for z-axis
  title : string
    title for plot
  subtitle : string
    subtitle for plot

All other given arguments will be passed to matplotlib.axes.Axes.scatter. 


Variables Details [hide private]

_backend_warn

Value:
"""No display detected, moving to 'Agg' backend in matplotlib."""

__date__

This module provides plotting routines for use in data quality investigations. All routines are written to work in as general a way as possible with ligolw tables and lsctables compatible columns, and to plot in a similar pythonic way to pylal.plotutils.

Value:
git_version.date