org.das2.qds.DataSetOps
Useful operations for QDataSets, such as slice2, leafTrim.
TODO: identify which functions appear here instead of Ops.java.
DS_LENGTH_LIMIT
absolute length limit for plots. This is used to limit the elements used in autoranging, etc.
applyIndexInSitu
applyIndexInSitu( org.das2.qds.WritableDataSet ds, QDataSet sort ) → void
apply the sort to the data on the zeroth dimension. The dataset
must be mutable, and the dataset itself is modified. This was introduced
to support AggregatingDataSource but should be generally useful.
Parameters
ds - a writable dataset that is still mutable.
sort - the new sort indeces.
Returns:
void (returns nothing)
search for examples
view on GitHub
view source
boundsContains
boundsContains( QDataSet bounds, Datum xValue, Datum yValue ) → boolean
return true of the bounds overlaps with the x and y values.
Parameters
bounds - bounding box
xValue - the x range
yValue - the y range
Returns:
true of the bounds overlap
search for examples
view on GitHub
view source
changesDimensions
changesDimensions( String p ) → boolean
indicate if this one operator changes the dimensions. For example,
|smooth doesn't change the dimensions, but fftPower and slice do.
Parameters
p - the filter, e.g. "|smooth"
Returns:
true if the dimensions change.
search for examples
view on GitHub
view source
dbAboveBackgroundDim0
dbAboveBackgroundDim0( QDataSet ds, double level ) → QDataSet
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.
There must be at least 10 elements. If the data is already in dB, then the result is a difference.
This is assuming the units are similar to voltage, not a power, we think,
containing code like 20 * Math.log10( ds / background ).
Parameters
ds -
level - the percentile level, e.g. 10= 10%
Returns:
the result dataset, in dB above background.
search for examples
view on GitHub
view source
dbAboveBackgroundDim1
dbAboveBackgroundDim1( QDataSet ds, double level ) → QDataSet
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.
If the data is already in dB, then the result is a difference.
This is assuming the units are similar to voltage, not a power, we think,
containing code like 20 * Math.log10( ds / background ).
Parameters
ds -
level - the percentile level, e.g. 10= 10%
Returns:
the result dataset, in dB above background.
search for examples
view on GitHub
view source
dependBounds
dependBounds( QDataSet ds ) → QDataSet
return a bounding qube of the independent dimensions containing
the dataset. If r is the result of the function, then for
- rank 1: r.slice(0) x bounds, r.slice(1) y bounds
- rank 2 waveform: r.slice(0) x bounds, r.slice(1) y bounds
- rank 2 table:r.slice(0) x bounds r.slice(1) DEPEND_0 bounds.
- rank 3 table:r.slice(0) x bounds r.slice(1) DEPEND_0 bounds.
Parameters
ds - rank 1,2, or 3 dataset.
Returns:
a bounding qube of the independent dimensions
search for examples
view on GitHub
view source
dependBoundsSimple
dependBoundsSimple( QDataSet ds ) → QDataSet
return a bounding qube of the independent dimensions containing
the dataset. If r is the result of the function, then for
- rank 1: r.slice(0) x bounds, r.slice(1) y bounds
- rank 2 waveform: r.slice(0) x bounds, r.slice(1) y bounds
- rank 2 table:r.slice(0) x bounds r.slice(1) DEPEND_0 bounds.
- rank 3 table:r.slice(0) x bounds r.slice(1) DEPEND_0 bounds.
This does not take DELTA_PLUS and DELTA_MINUS into account.
When all the data is fill, ds[0,0] will be positive infinity.
Parameters
ds - a rank 1,2, or 3 dataset.
Returns:
a bounding qube of the independent dimensions
search for examples
view on GitHub
view source
flattenBundleDescriptor
flattenBundleDescriptor( QDataSet bundle1 ) → QDataSet
returns a bundle descriptor roughly equivalent to the BundleDescriptor
passed in, but will describe each dataset as if it were rank 1. This
is useful for when the client can't work with mixed rank bundles anyway
(like display data).
Parameters
bundle1 -
Returns:
org.das2.qds.QDataSet
search for examples
view on GitHub
view source
flattenRank2
flattenRank2( QDataSet ds ) → QDataSet
flatten a rank 2 dataset. The result is a n,3 dataset
of [x,y,f].
History:
- modified for use in PW group.
- missing DEPEND_1 resulted in NullPointerException, so just use 0,1,2,..,n instead and always have rank 2 result.
Parameters
ds - rank 2 table dataset
Returns:
rank 2 dataset that is that is array of (x,y,f).
search for examples
view on GitHub
view source
flattenRank3
flattenRank3( QDataSet ds ) → QDataSet
flatten a rank 3 dataset. The result is a n,4 dataset
of [x,y,z,f], or if there are no tags just rank 1 f.
Parameters
ds - rank 3 table dataset
Returns:
rank 2 dataset that is array of (x,y,z,f) or rank 1 f.
search for examples
view on GitHub
view source
getBackgroundLevel
getBackgroundLevel( QDataSet ds, double level ) → QDataSet
Get the background level by sorting the data. The result is rank one less than the input rank.
Parameters
ds - rank 1, 2, or rank 3 join.
level - the level between 0 and 100.
Returns:
org.das2.qds.QDataSet
search for examples
view on GitHub
view source
getNthPercentileSort
getNthPercentileSort( QDataSet ds, double n ) → QDataSet
returns the value from within a distribution that is the nth percentile division. This
returns a fill dataset (Units.dimensionless.getFillDouble()) when the data is all fill.
Parameters
ds - the dataset
n - percent between 0 and 100.
Returns:
org.das2.qds.QDataSet
search for examples
view on GitHub
view source
indexOfBundledDataSet
indexOfBundledDataSet( QDataSet bundleDs, String name ) → int
return the index of the named bundled dataset. This cleans up
the name so that is contains just a Java-style identifier. Also, ch_1 is
always implicitly index 1.
Last, if safe names created from labels match that this is used. For example,
bds=ripplesVectorTimeSeries(100)
2==indexOfBundledDataSet( bds, "Z" )
demonstrates its use.
Last, extraneous spaces and underscores are removed to see if this will result in a match.
Parameters
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.
Returns:
the index or -1 if the name is not found.
search for examples
view on GitHub
view source
isProcessAsync
isProcessAsync( String c ) → boolean
return true if the process described in c is probably a slow
process that should be done asynchronously. For example, do
a long fft on a different thread and use a progress monitor. Processes
that take a trivial, constant amount of time should return false, and
may be completed on the event thread,etc.
Parameters
c - process string, as in sprocess.
Returns:
true if the process described in c is probably a slow process
search for examples
view on GitHub
view source
leafTrim
leafTrim( QDataSet ds, int start, int end ) → MutablePropertyDataSet
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.
This is extended to support rank 4 datasets.
TODO: This probably doesn't handle bundles property.
TODO: slice and trim should probably be implemented here for efficiently.
Parameters
ds - rank 1 or more dataset
start - first index to include.
end - last index, exclusive
Returns:
dataset of the same rank.
search for examples
view on GitHub
view source
makePropertiesMutable
makePropertiesMutable( QDataSet dataset ) → MutablePropertyDataSet
return a dataset that has mutable properties. If the dataset parameter already has, then the
dataset is returned. If the dataset is a MutablePropertyDataSet but the immutable flag is
set, then the dataset is wrapped to make the properties mutable.
Parameters
dataset - dataset
Returns:
a MutablePropertyDataSet that is has a wrapper around the dataset, or the dataset.
See Also:
DataSetWrapper
search for examples
view on GitHub
view source
makeWritable
makeWritable( QDataSet dataset ) → WritableDataSet
return a dataset that is writable. If the dataset parameter of this idempotent
function is already writable, then the
dataset is returned. If the dataset is a WritableDataSet but the immutable flag is
set, then the a copy is returned.
Parameters
dataset -
Returns:
a WritableDataSet that is either a copy of the read-only dataset provided, or the parameter writable dataset provided.
search for examples
view on GitHub
view source
moment
moment( QDataSet ds ) → RankZeroDataSet
performs the moment (mean,variance,etc) on the dataset.
Parameters
ds - rank N QDataSet.
Returns:
rank 0 dataset of the mean. Properties contain other stats:
stddev, RankZeroDataSet
validCount, Integer, the number valid measurements
invalidCount, Integer, the number of invalid measurements
search for examples
view on GitHub
view source
processDataSet
processDataSet( String c, QDataSet fillDs, ProgressMonitor mon ) → QDataSet
apply process to the data. This is like sprocess, except that the component can be extracted as the first step.
In general these can be done on the same thread (like
slice1), but some are slow (like fftPower). This is a copy of PlotElementController.processDataSet.
Parameters
c - the process string, like "bgsmx|slice0(9)|histogram()"
fillDs - the input dataset.
mon - a monitor for the processing
Returns:
dataset resulting form filters.
search for examples
view on GitHub
view source
removeElement
removeElement( int[] array, int index ) → int
removes the index-th element from the array.
Parameters
array - length N array
index - the index to remove
Returns:
array without the element, length N-1.
search for examples
view on GitHub
view source
sliceProperties0
sliceProperties0( int index, java.util.Map props ) → Map
method to help dataset implementations implement slice.
2010-09-23: support rank 2 DEPEND_2 and DEPEND_3
2010-09-23: add BINS_1 and BUNDLE_1, Slice0DataSet calls this.
2010-02-24: BUNDLE_0 handled.
2011-03-25: add WEIGHTS_PLANE
Parameters
index - the index to slice at in the zeroth index.
props - the properties to slice.
Returns:
the properties after the slice.
search for examples
view on GitHub
view source
suggestFillForComponentType
suggestFillForComponentType( java.lang.Class c ) → double
return a fill value that is representable by the type.
Parameters
c - the class type, including double.class, float.class, etc.
Returns:
a fill value that is representable by the type.
search for examples
view on GitHub
view source
transpose2
transpose2( QDataSet ds ) → QDataSet
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
search for examples
view on GitHub
view source
unbundleDefaultDataSet
unbundleDefaultDataSet( QDataSet bundleDs ) → QDataSet
extract the dataset that is dependent on others, or the last one.
For example, the dataset ds[:,"x,y"] → y[:]
Parameters
bundleDs - a bundle of datasets
Returns:
the default dataset
See Also:
Schemes#bundleDataSet()
search for examples
view on GitHub
view source