-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflume_reader.py
More file actions
60 lines (49 loc) · 1.55 KB
/
Copy pathflume_reader.py
File metadata and controls
60 lines (49 loc) · 1.55 KB
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
#!/usr/bin/env python
""" This script reads the profiles stored in the "raw" folder and coverts them
to JSON files in the "input" folder. The JSON file contains a dictionary with
the profile information arranged as a numpy array.
"""
from __future__ import division
import glob
import os
import pdb
import re
import numpy as np
import json
try:
import cPickle as pickle
except:
import pickle
# Set input and output folder locations
home = os.path.expanduser("~")
sourcepath = (home + '/Documents/Experiments/Data/raw/flume')
outputpath = (home + '/Documents/Experiments/Data/input/flume')
def main():
"""Converts the profile info from CSV to pickles"""
# Specify working directory as source path and change to it.
wd = sourcepath
os.chdir(wd)
# List all profiles in source path, sorted by feedrate
profile = 'flume.csv'
pdb.set_trace()
data_type = ['f8', 'f8', 'f8']
data_names = 'x, wse, bed'
# open the file and get the data
try:
data = np.genfromtxt(profile, dtype = data_type, delimiter=',',
skip_header = 1, names = data_names )
except ValueError:
print 'A value error popped up'
pdb.set_trace()
# Dump the profile in the corresponding input folder
wd = outputpath
os.chdir(wd)
# Create Pickle
pickle_hdr = 'flume_profile.pickle'
with open(pickle_hdr, 'wb') as pickle_outfile:
pickle.dump(data, pickle_outfile, -1)
print 'Script completed successfully'
pdb.set_trace()
return
if __name__ == '__main__':
main()