From 6e72ec21e2a282ba23ef50f7a5aba2661870d40e Mon Sep 17 00:00:00 2001 From: Jo Bovy Date: Wed, 18 Nov 2015 18:33:50 -0500 Subject: [PATCH] Add option to swap y and z dimensions --- galpy/snapshot_src/nemo_util.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/galpy/snapshot_src/nemo_util.py b/galpy/snapshot_src/nemo_util.py index 101a802cc..f7751850f 100644 --- a/galpy/snapshot_src/nemo_util.py +++ b/galpy/snapshot_src/nemo_util.py @@ -5,7 +5,7 @@ import numpy import tempfile import subprocess -def read(filename,ext=None): +def read(filename,ext=None,swapyz=False): """ NAME: read @@ -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: @@ -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]))