Commit ae9e86317eecb5f4ed3a18f7148f75e5e17203aa
1 parent
25b5d632
Exists in
master
changed EOL style coding for Fawlty strictness
Showing
1 changed file
with
70 additions
and
1 deletions
Show diff stats
src/idl_extern/JPBLib_for_Dustemwrap/General/index2ij.pro
1 | -FUNCTION index2ij,index,sizes ;+ ; NAME: ; index2ij ; CALLING SEQUENCE: ; coor=index2ij(ind,sizes) ; PURPOSE: ; returns the pixel postion of index ind in an array ; INPUTS: ; index = the index for which coordinates are needed (value or 1D) ; sizes = Array dimensions ; OPTIONAL INPUT: ; None ; OUTPUTS: ; coordinates corresponding to the index ; PROCEDURE AND SUBROUTINE USED ; ; SIDE EFFECTS: ; MODIFICATION HISTORY: ; written by Jean-Philippe Bernard 09-92 ; modified JPB 11-Sep-92 for 2D arrays ; modified JPB to allow complete indexes to be handled ; modified JPB 21-June-94 for large sets of indexes ; modified JPB 30-July-01 replaced fix by long allow large values of output ; modified 19 Jul 2016 JPB+AL fixed a bug in division remaining affecting first index of large arrays ; EXAMPLE: ; a=fltarr(12,15,17) ; a(10,10,5)=1 & a(11,5,16)=1 ; ind=where(a NE 0,count) ; ij=index2ij(ind,[12,15,17]) ; help,ij ; print,ij ; ind2=ij2index(ij,[12,15,17]) ; print,ind,ind2 ;- ;on_error,2 IF n_params(0) NE 2 THEN BEGIN print,'Calling sequence: coor=index2ij(index,sizes)' print,' index can be 1D or single value' goto,sortie ENDIF taille=n_elements(sizes) si=size(index) ;print,taille res=lonarr(si[1],taille) FOR i=0L,si[1]-1 DO BEGIN ind_val=index[i] FOR tt=taille,2,-1 DO BEGIN size_prod=1. FOR j=0L,tt-2 DO size_prod=size_prod*sizes[j] res[i,tt-1]=long(ind_val/size_prod) ind_val=ind_val-long(size_prod*res[i,tt-1]) ;remains in division ENDFOR ; res(i,1)=fix(ind_val/sizes(0)) res[i,0]=long(ind_val) ;stop ENDFOR return,res sortie: end | |
2 | 1 | \ No newline at end of file |
2 | +FUNCTION index2ij,index,sizes | |
3 | + | |
4 | +;+ | |
5 | +; NAME: | |
6 | +; index2ij | |
7 | +; CALLING SEQUENCE: | |
8 | +; coor=index2ij(ind,sizes) | |
9 | +; PURPOSE: | |
10 | +; returns the pixel postion of index ind in an array | |
11 | +; INPUTS: | |
12 | +; index = the index for which coordinates are needed (value or 1D) | |
13 | +; sizes = Array dimensions | |
14 | +; OPTIONAL INPUT: | |
15 | +; None | |
16 | +; OUTPUTS: | |
17 | +; coordinates corresponding to the index | |
18 | +; PROCEDURE AND SUBROUTINE USED | |
19 | +; | |
20 | +; SIDE EFFECTS: | |
21 | +; MODIFICATION HISTORY: | |
22 | +; written by Jean-Philippe Bernard 09-92 | |
23 | +; modified JPB 11-Sep-92 for 2D arrays | |
24 | +; modified JPB to allow complete indexes to be handled | |
25 | +; modified JPB 21-June-94 for large sets of indexes | |
26 | +; modified JPB 30-July-01 replaced fix by long allow large values of output | |
27 | +; modified 19 Jul 2016 JPB+AL fixed a bug in division remaining | |
28 | +; affecting first index of large arrays | |
29 | +; modified AH bcause fawlty does not like end of line style Mac | |
30 | +; EXAMPLE: | |
31 | +; a=fltarr(12,15,17) | |
32 | +; a(10,10,5)=1 & a(11,5,16)=1 | |
33 | +; ind=where(a NE 0,count) | |
34 | +; ij=index2ij(ind,[12,15,17]) | |
35 | +; help,ij | |
36 | +; print,ij | |
37 | +; ind2=ij2index(ij,[12,15,17]) | |
38 | +; print,ind,ind2 | |
39 | +;- | |
40 | + | |
41 | +;on_error,2 | |
42 | + | |
43 | +IF n_params(0) NE 2 THEN BEGIN | |
44 | + print,'Calling sequence: coor=index2ij(index,sizes)' | |
45 | + print,' index can be 1D or single value' | |
46 | + goto,sortie | |
47 | +ENDIF | |
48 | + | |
49 | +taille=n_elements(sizes) | |
50 | +si=size(index) | |
51 | + | |
52 | +;print,taille | |
53 | +res=lonarr(si[1],taille) | |
54 | +FOR i=0L,si[1]-1 DO BEGIN | |
55 | + ind_val=index[i] | |
56 | + FOR tt=taille,2,-1 DO BEGIN | |
57 | + size_prod=1. | |
58 | + FOR j=0L,tt-2 DO size_prod=size_prod*sizes[j] | |
59 | + res[i,tt-1]=long(ind_val/size_prod) | |
60 | + ind_val=ind_val-long(size_prod*res[i,tt-1]) ;remains in division | |
61 | + ENDFOR | |
62 | +; res(i,1)=fix(ind_val/sizes(0)) | |
63 | + res[i,0]=long(ind_val) | |
64 | + ;stop | |
65 | +ENDFOR | |
66 | + | |
67 | +return,res | |
68 | + | |
69 | +sortie: | |
70 | + | |
71 | +end | ... | ... |