yt.visualization.volume_rendering.camera_path module

Create smooth camera paths from keyframes.

class yt.visualization.volume_rendering.camera_path.Keyframes(x, y, z=None, north_vectors=None, up_vectors=None, times=None, niter=50000, init_temp=10.0, alpha=0.999, fixed_start=False)[source]

Bases: object


Generates all (i,j) pairs for (i,j) for 0-size


Create a distance matrix for the city coords that uses straight line distance

create_path(npoints, path_time=None, tension=0.5, shortest_path=False)[source]

Create a interpolated camera path from keyframes.

  • npoints (integer) – Number of points to interpolate from keyframes
  • path_time (array_like, optional) – Times of interpolated points. Default: Linearly spaced
  • tension (float, optional) – Controls how sharp of a curve the spline takes. A higher tension allows for more sharp turns. Default: 0.5
  • shortest_path (boolean, optional) – If true, estimate the shortest path between the keyframes. Default: False

path – Dictionary (time, position, north_vectors, up_vectors) of camera path. Also saved to self.path.

Return type:



Determine shortest path between all keyframes.

prob(prev, next, temperature)[source]

Generates values in random order, equivlanet to using shuffle in random without generation all values at once.


Generator to return all possible variations where a section between two cities are swapped.

setup_tsp(niter=50000, init_temp=10.0, alpha=0.999, fixed_start=False)[source]

Setup parameters for Travelling Salesman Problem.

  • niter (integer, optional) – Maximum number of iterations to find solution. Default: 50000
  • init_temp (float, optional) – Intital temperature for simulated annealing when finding a solution. Lower initial temperatures result in an initial solution in first several iterations that changes more rapidly. Default: 10.0
  • alpha (float, optional) – Exponent in cooling function in simulated annealing. Must be < 1. In each iteration, the temperature_new = temperature_old * alpha. Default: 0.999
  • fixed_start (boolean, optional) – If true, the first point never changes when searching for shortest path. Default: False

Calculate the total length of the tour based on the distance matrix


Writes camera path to ASCII file

Parameters:filename (string, optional) – Filename containing the camera path. Default: path.dat