Skip to content

Commit

Permalink
Merge branch 'yt_tweaks'
Browse files Browse the repository at this point in the history
Conflicts:
	CHANGES.rst
  • Loading branch information
keflavich committed Sep 16, 2014
2 parents 2a46d5b + be7255b commit 09d789c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
https://github.com/radio-astro-tools/spectral-cube/pull/129)
- Masks' `.include()` method works without ``data`` arguments.
(https://github.com/radio-astro-tools/spectral-cube/pull/147)
- Allow movie name to be specified in yt movie creation
(https://github.com/radio-astro-tools/spectral-cube/pull/145)

0.1 (2014-06-01)
----------------
Expand Down
11 changes: 8 additions & 3 deletions spectral_cube/ytcube.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def quick_render_movie(self, outdir, size=256, nframes=30,
transfer_function='auto',
start_index=0,
image_prefix="",
output_filename='out.mp4',
log_scale=False,
rescale=True):
"""
Expand Down Expand Up @@ -106,6 +107,9 @@ def quick_render_movie(self, outdir, size=256, nframes=30,
The number of the first image to save
image_prefix : str
A string to prepend to the image name for each image that is output
output_filename : str
The movie file name to output. The suffix may affect the file type
created. Defaults to 'out.mp4'. Will be placed in ``outdir``
Returns
-------
Expand Down Expand Up @@ -154,7 +158,8 @@ def quick_render_movie(self, outdir, size=256, nframes=30,
if rescale:
_rescale_images(images, os.path.join(outdir, image_prefix))

pipe = _make_movie(outdir, prefix=image_prefix)
pipe = _make_movie(outdir, prefix=image_prefix,
filename=output_filename)

return images

Expand Down Expand Up @@ -221,12 +226,12 @@ def _rescale_images(images, prefix):
image = image.rescale(cmax=cmax, amax=amax).swapaxes(0,1)
image.write_png("%s%04i.png" % (prefix, i), rescale=False)

def _make_movie(moviepath, prefix="", overwrite=True):
def _make_movie(moviepath, prefix="", filename='out.mp4', overwrite=True):
"""
Use ffmpeg to generate a movie from the image series
"""

outpath = os.path.join(moviepath,'out.mp4')
outpath = os.path.join(moviepath, filename)

if os.path.exists(outpath) and overwrite:
command = ['ffmpeg', '-y', '-r','5','-i',
Expand Down

0 comments on commit 09d789c

Please sign in to comment.