-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathclasses.py
300 lines (278 loc) · 9.12 KB
/
classes.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
import numpy as np
class CP_map():
def __init__(self):
# for one marker
self.CPs = {} # Colliding CPs
self.age = {}
self.nCPs = 0
self.nTrtot = 0
self.nTrCP = {}
def add(self,ID,age):
if ID in self.CPs.keys():
self.nTrCP[ID] += 1
else:
self.CPs[ID] = ID
self.nTrCP[ID] = 1
self.nCPs += 1
self.age[ID] = age
self.nTrtot += 1
########################################################
class COL(): # key are colliding CP combination
def __init__(self):
self.x = {} # dict with timesteps as key giving a list
self.y = {} # ...of all collision points for this CP combi
self.ntot= {} # ... of number of Tracers accumulating at collsion
def add(self,t,x,y,ntot):
if not t in self.x.keys():
self.x[t] = []
self.y[t] = []
self.ntot[t] = 0
self.x[t].append(x)
self.y[t].append(y)
self.ntot[t] += ntot
########################################################
class CPlife():
def __init__(self,ID,t):
self.ID = ID # ID
self.start = t
self.age = {} # age of CP based on precip onset
# if CP result from merger tracer may have different ages
self.age2nd = {} # CP age is than given by oldest precip event
self.noT = {} # no of tracer
self.noGP = {} # no of gp occupied from this CP
self.noIT = {} # no of individual tracer (not colldided with other CP)
self.noIGP = {} # no of individual grid point
self.x = {}
self.y = {}
self.combi = {}
def add(self,noT,noIT,noIGP,t,age,x,y):
if t in self.noGP.keys():
self.noGP[t] += 1
self.noT[t] += noT
self.noIT[t] += noIT
self.noIGP[t] += noIGP
if age < self.age[t]:
self.age2nd[t] = age
else:
self.age[t]= age
self.x[t].append(x)
self.y[t].append(y)
else:
self.noGP[t] = 1
self.noT[t] = noT
self.noIT[t] = noIT
self.noIGP[t] = noIGP
self.age[t] = age
self.x[t] = []
self.y[t] = []
def add_others(self,t,cp,n,nother):
if (t,cp) in self.combi.keys():
self.combi[t,cp] += n
else:
self.combi[t,cp] = n
#self.age[t] = age # it can happen, that age of individual tracers of CP differe when precip events merge
# and tracers for same Cp where set at different precip events
#self.noIT = noIT # no of individual tracer (not colldided with other CP)
#self.noIGP = noIGP # no of individual grid point
########################################################
class CP_terminate():
def __init__(self,ID):
self.ID = ID
self.x = {}
self.y = {}
def add(self,t,x,y):
if not t in self.x.keys():
self.x[t] = []
self.y[t] = []
self.x[t].append(x)
self.y[t].append(y)
class Pool():
def __init__(self,ID):
# for one marker
self.ID = ID # ID of CP marker belongs to
self.CPs = [] # Colliding CPs
self.size = []
self.ts = []
# self.x = [] #
# self.y = []
def add(self,t,r):
self.ts.append(t) #timestep
self.size.append(r) # size (average over all marker dists)
# self.x.append(xp)
# self.y.append(yp)
###########################################################################
class COLDPOOL():
def __init__(self,ID,tstart,dur):
self.ID = ID # ID
self.tstart = tstart # timestep when CP begins
self.dur = dur # duration of CP
self.ts = [] # timestep
self.x = [] # position of tracer at timestep
self.y = []
self.ColCPs = {} # colliding CPs
self.locx = {} # location of collision
self.locy = {} # location of collision
self.Colt = {} # time of collision
self.ColN = {} # number of tracer colliding
self.ColSum = {} # summed numbr of tracer collided
def add_marker(self,ID,t,xp,yp):
self.ts.append(t)
self.x.append(xp)
self.y.append(yp)
def add_coll(self,ID,tist,xp,yp):
self.ColCPs[ID]=ID
# self.ColCPs.append(ID)
self.Colt[ID] = tist #.append(tist)
self.locx[ID] = [xp]
self.locy[ID] = [yp]
self.ColN[ID] = 1 #.append(1)
self.ColSum[ID] =1
def add_loc(self,ID,xp,yp):
self.locx[ID].append(xp)
def add_t(self,ID,tist):
self.ColN[ID] += 1
###########################################################################
class Marker():
def __init__(self,ID):
# for one marker
self.ID = ID # ID of CP marker belongs to
self.ts = [] # timestep
self.x = [] # position of tracer at timestep
self.y = []
def add_marker(self,t,xp,yp):
self.ts.append(t)
self.x.append(xp)
self.y.append(yp)
###########################################################################
class Marker2():
def __init__(self,ID):
# for one marker
self.ID = ID # ID of CP marker belongs to
self.ts = [] # timestep
self.x = [] # position of tracer at timestep
self.y = []
self.age = []
self.dist= []
self.phi = []
def add_marker(self,t,xp,yp,a,r,p):
self.ts.append(t)
self.x.append(xp)
self.y.append(yp)
self.age.append(a)
self.dist.append(r)
self.phi.append(p)
def add_others(self,size):
self.size=size
class RAIN():
count = 0
xs = []
ys = []
IDs = []
tss = []
xps = []
yps = []
def __init__(self,dt,ts,x,y,ID,xps,yps):
self.number = RAIN.count
self.ts = ts #time when precip is initiated
self.dt = dt #time delay from initiation to onset
self.x = x # location of strongest updraft
self.y = y
self.ID = ID # ID of precipitation object/track
self.CPs = [] # create new emty list for involved CPs
self.noTCP = [] # no of tracers from current CP found in area
#self.CP1s = []
self.CP2s = []
self.noTCP2 = []
self.noCPs = len(self.CPs)
self.noCP2s = len(self.CP2s)
self.tCP2 = [] # when are CP-tracer pass area of precip initiation
self.xps = xps # all gp of current precip
self.yps = yps
self.prec = [] #precip intensity for all timesteps during the event
self.size = []
self.dur = len(self.prec) #duration of precip event
self.vol = np.sum(np.multiply(self.prec,self.size))
self.meanP = 0
self.firstP = 0
RAIN.count += 1
RAIN.IDs.append(ID)
RAIN.xs.append(x)
RAIN.ys.append(y)
RAIN.tss.append(ts)
def add_CP(self,CP):
self.CPs.append(CP)
self.noTCP.append(1) # counts number of tracer for this CP
def add_TCP(self,CP):
#self.noTCP[self.CPs==CP] += 1
print self.CPs
tin = self.CPs.index(CP)
print self.noTCP[tin]
self.noTCP[tin] += 1
def add_PREC(self,precip,sizes):
self.prec.append(precip)
self.size.append(sizes)
self.firstP = self.prec[0]
self.meanP = sum(self.prec) /max([self.dur,1])
#def add_earlierCP(self,CP,t):
# self.CP1s.append(CP)
def add_laterCP(self,CP,t):
self.CP2s.append(CP)
self.noCP2s = len(self.CP2s)
self.tCP2.append(t)
self.noTCP2.append(1)
def add_TCP2(self,CP):
self.noTCP2[self.CP2s==CP] += 1
######################################################
class RAIN2():
count = 0
xs = []
ys = []
IDs = []
tss = []
xps = []
yps = []
def __init__(self,dt,ts,x,y,ID,xps,yps):
self.number = RAIN2.count
self.ts = ts #time when precip is initiated
self.dt = dt #time delay from initiation to onset
self.x = x # location of strongest updraft
self.y = y
self.ID = ID # ID of precipitation object/track
self.CPs = [] # create new emty list for involved CPs
self.age = []
self.noTCP = [] # no of tracers from current CP found in area
self.noCPs = len(self.CPs)
self.tCP = [] # when are CP-tracer pass area of precip initiation
self.xps = xps # all gp of current precip
self.yps = yps
self.prec = [] #precip intensity for all timesteps during the event
self.size = []
self.cogx = []
self.cogy = []
self.dur = len(self.prec) #duration of precip event
self.vol = np.sum(np.multiply(self.prec,self.size))
self.meanP = 0
self.firstP = 0
RAIN2.count += 1
RAIN2.IDs.append(ID)
RAIN2.xs.append(x)
RAIN2.ys.append(y)
RAIN2.tss.append(ts)
def add_PREC(self,precip,sizes,comx,comy):
self.prec.append(precip)
self.size.append(sizes)
self.cogx.append(comx)
self.cogy.append(comy)
self.firstP = self.prec[0]
self.meanP = sum(self.prec) /max([self.dur,1])
#def add_earlierCP(self,CP,t):
# self.CP1s.append(CP)
def add_CP(self,CP,t,a):
self.CPs.append(CP)
self.noCPs = len(self.CPs)
self.tCP.append(t)
self.noTCP.append(1)
self.age.append(a)
def add_TCP(self,CP):
self.noTCP[self.CPs==CP] += 1
######################################################