Having some more fun in
Autoplot:
I was happy to be able to move the GIF-writing code into a library. (To keep things neat, I added a "contrib" directory in the "jython" directory within "autoplot_data". Looking at sys.path, you can see that "autoplot_data/jython" is included.)
import os.path
from contrib import gif
from org.das2.graph import DasColorBar
def xor_mod_plot(n=256, modulus=9):
x = outerProduct(linspace(0, n - 1, n), ones(n))
plot(gt(bitwiseXor(x, transpose(x)) % modulus, zeros(n, n)), renderType='nnSpectrogram>rebin=noInterpolate')
dom.plots[0].setColortable(DasColorBar.Type.GRAYSCALE)
gif.plot_to_gif(xor_mod_plot, os.path.expanduser('~/autoplot/xor_mod_zoom.gif'),
keyword_params=[dict(n=n) for n in range(4, 513)], delay_tenths_sec=5)
The only change required for the GIF-writing code was the call to writeToBufferedImage(), which required an explicit import when used within the library:
from org import autoplot
...
images.append(autoplot.ScriptContext.writeToBufferedImage())
No comments:
Post a Comment