-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCalcdA.py
More file actions
executable file
·28 lines (18 loc) · 857 Bytes
/
Copy pathCalcdA.py
File metadata and controls
executable file
·28 lines (18 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from numpy import empty,reshape,triu,ones,zeros,concatenate
from CalcU import CalcU
def CalcdA(D,Obs):
DeltaAHat=empty( (D.nR,D.nt-1) )
for r in range(0,D.nR):
for t in range(0,D.nt-1):
DeltaAHat[r,t]=(Obs.w[r,t]+Obs.w[r,t+1])/2 * (Obs.h[r,t+1]-Obs.h[r,t])
# changed how this part works compared with Matlab, avoiding translating calcU
DeltaAHatv=reshape(DeltaAHat,(D.nR*(D.nt-1),1) )
Obs.dA= concatenate( (zeros( (D.nR,1) ), DeltaAHat @ triu(ones( (D.nt-1,D.nt-1) ),0)),1 )
U=CalcU(D)
Obs.dAv=U @ DeltaAHatv
# Note that the below commented command is equivalent, but "U" is needed in
# other functions, and this is a good test for consistency
#Obs.dAv=reshape(Obs.dA, (D.nR*D.nt,1))
return Obs