## org.das2.qds.SemanticOps

Common expressions that apply semantics to QDataSet. Introduced to reduce a lot of repeated code, but also to make it clear where semantics are being applied.

## bounds

bounds( QDataSet ds ) → QDataSet

return the bounds DS[ JOIN_0=x,y; BINS_1=min,maxInclusive ] of the datasets independent parameters. This is only implemented for:

rank 2 Tables | extent(X),extent(Y) and Z is not represented
rank 3 array of tables | extent(X),extent(Y) and Z is not represented
rank 1 Y(X) | extent(X),extent(Y)
not for rank 2 bundle dataset
not for rank 1 bundle dataset

The zeroth dimension will be the physical dimension of the DEPEND_0 values. Or said another way:

bounds[0,0]= X min | bounds[0,1] = X max | bounds.slice(0) is the extent of X |
bounds[1,0]= Y min | bounds[1,1] = Y max | bounds.slice(1) is the extent of Y |

### Parameters

ds - rank 2 dataset with BINS_1="min,maxInclusive"

### Returns:

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

## cadenceCheck

cadenceCheck( QDataSet tds, QDataSet ds ) → QDataSet

return a dataset with 1's where the cadence following this measurement is acceptable, and 0's where there should be a break in the data. For example, here's some pseudocode:

>        findex= Ops.interpolate( xds, x )
>        cadenceCheck= cadenceCheck(xds)
>        r= where( cadenceCheck[floor(findex)] eq 0 )
>        x[r]= fill

Presently this just uses guessXTagWidth to get the cadence, but this may allow a future version to support mode changes. The result is a dataset with the same length, and the last element is always 1.

### Parameters

tds - rank 1 dataset of length N.
ds - dataset dependent on tds and used to detect valid measurements, or null.

### Returns:

dataset with length N

### See Also:

Ops#valid which checks for fill and valid_min, valid_max.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## checkPropertyType

checkPropertyType( String prop, Object value, boolean throwException ) → boolean

verify property types. For example, that UNITS is a org.das2.datum.Units, etc. Returns true for unrecognized property names (future expansion) and null. If throwException is true, then an IllegalArgumentException is thrown.

### Parameters

prop - the property name, e.g. QDataSet.CADENCE
value - the candidate value for the property.
throwException - if true, throw descriptive exception instead of returning false.

### Returns:

true if the property type is okay.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## doubleValue

doubleValue( Number value ) → Double

returns the Double value of the number, preserving null and NaN.

### Parameters

value - a Number

### Returns:

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

## getComponentLabels

getComponentLabels( QDataSet ds ) → String[]

return the labels for a dataset using BUNDLE_1 and DEPEND_1. If BUNDLE_1 is defined and contains a LABEL, then it is used, otherwise a string value of the data is used, supporting legacy bundles, and if no DEPEND_1 is found then use the NAME properties from the bundle, or "ch_i" for each channel.

### Parameters

ds - the dataset, with a BUNDLE_1 or DEPEND_1 dimension which could be used.

### Returns:

labels for each bundled dataset.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getComponentNames

getComponentNames( QDataSet ds ) → String[]

return the labels for a bundle dataset. For a rank 2 bundle, this will be found in BUNDLE_1, or legacy ones may have nominal data for DEPEND_1. For a rank 1 bundle this will be BUNDLE_0.

### Parameters

ds - rank 1 or rank 2 bundle.

### Returns:

the column names.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getDatum

getDatum( QDataSet ds, double d ) → Datum

returns the value as a datum. Note this should be used with reservation, this is not very efficient when the operation is done many times.

### Parameters

ds - dataset providing the UNITS and VALID_MIN, VALID_MAX and FILL_VALUE.
d - the double.

### Returns:

a datum representing the value.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getDependentDataSet

getDependentDataSet( QDataSet ds ) → QDataSet

return the dataset that is dependent on others. For a bundle, we use DataSetOps.unbundleDefaultDataSet

### Parameters

ds - a QDataSet

### Returns:

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

## getLooseUnitsConverter

