1 | # -*- coding: utf-8 -*- |
---|
2 | """ |
---|
3 | Created on Sun Mar 5 18:51:17 2017 |
---|
4 | |
---|
5 | Calculates the mean of several data set |
---|
6 | |
---|
7 | @author: delerue |
---|
8 | """ |
---|
9 | |
---|
10 | import glob |
---|
11 | import os |
---|
12 | import numpy as np |
---|
13 | |
---|
14 | global data_directory |
---|
15 | |
---|
16 | from clio_constants import * |
---|
17 | |
---|
18 | filemask="data_CLIO*.zoom_txt" |
---|
19 | list_of_files = glob.glob(data_directory+filemask) |
---|
20 | |
---|
21 | print repr(list_of_files) |
---|
22 | |
---|
23 | #prepare the figures |
---|
24 | fig=plt.figure(9,figsize=(12, 8)) |
---|
25 | |
---|
26 | nfiles=0 |
---|
27 | for filename in list_of_files: |
---|
28 | print filename |
---|
29 | filedata=np.loadtxt(filename) |
---|
30 | if (nfiles==0): |
---|
31 | nchannels=np.size(filedata,0) |
---|
32 | ndatapoints=np.size(filedata,1) |
---|
33 | alldata=np.zeros((nchannels,ndatapoints)) |
---|
34 | else: |
---|
35 | if (nchannels!=np.size(filedata,0)): |
---|
36 | print "Incorrect number of channels in file!" |
---|
37 | if (ndatapoints!=np.size(filedata,1)): |
---|
38 | print "Incorrect number of data points in file!" |
---|
39 | plt.figure(9) |
---|
40 | plt.plot(range(1,ndatapoints),filedata[1,range(1,ndatapoints)]) |
---|
41 | print repr(alldata) |
---|
42 | alldata=alldata+filedata |
---|
43 | nfiles+=1 |
---|
44 | |
---|
45 | print "nfiles "+str(nfiles) |
---|
46 | |
---|
47 | #prepare the figures |
---|
48 | fig=plt.figure(1,figsize=(12, 8)) |
---|
49 | plt.figure(1) |
---|
50 | plt.plot(range(1,ndatapoints),alldata[1,range(1,ndatapoints)]) |
---|
51 | |
---|