forked from SGenheden/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock_err.py
More file actions
26 lines (22 loc) · 837 Bytes
/
block_err.py
File metadata and controls
26 lines (22 loc) · 837 Bytes
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
# Author: Samuel Genheden samuel.genheden@gmail.com
"""
Program that prints block error of each column of
data parsed from standard input. The data on standard input should contain
nothing but numbers in rows and columns. The number of block is two by
default but can be supplied at the command line
"""
import sys, math
from sgenlib import parsing
if __name__ == '__main__':
stde = len(sys.argv) > 1 and sys.argv[1] == "-e"
if stde :
sys.argv.pop(1)
nblocks = 2 if len(sys.argv) == 1 else int(sys.argv[1])
sys.argv = [sys.argv[0]]
data = parsing.stdin2ndarray()
stride = data.shape[0] / nblocks
data = data[stride::stride,:].T
if stde :
print "\t".join("%10.4f"%(col.std()/math.sqrt(len(col))) for col in data)
else :
print "\t".join("%10.4f"%(col.std()) for col in data)