M
Maarten van Reeuwijk
Hello,
I am using the Numeric package, and I need to strip edge cells off an array
(dimension unknown) in an a-priori unknown direction. I implented this as
follows:
def el_remove_bcells(var, axis):
""" elementary routine to strip the edge cells of an array for the given
direction.
"""
if axis == 0:
return var[1:-1]
if axis == 1:
return var[:, 1:-1]
else:
return var[:, :,1:-1]
But this only works for at most 3D arrays. It must be possible to program
this fragment without the ifs, for arrays of arbitrary dimension. Is there
a command in the Numerical package I can use for this? It is very important
that this method is very fast, as my arrays normally are in the order of
100 Mb.
TIA, Maarten
I am using the Numeric package, and I need to strip edge cells off an array
(dimension unknown) in an a-priori unknown direction. I implented this as
follows:
def el_remove_bcells(var, axis):
""" elementary routine to strip the edge cells of an array for the given
direction.
"""
if axis == 0:
return var[1:-1]
if axis == 1:
return var[:, 1:-1]
else:
return var[:, :,1:-1]
But this only works for at most 3D arrays. It must be possible to program
this fragment without the ifs, for arrays of arbitrary dimension. Is there
a command in the Numerical package I can use for this? It is very important
that this method is very fast, as my arrays normally are in the order of
100 Mb.
TIA, Maarten