From ba4ac5c108e841edc4855bafa35bb52a2928d1a3 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 14 Nov 2022 12:42:13 +0100 Subject: [PATCH] less repetition --- python/damask/_grid.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/damask/_grid.py b/python/damask/_grid.py index feff001f3..db884873b 100644 --- a/python/damask/_grid.py +++ b/python/damask/_grid.py @@ -972,15 +972,16 @@ class Grid: # materials: 1 """ - options = ('nearest',False,None) orig = tuple(map(np.linspace,self.origin + self.size/self.cells*.5, self.origin + self.size - self.size/self.cells*.5,self.cells)) + interpolator = partial(interpolate.RegularGridInterpolator, + points=orig,method='nearest',bounds_error=False,fill_value=None) new = grid_filters.coordinates0_point(cells,self.size,self.origin) - return Grid(material = interpolate.RegularGridInterpolator(orig,self.material,*options)(new).astype(int), + return Grid(material = interpolator(values=self.material)(new).astype(int), size = self.size, origin = self.origin, - initial_conditions = {k: interpolate.RegularGridInterpolator(orig,v,*options)(new) + initial_conditions = {k: interpolator(values=v)(new) for k,v in self.initial_conditions.items()}, comments = self.comments+[util.execution_stamp('Grid','scale')], )