Next: Creating Sequence Masks Up: Some Functions and Methods Previous: Time Series Handling Contents

## Subsetting Data Series

Some specific utilities are provided for simple operations on sequences.

  `void get_subsequence(Sequence& seq,int start=0, int num=-1 )`
  On return, `seq` contains a subsequence of `num` elements, starting from the index `start`. The default start index is 0, while if the number of elements to return is set to -1 (the default) the remainder of the sequence starting at index `start` is returned.

        #include "Qdos.h"
        QdRMatrixSeq_var ms = QdRMatrixSeq::narrow(ts_in);
        QdRMatrixSeq_var sub_seq = new QdRMatrixSeq();
          // get first 10 elements of sequence...
        ms->get_subsequence(sub_seq,0,10);
          // sub_seq contains 10 QdRMatrix objects starting from ms[0]

  Note that in the above example we initialise the matrix sequence to be empty. A more efficient use of memory would be achieved if we had created it with the required number of elements and matrices of the correct dimensions, e.g.
  `QdRMatrixSeq_var sub_seq = new QdRMatrixSeq(10,(ms[0]).dimdata());`
  See Matrix Sequences below for details of this constructor.
  `QdTimeSeq_var get_timetags_inrange(QdTimeSeq_var& ts_in,`
  `QdTimeInterval_var& tint)`
  Constructs and returns a subsequence of the time tags object that is delimited by the specified time interval.

        #include "qplug_if.h"
        #include "Qdos.h"
        #include "QsasUtils.h"
        using namespace QSAS;
         QdObject_var input1 = (* object_list)[1];
         QdObject_var input2 = (* object_list)[2];
         QdTimeInterval_var ti = get_timeinterval(input1);
         QdTimeSeq_var tt = get_timetags(input2);
         // subset time tags on interval set in input slot 1.
         QdTimeSeq_var tt_subset = get_timetags_inrange(tt, ti);

  Note this utility returns the time-tags subset, it does not subset the data series associated (see sequence mask methods below).(A)

  `int get_num_timetags_inrange(QdTimeSeq_var& ts,`
  `QdTimeInterval_var& tint)`
  This works as for the method above, but returns the number of time tags that lie in the requested range rather than the tags themselves. `int n = get_num_timetags_inrange(ts,ti)` See also sequence masks below. (A)

Next: Creating Sequence Masks Up: Some Functions and Methods Previous: Time Series Handling Contents