The use of size function in IDL

The size function is a commonly used function in IDL, and its return value is an array of data structure information

Its syntax is:
Result=SIZE(Expression [, /L64] [, /DIMENSIONS | , /FILE_LUN | , /FILE_OFFSET | , /N_DIMENSIONS | , /N_ELEMENTS | , /SNAME, | , /STRUCTURE | , /TNAME | , / TYPE] )

The keywords are: (the green part is personal understanding, if there is any error, please correct it)

Expression is a scalar, array, or [expression]

expression can be regarded as an identifier, an array name; [, /L64] can be regarded as the number of elements set in an array, which is 64 bits long. The total meaning is equivalent to a[5] (an array name + the number of 5 elements set)

DIMENSIONS set the function to return only the size of each dimension

There are n values ​​returned to represent that the data is n-dimensional, and then the first to nth values ​​are the size of each dimension.

Such as: 500, 600, 700

It means that the data is three-dimensional data, the size of the first dimension is 500, the size of the second dimension is 600, and the size of the third dimension is 700

FILE_LUN: The full name of LUN is Logical Unit Number, which is the logical unit number. Its main function is to assign a logical unit number (LUN) to the connected server (you can ignore it)

FILE_OFFSET: file offset, the address in the file is different from the memory representation, it is represented by the offset (File offset) ( you can ignore it)
N_DIMENSIONS setting function only returns the total dimension of the data

Such as: 0 – constant or variable undefined

1 – one dimension

2 – two-dimensional….
N_ELEMENTS sets the function to return only the number of elements

It is equivalent to the total number of elements of the data, including all dimensions, which is probably the result of multiplying the number of elements in all dimensions (the result is similar, not necessarily accurate, because not all dimensions can be filled with elements)

SNAME: structure name (can be omitted)

STRUCTURE: structure (can not be seen)

The TNAME setting function only returns the data type name

is the data type

The TYPE setting function only returns the code of the data type

is the number corresponding to the data type

Type code, 0: undefined, 1: byte, 2: int, 3: long, 4: float…

Output order:

Second to N_dims+1: DIMENSIONS

(There are n-dimension output n numbers, only one dimension is a number)
The penultimate: TYPE
The penultimate one: N_ELEMENTS


Note: The red font at the beginning of the article indicates that the size function returns an array, so we can use it like an array

Example: IDL used


2: arr is a two-dimensional data

3: The first dimension, which is the column, has three numbers

3: The second dimension, or row, has three numbers

2: The corresponding number of the data type is 2, and 2 is an integer

9: arr has a total of 9 numbers


See this blog post, written in great detail: IDL size function

Leave a Comment

Your email address will not be published. Required fields are marked *