def _interpolate_loops(self, ds):
"""
Interpolate all loops to a resolution (`ds`) below the minimum bin width of all of the
instruments. This ensures that the image isn't 'patchy' when it is binned.
"""
if ds is None:
ds = 0.1*np.min([min(instr.resolution.x.value, instr.resolution.y.value)
for instr in self.instruments])*self.instruments[0].resolution.x.unit
ds = self.field._convert_angle_to_length(ds)
# FIXME: memory requirements for this list will grow with number of loops, consider saving
# it to the instrument files, both the interpolated s and total_coordinates
total_coordinates = []
interpolated_loop_coordinates = []
for loop in self.field.loops:
self.logger.debug('Interpolating loop {}'.format(loop.name))
n_interp = int(np.ceil(loop.full_length/ds))
interpolated_s = np.linspace(loop.field_aligned_coordinate.value[0],
loop.field_aligned_coordinate.value[-1], n_interp)
interpolated_loop_coordinates.append(interpolated_s)
nots, _ = splprep(loop.coordinates.value.T)
_tmp = splev(np.linspace(0, 1, n_interp), nots)
total_coordinates += [(x, y, z) for x, y, z in zip(_tmp[0], _tmp[1], _tmp[2])]
total_coordinates = np.array(total_coordinates)*loop.coordinates.unit
return total_coordinates, interpolated_loop_coordinates
评论列表
文章目录