Re: Newbie question concerning summations/loops in IDL [message #61803 is a reply to message #61737] |
Thu, 31 July 2008 01:37   |
Wox
Messages: 184 Registered: August 2006
|
Senior Member |
|
|
On Wed, 30 Jul 2008 16:55:35 -0700 (PDT), mbweller@gmail.com wrote:
<snip>
> The number of sums or (N) needs to be equal to the number of the
> faults down selected by Ind_small (or since ind_small =
> where(thaext[1,*] lt t), it needs to sum the number of the second
> column in the array). This number will be different for bot the large
> and small cases (eg. ind_large = where(thaext[1,*] ge t)). So, i then
> should be # of points in column 2 of ind_small/ind_large - 1 (I would
> think).
>
> The summation is [D[i]*L[i]*H[i]] for small faults and the summation
> is [D[i]*L[i]] for large faults, where:
> D[i]=C[i]*L[i] for small faults and
> D[i]=C[i]*H[i] for large faults,
> L[i]= length (from column 2 of thaext_small/thaext_large) and
> H[i]=(1/2 or 1/3)*L[i] for small faults and
> H[i] = t/sin(o) for large faults and
> C[i] may or may not be a constant
>
> This should now read as constant * summation[C[i]*L[i]*L[i]*L[i]] for
> small faults and constant * summation [C[i]*L[i]] for large
> faults.
>
> I think that's everything I need to be able to do, hopefully it's a
> bit clearer now.
>
> Thanks,
> ~Matt
Still not clear to me! Check the code below for what Chris and I think
you want. The step from ARRsmall to Ssmall is just a summation with
the "total"-function. So somehow I think you want something else. Do
you know LaTeX? Maybe you can write what you need in LaTeX. So the IDL
code below does this (LaTeX):
\begin{eqnarray}
\mathrm{Ssmall} &=& \sum_{i=0}^{\mathrm{nsmall}-1}
C_{\mathrm{indsmall}_{i}} \cdot L_{\mathrm{indsmall}_{i}} \cdot
\frac{t}{\sin o} \\
\mathrm{Slarge} &=& \sum_{i=0}^{\mathrm{nlarge}-1}
C_{\mathrm{indlarge}_{i}} \cdot L_{\mathrm{indlarge}_{i}}^{3} \cdot
\frac{1}{2}
\end{eqnarray}
So Ssmall is 1 number and Slarge is 1 number (you can bring the
constants outside the sum off course). You say above there are (N)
number of sums... I don't get it.
pro test
v= 1. ; volume of region
a= 1. ; area of region
o= 60*!pi/180 ; fault dip angle
t= 150 ; elastic lithosphere thickness
n=100 ; number of points
; [id,length between 0 and 300]
thaext=[lindgen(1,n),reform(round(IMSL_RANDOM(n)*300),1,n)]
; some numbers
C=reform(round(IMSL_RANDOM(n)*10),1,n)
; indices for small and large lengths
ind_small=where(thaext[1,*] lt t,$
nsmall,comp=ind_large,ncomp=nlarge)
; arrays for summation
ARRsmall=C*thaext[1,ind_small]*(t/sin(o))
ARRlarge=C*(thaext[1,ind_large])^3./2
; summation
Ssmall=total(ARRsmall,/pres)
Slarge=total(ARRlarge,/pres)
; horizontal normal strain for small faults
ens=(sin(o)*cos(o)/v)*Ssmall
; horizontal normal strain for large faults
enl=(cos(o)/a)*Slarge
; vertical normal strain for small faults
evs=(-sin(o)*cos(o)/v)*Ssmall
; vertical normal strain for large faults
evl=(-cos(o)/a)*Slarge
end
|
|
|