Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
yt-project
GitHub Repository: yt-project/yt
Path: blob/main/doc/source/cookbook/multi_width_image.py
928 views
1
import yt
2
3
# Load the dataset.
4
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
5
6
# Create a slice plot for the dataset. With no additional arguments,
7
# the width will be the size of the domain and the center will be the
8
# center of the simulation box
9
slc = yt.SlicePlot(ds, "z", ("gas", "density"))
10
11
# Create a list of a couple of widths and units.
12
# (N.B. Mpc (megaparsec) != mpc (milliparsec)
13
widths = [(1, "Mpc"), (15, "kpc")]
14
15
# Loop through the list of widths and units.
16
for width, unit in widths:
17
# Set the width.
18
slc.set_width(width, unit)
19
20
# Write out the image with a unique name.
21
slc.save("%s_%010d_%s" % (ds, width, unit))
22
23
zoomFactors = [2, 4, 5]
24
25
# recreate the original slice
26
slc = yt.SlicePlot(ds, "z", ("gas", "density"))
27
28
for zoomFactor in zoomFactors:
29
# zoom in
30
slc.zoom(zoomFactor)
31
32
# Write out the image with a unique name.
33
slc.save("%s_%i" % (ds, zoomFactor))
34
35