[2] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ;+ |
---|
| 5 | ; |
---|
[133] | 6 | ; @fie-comments |
---|
| 7 | ; extractoin of subdomains of matrixes; Even if the subdomain is "pierced" (see the example) |
---|
| 8 | ; By default, IDL can make extractions of subdomain: |
---|
[2] | 9 | ; |
---|
| 10 | ; IDL> a=indgen(5,5) |
---|
| 11 | ; IDL> print, a |
---|
| 12 | ; 0 1 2 3 4 |
---|
| 13 | ; 5 6 7 8 9 |
---|
| 14 | ; 10 11 12 13 14 |
---|
| 15 | ; 15 16 17 18 19 |
---|
| 16 | ; 20 21 22 23 24 |
---|
| 17 | ; IDL> print, a[[0,2],3] |
---|
| 18 | ; 15 17 |
---|
| 19 | ; IDL> print, a[[0,2],*] |
---|
| 20 | ; 0 2 |
---|
| 21 | ; 5 7 |
---|
| 22 | ; 10 12 |
---|
| 23 | ; 15 17 |
---|
| 24 | ; 20 22 |
---|
[133] | 25 | ; but |
---|
[2] | 26 | ; IDL> print, a[[0,2],[3,4]] |
---|
| 27 | ; 15 22 |
---|
[133] | 28 | ; while |
---|
[2] | 29 | ; IDL> print, extrait(a,[0,2],[3,4]) |
---|
| 30 | ; 15 17 |
---|
| 31 | ; 20 22 |
---|
| 32 | ; |
---|
| 33 | ; |
---|
[133] | 34 | ; you better use extrac2 |
---|
[2] | 35 | ; |
---|
[133] | 36 | ; @obsolete |
---|
[2] | 37 | ; |
---|
[133] | 38 | ; @categories utilities |
---|
[2] | 39 | ; |
---|
[133] | 40 | ; @param tab {in}{required} a 1,2,3 or 4 dim table |
---|
[2] | 41 | ; |
---|
[133] | 42 | ; @param indicex {in}{required} can have 2 forms: |
---|
| 43 | ; 1)a vector containing indexes of lines we want to keep |
---|
| 44 | ; 2)the string '*' if we want to keep all lines. |
---|
[2] | 45 | ; |
---|
[133] | 46 | ; @param indicey {in}{required} the same thing that indicex but for dim 2. |
---|
[2] | 47 | ; |
---|
[133] | 48 | ; @param indicez {in}{required} the same thing that indicex but for dim 3. |
---|
| 49 | ; |
---|
| 50 | ; @param indicet {in}{required} the same thing that indicex but for dim 4. |
---|
[2] | 51 | ; |
---|
[133] | 52 | ; @returns a matrix 1,2,3 or 4d extract from tab |
---|
[2] | 53 | ; |
---|
[133] | 54 | ; @restrictions res=-1 in case of mistake |
---|
[2] | 55 | ; |
---|
[133] | 56 | ; |
---|
| 57 | ; @examples I have a dim 2 matrix named A. I want extract a small intersection |
---|
| 58 | ; matrix 2d of the line 2,3 and 7 and of the column 0 and 1: |
---|
[2] | 59 | ; |
---|
| 60 | ; res=extrait(A,[2,3,7],[0,1]) |
---|
| 61 | ; |
---|
[133] | 62 | ;other ex: |
---|
[2] | 63 | ; IDL> print, a |
---|
| 64 | ; a b c |
---|
| 65 | ; d e f |
---|
| 66 | ; g h i |
---|
| 67 | ; IDL> print, extrait(a,[0,2],[0,2]) |
---|
| 68 | ; a c |
---|
| 69 | ; g i |
---|
| 70 | ; |
---|
[133] | 71 | ; @history Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
[2] | 72 | ; 12/1/1999 |
---|
[133] | 73 | ; 29/4/1999: correction of a bug and complement of the heading |
---|
| 74 | ; |
---|
| 75 | ; @version $Id$ |
---|
| 76 | ; |
---|
[2] | 77 | ;- |
---|
| 78 | ;------------------------------------------------------------ |
---|
| 79 | ;------------------------------------------------------------ |
---|
| 80 | ;------------------------------------------------------------ |
---|
| 81 | FUNCTION extrait, tab, indicex, indicey, indicez, indicet |
---|
| 82 | ;------------------------------------------------------------ |
---|
[114] | 83 | ; |
---|
| 84 | compile_opt idl2, strictarrsubs |
---|
| 85 | ; |
---|
[133] | 86 | case n_params() of |
---|
| 87 | 0:return, extrac2() |
---|
| 88 | 1:return, extrac2(tab) |
---|
| 89 | 2:return, extrac2(tab, indicex) |
---|
| 90 | 3:return, extrac2(tab, indicex, indicey) |
---|
| 91 | 4:return, extrac2(tab, indicex, indicey, indicez) |
---|
| 92 | 5:return, extrac2(tab, indicex, indicey, indicez, indicet) |
---|
| 93 | endcase |
---|
[2] | 94 | end |
---|