Subset

Summary

Creates a raster object that is a subset of the input multidimensional raster based on selected variables and dimension intervals.

Discussion

Use the Subset function to extract a subgroup of variable data from a multidimensional raster object. You can use the subgroup as an input to additional functions.

The function creates a raster object that is a subgroup of the input, with dimension and variable information defined by the input parameters.

The referenced raster dataset for the raster object is temporary. To make it permanent, you can call the raster object's save method.

Syntax

Subset (in_raster, {variables}, {dimension_definitions})
ParameterExplanationData Type
in_raster

The input multidimensional raster dataset.

Raster
variables
[variables,...]

A variable name or a list of variable names to be included in the output raster. If not specified, all variables will be included.

String
dimension_definitions

The dimension interval used to subset the multidimensional raster. This parameter is passed as a dictionary in which the key:value pairs are described as dimension_name:dimension interval. The key is the name of the dimension along which you wish to subset, and the value is the dimension interval. The dimension interval must use one of the following formats:

  • A single dimension input.

    For example, to subset variables only at the depth of 0, use {"depth": 0 }.

  • A tuple containing the minimum and maximum dimension values.

    For example, to subset variables from a depth of 0 to 100, use {"depth": (-100,0)}.

  • A tuple containing minimum and maximum dimension values, an increment size and an increment unit.

    For example, to subset variables from the year 1980 until the end of the time series, extracting the first day of every year, use {"StdTime": ('1980-01-01T12:00:00', None, 1, 'year')}.

    To subset variables with the time dimension 1980 to 2000, extracting January of every year, use {"StdTime": ('1980-01-01T12:00:00', 1980-31-01T12:00:00', 1, 'year')}.

  • A list containing any of the above. You can include multiple single-dimension inputs and multiple minimum and maximum ranges.

    For example, to subset variables at depths of 0, 50, and 200, use {"depth": [0, -50, -200]}.

    For example, to subset variables from a depth of 0 to 100 and also at a depth of 500, use {"depth": [-500, (-100, 0)]}.

Dictionary
Return Value
Data TypeExplanation
Raster

The output subset multidimensional raster.


In this topic