3 Created on Tue Aug 07 23:05:36 2018 8 from __future__
import print_function
42 f=f+dv*np.sum((data-fa)**2)
46 ''' Return the 3-D index with the minimum of array a''' 48 return np.unravel_index(i,np.shape(a))
51 ''' Return the 3-D index with the maximum of array a''' 53 return np.unravel_index(i,np.shape(a))
56 """ Allow a snapshot, a patch, or a list of patches """ 65 def stat(s,iv=0,i4=0):
75 rmax=[p.x[m[0]],p.y[m[1]],p.z[m[2]]]
77 rmin=[p.x[m[0]],p.y[m[1]],p.z[m[2]]]
89 rmax=[p.x[m[0]],p.y[m[1]],p.z[m[2]]]
93 rmin=[p.x[m[0]],p.y[m[1]],p.z[m[2]]]
102 f=f+dv*np.sum((data-av)**2)
103 rm=np.sqrt(float(f/v))
104 print(
'average: {:12.4e}'.format(av))
105 print(
' rms: {:12.4e}'.format(rm))
106 print(
' max: {:12.4e}, at {}'.format(dmax,rmax))
107 print(
' min: {:12.4e}, at {}'.format(dmin,rmin))
109 def haver1(s,iv=0,point=0.0,dir=2,x=None,y=None,z=None,all=False,i4=0,verbose=0):
110 """ Horizontal average in one plane """ 126 lc=p.position[dir]-p.size[dir]/2.0
127 uc=p.position[dir]+p.size[dir]/2.0
128 if all
and p.guard_zones:
129 lc=lc-p.ng[dir]*p.ds[dir]
130 uc=uc+p.ng[dir]*p.ds[dir]
134 if uc >= point
and lc <= point:
139 i=max(0,min(n-2,np.floor(fi)))
151 print (
'id:',p.id,
'i:',i,
'w:',w0,w1)
154 data=p.var(iv,i4=i4,all=all)
159 f=f+dv*np.sum(data[i,:,:])*w0
161 f=f+dv*np.sum(data[i+1,:,:])*w1
163 f=f+dv*np.sum(data[:,i,:])*w0
165 f=f+dv*np.sum(data[:,i+1,:])*w1
167 f=f+dv*np.sum(data[:,:,i])*w0
169 f=f+dv*np.sum(data[:,:,i+1])*w1
171 print(
'using',n_patch,
'patches')
174 def hminmax(s,iv=0,dir=2,i4=0,all=False,verbose=0):
175 """ Find the smallest and largest values in planes perpendicular to dir """ 187 data=p.var(iv,all=all,i4=i4)
188 for i
in range(data.shape[dir]):
217 while i<len(xx)
and xx[i]==x0:
229 def haver(s,iv=0,dir=2,i4=0,all=False,verbose=0):
230 """ Horizontal average in all planes """ 235 jv=dispatch.map_var(p,iv)
237 es=0.5
if p.no_mans_land
else 0.0
238 es=es+p.idx.h[dir,jv]
239 n=p.gn
if all
else p.n
245 data=p.var(iv,i4=i4,all=all)
246 for i
in range(data.shape[dir]):
269 while i<len(xx)
and xx[i]==x0: