## magnitude

magnitude( QDataSet ds ) → QDataSet

return the magnitudes of vectors in a rank 1 or greater dataset (typically rank 2). The last index should be the cartesian dimension. For example,

>      ds= getDataSet('http://autoplot.org/data/autoplot.cdf?BGSM') # BGSM[Epoch=24,cart=3]
>      m= magnitude(ds)

For rank 0, this just returns the absolute value, but with the same units.

### Parameters

ds - dataset of Rank N.

### Returns:

dataset of Rank N-1.

### See Also:

abs(QDataSet)
[search for examples] [view on GitHub] [view on old javadoc] [view source]
magnitude( Object ds1 ) → QDataSet [view source]

## matrixFormat

matrixFormat( QDataSet mm, String style ) → String

format the matrix values, using %.3f and tabs to make it legible.

### Parameters

mm - the 3x3 matrix.
style - "code" or "newlines". None/null is newlines.

### Returns:

formatted matrix

### See Also:

matrixParse(java.lang.String) will parse when style is "code"
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## matrixFromEuler

matrixFromEuler( String seq, Datum angle ) → QDataSet

return the matrix rotating about one axis.

### Parameters

seq - the string "x", "y", or "z"
angle - the angle in degrees or radians.

### Returns:

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

## matrixMultiply

matrixMultiply( QDataSet m, QDataSet v ) → QDataSet

matrix multiply the components of vector `v` by matrix `m`. Argument `v` can also be a rank 2 series of vectors (vv[n,3]), and argument `m` can be an array of matrices (mm[n,3,3]). Note that to multiply a vector and a matrix (instead of matrix and a vector), use matrixMultiply( transpose(m), v ).

### Parameters

m - matrix or array of matrices
v - vector or array of vectors

### Returns:

vectors in the same form as `b`

### See Also:

bundle(QDataSet, QDataSet, QDataSet) bundle for creating vectors from components.
slice1(QDataSet, int) for extracting components from the result.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## matrixParse

matrixParse( String smat ) → QDataSet

parse the string into a rank 2 matrix

### Parameters

smat - a string like '[[1,0,0],[0,1,0],[0,0,1]]'

### Returns:

rank 2 matrix.

### See Also:

matrixFormat(QDataSet, java.lang.String)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## maybeCopy

maybeCopy( QDataSet ads0 ) → org.das2.qds.WritableDataSet

Copy the dataset to an ArrayDataSet only if the dataset is not already an ArrayDataSet or BufferDataSet. Note this does not consider the mutability of the data. If the dataset is not mutable, then the original data could be returned (probably).

### Parameters

ads0 - a dataset.

### Returns:

an ArrayDataSet or BufferDataSet
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## mean

mean( QDataSet ds ) → QDataSet

Mean function that returns the average of the valid elements of a rank N dataset

### Parameters

ds - rank N dataset

### Returns:

rank 0 dataset

### See Also:

mode
median
variance(QDataSet)
meanAverageDeviation(QDataSet)
[search for examples] [view on GitHub] [view on old javadoc] [view source]
mean( Object o ) → QDataSet [view source]

## meanAverageDeviation

meanAverageDeviation( QDataSet ds ) → QDataSet

return the Mean Average Deviation (MAD) of the rank N dataset. The result will contain the USER_PROPERTIES with a map containing the mean and number of points.

### Parameters

ds - the rank N dataset.

### Returns:

the rank 0 mean average deviation of the dataset.

### See Also:

mean(QDataSet)
BinAverage#binMeanAverageDeviation(QDataSet, QDataSet)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## median

median( Object o ) → QDataSet

Median function that sorts a rank N dataset and returns its median. If lists are equal in size (even number of elements), always choose first element of 'more' list

### Parameters

o - object which can be interpreted as a dataset.

### Returns:

rank 0 dataset

### See Also:

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

## median

median( QDataSet ds ) → QDataSet

Median function that sorts a rank N dataset and returns its median. If lists are equal in size (even number of elements), always choose first element of 'more' list

### Parameters

ds - rank N dataset.

### Returns:

rank 0 dataset

### See Also:

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

## medianFilter

medianFilter( QDataSet ds, int size ) → QDataSet

1-D median filter with a boxcar of the given size. The first size/2 elements, and the last size/2 elements are copied from the input.

### Parameters

ds - rank 1 or rank 2 dataset. Future implementations may support higher rank data.
size - the boxcar size

### Returns:

rank 1 or rank 2 dataset.

### See Also:

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

## merge

merge( QDataSet ds1, QDataSet ds2 ) → QDataSet

Merge the two sorted rank N datasets, using their DEPEND_0 datasets, into one rank N dataset. If neither dataset has DEPEND_0, then this will use the datasets themselves. When ds1 occurs "before" ds2, then this is the same as concatenate. When there is a collision where two data points are coincident, use ds1[j]. This is fuzzy, based on the depend_0 cadence of ds1. When ds1 is null (or None), use ds2. Thanks to: http://stackoverflow.com/questions/5958169/how-to-merge-two-sorted-arrays-into-a-sorted-array

### Parameters

ds1 - rank N dataset, or null.
ds2 - rank N dataset

### Returns:

dataset of rank N with elements interleaved.

### See Also:

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

## mod

mod( QDataSet ds1, QDataSet ds2 ) → QDataSet

element-wise mod of two datasets with compatible geometry. This should support Units.t2000 mod "24 hours" to get result in hours.

### Parameters

ds1 - the numerator
ds2 - the divisor

### Returns:

the remainder after the division
[search for examples] [view on GitHub] [view on old javadoc] [view source]
mod( Object ds1, Object ds2 ) → QDataSet [view source]

## mode

mode( QDataSet ds ) → QDataSet

return the most frequently occurring element of the valid elements of a rank N dataset

### Parameters

ds - rank N dataset.

### Returns:

the rank 0 dataset

### See Also:

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

## modp

modp( QDataSet ds1, QDataSet ds2 ) → QDataSet

element-wise mod of two datasets with compatible geometry. This returns a positive number for -18 % 10. This is Python's behavior. This should support Units.t2000 mod "24 hours" to get result in hours.

### Parameters

ds1 - the numerator
ds2 - the divisor

### Returns:

the remainder after the division

### See Also:

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

## monotonicSubset

monotonicSubset( QDataSet ds ) → org.das2.qds.MutablePropertyDataSet

ensure that there are no non-monotonic or repeat records, by removing the first N-1 records of N repeated records. Warning: this was extracted from AggregatingDataSource to support BufferDataSets, and is minimally implemented. When ds has property QDataSet.DEPEND_0, then this is used to identify the monotonic subset. When ds is a set of timetags, then these are used.

### Parameters

ds - MutablePropertyDataSet, which must be writable.

### Returns:

dataset, possibly with records removed.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## multiply

multiply( QDataSet ds1, QDataSet ds2 ) → QDataSet

element-wise multiply of two datasets with compatible geometry. Presently, either ds1 or ds2 should be dimensionless. TODO: units improvements.

### Parameters

ds1 - a QDataSet
ds2 - a QDataSet

### Returns:

a QDataSet

### See Also:

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