Skip to content

Commit

Permalink
Add option to swap y and z dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
jobovy committed Nov 18, 2015
1 parent 22e2469 commit 6e72ec2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion galpy/snapshot_src/nemo_util.py
Expand Up @@ -5,7 +5,7 @@
import numpy
import tempfile
import subprocess
def read(filename,ext=None):
def read(filename,ext=None,swapyz=False):
"""
NAME:
read
Expand All @@ -14,6 +14,7 @@ def read(filename,ext=None):
INPUT:
filename - name of the file
ext= if set, 'nemo' for NEMO binary format, otherwise assumed ASCII; if not set, gleaned from extension
swapyz= (False) if True, swap the y and z axes in the output (only for position and velocity)
OUTPUT:
snapshots [nbody,ndim,nt]
HISTORY:
Expand All @@ -39,6 +40,9 @@ def read(filename,ext=None):
# Now read
out= numpy.loadtxt(asciifilename,comments='#')
if ext.lower() == 'nemo': os.remove(asciifilename)
if swapyz:
out[:,[2,3]]= out[:,[3,2]]
out[:,[5,6]]= out[:,[6,5]]
# Get the number of snapshots
nt= (_wc(asciifilename)-out.shape[0])//13 # 13 comments/snapshot
out= numpy.reshape(out,(nt,out.shape[0]//nt,out.shape[1]))
Expand Down

0 comments on commit 6e72ec2

Please sign in to comment.