yt.visualization.volume_rendering.camera_path module

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

all_pairs()[source]

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

cartesian_matrix()[source]

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

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

Create a interpolated camera path from keyframes.

Parameters:
  • 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

Returns:

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

Return type:

dict

get_shortest_path()[source]

Determine shortest path between all keyframes.

prob(prev, next, temperature)[source]
rand_seq()[source]

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

reversed_sections(tour)[source]

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

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

Setup parameters for Travelling Salesman Problem.

Parameters:
  • niter (integer, optional) – Maximum number of iterations to find solution. Default: 50000

  • init_temp (float, optional) – Initial 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

tour_length(tour)[source]

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

write_path(filename='path.dat')[source]

Writes camera path to ASCII file

Parameters:

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