subset

From DavinciWiki
Jump to: navigation, search

Description

Return a subset of the data array

This function provides the user the ability to select multiple ranges for each direction of the array. This mimics the functionality of vm which was a spectral processing tool for TES data.

See subset operations for other common subset usages. Any technique or syntax shown on that page can be used in combination with this function.

Arguments and Return Values

Arguments: any data type and the corresponding indexes and ranges

Return Value: the subsetted data, either returned or with the input variable modified

Usage

Syntax: subset(data [,ranges] [,x=STRING][, y=STRING][, z=STRING][, struct=BOOL])

data = the input data as pass by reference

Or

Syntax: subset(data=VAL [,ranges][,x=STRING][, y=STRING][, z=STRING][, struct=BOOL])

Usage:

data = input data as pass by name type

Note: this type will not return data but modify the input variable

Options:

ranges = string of all ranges for all dimensions (comma separated). This or explicitly specified axes may not be used simultaneously

x = string of ranges in x (e.g. "1//2//4:8//11:", default is none)

y = string of ranges in y (e.g. "1//2//4:8//11:", default is none)

z = string of ranges in z (e.g. "1//2//4:8//11:", default is none)


Or they can be specified individually as concatenated numbers in the x direction

x = string of ranges in x (e.g. 1//2//4//8//11, default is none)

y = string of ranges in y (e.g. 1//2//4//8//11, default is none)

z = string of ranges in z (e.g. 1//2//4//8//11, default is none)

struct = return the full structure with how args were parsed

Examples

First create the input test array. We will use just a 3D array but this can work with any davinci datatype except indexing of structures.

dv> a=create(100,100,100)
100x100x100 array of int, bsq format [4,000,000 bytes]

In the below cases, we return the data as the variable "out"

This is just a case in x with single indices in x only

dv> out=subset(a,x="10//54//55")
3x100x100 array of int, bsq format [120,000 bytes]

This is a combination case of overlapping ranges and indices in x only

dv> out=subset(a,x="10:15//54:64//55:65")
28x100x100 array of int, bsq format [1,120,000 bytes]

More complicated subset, using one sided ranges, indices and two sided ranges in x and y

dv> out=subset(a,x=":10//54//57//59//61:68//66//1//99:",y="55:65")
25x11x100 array of int, bsq format [110,000 bytes]

Add the z component and we have most the options for this function

dv> out=subset(a,x=":10//54//57//59//61:68//66//1//99:",y="55:65",z="44")
25x11x1 array of int, bsq format [1,100 bytes]

Using the single argument option with all dimensions specified

dv> out=subset(a,":10//54//57//59//61:68//66//1//99:,55:65,44")
25x11x1 array of int, bsq format [1,100 bytes]

Using the single argument option with only one dimension specified

dv> out=subset(a,",55:65//77,")
100x12x100 array of int, bsq format [480,000 bytes]

Here we use the second colon (in the first range) to choose every 3rd (but can be Nth) pixel, with indices, and two sided ranges

dv> out=subset(a,x="10:27:3//57//59//42:52")
19x100x100 array of int, bsq format [760,000 bytes]

In this case we alter the input variable "a" and return nothing

dv> subset(data=a,x=":10//54//57//59//61:68//66//1//99:",y="55:65",z="44")

It also works on text arrays for example

Create the blank text array and fill it with some random words

dv> text=text(10)
Text Buffer with 10 lines of text
   1:
   2:
   3:
   4:
   5:
   6:
   7:
   8:
   9:
   10:
dv> text[,1]="Mary had a little lamb"
"Mary had a little lamb"
dv> text[,2::3]="Who's fleece was white as snow"
"Who's fleece was white as snow"

Show the result variable

dv> text
Text Buffer with 10 lines of text
   1: Mary had a little lamb
   2: Who's fleece was white as snow
   3:
   4:
   5: Who's fleece was white as snow
   6:
   7:
   8: Who's fleece was white as snow
   9:
   10:

Run the subset in x and y, where x is the character column per line (y) of text

dv> out=subset(text,x="1:4//12:17",y="1//5:6//8//10")
Text Buffer with 5 lines of text
   1: Marylittle
   2: Who'e was
   3:
   4: Who'e was
   5:

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Recent Library Changes

Created On: 03-26-2011
Modified On: 04-25-2011

Personal tools