next up previous contents
Next: Using Sequence Masks Up: Some Functions and Methods Previous: Subsetting Data Series   Contents

Creating Sequence Masks

Subsetting data series is normally done through a sequence mask. The following methods show the construction of a sequence mask.

$\bullet$
SequenceMask msk(int n_in_seq, bool accept);
This constructor creates a new sequence mask with n_in_seq entries, each of which takes the boolean value accept.
  #include "Qdos.h"
  QdRScalar_var xdo = QdRScalar::narrow((* object_list)[0]);
  int ndata = xdo->sequence_size();
  SequenceMask msk(ndata, true);

$\bullet$
SequenceMask msk(const SequenceMask &mask);
This constructor creates a new sequence mask from the mask mask. It is used for creating a mask from the return value of the method get_mask().

The method get_mask operates on sequence types to construct a mask based on some criterion applicable to the particular sequence type. This generally takes the form
SequenceMask msk(QdSequence_var seq->get_mask(condition));
The constructor for a sequence mask here creates a mask msk using the get_mask() method for a QdSequence object. The possible values of argument condition depend on the sequence type used. Some example conditions are given below.

$\bullet$
QdRScalarSeq::InRange(double x1, double x2)
returns true for all members of the scalar sequence which satisfy the bounding condition.
  #include "Qdos.h"
  double xmin = 0.0;
  double xmax = 100.0;
  QdRScalarSeq_var xdo = QdRScalarSeq::narrow(input1);
  SequenceMask msk( xdo->get_mask(InRange(xmin, xmax)) );

$\bullet$
QdTimeSeq::InRange
  #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 interval = get_timeinterval(input1);
  QdTimeSeq_var tt = get_timetags(input2);
  // create mask based on timetags from input 2 
  //   that lie in interval set by input 1
  SequenceMask msk(tt->get_mask(QdTimeSeq::InRange(interval->start(),
                                                   interval->end())));

$\bullet$
EQ, NEQ, LE, GE, LT, GT
These operators allow masks to be constructed on a single condition, such as Greater Than (GT).
  #include "qplug_if.h"
  #include "Qdos.h"
  #include "QsasUtils.h"
  using namespace QSAS;
  QdTime_var tc = new QdTime("02-Jan-2000 12:00:00.000");
  QdTimeSeq_var tt_in = get_timetags((* object_list)[2]);
  // create mask for timetags less than specified value
   SequenceMask msk(tt_in->get_mask( QdTimeSeq::LT( tc )));

$\bullet$
(SequenceMask) msk[n] = (bool) accept;
Sets the mask value to the boolean value accept.
  #include "Qdos.h"
  QdRScalar_var xdo = QdRScalar::narrow((* object_list)[0]);
  int ndata = xdo->sequence_size();
  SequenceMask msk(ndata, true);
  for(int i=0; i<ndata; i++)
  {
    // create mask that keeps only positive values
    if( xdo[i] < 0 ) msk[i] = false;
  }


next up previous contents
Next: Using Sequence Masks Up: Some Functions and Methods Previous: Subsetting Data Series   Contents
Anthony Allen 2005-11-07