import vdj.analysis
import timeseries

option_parser = optparse.OptionParser()
option_parser.add_option('-r','--threshold',type='float')
option_parser.add_option('-o','--outputbasename')
option_parser.add_option('-q','--quantify')
option_parser.add_option('-n','--normalize',action='store_true')
(options,args) = option_parser.parse_args()

if len(args) == 1:
    inhandle = open(args[0],'r')
else:
    raise ValueError, "Must give a single argument that is a timeseries data file"

data = timeseries.load_timeseries(inhandle)
labels = data['labels']
times = data['times']
timeseriesmatrix = data['matrix']

try:
    sums = data['sums']
except KeyError:
    sums = timeseriesmatrix.sum(axis=0)

# normalize if desired
if options.normalize:
    timeseriesmatrix = np.float_(timeseriesmatrix) / np.asarray(sums)

# define which time series to plot
if options.threshold:
示例#2
0
option_parser = optparse.OptionParser()
# option_parser.add_option('-x','--xxx',dest='xxxx',type='int')
(options, args) = option_parser.parse_args()

if len(args) == 2:
    inhandle = open(args[0], 'r')
    outhandle = open(args[1], 'w')
elif len(args) == 1:
    inhandle = open(args[0], 'r')
    outhandle = sys.stdout
elif len(args) == 0:
    inhandle = sys.stdin
    outhandle = sys.stdout

data = timeseries.load_timeseries(inhandle)

# eliminate numpy-ness of objects before JSON output
np_matrix = data['matrix']
py_matrix = []
for row in np_matrix:
    py_matrix.append(list(row))
data['matrix'] = py_matrix
data['labels'] = list(data['labels'])

for label in data.keys():
    if label == 'labels' or label == 'matrix':
        continue
    data[label] = list(data[label])

json.dump(data, outhandle)