def to_movie(self, output_fn, fps=15., dpi=50, cut=None, cmap='gray', extension=1):
viz = []
with click.progressbar(self.mosaic_filenames, label="Reading mosaics", show_pos=True) as bar:
for fn in bar:
try:
frame = KeplerMosaicMovieFrame(fn)
fig = frame.to_fig(rowrange=self.rowrange, colrange=self.colrange,
dpi=dpi, cut=cut, cmap=cmap, extension=extension,)
img = np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8, sep='')
img = img.reshape(fig.canvas.get_width_height()[::-1] + (3,))
pl.close(fig) # Avoid memory leak!
viz.append(img)
except InvalidFrameException:
print("InvalidFrameException for {}".format(fn))
# Save the output as a movie
if output_fn.endswith('.gif'):
kwargs = {'duration': 1. / fps}
else:
kwargs = {'fps': fps}
imageio.mimsave(output_fn, viz, **kwargs)
评论列表
文章目录