add autoshift_dxyz and copy()

lethe/LATEST
jan 8 lat temu
rodzic 7cc578cac4
commit 1e4ee5e057

@ -5,6 +5,7 @@ from numpy import diff, floor, ceil, zeros, hstack, newaxis
import pickle
import warnings
import copy
from float_raster import raster
@ -169,6 +170,16 @@ class Grid(object):
dxyz = self.shifted_dxyz(which_shifts)
return [exyz[a][:-1] + dxyz[a] / 2.0 for a in range(3)]
def autoshifted_dxyz(self):
"""
Return cell widths, with each dimension shifted by the corresponding shifts.
:return: [grid.shifted_dxyz(which_shifts=a)[a] for a in range(3)]
"""
if len(self.grids) != 3:
raise GridError('autoshifting requires exactly 3 grids')
return [self.shifted_dxyz(which_shifts=a)[a] for a in range(3)]
def ind2pos(self,
ind: numpy.ndarray or List,
which_shifts: int = None,
@ -346,6 +357,14 @@ class Grid(object):
with open(filename, 'wb') as f:
pickle.dump(self.__dict__, f, protocol=2)
def copy(self):
"""
Return a deep copy of the grid.
:return: Deep copy of the grid.
"""
return copy.deepcopy(self)
def draw_polygons(self,
surface_normal: Direction or int,
center: List or numpy.ndarray,

Ładowanie…
Anuluj
Zapisz