Grabbing online or offline data progressively

Use the method connection.iterate() to retrieve data progressively or online. Use connection.next() to grab each chunk as it becomes available. connection.iterate() supports the following arguments:

Warning

If your request includes one or more minute-trend channels, then start, stop, and step must be divisible by 60.

Warning

If you specify a GPS stop time, the returned buffers may not exactly end on that GPS stop time, because connection.next() makes no attempts to trim the received buffers to size.

Example 4.16. Grabbing online or offline data progressively in Python

In Python, connection.iterate() returns the original nds2.connection object, which implements the Python iterator protocol. As a result, you can use connection.iterate() as the iterator of a for...in loop.
As these requests are for older data explicitly allow data on tape.
>>> conn.set_parameter('ALLOW_DATA_ON_TAPE', '1')

To progressively download offline data in small chunks,
call connection.iterate() with the same arguments as connection.fetch():
GPS start and stop times, and list of channel names.
>>> for bufs in conn.iterate(1024417918, 1024417928, ['H1:PSL-ISS_PDA_OUT_DQ', 'H1:PSL-ISS_PDB_OUT_DQ']):
...     print bufs
...

('<H1:PSL-ISS_PDA_OUT_DQ (GPS time 1024417918.000000000, 32768 samples)>', '<H1:PSL-ISS_PDB_OUT_DQ (GPS time 1024417918.000000000, 32768 samples)>')
('<H1:PSL-ISS_PDA_OUT_DQ (GPS time 1024417919.000000000, 32768 samples)>', '<H1:PSL-ISS_PDB_OUT_DQ (GPS time 1024417919.000000000, 32768 samples)>')
...

Alternatively, to initiate online data retrieval starting from the current time,
omit the GPS start and stop time when calling connection.iterate().
>>> for bufs in conn.iterate(['H1:PSL-ISS_PDA_OUT_DQ', 'H1:PSL-ISS_PDB_OUT_DQ']):
...     print bufs
...

Example 4.17. Grabbing online or offline data progressively in Octave

In Octave, there is no for...in loop, but you can retrieve the buffers in a while loop, checking whether there is more data remaining with connection.has_next().
As these requests are for older data explicitly allow data on tape.
octave:1> conn.set_parameter('ALLOW_DATA_ON_TAPE', '1')

To progressively download offline data in small chunks,
call connection.iterate() with the same arguments as connection.fetch():
GPS start and stop times, and list of channel names.
octave:2> conn.iterate(1024417918, 1024417928, {'H1:PSL-ISS_PDA_OUT_DQ', 'H1:PSL-ISS_PDB_OUT_DQ'});

After calling connection.iterate(), call connection.next() repeatedly to retrieve bufferes repeatedly.
octave:3> while conn.has_next()
> bufs = conn.next();
> disp(bufs);
> end
(
  [1] =

<H1:PSL-ISS_PDA_OUT_DQ (GPS time 1024417918.000000000, 32768 samples)>
  [2] =

<H1:PSL-ISS_PDB_OUT_DQ (GPS time 1024417918.000000000, 32768 samples)>
)
(
  [1] =

<H1:PSL-ISS_PDA_OUT_DQ (GPS time 1024417919.000000000, 32768 samples)>
  [2] =

<H1:PSL-ISS_PDB_OUT_DQ (GPS time 1024417919.000000000, 32768 samples)>
)
...

Alternatively, to initiate online data retrieval starting from the current time,
omit the GPS start and stop time when calling connection.iterate().
octave:5> conn.iterate({'H1:PSL-ISS_PDA_OUT_DQ', 'H1:PSL-ISS_PDB_OUT_DQ'});
octave:6> while conn.has_next()
> bufs = conn.next();
> ...

Example 4.18. Grabbing online or offline data progressively in MATLAB

You can also use a while conn.hasNext() loop in MATLAB.
As these requests are for older data explicitly allow data on tape.
>> conn.setParameter('ALLOW_DATA_ON_TAPE', '1')

To progressively download offline data in small chunks,
call connection.iterate() with the same arguments as connection.fetch():
GPS start and stop times, and list of channel names.
>> conn.iterate(1024417918, 1024417928, {'H1:PSL-ISS_PDA_OUT_DQ', 'H1:PSL-ISS_PDB_OUT_DQ'});

After calling connection.iterate(), call connection.next() repeatedly to retrieve bufferes repeatedly.
>> while conn.hasNext()
bufs = conn.next();
disp(bufs);
end
nds2.buffer[]:
    [nds2.buffer]
    [nds2.buffer]



nds2.buffer[]:
    [nds2.buffer]
    [nds2.buffer]

...

Alternatively, to initiate online data retrieval starting from the current time,
omit the GPS start and stop time when calling connection.iterate().
>> conn.iterate({'H1:PSL-ISS_PDA_OUT_DQ', 'H1:PSL-ISS_PDB_OUT_DQ'});
>> while conn.hasNext()
bufs = conn.next();
...