Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Added mat2ftsv to naïvely convert matlab matrices to ftsv files. Works in at

least one case, but does not try to guess anything sensible for identifiers.
This commit is contained in:
Einar Ryeng 2007-10-31 17:43:02 +00:00
parent b114d5aeec
commit ca51a0b382
1 changed files with 37 additions and 0 deletions

37
bin/mat2ftsv Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/python
import sys
from getopt import getopt
def show_help():
print "mat2ftsv - Matlab matrix to fluents dataset converter."
print
print "Usage: mat2ftsv <mat-file> [<matfile> ...]"
print
print "Description: For each mat file given as input, a ftsv file"
print " will be created with the same name, but suffixed with.ftsv"
print " in addition to .mat or any other suffix already on the"
print " file name."
options, params = getopt(sys.argv[1:], 'h', ['help'])
for opt, val in options:
if opt in ['-h', '--help']:
show_help()
sys.exit(0)
if len(params) == 0:
show_help()
sys.exit(0)
from scipy import io
from numpy import ndarray
from fluents import dataset
fn_in = params[0]
data = io.loadmat(fn_in)
for key, value in data.items():
if isinstance(value, ndarray):
ds = dataset.Dataset(value, name=key)
dataset.write_ftsv(fn_in + '.ftsv', ds)