## org.das2.qds.ops.Ops

A fairly complete set of operations for QDataSets, including binary operations like "add" and "subtract", but also more abstract (and complex) operations like smooth and fftPower. Most operations check data units and validity, but consult the documentation for each function. These operations are all available in Jython scripts, and some, like add, are connected to operator symbols like +.

## PI

closest double to π or TAU/2

## TAU

closest double to τ or 2*PI

## E

the closest double to e, the base of natural logarithms.

## abs

abs( QDataSet ds1 ) → QDataSet

element-wise abs. For vectors, this returns the length of each element. Note Jython conflict needs to be resolved. Note the result of this will have dimensionless units, and see magnitude for the more abstract operator. For ratio-type units (Stevens) like "kms", the unit is preserved.

### Parameters

ds1 - the dataset

### Returns:

dataset with the same geometry

### See Also:

Ops#magnitude(QDataSet) magnitude(ds), which preserves the sign.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## abs

abs( long x ) → long

return the abs of the long, to support Jython properly.

### Parameters

x - the long

### Returns:

abs of the long
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## abs

abs( double v ) → double

return the abs of the double, to support Jython properly.

### Parameters

v - the valye

### Returns:

abs of the value
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## abs

abs( Object ds1 ) → QDataSet

promote the list, double, array etc to QDataSet before taking abs.

### Parameters

ds1 - list, double, array, etc

### Returns:

the abs in a QDataSet
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## accum

accum( QDataSet accumDs, QDataSet ds ) → QDataSet

return an array that is the running sum of each element in the array, starting with the value accum. Result[i]= accum + total( ds[0:i+1] )

### Parameters

accumDs - the initial value of the running sum. Last value of Rank 0 or Rank 1 dataset is used, or may be null.
ds - each element is added to the running sum

### Returns:

the running of each element in the array.

### See Also:

diff(QDataSet)
[search for examples] [view on GitHub] [view on old javadoc] [view source]
accum( Object accumDs, Object ds ) → QDataSet [view source]

## accum

accum( QDataSet ds ) → QDataSet

return an array that is the running sum of each element in the array, starting with the value accum. Result[i]= total( ds[0:i+1] )

### Parameters

ds - each element is added to the running sum

### Returns:

the running of each element in the array.

### See Also:

diff(QDataSet)
[search for examples] [view on GitHub] [view on old javadoc] [view source]
accum( Object ds ) → QDataSet [view source]

## acos

acos( QDataSet ds ) → QDataSet

element-wise arccos.

### Parameters

ds - a QDataSet

### Returns:

a QDataSet
[search for examples] [view on GitHub] [view on old javadoc] [view source]
acos( double ds ) → double [view source]
acos( Object ds ) → QDataSet [view source]

## add

add( QDataSet ds1, QDataSet ds2 ) → QDataSet

add the two datasets which have the compatible geometry and units. For example,

>     ds1=timegen('2014-10-15T07:23','60s',300)
>     ds2=dataset('30s')
>     print add(ds1,ds2)

The units handling is quite simple, and this will soon change. Note that the Jython operator + is overloaded to this method.

### Parameters

ds1 - a rank N dataset
ds2 - a rank M dataset with compatible geometry

### Returns:

the element-wise sum of the two datasets.

### See Also:

addGen(QDataSet, QDataSet, java.util.Map) addGen, which shows how units are resolved.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## add

add( Object ds1, Object ds2 ) → QDataSet

add the two datasets which have the compatible geometry and units.

### Parameters

ds1 - QDataSet, array, string, scalar argument
ds2 - QDataSet, array, string, scalar argument with compatible geometry.

### Returns:

the element-wise sum of the two datasets.

### See Also:

dataset(java.lang.Object)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## and

and( QDataSet ds1, QDataSet ds2 ) → QDataSet

element-wise logical and function. non-zero is true, zero is false.

### Parameters

ds1 - a QDataSet
ds2 - a QDataSet

### Returns:

a QDataSet

### See Also:

bitwiseAnd(QDataSet, QDataSet)
[search for examples] [view on GitHub] [view on old javadoc] [view source]
and( Object ds1, Object ds2 ) → QDataSet [view source]

## append

append( QDataSet ds1, QDataSet ds2 ) → QDataSet

append two datasets that are QUBEs. DEPEND_0 and other metadata is handled as well. So for example:

>     ds1= findgen(10)
>     ds2= findgen(12)
>     print append(ds1,ds2)  ; dataSet[22] (dimensionless)

If both datasets are ArrayDataSets and of the same component type, then the result will have this type as well. Otherwise DDataSet is returned.

### Parameters

ds1 - null or rank N dataset
ds2 - rank N dataset with compatible geometry.

### Returns:

a QDataSet
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## appendEvents

appendEvents( QDataSet ev1, QDataSet ev2 ) → QDataSet

provide explicit method for appending two events scheme datasets. This will probably be deprecated, and this was added at 17:30 for a particular need.

### Parameters

ev1 - a QDataSet
ev2 - a QDataSet

### Returns:

a QDataSet
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## applyBinaryOp

applyBinaryOp( QDataSet ds1, QDataSet ds2, org.das2.qds.ops.Ops.BinaryOp op ) → org.das2.qds.MutablePropertyDataSet

