Skip to content

Commit

Permalink
Make scanner work when scan_dim is not passed as a tuple but other ar…
Browse files Browse the repository at this point in the history
…ray-like. (#281)
  • Loading branch information
NikoOinonen authored May 23, 2024
1 parent d104022 commit 8ebe873
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions ppafm/ocl/relax.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def prepareBuffers(self, FEin_np=None, lvec=None, FEin_cl=None, FEin_shape=None,

# see: https://stackoverflow.com/questions/39533635/pyopencl-3d-rgba-image-from-numpy-array
if scan_dim is not None:
self.scan_dim = scan_dim
self.scan_dim = tuple(scan_dim)
fsize = np.dtype(np.float32).itemsize
f4size = fsize * 4
nxy = self.scan_dim[0] * self.scan_dim[1]
Expand All @@ -194,14 +194,7 @@ def prepareBuffers(self, FEin_np=None, lvec=None, FEin_cl=None, FEin_shape=None,
nbytes += bsz * self.nDimConvOut
self.cl_WZconv = cl.Buffer(self.ctx, mf.READ_ONLY, fsize * self.nDimConv)
nbytes += fsize * self.nDimConv
self.FEconv = np.empty(
self.scan_dim[:2]
+ (
self.nDimConvOut,
4,
),
dtype=np.float32,
)
self.FEconv = self.prepareFEConv()

if bZMap:
self.cl_zMap = cl.Buffer(self.ctx, mf.WRITE_ONLY, nxy * fsize)
Expand Down Expand Up @@ -257,6 +250,9 @@ def tryReleaseBuffers(self):
except:
pass

def prepareFEConv(self):
return np.empty(self.scan_dim[:2] + (self.nDimConvOut, 4), dtype=np.float32)

def preparePosBasis(self, start=(-5.0, -5.0), end=(5.0, 5.0)):
self.start = start
self.end = end
Expand Down Expand Up @@ -474,16 +470,6 @@ def run_getFEinStrokesTilted(self, FEout=None, FEin=None, lvec=None, nz=None):
self.queue.finish()
return FEout

def prepareFEConv(self):
return np.empty(
self.scan_dim[:2]
+ (
self.nDimConvOut,
4,
),
dtype=np.float32,
)

def run_convolveZ(self, FEconv=None, nz=None):
"""
convolve 3D forcefield in FEout with 1D weight mask WZconv
Expand Down

0 comments on commit 8ebe873

Please sign in to comment.