Changeset 136 for trunk/SRC/Matrix/extrac2.pro
- Timestamp:
- 07/10/06 17:20:19 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Matrix/extrac2.pro
r134 r136 4 4 ;+ 5 5 ; 6 ; @fie-comments 7 ; extractoin of subdomains of matrixes; Even if the subdomain is "pierced" (see the example) 6 ; @file_comments 7 ; extraction of subdomains of matrixes; 8 ; Even if the subdomain is "pierced" (see the example) 8 9 ; By default, IDL can make extractions of subdomain: 9 10 ; 10 ; IDL> a=indgen(5,5) 11 ; IDL> print, a 11 ; IDL> a=indgen(5,5) 12 ; IDL> print, a 12 13 ; 0 1 2 3 4 13 14 ; 5 6 7 8 9 … … 15 16 ; 15 16 17 18 19 16 17 ; 20 21 22 23 24 17 ; IDL> print, a[[0,2],3] 18 ; IDL> print, a[[0,2],3] 18 19 ; 15 17 19 ; IDL> print, a[[0,2],*] 20 ; IDL> print, a[[0,2],*] 20 21 ; 0 2 21 22 ; 5 7 … … 24 25 ; 20 22 25 26 ; but 26 ; IDL> print, a[[0,2],[3,4]] 27 ; IDL> print, a[[0,2],[3,4]] 27 28 ; 15 22 28 29 ; while 29 ; IDL> print, extrac2(a,[0,2],[3,4]) 30 ; IDL> print, extrac2(a,[0,2],[3,4]) 30 31 ; 15 17 31 32 ; 20 22 … … 33 34 ; @categories utilities 34 35 ; 35 ; @param array {in}{required} a 1,2,3 or 4 dim input array 36 ; @param array {in}{required} 37 ; a 1,2,3 or 4 dim input array 36 38 ; 37 ; @param index1 {in}{required} can have 2 forms: 38 ; 1)a vector containing indexes of lines we want to keep 39 ; 2)the string '*' if we want to keep all lines. 39 ; @param index1 {in}{required} 40 ; can have 2 forms: 41 ; 1)a vector containing indexes of lines we want to keep 42 ; 2)the string '*' if we want to keep all lines. 40 43 ; 41 ; @param index2 {in}{required} the same thing that index1 but for dim 2. 44 ; @param index2 {in}{required} 45 ; the same thing that index1 but for dim 2. 42 46 ; 43 ; @param index3 {in}{required} the same thing that index1 but for dim 3. 47 ; @param index3 {in}{required} 48 ; the same thing that index1 but for dim 3. 49 ; 50 ; @param index4 {in}{required} 51 ; the same thing that index1 but for dim 4. 52 ; 53 ; @returns 54 ; a matrix 1,2,3 or 4d extract from input array 55 ; 56 ; @restrictions 57 ; -1 in case of mistake 58 ; 59 ; @examples 60 ; I have a dim 2 matrix named A. I want extract a small intersection 61 ; matrix 2d of the line 2,3 and 7 and of the column 0 and 1: 44 62 ; 45 ; @param index4 {in}{required} the same thing that index1 but for dim 4.63 ; IDL> res=extrac2(A,[2,3,7],[0,1]) 46 64 ; 47 ; @returns a matrix 1,2,3 or 4d extract from input array 65 ; other ex: 66 ; IDL> print, a 67 ; a b c 68 ; d e f 69 ; g h i 70 ; IDL> print, extrac2(a,[0,2],[0,2]) 71 ; a c 72 ; g i 48 73 ; 49 ; @restrictions res=-1 in case of mistake 50 ; 51 ; 52 ; @examples I have a dim 2 matrix named A. I want extract a small intersection 53 ; matrix 2d of the line 2,3 and 7 and of the column 0 and 1: 54 ; 55 ; res=extrac2(A,[2,3,7],[0,1]) 56 ; 57 ;other ex: 58 ; IDL> print, a 59 ; a b c 60 ; d e f 61 ; g h i 62 ; IDL> print, extrac2(a,[0,2],[0,2]) 63 ; a c 64 ; g i 65 ; 66 ; @history Sebastien Masson (smasson@lodyc.jussieu.fr) 74 ; @history Sebastien Masson (smasson\@lodyc.jussieu.fr) 67 75 ; 12/1/1999 68 76 ; 29/4/1999: correction of a bug and complement of the heading … … 86 94 if n_params() NE taille[0]+1 THEN $ 87 95 return, report('we need as many indexes as the number of dimensions of the input array') 88 IF n_params() GE 5 THEN BEGIN 96 IF n_params() GE 5 THEN BEGIN 89 97 if size(index4,/type) EQ 7 then index4 = lindgen(taille[4]) $ 90 98 ELSE index4 = long(index4) 91 nt = n_elements(index4) 92 ENDIF 93 IF n_params() GE 4 THEN BEGIN 99 nt = n_elements(index4) 100 ENDIF 101 IF n_params() GE 4 THEN BEGIN 94 102 if size(index3,/type) EQ 7 then index3 = lindgen(taille[3]) $ 95 103 ELSE index3 = long(index3) 96 nz = n_elements(index3) 97 ENDIF 98 IF n_params() GE 3 THEN BEGIN 104 nz = n_elements(index3) 105 ENDIF 106 IF n_params() GE 3 THEN BEGIN 99 107 if size(index2,/type) EQ 7 then index2 = lindgen(taille[2]) $ 100 108 ELSE index2 = long(index2) 101 ny = n_elements(index2) 109 ny = n_elements(index2) 102 110 ENDIF 103 IF n_params() GE 2 THEN BEGIN 111 IF n_params() GE 2 THEN BEGIN 104 112 if size(index1,/type) EQ 7 then index1 = lindgen(taille[1]) $ 105 113 ELSE index1 = long(index1) 106 nx = n_elements(index1) 114 nx = n_elements(index1) 107 115 ENDIF 108 116 109 117 ;------------------------------------------------------------ 110 118 ; construction of an array of indexes and of results following the size of array … … 115 123 index = index1#replicate(1, ny)+taille[1]*replicate(1, nx)#index2 116 124 res = array[index] 117 END 125 END 118 126 3:BEGIN 119 127 index = index1#replicate(1, ny)+taille[1]*replicate(1, nx)#index2 … … 121 129 +taille[1]*taille[2]*replicate(1, nx*ny)#index3 122 130 res = array[reform(index, nx, ny, nz, /over)] 123 END 131 END 124 132 4:BEGIN 125 133 index = index1#replicate(1, ny)+taille[1]*replicate(1, nx)#index2 … … 129 137 +taille[1]*taille[2]*taille[3]*replicate(1, nx*ny*nz)#index4 130 138 res = array[reform(index, nx, ny, nz, nz, /over)] 131 END 139 END 132 140 endcase 133 141
Note: See TracChangeset
for help on using the changeset viewer.