getLooseUnitsConverter( QDataSet src, QDataSet dst ) → org.das2.datum.UnitsConverter

returns the UnitsConverter, or IDENTITY if the converter cannot be found and one of the two units is dimensionless.

### Parameters

src - the dataset from which we get the original units.
dst - the dataset from which we get the destination units.

### Returns:

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

## getPlanarView

getPlanarView( QDataSet ds, String name ) → QDataSet

returns the plane requested by name, or null if it does not exist. If the name is PLANE_i, then return PLANE_i, otherwise return the dataset with this name. Note QDataSet has the rule that if PLANE_i is null, then all PLANE_(i+1) must also be null.

### Parameters

ds - a QDataSet
name - a String

### Returns:

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

## getPropertyType

getPropertyType( String prop ) → String

return the property type expected for the property.

### Parameters

prop - a String

### Returns:

QDataSet, String, Number, Units, or CacheTag
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getSimpleTableContaining

getSimpleTableContaining( QDataSet tds, Datum x, Datum y ) → QDataSet

return the first table of the bundle containing x and y

### Parameters

tds - a QDataSet
x - a Datum
y - a Datum

### Returns:

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

## getUnits

getUnits( QDataSet ds ) → Units

returns the units found in the UNITS property of the dataset, or Units.dimensionless if it is not found.

### Parameters

ds - a QDataSet

### Returns:

the units found in the dataset, or Units.dimensionless.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getUnitsConverter

getUnitsConverter( QDataSet src, QDataSet dst ) → org.das2.datum.UnitsConverter

return the UnitsConverter that will convert data from src to the units of dst.

### Parameters

src - the dataset from which we get the original units.
dst - the dataset from which we get the destination units.

### Returns:

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

## guessXTagWidth

guessXTagWidth( QDataSet ds, QDataSet yds ) → Datum

return a reasonable tag width to use, or null if one cannot be guessed.

### Parameters

ds - the dataset containing data with a cadence.
yds - null or a dataset that may contain fill.

### Returns:

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

## isBins

isBins( QDataSet ds ) → boolean

Test for bins scheme, where BINS_1 (or BINS_0) is set. This is where a two-element index is min, max. Note the BINS dimension must be the last index of the QDataSet.

### Parameters

ds - a QDataSet

### Returns:

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

## isBundle

isBundle( QDataSet ds ) → boolean

Test for bundle scheme. Returns true if the BUNDLE_1 is set.

### Parameters

ds - a QDataSet

### Returns:

true if the dataset is a bundle
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## isJoin

isJoin( QDataSet ds ) → boolean

returns true if the dataset is rank 2 or greater with the first dimension a join dimension. Note this does not return true for implicit joins, where JOIN_0 is not set.

### Parameters

ds - a QDataSet

### Returns:

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

## isLegacyBundle

isLegacyBundle( QDataSet zds ) → boolean

See Ops.isLegacyBundle

### Parameters

zds - a QDataSet

### Returns:

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

## isMonotonic

isMonotonic( QDataSet ds ) → boolean

returns true if the dataset indicates that it is monotonically increasing. See DataSetUtil.isMonotonic.

### Parameters

ds - a QDataSet

### Returns:

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

## isRank1Bundle

isRank1Bundle( QDataSet ds ) → boolean

### Parameters

ds - a QDataSet

### Returns:

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

## isRank2Waveform

isRank2Waveform( QDataSet fillDs ) → boolean

Test for rank 2 waveform dataset, where DEPEND_1 is offset from DEPEND_0, and the data is the waveform. Other rules include:

