Skip to content
Snippets Groups Projects
Commit c1c1deed authored by Yngve Levinsen's avatar Yngve Levinsen
Browse files

was incorrectly saving file (x,y units)

can now save toutatis files correctly
parent c9e55d5c
No related branches found
No related tags found
No related merge requests found
......@@ -76,15 +76,19 @@ class dst:
except:
raise ValueError("Available keys: "+str(self._columns))
def save(self, filename):
def save(self, filename, toutatis=False):
'''
Save the distribution file
so it can be read by TraceWin again
:param filename: Name of file
:param toutatis: Include 7th column of zeros
Stolen from Ryoichi's func.py (with permission)
'''
from struct import pack
import numpy
fout=open(filename,'w')
out =pack('b',125)
......@@ -96,18 +100,25 @@ class dst:
data=self._data.copy()
if toutatis and data.shape[1]==6:
data=numpy.append(data,numpy.zeros((len(data),1)),1)
elif not toutatis and data.shape[1]==7:
data=data[:,:-1]
# convert x,y from m to cm:
data[:,0]*=1e2
data[:,2]*=1e2
data=self._data.reshape(self.Np*6,1)
if toutatis:
data=data.reshape(self.Np*7,1)
else:
data=data.reshape(self.Np*6,1)
for x in data:
out+=pack('d',x)
out+=pack('d',self.mass)
print >>fout, out
#data.tofile(fout)
fout.close()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment