mirror of
https://github.com/Richard-Sti/csiborgtools.git
synced 2024-12-22 19:58:01 +00:00
add columns flip
This commit is contained in:
parent
e97609da05
commit
b3c7d687b7
2 changed files with 25 additions and 1 deletions
|
@ -15,4 +15,4 @@
|
|||
|
||||
from .readsim import (get_sim_path, open_particle, open_unbinding,
|
||||
read_particle, read_clumpid, read_clumps,
|
||||
convert_mass_cols, convert_position_cols)
|
||||
convert_mass_cols, convert_position_cols, flip_cols)
|
||||
|
|
|
@ -363,3 +363,27 @@ def convert_position_cols(arr, cols, zero_centered=False):
|
|||
arr[col] *= BOXSIZE
|
||||
if zero_centered:
|
||||
arr[col] -= BOXSIZE / 2
|
||||
|
||||
|
||||
def flip_cols(arr, col1, col2):
|
||||
"""
|
||||
Flip values in columns `col1` and `col2`. `arr` is passed by reference and
|
||||
is not explicitly returned back.
|
||||
|
||||
|
||||
Parameters
|
||||
----------
|
||||
arr : structured array
|
||||
The array whose columns are to be converted.
|
||||
col1 : str
|
||||
The first column name.
|
||||
col2 : str
|
||||
The second column name.
|
||||
|
||||
Returns
|
||||
-------
|
||||
nothing
|
||||
"""
|
||||
dum = numpy.copy(arr[col1])
|
||||
arr[col1] = arr[col2]
|
||||
arr[col2] = dum
|
||||
|
|
Loading…
Reference in a new issue