def create_image(filename_prefix): fields = ['noise%d' % i for i in range(4)] p = SlicePlot(ds, 'z', fields) p.save('%s_log' % filename_prefix) p.set_log('all', False) p.save('%s_lin' % filename_prefix)
def create_image(filename_prefix): fields = ["noise%d" % i for i in range(4)] p = SlicePlot(ds, "z", fields) p.save(f"{filename_prefix}_log") p.set_log("all", False) p.save(f"{filename_prefix}_lin")
def create_image(filename_prefix): fields = ["noise%d" % i for i in range(4)] for normal in ("phi", "theta"): p = SlicePlot(ds, normal, fields) p.save(f"{filename_prefix}_{normal}")
units = 'kpc' color_map = 'algae' show_annotations = True image_name = 'testslice44' #my_sphere = ds.sphere(center, (width, units)) from yt import SlicePlot #p = SlicePlot(my_sphere, axis, variable, center = center, width = (width, units)) p = SlicePlot(ds, axis, variable, center=center, width=(width, units)) p.hide_axes() p.hide_colorbar() plot = p.plots[variable] p.set_cmap(variable, "hot") p.save('~/Desktop/testslc.png') #fig = plot.figure #f = BytesIO() #vv = yt.write_image(np.log10(p.frb[variable][:,:-1].d),f, cmap_name = color_map) plot.canvas.draw() buff = plot.canvas.tostring_argb() ncols, nrows = plot.canvas.get_width_height() vv = np.fromstring(buff, dtype=np.uint8).reshape((nrows, ncols, 4), order="C") if show_annotations: p = SlicePlot(ds, axis, variable, center=center, width=(width, units)) plot = p.plots[variable] plot.canvas.draw() buff2 = plot.canvas.tostring_argb() ncols2, nrows2 = plot.canvas.get_width_height() vv2 = np.fromstring(buff2, dtype=np.uint8).reshape((nrows2, ncols2, 4),