import numpy as np12import yt34# Load the dataset.5ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")67# Choose a center for the render.8c = [0.5, 0.5, 0.5]910# Our image plane will be normal to some vector. For things like collapsing11# objects, you could set it the way you would a cutting plane -- but for this12# dataset, we'll just choose an off-axis value at random. This gets normalized13# automatically.14L = [1.0, 0.0, 0.0]1516# Our "width" is the width of the image plane as well as the depth.17# The first element is the left to right width, the second is the18# top-bottom width, and the last element is the back-to-front width19# (all in code units)20W = [0.04, 0.04, 0.4]2122# The number of pixels along one side of the image.23# The final image will have Npixel^2 pixels.24Npixels = 5122526# Create the off axis projection.27# Setting no_ghost to False speeds up the process, but makes a28# slightly lower quality image.29image = yt.off_axis_projection(ds, c, L, W, Npixels, ("gas", "density"), no_ghost=False)3031# Write out the final image and give it a name32# relating to what our dataset is called.33# We save the log of the values so that the colors do not span34# many orders of magnitude. Try it without and see what happens.35yt.write_image(np.log10(image), f"{ds}_offaxis_projection.png")363738