forked from dave2pi/davepy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe_series.py
84 lines (67 loc) · 3.13 KB
/
e_series.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
'''
Collection of prefered value series over a single decade including a function
to expand the series over multiple decades.
'''
from math import log10 as _log10
def expand(series, min=1.0, max=10.0E6):
'''
Expand a single decade series over multiple decades.
series = single decade series to expand.
min = minimum value of expanded series.
max = maximum value of expanded series.
eg. expand(E12, 10.0, 100E3)
'''
# Calc range of multipliers required.
# -3/-1: Adjusted because series arrays normalized to 1E2.
exp_min = int(_log10(min)-3)
exp_max = int(_log10(max))
# Expand series.
return [x*10**m for m in range(exp_min, exp_max)
for x in series
if x*10**m >= min
if x*10**m <= max]
# Define single decade series E6 to E192
_E6 = [100, 150, 220, 330, 470, 680]
_E12 = [100, 120, 150, 180, 220, 270, 330, 390, 470, 560, 680, 820]
_E24 = [100, 110, 120, 130, 150, 160, 180, 200, 220, 240, 270, 300, 330, 360,
390, 430, 470, 510, 560, 620, 680, 750, 910]
_E48 = [100, 105, 110, 115, 121, 127, 133, 140, 147, 154, 162, 169, 178, 187,
196, 205, 215, 226, 237, 249, 261, 274, 287, 301, 316, 332, 348, 365, 383,
402, 422, 442, 464, 487, 511, 536, 562, 590, 619, 649, 681, 715, 750, 787,
825, 866, 909, 953]
_E96 = [100, 121, 147, 178, 215, 261, 316, 383, 464, 562, 681, 825, 102, 124,
150, 182, 221, 267, 324, 392, 475, 576, 698, 845, 105, 127, 154, 187, 226,
274, 332, 402, 487, 590, 715, 866, 107, 130, 158, 191, 232, 280, 340, 412,
499, 604, 732, 887, 110, 133, 162, 196, 237, 287, 348, 422, 511, 619, 750,
909, 113, 137, 165, 200, 243, 294, 357, 432, 523, 634, 768, 931, 115, 140,
169, 205, 249, 301, 365, 442, 536, 649, 787, 953, 118, 143, 174, 210, 255,
309, 374, 453, 549, 665, 806, 976]
_E192 = [100, 121, 147, 178, 215, 261, 316, 383, 464, 562, 681, 825, 101,
123, 149, 180, 218, 264, 320, 388, 470, 569, 690, 835, 102, 124, 150, 182,
221, 267, 324, 392, 475, 576, 698, 845, 104, 126, 152, 184, 223, 271, 328,
397, 481, 583, 706, 856, 105, 127, 154, 187, 226, 274, 332, 402, 487, 590,
715, 866, 106, 129, 156, 189, 229, 277, 336, 407, 493, 597, 723, 876, 107,
130, 158, 191, 232, 280, 340, 412, 499, 604, 732, 887, 109, 132, 160, 193,
234, 284, 344, 417, 505, 612, 741, 898, 110, 133, 162, 196, 237, 287, 348,
422, 511, 619, 750, 909, 111, 135, 164, 198, 240, 291, 352, 427, 517, 626,
759, 920, 113, 137, 165, 200, 243, 294, 357, 432, 523, 634, 768, 931, 114,
138, 167, 203, 246, 298, 361, 437, 530, 642, 777, 942, 115, 140, 169, 205,
249, 301, 365, 442, 536, 649, 787, 953, 117, 142, 172, 208, 252, 305, 370,
448, 542, 657, 796, 965, 118, 143, 174, 210, 255, 309, 374, 453, 549, 665,
806, 976, 120, 145, 176, 213, 258, 312, 379, 459, 556, 673, 816, 988]
def e6(min=100, max=999):
return expand(_E6, min, max)
def e12(min=100, max=999):
return expand(_E12, min, max)
def e24(min=100, max=999):
return expand(_E24, min, max)
def e48(min=100, max=999):
return expand(_E48, min, max)
def e96(min=100, max=999):
return expand(_E96, min, max)
def e192(min=100, max=999):
return expand(_E192, min, max)
# Define commonly used resistor series
RN73 = expand(_E96, 4.7, 1E6)
WCR = expand(_E24, 10.0, 10E6)
MRS25 = expand(_E96, 1.0, 10E6)