-
Notifications
You must be signed in to change notification settings - Fork 1
/
mylib_misc.py
executable file
·34 lines (30 loc) · 1023 Bytes
/
mylib_misc.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
#!/usr/bin/env python
#
# Author: Patrick Brockmann
# Contact: [email protected]
# $Date: $
# $Name: $
# $Revision: $
# History:
# Modification:
#
################################################################
def my_print(verbose, *args):
if verbose or verbose == "active":
for i in range(len(args)):
print("%s" % str(args[i]), end=" ")
print()
################################################################
def scalefactor(var):
scalefactor = 1.0
valuerange = max(var)-min(var)
if valuerange == 0:
return scalefactor
while abs(valuerange*scalefactor) < 1000.0:
scalefactor = scalefactor*100.0
#print("inf %f %1.0e %g"%(valuerange,scalefactor,valuerange*scalefactor))
while abs(valuerange*scalefactor) > 1000.0:
scalefactor = scalefactor/100.0
#print("sup %f %1.0e %g"%(valuerange,scalefactor,valuerange*scalefactor))
return scalefactor
################################################################