def read_series(source, name, match=None):
from ligo.lw.ligolw import (LIGO_LW, Time, Array, Dim)<EOL>from ligo.lw.param import get_param<EOL>xmldoc = read_ligolw(source, contenthandler=series_contenthandler())<EOL>if match is None:<EOL><INDENT>match = dict()<EOL><DEDENT>def _is_match(elem):<EOL><INDENT>try:<EOL><INDENT>if elem.Name != name:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>except AttributeError:  <EOL><INDENT>return False<EOL><DEDENT>for key, value in match.items():<EOL><INDENT>try:<EOL><INDENT>if get_param(elem, key).pcdata != value:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>except ValueError:  <EOL><INDENT>return False<EOL><DEDENT><DEDENT>return True<EOL><DEDENT>matches = filter(_is_match, xmldoc.getElementsByTagName(LIGO_LW.tagName))<EOL>try:<EOL><INDENT>elem, = matches<EOL><DEDENT>except ValueError as exc:<EOL><INDENT>if not matches:<EOL><INDENT>exc.args = ("<STR_LIT>",)<EOL><DEDENT>else:<EOL><INDENT>exc.args = ('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>',)<EOL><DEDENT>raise<EOL><DEDENT>array, = elem.getElementsByTagName(Array.tagName)<EOL>dims = array.getElementsByTagName(Dim.tagName)<EOL>xdim = dims[<NUM_LIT:0>]<EOL>x0 = xdim.Start<EOL>dx = xdim.Scale<EOL>xunit = xdim.Unit<EOL>try:<EOL><INDENT>ndim = dims[<NUM_LIT:1>].n<EOL><DEDENT>except IndexError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if ndim > <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>".format(ndim))<EOL><DEDENT><DEDENT>array_kw = {<EOL>'<STR_LIT:name>': array.Name,<EOL>'<STR_LIT>': array.Unit,<EOL>'<STR_LIT>': xunit,<EOL>}<EOL>try:<EOL><INDENT>array_kw['<STR_LIT>'] = to_gps(<EOL>elem.getElementsByTagName(Time.tagName)[<NUM_LIT:0>].pcdata)<EOL><DEDENT>except IndexError:<EOL><INDENT>pass<EOL><DEDENT>for key in ('<STR_LIT>',):<EOL><INDENT>try:<EOL><INDENT>array_kw[key] = get_param(elem, key)<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>try:<EOL><INDENT>xindex, value = array.array<EOL><DEDENT>except ValueError:  <EOL><INDENT>return Series(array.array[<NUM_LIT:0>], x0=x0, dx=dx, **array_kw)<EOL><DEDENT>return Series(value, xindex=xindex, **array_kw)<EOL>
Read a `Series` from LIGO_LW-XML

    Parameters
    ----------
    source : `file`, `str`, :class:`~ligo.lw.ligolw.Document`
        file path or open LIGO_LW-format XML file

    name : `str`
        name of the relevant `LIGO_LW` element to read

    match : `dict`, optional
        dict of (key, value) `Param` pairs to match correct LIGO_LW element,
        this is useful if a single file contains multiple `LIGO_LW` elements
        with the same name