Back Home Up Next

Subchapters:

Working with arrays

You can extract a part of an array, let say the 4th to the 7th elements of vec1 (the arrays begin with the index = 0):

        IDL> print,vec1[3:6]
                   4       3       2       3

The version 5.0 of IDL recommends to use [ ] instead of ( ) for the arrays.

You can also extract part of an image. The * (star) symbol means all the (remaining) elements in the considered dimension.

        IDL> sub_image = image1[101:400,101:400]
        IDL> help,sub_image
            SUB_IMAGE       FLOAT     = Array[300, 300]
        IDL> spectr = image1[245,*]
        IDL> help,spectr
            SPECTR          FLOAT     = Array[1, 512]
        IDL> help,image1[200:*,200:*]

Tip:  The spectr here is a 2D array, with only 1 column. If you want to have a 1D vector, you have to reform it:

        IDL> spectr = reform(spectr)
        IDL> help,spectr
            SPECTR          FLOAT     = Array[512]

This is not the case for the row vectors, compare:

        IDL> help,image1[0,*]
        IDL> help,image1[*,0]

 

IDL courses C. Morisset © 2004 IA/UNAM V 2.2

Back Home Up Next