-
Notifications
You must be signed in to change notification settings - Fork 0
/
POD_from_W_L_N.py
334 lines (305 loc) · 7.97 KB
/
POD_from_W_L_N.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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
"""
POD_from_W_L_T.py
Compute POD/Coverage from sweep width, one searcher's track length, and number of searchers on team
C = WNL/A = (W/5280)*N*L/A
Taking log of both sides, this defines the type 3 nomograph:
log C = log W-log(5280) + log(N) + log(L) - log(A)
or
log C - log W + log(5280) - log N - log L + log A = 0
Rd to W is done in one type 1 nomograph, and the rest in type 3
"""
import sys
sys.path.insert(0, "..")
from pynomo.nomographer import *
from pyx import *
from math import log,log10
# Scale limit parameters
# Range of sweep widths
Wmin=10
Wmax=200
# range of searcher track lengths (miles)
Lmin=.5
Lmax=10
# Range of areas
Amin=.25
Amax=10
# range of team sizes (# searchers
N_min=3
N_max=10
# Range of coverage scale
Coverage_min=.27
Coverage_max=3
# Example isopleth calculation
Isopleth_W=95
Isopleth_W_mi=Isopleth_W/5280.0
Isopleth_A=.5
Isopleth_L = 5.0 # Miles
Isopleth_N = 6 # searchers
Isopleth_C = Isopleth_W_mi*Isopleth_L*Isopleth_N/Isopleth_A
print ("Computed coverage should be ",Isopleth_C)
# Primary range of detection scale
Rd_params={
'tag':'Rd',
'u_min':Wmin/1.8,
'u_max':Wmax/1.8,
'function':lambda u:(-log10(u)),
'title':r'$R_d$',
'title_y_shift':0.5,
'tick_levels':3,
'tick_text_levels':2,
'tick_side':'left',
'scale_type':'log',
'extra_titles':[
{'dx':-1.25,
'dy':-0.08,
'text':r'\small $ft$',
'width':5,
}]
}
# Secondary range of detection scale, in meters
Rd_params_meters={
'tag':'Rd',
'u_min':Wmin/1.8*0.3048,
'u_max':Wmax/1.9*0.3048,
'function':lambda u:(-log10(u)),
'align_func':lambda u:u/0.3048,
'title':r'\small $m$',
'title_x_shift':0.4,
'tick_levels':3,
'tick_text_levels':2,
'tick_side':'right',
'scale_type':'log',
}
# Scale for object visibility, high, average, low, per Koester et. al,
# WILDERNESS &ENVIRONMENTALMEDICINE, 25, 132-142 (2014)
Multiplier_params={
'u_min':1.1,
'u_max':1.8,
'function':lambda u:(-log10(u)),
'scale_type':'linear',
'title':r'Visibility',
'title_x_shift':.5,
'title_draw_center':True,
'tick_levels':1,
'tick_text_levels':1,
'scale_type':'manual line',
'linewidth_ticks':style.linewidth.THick,
'manual_axis_data':{1.1:'Low',
1.6:'Average',
1.8:'High'
},
}
# Sweep width primary scale
W0_params={
'tag':'SweepWidth',
'u_min':Wmin,
'u_max':Wmax,
'function':lambda u:(log10(u)),
'title':r'Sweep width',
'title_y_shift':0.8,
'tick_levels':3,
'tick_text_levels':2,
'tick_side':'left',
'scale_type':'log',
'extra_titles':[
{'dx':-1.25,
'dy':0.25,
'text':r'\small $ft$',
'width':5,
}]
}
# Sweep width primary scale, duplicated for second nomograph, lined up with
# W0 scale
W_params={
'tag':'SweepWidth',
'u_min':Wmin,
'u_max':Wmax,
'function':lambda u:(-log10(u)+log10(5280.0)),
'title':r'Sweep width',
'title_y_shift':0.8,
'tick_levels':3,
'tick_text_levels':2,
'tick_side':'left',
'scale_type':'log',
'extra_titles':[
{'dx':-1.25,
'dy':0.25,
'text':r'\small $ft$',
'width':5,
}]
}
# Sweep width secondary scale, in meters
W_params_meters={
'tag':'SweepWidth',
'u_min':Wmin*0.3048,
'u_max':Wmax*0.3048,
'function':lambda u:(-log10(u)+log10(5280.0)),
'align_func':lambda u:u/0.3048,
'title':r'\small $m$',
'title_x_shift':0.4,
'tick_levels':3,
'tick_text_levels':2,
'tick_side':'right',
'scale_type':'log',
}
# Single searcher track length, in miles
L_params={
'u_min':Lmin,
'u_max':Lmax,
'function':lambda u:(-log10(u)),
'title':r'Track length',
'title_y_shift':.8,
'tick_levels':3,
'tick_text_levels':2,
'scale_type':'log',
'extra_titles':[
{'dx':-1,
'dy':.25,
'text':r'\small Miles',
'width':5,
}]
}
# Area scale in square miles
A_params={
'u_min':Amin,
'u_max':Amax,
'function':lambda u:log10(u),
'title':r'Area',
'title_y_shift':0.8,
'tick_levels':2,
'tick_text_levels':2,
'tick_side':'left',
'scale_type':'log smart',
'extra_titles':[
{'text':r'$mi{}^2$',
'dx':-1.25,
'dy':0.25,
}]
}
# Team size (# searchers)
N_params={
'u_min':N_min,
'u_max':N_max,
'function':lambda u:(-log10(u)),
'title':r'N',
'title_y_shift':0.75,
'tick_levels':1,
'tick_text_levels':1,
'tick_side':'left',
'scale_type':'linear',
'extra_titles':[
{'dx':-1.5,
'dy':0.2,
'text':r'\small (searchers)',
'width':5,
}]
}
# Coverage scale
Coverage_params={
'tag':'pod',
'u_min':Coverage_min,
'u_max':Coverage_max,
'function':lambda u:(log10(u)),
'title':r'\large Coverage',
'title_x_shift':-1,
'tick_levels':3,
'tick_text_levels':2,
'tick_side':'left',
'scale_type':'log',
}
def POD(C):
return (1.0-exp(-C))*100.0
def PODint(C):
return int((1-exp(-C))*1000.0)/10.0
def Coverage(POD):
return(-log(1.0-POD/100.0))
# Define the POD ticks to line up correctly with corresponding coverage
POD_Axis_Range={}
for POD in range(25,96):
if (POD%5 == 0):
POD_Axis_Range[Coverage(POD)]='%d'%POD
else:
POD_Axis_Range[Coverage(POD)]=''
#POD scale
POD_params={
'tag':'pod',
'u_min':Coverage_min,
'u_max':Coverage_max,
'function':lambda u:(log10(u)),
'align_func':lambda u:u,
'title':r'POD',
'title_x_shift':0.75,
'title_y_shift':0.45,
'tick_levels':3,
'tick_text_levels':2,
'tick_side':'right',
'scale_type':'manual line',
'manual_axis_data':POD_Axis_Range,
'extra_titles':[
{'dx':-.25,
'dy':0.15,
'text':r'\small \%',
'width':5,
},
{'dx':-1.25,
'dy':-12,
'text':r'\small $POD = 1-\exp(-WNL/A)$',
'width':5,
},
]
}
# Define the nomographs
# Block 0 is the nomograph for converting Range of Detection to Sweep Width
block_0_params={
'block_type':'type_1',
'width':2.0,
'height':20.0,
'f1_params':W0_params,
'f2_params':Multiplier_params,
'f3_params':Rd_params,
'isopleth_values':[['x',1.6,Isopleth_W/1.6]],
}
# This is the meters scale for range of detection, so Rd measurements in
# either units can be used
block_0b_params={
'block_type':'type_8',
'f_params':Rd_params_meters,
'isopleth_values':[['x']],
}
# This is the meters scale for sweep width, just in case users have W tables
# in meters already --- they can then skip the Rd -> W computation.
block_1b_params={
'block_type':'type_8',
'f_params':W_params_meters,
'isopleth_values':[['x']],
}
# This is the POD scale, to be lined up with coverage scale
block_3b_params={
'block_type':'type_8',
'f_params':POD_params,
'isopleth_values':[['x']],
}
# This is the main nomograph block, computing coverage from W, N, L and A.
block_main_params={
'block_type':'type_3',
'width':10.0,
'height':20.0,
'f_params':[W_params,L_params,N_params,A_params,Coverage_params],
'reference_titles':['A','B'],
'isopleth_values':[[Isopleth_W,Isopleth_L,Isopleth_N,Isopleth_A,'x']],
}
# Now generate the thing for real.
# Note that the order of blocks in the block_params field makes no immediate
# sense --- it is neither left-to-right nor right-to-left. I had to move
# things around here until the nomograph looked as I wanted it to.
main_params={
'filename':'POD_from_W_L_N.pdf',
'paper_height':20,
'paper_width':20,
'block_params':[block_main_params,block_3b_params,block_0_params,block_0b_params,block_1b_params],
'transformations':[('rotate',0.01),('scale paper',),('polygon',)],
'title_str':r'\large POD Calculator for Debriefing',
'title_x':12.5,
'title_y':0,
}
Nomographer(main_params)