precisionTuple = _precision(self.precision)
// check wether self.freq is part of SteeringVector.f
freqInSteerObjFreq = isclose(array(self._steer_obj.f), self.freq)
if freqInSteerObjFreq.any():
freqInd = flatnonzero(freqInSteerObjFreq)[0]
else:
warn("PointSpreadFunction.freq (%s Hz) was appended to PointSpreadFunction._steer_obj.f, "\
"as it was not an element of the original list!" % self.freq, Warning, stacklevel = 2)
self._steer_obj.f.append(self.freq)
freqInd = int(-1)
// get the cached data, or, if non-existing, create new structure
if not fr in self.h5f.root:
if self.calcmode == "readonly":
raise ValueError("Cannot calculate missing PSF (freq %s) in \"readonly\" mode." % fr)
group = self.h5f.create_group(self.h5f.root, fr)
shape = (gs, gs)
atom = precisionTuple[3]()
filters = tables.Filters(complevel=5, complib="blosc")
ac = self.h5f.create_carray(group, "result", atom, shape, filters=filters)
shape = (gs,)
atom = tables.BoolAtom()
gp = self.h5f.create_carray(group, "gridpts", atom, shape, filters=filters)
else:
ac = self.h5f.get_node("/"+fr, "result")
gp = self.h5f.get_node("/"+fr, "gridpts")
// are there grid points for which the PSF hasn"t been calculated yet?
if not gp[:][self.grid_indices].all():
if self.calcmode == "readonly":
raise ValueError("Cannot calculate missing PSF (points) in \"readonly\" mode.")
elif self.calcmode != "full":
// calc_ind has the form [True, True, False, True], except
// when it has only 1 entry (value True/1 would be ambiguous)
if self.grid_indices.size == 1:
calc_ind = [0]
else:
calc_ind = invert(gp[:][self.grid_indices])
// get indices which have the value True = not yet calculated
g_ind_calc = self.grid_indices[calc_ind]
if self.calcmode == "single":
for ind in g_ind_calc:
ac[:,ind] = self._steer_obj._psfCall(freqInd, [ind], self.precision)[0,:,0]
gp[ind] = True
elif self.calcmode == "full":
gp[:] = True
ac[:] = self._steer_obj._psfCall(freqInd, arange(self._steer_obj.grid.size), self.precision)[0,:,:]
else: // "block"
hh = self._steer_obj._psfCall(freqInd, g_ind_calc, self.precision)
indh = 0
After Change
gp[ind] = True
elif self.calcmode == "full": // calculate all psfs in one go
gp[:] = True
ac[:] = self._psfCall(arange(gs))
else: // "block" // calculate selected psfs in one go
hh = self._psfCall(g_ind_calc)
indh = 0
for ind in g_ind_calc: