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( long x ) → long
abs( double v ) → double
abs( Object ds1 ) → QDataSet

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] ) + ds[i]
If a fill value is encountered, then zero is added to the accumulation.

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
accum( QDataSet ds ) → QDataSet
accum( Object ds ) → QDataSet

acos

acos( QDataSet ds ) → QDataSet

element-wise arccos, the inverse of the cos function.

Parameters

ds - the values

Returns:

the angles for the values in radians

See Also:

Math#acos(double)


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

acos( double ds ) → double
acos( Object ds ) → QDataSet

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.
https://sourceforge.net/p/autoplot/bugs/2558/, which shows the issues with CDF_TT2000.


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

add( Object ds1, Object ds2 ) → QDataSet
add( QDataSet ds1, QDataSet ds2, QDataSet ds3 ) → QDataSet

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

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

See Also:

concatenate(QDataSet, QDataSet) which is the same thing.


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


appendEvents

Deprecated: since append works with events datasets.

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( Object ds1, Object ds2, org.das2.qds.ops.Ops.BinaryOp op ) → org.das2.qds.MutablePropertyDataSet

applyIndex

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

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

Parameters

vv - values to return, a rank 1, N-element dataset.
ds - the indices.
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( QDataSet ds, QDataSet r ) → org.das2.qds.WritableDataSet
applyIndex( Object dso, QDataSet r ) → org.das2.qds.WritableDataSet
applyIndex( QDataSet ds, int dimension, QDataSet indices ) → org.das2.qds.MutablePropertyDataSet

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 and other appropriate metadata.

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( Object ds1, org.das2.qds.ops.Ops.UnaryOp op ) → org.das2.qds.MutablePropertyDataSet

arange

arange( int len0 ) → QDataSet

returns rank 1 dataset with values [0.,1.,2.,...]

Parameters

len0 - an int

Returns:

a rank 1 dataset

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


asin

asin( QDataSet ds ) → QDataSet

element-wise arcsin, the inverse of the sin function.

Parameters

ds - the values

Returns:

the angles for the values in radians

See Also:

Math#asin(double)


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

asin( double ds ) → double
asin( Object ds ) → QDataSet

atan

atan( QDataSet ds ) → QDataSet

element-wise arc tangent function

Parameters

ds - the values

Returns:

the angles in radians

See Also:

Math#atan(double)


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

atan( double ds ) → double
atan( Object ds ) → QDataSet

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
atan2( Object dsy, Object dsx ) → QDataSet

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]