org.virbo.dataset
Class DataSetOps

java.lang.Object
  extended by org.virbo.dataset.DataSetOps

public class DataSetOps
extends java.lang.Object

Useful operations for QDataSets


Constructor Summary
DataSetOps()
           
 
Method Summary
static WritableDataSet applyIndex(QDataSet ds, int idim, QDataSet sort, boolean deps)
          Applies the sort index to the idim-th dimension of the qube dataset ds.
static QDataSet histogram(QDataSet ds, double min, double max, double binsize)
          returns a rank 1 dataset that is a histogram of the data.
static MutablePropertyDataSet leafTrim(QDataSet ds, int start, int end)
          pull out a subset of the dataset by reducing the number of columns in the last dimension.
static QDataSet moment(QDataSet ds)
          performs the moment (mean,variance,etc) on the dataset.
static int[] removeElement(int[] array, int index)
          removes the index-th element from the array.
static MutablePropertyDataSet slice0(QDataSet ds, int index)
          slice on the first dimension
static MutablePropertyDataSet slice1(QDataSet ds, int index)
          this strange dataset operator assumes a square or qube dataset by picking the index-th element of dataset's second dimension, without regard to tags.
static MutablePropertyDataSet slice2(QDataSet ds, int index)
          this strange dataset operator assumes a square or qube dataset by picking the index-th element of dataset's second dimension, without regard to tags.
static QDataSet sort(QDataSet ds)
          returns a list of indeces that sort the dataset.
static QDataSet transpose2(QDataSet ds)
          transpose the rank 2 qube dataset so the rows are columns and the columns are rows.
static MutablePropertyDataSet trim(QDataSet ds, int offset, int len)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSetOps

public DataSetOps()
Method Detail

slice0

public static MutablePropertyDataSet slice0(QDataSet ds,
                                            int index)
slice on the first dimension


slice1

public static MutablePropertyDataSet slice1(QDataSet ds,
                                            int index)
this strange dataset operator assumes a square or qube dataset by picking the index-th element of dataset's second dimension, without regard to tags.


slice2

public static MutablePropertyDataSet slice2(QDataSet ds,
                                            int index)
this strange dataset operator assumes a square or qube dataset by picking the index-th element of dataset's second dimension, without regard to tags.


trim

public static MutablePropertyDataSet trim(QDataSet ds,
                                          int offset,
                                          int len)

removeElement

public static int[] removeElement(int[] array,
                                  int index)
removes the index-th element from the array.

Parameters:
array -
index -
Returns:

leafTrim

public static MutablePropertyDataSet leafTrim(QDataSet ds,
                                              int start,
                                              int end)
pull out a subset of the dataset by reducing the number of columns in the last dimension. This does not reduce rank. This assumes the dataset has no row with length>end.

Parameters:
start - first index to include.
end - last index, exclusive

sort

public static QDataSet sort(QDataSet ds)
returns a list of indeces that sort the dataset. I don't like this implementation, because it requires that an array of Integers (not int[]) be created. Invalid measurements are not indexed in the returned dataset.


applyIndex

public static WritableDataSet applyIndex(QDataSet ds,
                                         int idim,
                                         QDataSet sort,
                                         boolean deps)
Applies the sort index to the idim-th dimension of the qube dataset ds. TODO: consider sorting multiple dimensions at once, to reduce excessive copying.

Parameters:
ds - rank 1,2, or 3 qube dataset
idim - the dimension being sorted.
sort - rank 1 dataset of new indeces, needn't be same size as index.
deps - do dependencies as well. Note this does not rearrange planes!
Returns:
new dataset that is a copy of the first, resorted.
See Also:
for similar functionality

histogram

public static QDataSet histogram(QDataSet ds,
                                 double min,
                                 double max,
                                 double binsize)
returns a rank 1 dataset that is a histogram of the data.

Parameters:
ds - rank N dataset
min - the min of the first bin.
max - the max of the last bin.
binsize - the size of each bin.
Returns:
a rank 1 dataset with each bin's count. DEPEND_0 indicates the bin locations.

moment

public static QDataSet moment(QDataSet ds)
performs the moment (mean,variance,etc) on the dataset.

Parameters:
ds - rank N QDataSet.
Returns:
QDataSet rank 1 dataset with one tag, the mean. Properties contain other stats.

transpose2

public static QDataSet transpose2(QDataSet ds)
transpose the rank 2 qube dataset so the rows are columns and the columns are rows.

Parameters:
ds - rank 2 Qube DataSet.
Returns:
rank 2 Qube DataSet