@io_nds2.open_connection<EOL>def fetch(channels, start, end, type=None, dtype=None, allow_tape=None,<EOL>connection=None, host=None, port=None, pad=None, scaled=True,<EOL>verbose=False, series_class=TimeSeries):<EOL>
<EOL>if allow_tape is not None:<EOL><INDENT>set_parameter(connection, '<STR_LIT>', str(allow_tape),<EOL>verbose=verbose)<EOL><DEDENT>type = _parse_nds_enum_dict_param(channels, '<STR_LIT:type>', type)<EOL>dtype = _parse_nds_enum_dict_param(channels, '<STR_LIT>', dtype)<EOL>print_verbose("<STR_LIT>", end='<STR_LIT:U+0020>',<EOL>verbose=verbose)<EOL>utype = reduce(operator.or_, type.values())  <EOL>udtype = reduce(operator.or_, dtype.values())<EOL>epoch = (start, end) if connection.get_protocol() > <NUM_LIT:1> else None<EOL>ndschannels = io_nds2.find_channels(channels, connection=connection,<EOL>epoch=epoch, type=utype, dtype=udtype,<EOL>unique=True)<EOL>names = [Channel.from_nds2(c).ndsname for c in ndschannels]<EOL>print_verbose('<STR_LIT>', verbose=verbose)<EOL>if (any(c.endswith('<STR_LIT>') for c in names) and<EOL>(start % <NUM_LIT> or end % <NUM_LIT>)):<EOL><INDENT>warnings.warn("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>start, end = io_nds2.minute_trend_times(start, end)<EOL><DEDENT>span = SegmentList([Segment(start, end)])<EOL>if pad is None:<EOL><INDENT>qsegs = span<EOL>gap = '<STR_LIT>'<EOL><DEDENT>elif connection.get_protocol() == <NUM_LIT:1>:<EOL><INDENT>qsegs = span<EOL>gap = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>print_verbose("<STR_LIT>", end='<STR_LIT:U+0020>',<EOL>verbose=verbose)<EOL>pad = float(pad)<EOL>gap = '<STR_LIT>'<EOL>qsegs = _get_data_segments(ndschannels, start, end, connection) & span<EOL>print_verbose('<STR_LIT>'<EOL>'<STR_LIT>'.format(len(qsegs),<EOL>abs(qsegs) / abs(span) * <NUM_LIT:100>),<EOL>verbose=verbose)<EOL>if span - qsegs:<EOL><INDENT>warnings.warn("<STR_LIT>"<EOL>"<STR_LIT>".format(<EOL>connection.get_host(), pad))<EOL><DEDENT><DEDENT>out = series_class.DictClass()<EOL>desc = verbose if isinstance(verbose, str) else '<STR_LIT>'<EOL>with progress_bar(total=float(abs(qsegs)), desc=desc,<EOL>unit='<STR_LIT:s>', disable=not bool(verbose)) as bar:<EOL><INDENT>for seg in qsegs:<EOL><INDENT>total = <NUM_LIT:0.><EOL>for buffers in connection.iterate(int(seg[<NUM_LIT:0>]), int(seg[<NUM_LIT:1>]), names):<EOL><INDENT>for buffer_, chan in zip(buffers, channels):<EOL><INDENT>series = series_class.from_nds2_buffer(<EOL>buffer_,<EOL>scaled=scaled,<EOL>copy=chan not in out,  <EOL>)<EOL>out.append({chan: series}, pad=pad, gap=gap)<EOL><DEDENT>new = buffer_.length / buffer_.channel.sample_rate<EOL>total += new<EOL>bar.update(new)<EOL><DEDENT>if not total and gap != '<STR_LIT>':<EOL><INDENT>raise RuntimeError("<STR_LIT>".format(<EOL>connection.get_host(), seg))<EOL><DEDENT><DEDENT><DEDENT>if pad is not None:<EOL><INDENT>for chan, ndschan in zip(channels, ndschannels):<EOL><INDENT>try:<EOL><INDENT>ts = out[chan]<EOL><DEDENT>except KeyError:<EOL><INDENT>out[chan] = _create_series(ndschan, pad, start, end,<EOL>series_class=series_class)<EOL><DEDENT>else:<EOL><INDENT>out[chan] = _pad_series(ts, pad, start, end)<EOL><DEDENT><DEDENT><DEDENT>return out<EOL>
Fetch a dict of data series from NDS2

    This method sits underneath `TimeSeries.fetch` and related methods,
    and isn't really designed to be called directly.