apply the binary operator element-for-element of the two datasets, minding dataset geometry, fill values, etc. The two datasets are coerced to compatible geometry, if possible (e.g.Temperature[Time]+2deg), using CoerceUtil.coerce. Structural metadata such as DEPEND_0 are preserved where this is reasonable, and dimensional metadata such as UNITS are dropped.

### Parameters

ds1 - the first argument
ds2 - the second argument
op - binary operation for each pair of elements

### Returns:

the result with the same geometry as the pair.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## applyBinaryOp

applyBinaryOp( Object ds1, Object ds2, org.das2.qds.ops.Ops.BinaryOp op ) → org.das2.qds.MutablePropertyDataSet

As with applyBinaryOp, but promote compatible objects to QDataSet first.

### Parameters

ds1 - the first operand
ds2 - the second operand
op - binary operation for each pair of elements

### Returns:

the result with the same geometry as the pair.

### See Also:

dataset(java.lang.Object)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## applyIndex

applyIndex( QDataSet vv, QDataSet ds, Number fillValue ) → org.das2.qds.WritableDataSet

apply the indeces, checking for out-of-bounds values.

### Parameters

vv - values to return, a rank 1, N-element dataset.
ds - the indeces.
fillValue - the value to use when the index is out-of-bounds.

### Returns:

data a dataset with the geometry of ds and the units of values.

### See Also:

subset(QDataSet, QDataSet) subset, which does the same thing.
applyIndex(QDataSet, int, QDataSet)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## applyIndex

applyIndex( QDataSet ds, QDataSet r ) → org.das2.qds.WritableDataSet

apply the indeces

### Parameters

ds - values to return, a rank 1 N-element dataset, or rank 2 N by m element dataset.
r - the indeces.

### Returns:

data a dataset with the geometry of ds and the units of values.

### See Also:

subset(QDataSet, QDataSet) subset, which does the same thing.
applyIndex(QDataSet, int, QDataSet)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## applyIndex

applyIndex( Object dso, QDataSet r ) → org.das2.qds.WritableDataSet

apply the indeces

### Parameters

dso - values to return, a rank 1, N-element dataset.
r - the indices.

### Returns:

data a dataset with the geometry of ds and the units of values.

### See Also:

applyIndex(QDataSet, int, QDataSet)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## applyIndex

applyIndex( QDataSet ds, int dimension, QDataSet indices ) → org.das2.qds.MutablePropertyDataSet

apply the indeces to the given dimension.

### Parameters

ds - a QDataSet
dimension - an int
indices - a QDataSet

### Returns:

an org.das2.qds.MutablePropertyDataSet

### See Also:

SubsetDataSet
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## applyUnaryOp

applyUnaryOp( QDataSet ds1, org.das2.qds.ops.Ops.UnaryOp op ) → org.das2.qds.MutablePropertyDataSet

apply the unary operation (such as "cos") to the dataset, propagating DEPEND_0 through DEPEND_3 are propagated. TODO: This should be reviewed for speed (iterator is known to be slow) and other metadata that can be preserved.

### Parameters

ds1 - the argument
op - the operation for each element.

### Returns:

the result the the same geometry.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## applyUnaryOp

applyUnaryOp( Object ds1, org.das2.qds.ops.Ops.UnaryOp op ) → org.das2.qds.MutablePropertyDataSet

apply the unary operation (such as "cos") to the dataset. DEPEND_[0-3] is propagated.

### Parameters

ds1 - the argument which can be converted to a dataset.
op - the operation for each element.

### Returns:

the result the the same geometry.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## asin

asin( QDataSet ds ) → QDataSet

element-wise arcsin.

### Parameters

ds - a QDataSet

### Returns:

a QDataSet
[search for examples] [view on GitHub] [view on old javadoc] [view source]
asin( double ds ) → double [view source]
asin( Object ds ) → QDataSet [view source]

## atan

atan( QDataSet ds ) → QDataSet

element-wise atan.

### Parameters

ds - a QDataSet

### Returns:

a QDataSet
[search for examples] [view on GitHub] [view on old javadoc] [view source]
atan( double ds ) → double [view source]
atan( Object ds ) → QDataSet [view source]

## atan2

atan2( QDataSet y, QDataSet x ) → QDataSet

element-wise atan2, 4-quadrant atan. From the Java atan2 documentation: "Returns the angle theta from the conversion of rectangular coordinates ( x, y) to polar coordinates (r, theta). This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi."

Note different languages have different argument order. Microsoft Office uses atan2(x,y); IDL uses atan(y,x); Matlab uses atan2(y,x); and NumPy uses arctan2(y,x).

### Parameters

y - the y values
x - the x values

### Returns:

angles between -PI and PI

### See Also:

java.lang.Math#atan2(double, double)
[search for examples] [view on GitHub] [view on old javadoc] [view source]
atan2( double y, double x ) → double [view source]
atan2( Object dsy, Object dsx ) → QDataSet [view source]

## autoHistogram

autoHistogram( QDataSet ds ) → QDataSet

AutoHistogram is a one-pass self-scaling histogram, useful in autoranging data. The data is fed into the routine, and bins will grow as more and more data is added, to result in about 100 bins. For example, if the initial binsize is 1.0 unit, and the data extent is 0-200, then bins are combined so that the new binsize is 2.0 units and 100 bins are used.

### Parameters

ds - rank N dataset (all ranks are supported).

### Returns:

rank 1 dataset
[search for examples] [view on GitHub] [view on old javadoc] [view source]