"""
This is a recipe that takes a slice through the most dense point, then creates
a bunch of frames as it zooms in.  It's important to note that this particular
recipe is provided to show how to be more flexible and add annotations and the
like -- the base system, of a zoomin, is provided by the ``yt zoomin`` command.
"""
from yt.mods import * # set up our namespace

fn = "RedshiftOutput0005" # parameter file to load
n_frames = 5  # This is the number of frames to make -- below, you can see how
              # this is used.
min_dx = 40   # This is the minimum size in smallest_dx of our last frame.
              # Usually it should be set to something like 400, but for THIS
              # dataset, we actually don't have that great of resolution.

pf = load(fn) # load data
frame_template = "frame_%05i" # Template for frame filenames

pc = PlotCollection(pf, center=[0.5, 0.5, 0.5]) # We make a plot collection that defaults to being
                        # centered at the most dense point.
p = pc.add_slice("Density", 2) # Add our slice, along z
p.modify["contour"]("Temperature") # We'll contour in temperature -- this kind
                                    # of modification can't be done on the command
                                    # line, so that's why we have the recipe!

# What we do now is a bit fun.  "enumerate" returns a tuple for every item --
# the index of the item, and the item itself.  This saves us having to write
# something like "i = 0" and then inside the loop "i += 1" for ever loop.  The
# argument to enumerate is the 'logspace' function, which takes a minimum and a
# maximum and the number of items to generate.  It returns 10^power of each
# item it generates.
for i,v in enumerate(na.logspace(
            0, na.log10(pf.h.get_smallest_dx()*min_dx), n_frames)):
    # We set our width as necessary for this frame ...
    pc.set_width(v,'1')
    # ... and we save!
    pc.save(frame_template % (i))
