public class DataSetOps
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DS_LENGTH_LIMIT
absolute length limit for plots.
|
Constructor and Description |
---|
DataSetOps() |
Modifier and Type | Method and Description |
---|---|
static int[] |
addElement(int[] array,
int value)
adds an element to the array
|
static int[] |
addElement(int value,
int[] array)
adds an element to the beginning of an array
|
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 |
applyIndex(QDataSet ds,
QDataSet indices)
return the dataset with records rearranged according to indices.
|
static ArrayDataSet |
applyIndexAllLists(QDataSet rods,
QDataSet[] lists)
handle special case where rank 1 datasets are used to index a rank N array.
|
static void |
applyIndexInSitu(WritableDataSet ds,
QDataSet sort)
apply the sort to the data on the zeroth dimension.
|
static boolean |
boundsContains(QDataSet bounds,
Datum xValue,
Datum yValue)
return true of the bounds overlaps with the x and y values.
|
static java.lang.String[] |
bundleNames(QDataSet bundleDs)
return the names of the dataset that can be unbundled.
|
static boolean |
changesDimensions(java.lang.String p)
indicate if this one operator changes the dimensions.
|
static boolean |
changesDimensions(java.lang.String c0,
java.lang.String c1)
indicate if the operators change dimensions of the dataset.
|
static boolean |
changesIndependentDimensions(java.lang.String p)
indicate if this one operator changes the independent dimensions.
|
static boolean |
changesIndependentDimensions(java.lang.String c0,
java.lang.String c1)
indicate if the operators change dimensions of the dataset.
|
static QDataSet |
dbAboveBackgroundDim0(QDataSet ds,
double level)
normalize the level-th percentile from:
rank 1: each element (same as removeBackground1)
rank 2: each column of the dataset
rank 3: each column of each rank 2 dataset slice.
|
static QDataSet |
dbAboveBackgroundDim1(QDataSet ds,
double level)
normalize the nth-level percentile from:
rank 1: each element
rank 2: each row of the dataset
rank 3: each row of each rank 2 dataset slice.
|
static QDataSet |
dbAboveBackgroundDim1(QDataSet ds,
double level,
boolean power)
normalize the nth-level percentile from:
rank 1: each element
rank 2: each row of the dataset
rank 3: each row of each rank 2 dataset slice.
|
static QDataSet |
dependBounds(QDataSet ds)
return a bounding qube of the independent dimensions containing
the dataset.
|
static QDataSet |
dependBoundsSimple(QDataSet ds)
return a bounding qube of the independent dimensions containing
the dataset.
|
static QDataSet |
flattenBundleDescriptor(QDataSet bundle1)
returns a bundle descriptor roughly equivalent to the BundleDescriptor
passed in, but will describe each dataset as if it were rank 1.
|
static QDataSet |
flattenRank2(QDataSet ds)
flatten a rank 2 dataset.
|
static QDataSet |
flattenRank3(QDataSet ds)
flatten a rank 3 dataset.
|
static QDataSet |
flattenRank4(QDataSet ds)
flatten a rank 4 dataset.
|
static QDataSet |
flattenWaveform(QDataSet ds)
flatten a rank 2 dataset where the y depend variable is just an offset from the xtag.
|
static QDataSet |
getBackgroundLevel(QDataSet ds,
double level)
Get the background level by sorting the data.
|
static java.lang.Class |
getComponentType(QDataSet ds)
return the class type that can accurately store data in this
dataset.
|
protected static QDataSet |
getContextForUnbundle(QDataSet bundle1,
int index)
given the bundle descriptor bds, return the dataset to be put in the context property.
|
static QDataSet |
getNthPercentileSort(QDataSet ds,
double n)
returns the value from within a distribution that is the nth percentile division.
|
static QDataSet |
grid(QDataSet ds)
takes rank 2 link (x,y,z) and makes a table from it z(x,y)
|
static QDataSet |
histogram(QDataSet ds,
double min,
double max,
double binsize)
returns a rank 1 dataset that is a histogram of the data.
|
static int |
indexOfBundledDataSet(QDataSet bundleDs,
java.lang.String name)
return the index of the named bundled dataset.
|
static boolean |
isProcessAsync(java.lang.String c)
return true if the process described in c is probably a slow
process that should be done asynchronously.
|
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 java.lang.String |
makeProcessStringCanonical(java.lang.String s)
replace any component reference C, to explicit "|unbundle(C)"
|
static MutablePropertyDataSet |
makePropertiesMutable(QDataSet dataset)
return a dataset that has mutable properties.
|
static WritableDataSet |
makeWritable(QDataSet dataset)
return a dataset that is writable.
|
static RankZeroDataSet |
moment(QDataSet ds)
performs the moment (mean,variance,etc) on the dataset.
|
static QDataSet |
processDataSet(java.lang.String c,
QDataSet fillDs,
ProgressMonitor mon)
apply process to the data.
|
static int[] |
removeElement(int[] array,
int index)
removes the index-th element from the array.
|
static MutablePropertyDataSet |
slice(QDataSet ds,
int dimension,
int index)
slice on the dimension.
|
static MutablePropertyDataSet |
slice0(QDataSet ds,
int index)
slice on the first dimension.
|
static MutablePropertyDataSet |
slice1(QDataSet ds,
int index)
slice dataset operator assumes a qube dataset
by picking the index-th element of dataset's second dimension, without
regard to tags.
|
static MutablePropertyDataSet |
slice2(QDataSet ds,
int index)
slice dataset operator assumes a qube dataset
by picking the index-th element of dataset's second dimension, without
regard to tags.
|
static MutablePropertyDataSet |
slice3(QDataSet ds,
int index)
slice dataset operator assumes a qube dataset
by picking the index-th element of dataset's second dimension, without
regard to tags.
|
static java.util.Map<java.lang.String,java.lang.Object> |
sliceProperties(java.util.Map<java.lang.String,java.lang.Object> properties,
int sliceDimension)
we've sliced a dataset, removing an index.
|
static java.util.Map<java.lang.String,java.lang.Object> |
sliceProperties0(int index,
java.util.Map<java.lang.String,java.lang.Object> props)
method to help dataset implementations implement slice.
|
static QDataSet |
sort(QDataSet ds)
returns a list of indeces that sort the dataset.
|
static QDataSet |
sprocess(java.lang.String c,
QDataSet fillDs,
ProgressMonitor mon)
sprocess implements the poorly-named filters string / process string of Autoplot, allowing
clients to "pipe" data through a chain of operations.
|
static double |
suggestFillForComponentType(java.lang.Class c)
return a fill value that is representable by the type.
|
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)
reduce the number of elements in the dataset to the dim 0 indeces specified.
|
static MutablePropertyDataSet |
trim(QDataSet dep,
int start,
int stop,
int stride)
reduce the number of elements in the dataset to the dim 0 indeces specified.
|
static QDataSet |
unbundle(QDataSet bundleDs,
int ib)
Extract a bundled dataset from a bundle of datasets.
|
static QDataSet |
unbundle(QDataSet bundleDs,
int ib,
boolean highRank)
Extract a bundled dataset from a bundle of datasets.
|
static QDataSet |
unbundle(QDataSet bundleDs,
java.lang.String name)
Extract the named bundled dataset.
|
static QDataSet |
unbundleDefaultDataSet(QDataSet bundleDs)
extract the dataset that is dependent on others, or the last one.
|
public static final int DS_LENGTH_LIMIT
public static MutablePropertyDataSet makePropertiesMutable(QDataSet dataset)
dataset
- datasetDataSetWrapper
public static WritableDataSet makeWritable(QDataSet dataset)
dataset
- public static MutablePropertyDataSet slice(QDataSet ds, int dimension, int index)
ds
- the rank N data to slice.dimension
- the dimension to slice, 0 is the first.index
- the index to slice at.public static MutablePropertyDataSet slice0(QDataSet ds, int index)
ds
- rank 1 or more datasetindex
- the index to slice atQDataSet.slice(int)
public static MutablePropertyDataSet slice1(QDataSet ds, int index)
ds
- rank 2 or more datasetindex
- the index to slice atpublic static MutablePropertyDataSet slice2(QDataSet ds, int index)
ds
- rank 3 or more datasetindex
- the index to slice at.public static MutablePropertyDataSet slice3(QDataSet ds, int index)
ds
- rank 4 or more dataset.index
- index to slice atpublic static MutablePropertyDataSet trim(QDataSet ds, int offset, int len)
ds
- the datasetoffset
- the offsetlen
- the length, (not the stop index!)public static MutablePropertyDataSet trim(QDataSet dep, int start, int stop, int stride)
dep
- the dataset.start
- first index to includestop
- last index, exclusivestride
- the step size, e.g. 2 is every other element.public static QDataSet flattenRank2(QDataSet ds)
ds
- rank 2 table datasetpublic static QDataSet flattenRank3(QDataSet ds)
ds
- rank 3 table datasetpublic static QDataSet flattenRank4(QDataSet ds)
ds
- rank 3 table datasetpublic static QDataSet flattenWaveform(QDataSet ds)
ds
- rank 2 waveform with tags for DEPEND_0 and offsets for DEPEND_1public static QDataSet grid(QDataSet ds)
ds
- rank 2 link (x,y,z)public static int[] removeElement(int[] array, int index)
array
- length N arrayindex
- the index to removepublic static int[] addElement(int[] array, int value)
array
- length N arrayvalue
- the value to appendpublic static int[] addElement(int value, int[] array)
array
- length N arrayvalue
- the value to appendpublic static MutablePropertyDataSet leafTrim(QDataSet ds, int start, int end)
ds
- rank 1 or more datasetstart
- first index to include.end
- last index, exclusivepublic static QDataSet sort(QDataSet ds)
ds
- rank 1 dataset, possibly containing fill.public static void applyIndexInSitu(WritableDataSet ds, QDataSet sort)
ds
- a writable dataset that is still mutable.sort
- the new sort indeces.public static java.lang.Class getComponentType(QDataSet ds)
ds
- the dataset.ArrayDataSet.create(java.lang.Class, int[])
public static double suggestFillForComponentType(java.lang.Class c)
c
- the class type, including double.class, float.class, etc.public static QDataSet applyIndex(QDataSet ds, QDataSet indices)
ds
- rank N dataset, where N>0indices
- rank 1 dataset, length m.applyIndex(org.das2.qds.QDataSet, int, org.das2.qds.QDataSet, boolean)
public static WritableDataSet applyIndex(QDataSet ds, int idim, QDataSet sort, boolean deps)
ds
- rank 1,2, or 3 qube datasetidim
- 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!for similar functionality
,
Ops.decimate(org.das2.qds.QDataSet, int, int)
,
applyIndexAllLists(org.das2.qds.QDataSet, org.das2.qds.QDataSet[])
public static ArrayDataSet applyIndexAllLists(QDataSet rods, QDataSet[] lists)
rods
- the datasetlists
- datasets of rank 0 or rank 1which is similar
public static QDataSet histogram(QDataSet ds, double min, double max, double binsize)
ds
- rank N datasetmin
- the min of the first bin. If min=-1 and max=-1, then automatically set the min and max.max
- the max of the last bin.binsize
- the size of each bin.public static RankZeroDataSet moment(QDataSet ds)
ds
- rank N QDataSet.public static QDataSet transpose2(QDataSet ds)
ds
- rank 2 Qube DataSet.public static java.util.Map<java.lang.String,java.lang.Object> sliceProperties0(int index, java.util.Map<java.lang.String,java.lang.Object> props)
index
- the index to slice at in the zeroth index.props
- the properties to slice.public static java.util.Map<java.lang.String,java.lang.Object> sliceProperties(java.util.Map<java.lang.String,java.lang.Object> properties, int sliceDimension)
properties
- the properties to slice.sliceDimension
- the dimension to slice at (0,1,2...QDataSet.MAX_HIGH_RANK)public static QDataSet flattenBundleDescriptor(QDataSet bundle1)
bundle1
- public static java.lang.String[] bundleNames(QDataSet bundleDs)
bundleDs
- java.lang.IllegalArgumentException
- when bundleDs is not a bundle.unbundle(org.das2.qds.QDataSet, java.lang.String)
public static int indexOfBundledDataSet(QDataSet bundleDs, java.lang.String name)
demonstrates its use. Last, extraneous spaces and underscores are removed to see if this will result in a match.bds=ripplesVectorTimeSeries(100) 2==indexOfBundledDataSet( bds, "Z" )
bundleDs
- a bundle dataset with the property BUNDLE_1 or DEPEND_1 having EnumerationUnits, (or BUNDLE_0 for a rank 1 dataset).name
- the named dataset.public static QDataSet unbundle(QDataSet bundleDs, java.lang.String name)
bundleDs
- a bundle of datasetsname
- the name of the bundled dataset, or "ch_<i>" where i is the dataset numberjava.lang.IllegalArgumentException
- if no named dataset is found.unbundle(org.das2.qds.QDataSet, int)
public static QDataSet unbundleDefaultDataSet(QDataSet bundleDs)
bundleDs
- a bundle of datasetsSchemes.bundleDataSet()
public static QDataSet unbundle(QDataSet bundleDs, int ib)
bundleDs
- the bundle dataset.ib
- index of the dataset to extract. If the index is within a dataset,
then the entire dataset is returned.java.lang.IndexOutOfBoundsException
- if the index is invalid.java.lang.IllegalArgumentException
- if the dataset is not a bundle dataset, with either BUNDLE_1 or DEPEND_1 set.public static QDataSet unbundle(QDataSet bundleDs, int ib, boolean highRank)
bundleDs
- the bundle dataset.ib
- index of the dataset to extract. If the index is within a dataset,
then the entire dataset is returned.highRank
- if true, then if the dataset at ib is rank 2 or greater, then
then the entire dataset is returned. If false, only the slice of the dataset is
returned.java.lang.IndexOutOfBoundsException
- if the index is invalid.java.lang.IllegalArgumentException
- if the dataset is not a bundle dataset, with either BUNDLE_1 or DEPEND_1 set.Ops.bundle(org.das2.qds.QDataSet, org.das2.qds.QDataSet)
protected static QDataSet getContextForUnbundle(QDataSet bundle1, int index)
bundle1
- rank 2 bundle descriptor of length n with indexed properties. This was introduced
when sloppy slice code was using the NAME and dropping the LABEL.index
- 0<=index<n index of the unbundlepublic static QDataSet getNthPercentileSort(QDataSet ds, double n)
ds
- the datasetn
- percent between 0 and 100.public static QDataSet getBackgroundLevel(QDataSet ds, double level)
ds
- rank 1, 2, or rank 3 join.level
- the level between 0 and 100.public static QDataSet dbAboveBackgroundDim1(QDataSet ds, double level)
ds
- level
- the percentile level, e.g. 10= 10%public static QDataSet dbAboveBackgroundDim1(QDataSet ds, double level, boolean power)
ds
- level
- the percentile level, e.g. 10= 10%power
- if true, return 10*Math.log10(ds / background ).public static QDataSet dbAboveBackgroundDim0(QDataSet ds, double level)
ds
- level
- the percentile level, e.g. 10= 10%public static boolean isProcessAsync(java.lang.String c)
c
- process string, as in sprocess.public static QDataSet processDataSet(java.lang.String c, QDataSet fillDs, ProgressMonitor mon) throws java.lang.RuntimeException, java.lang.Exception
c
- the process string, like "bgsmx|slice0(9)|histogram()"fillDs
- the input dataset.mon
- a monitor for the processingjava.lang.Exception
- when the processStr cannot be processed.java.lang.RuntimeException
- when the component (e.g. bgsmx) is not found.public static QDataSet sprocess(java.lang.String c, QDataSet fillDs, ProgressMonitor mon) throws java.lang.Exception
c
- process string like "slice0(9)|histogram()"fillDs
- The dataset loaded from the data source controller, with initial filters (like fill) applied.mon
- monitor for the processing.java.text.ParseException
- when the string cannot be parsedjava.lang.Exception
- when a function cannot be processed (e.g. index out of bounds)public static boolean changesDimensions(java.lang.String p)
p
- the filter, e.g. "|smooth"public static boolean changesIndependentDimensions(java.lang.String p)
p
- the filter, e.g. "|smooth"public static java.lang.String makeProcessStringCanonical(java.lang.String s)
s
- the process string, like "X|fftPower(512,2)"public static boolean changesIndependentDimensions(java.lang.String c0, java.lang.String c1)
c0
- old value for the process string, e.g. "|slice0(0)"c1
- new value for the process string, e.g. "|slice0(0)|slice1(0)"public static boolean changesDimensions(java.lang.String c0, java.lang.String c1)
c0
- old value for the process string, e.g. "|slice0(0)"c1
- new value for the process string, e.g. "|slice0(0)|slice1(0)"public static QDataSet dependBoundsSimple(QDataSet ds)
ds
- a rank 1,2, or 3 dataset.public static QDataSet dependBounds(QDataSet ds)
ds
- rank 1,2, or 3 dataset.public static boolean boundsContains(QDataSet bounds, Datum xValue, Datum yValue)
bounds
- bounding boxxValue
- the x rangeyValue
- the y rangejava.lang.IllegalArgumentException
- if the units cannot be convertedjava.lang.IllegalArgumentException
- if the bounds does not have BINS_0 and BINS_1.