- DEPEND_1 must be at least 128 elements long.
- DEPEND_1 must not be dimensionless.
- if DEPEND_1 is in the same units as DEPEND_0, then DEPEND_0 can be ignored.

  ### Parameters

  fillDs - a QDataSet

  ### Returns:

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

  ## isRank3JoinOfRank2Waveform

  isRank3JoinOfRank2Waveform( QDataSet ds ) → boolean

  Test for rank 3 dataset that is a join of rank 2 waveform datasets.

  ### Parameters

  ds - a QDataSet

  ### Returns:

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

  ## isSimpleBundleDataSet

  isSimpleBundleDataSet( QDataSet ds ) → boolean

  returns true if the dataset is a bundle of rank 1 datasets. If no dependence is declared, it is assumed that the first one or two datasets are the independent datasets, and the last is the dependent.

  >         X,Y   -->  Y(X)
  >         X,Y,Z -->  Z(X,Y)

  ### Parameters

  ds - a QDataSet

  ### Returns:

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

  ## isSimpleTableDataSet

  isSimpleTableDataSet( QDataSet ds ) → boolean

  returns true if the dataset is the scheme of a legacy TableDataSet with only one table. Note "Tables" have just one X unit and one Y unit, no bundles. Consider: rule about "duck typing": rules like !Ops.isBundle break this because it requires to be a simpleTable, you cannot be a bundle. LANL rich ASCII allows datasets to be both bundles and simple tables.

  ### Parameters

  ds - a QDataSet

  ### Returns:

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

  ## isTableDataSet

  isTableDataSet( QDataSet ds ) → boolean

  returns true if the dataset is the scheme of a legacy TableDataSet

  ### Parameters

  ds - a QDataSet

  ### Returns:

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

  ## isTimeSeries

  isTimeSeries( QDataSet ds ) → boolean

  returns true if the dataset is a time series. This is either something that has DEPEND_0 as a dataset with time location units, or a join of other datasets that are time series.

  ### Parameters

  ds - a QDataSet

  ### Returns:

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

  ## lookupTimeLengthUnit

  Deprecated: use Units.lookupTimeLengthUnit

  ## lookupTimeUnits

  Deprecated: use Units.lookupTimeUnits

  ## lookupTimeUnits

  Deprecated: use Units.lookupTimeUnits

  ## lookupUnits

  Deprecated: use Units.lookupUnits

  ## trim

  trim( QDataSet ds, DatumRange xrange, DatumRange yrange ) → QDataSet

  return the parts of the dataset within the bounds. This assumes how the data is visualized, so for example see SemanticOps.xtagsDataSet for which dimensions correspond to x and y.

  ### Parameters

  ds - the rank 1 or more dataset, including joins.
  xrange - the range or null if no trimming should be done
  yrange - the range or null if no trimming should be done

  ### Returns:

  the trimmed dataset.
  [search for examples] [view on GitHub] [view on old javadoc] [view source]

  ## weightsDataSet

  weightsDataSet( QDataSet ds ) → QDataSet

  return the weights dataset, possibly creating one based on VALID_MIN VALID_MAX and FILL_VALUE properties. The weights dataset will have value zero where the data is invalid, and a non-zero weight where it is valid. DataSets may also contain a weights table with relative weights, but this is not uniformly supported. Note: this uses QDataSet.WEIGHTS_PLANE Note: calls org.das2.qds.DataSetUtil.weightsDataSet.

  ### Parameters

  ds - a QDataSet

  ### Returns:

  QDataSet with same geometry containing zeros and non-zeros.

  ### See Also:

  org.das2.qds.ops.Ops#valid which is equivalent
  cadenceCheck which detects for gaps in cadence.
  [search for examples] [view on GitHub] [view on old javadoc] [view source]

  ## xtagsDataSet

  xtagsDataSet( QDataSet ds ) → QDataSet

  return the dataset containing the x tags for the dataset. This is QDataSet.DEPEND_0, or if that's null then IndexGenDataSet(ds.length). For a bundle, this is just the 0th dataset. For a join, this is a join of the xtags datasets of each dataset.

  ### Parameters

  ds - a QDataSet

  ### Returns:

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

  ## ytagsDataSet

  ytagsDataSet( QDataSet ds ) → QDataSet

  return the ytags for the simple table that is ds.

  - rank 2 spectrogram: Z[X,Y] → Y
  - bundle_1: ds[ :, [x,y,z] ] → y
  - [x,y,z] → y
  TODO: consider that these break duck typing goal, and really need a scheme to tell it how to get the dataset.

  ### Parameters

  ds - the dataset

  ### Returns:

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