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] ) + 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 [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, 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
acos( double ds ) → double
return the acos of the real number in radians.
Parameters
ds - the cos of the angle
Returns:
the angle in radians
[search for examples]
[view on GitHub]
[view on old javadoc]
[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.
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
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]
add
add( QDataSet ds1, QDataSet ds2, QDataSet ds3 ) → QDataSet
three-argument add is provided as a convenience for environments (like Java
and the Mash-up tool in Autoplot) where add is not an in-fix operator. For example,
when taking the magnitude this allows for sqrt( add( pow( ds1,2), pow( ds2,2), pow( ds3,2) ) )
which is more readable than sqrt( add( add( pow( ds1,2), pow( ds2,2) ), pow( ds3,2) ) ) )
Parameters
ds1 - a rank N dataset
ds2 - a rank N dataset or one with compatible geometry
ds3 - a rank N dataset or one with compatible geometry
Returns:
the sum
[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
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
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 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
applyIndex( QDataSet ds, QDataSet r ) → org.das2.qds.WritableDataSet
apply the indices to the dataset, resorting the 0th dimension using the indices of r.
Parameters
ds - values to return, a rank 1 N-element dataset, or rank 2 N by m element dataset.
r - the indices.
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 indices
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 indices to the given dimension.
Parameters
ds - rank N qube of data.
dimension - the dimension on which the indices should be applied.
indices - the indices to apply.
Returns:
the data with in indices applied.
See Also:
https://github.com/autoplot/dev/blob/master/demos/2023/20230909/demoApplyIndex.jy
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 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
applyUnaryOp( Object 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 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]
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
asin( double ds ) → double
return the asin of the real number in radians.
Parameters
ds - the sin of the angle
Returns:
the angle in radians
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
asin( Object ds ) → QDataSet [view source]
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
atan( double ds ) → double
arc tangent function
Parameters
ds - the value
Returns:
the angle in radians
See Also:
Math#atan(double)
[search for examples]
[view on GitHub]
[view on old javadoc]
[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
atan2( double y, double x ) → double
4-quadrant arc tangent. 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 position
x - the x position
Returns:
the angle in radians
See Also:
Math#atan2(double, double)
[search for examples]
[view on GitHub]
[view on old javadoc]
[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]