Commit 1c2cf39d authored by Maude Le Jeune's avatar Maude Le Jeune
Browse files

working dmc io

parent c6081027
......@@ -246,9 +246,9 @@ def read_table (file):
grp = pio.OpenTAB2DGrp(grpname, "r")
ncols = pio.GetTAB2DColumnGrp(grp)
nrows = len(tab)/ncols
cov = zeros((nrows, ncols))
cov = np.zeros((nrows, ncols))
for c in range(ncols):
cov[:,c] = squeeze(tab[c::ncols])
cov[:,c] = np.squeeze(tab[c::ncols])
val = pio.CloseTAB2DGrp(grp)
except pio.pioError,val:
return str(val)
......@@ -274,11 +274,16 @@ def read_covmat (file):
grp = pio.OpenTAB2DGrp(grpname, "r")
ncols = pio.GetTAB2DColumnGrp(grp)
nrows = len(tab)/ncols
nmodes = squeeze(tab[0::ncols])
cov = zeros((nrows, ncols-1))
nmodes = np.squeeze(tab[0::ncols])
cov = np.zeros((nrows, ncols-1))
for c in range(ncols-1):
cov[:,c] = squeeze(tab[c+1::ncols])
cov[:,c] = np.squeeze(tab[c+1::ncols])
val = pio.CloseTAB2DGrp(grp)
ndet = np.int(np.sqrt(ncols*2))
stats = np.zeros ((ndet, ndet, nrows))
for q in range(nrows):
stats[:,:,q] = sp.vec2mat(cov[q,:])
cov = stats
except pio.pioError,val:
return str(val)
else:
......@@ -340,8 +345,7 @@ def write_table(file, tab):
checkgroup (grpname, "TAB2D", str(nc))
grp = pio.OpenTAB2DGrp(grpname, "w")
val = pio.CreateTAB2DObject(file,'PIODOUBLE')
val = pio.WriteTAB2DObject(tab,file, 'PIODOUBLE',"tab=0:%d,0:%d"%((n
c-1),(nr-1)) , grp)
val = pio.WriteTAB2DObject(tab,file, 'PIODOUBLE',"tab=0:%d,0:%d"%((nc-1),(nr-1)) , grp)
pio.CloseTAB2DGrp(grp)
except pio.pioError,val:
return str(val)
......@@ -367,7 +371,7 @@ def main():
elif options.object_type=='table':
o = read_table (fn1)
write_table(fn2, o)
elif options.object_ty=='covmat':
elif options.object_type=='covmat':
(o,n) = read_covmat (fn1)
write_covmat(fn2, o, nbmodes=n)
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment