yt.visualization.volume_rendering.old_camera module

class yt.visualization.volume_rendering.old_camera.Camera(center, normal_vector, width, resolution, transfer_function=None, north_vector=None, steady_north=False, volume=None, fields=None, log_fields=None, sub_samples=5, ds=None, min_level=None, max_level=None, no_ghost=True, data_source=None, use_light=False)[source]

Bases: ParallelAnalysisInterface

A viewpoint into a volume, for volume rendering.

The camera represents the eye of an observer, which will be used to generate ray-cast volume renderings of the domain.

Parameters:
  • center (array_like) – The current “center” of the view port – the focal point for the camera.

  • normal_vector (array_like) – The vector between the camera position and the center.

  • width (float or list of floats) – The current width of the image. If a single float, the volume is cubical, but if not, it is left/right, top/bottom, front/back.

  • resolution (int or list of ints) – The number of pixels in each direction.

  • transfer_function (yt.visualization.volume_rendering.TransferFunction) – The transfer function used to map values to colors in an image. If not specified, defaults to a ProjectionTransferFunction.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

  • steady_north (bool, optional) – Boolean to control whether to normalize the north_vector by subtracting off the dot product of it and the normal vector. Makes it easier to do rotations along a single axis. If north_vector is specified, is switched to True. Default: False

  • volume (yt.extensions.volume_rendering.AMRKDTree, optional) – The volume to ray cast through. Can be specified for finer-grained control, but otherwise will be automatically generated.

  • fields (list of fields, optional) – This is the list of fields we want to volume render; defaults to Density.

  • log_fields (list of bool, optional) – Whether we should take the log of the fields before supplying them to the volume rendering mechanism.

  • sub_samples (int, optional) – The number of samples to take inside every cell per ray.

  • ds (Dataset) – For now, this is a require parameter! But in the future it will become optional. This is the dataset to volume render.

  • max_level (int, optional) – Specifies the maximum level to be rendered. Also specifies the maximum level used in the kd-Tree construction. Defaults to None (all levels), and only applies if use_kd=True.

  • no_ghost (bool, optional) – Optimization option. If True, homogenized bricks will extrapolate out from grid instead of interpolating from ghost zones that have to first be calculated. This can lead to large speed improvements, but at a loss of accuracy/smoothness in resulting image. The effects are less notable when the transfer function is smooth and broad. Default: True

  • data_source (data container, optional) – Optionally specify an arbitrary data source to the volume rendering. All cells not included in the data source will be ignored during ray casting. By default this will get set to ds.all_data().

Examples

>>> import yt.visualization.volume_rendering.api as vr
>>> ds = load("DD1701")  # Load a dataset
>>> c = [0.5] * 3  # Center
>>> L = [1.0, 1.0, 1.0]  # Viewpoint
>>> W = np.sqrt(3)  # Width
>>> N = 1024  # Pixels (1024^2)

# Get density min, max >>> mi, ma = ds.all_data().quantities[“Extrema”](“Density”)[0] >>> mi, ma = np.log10(mi), np.log10(ma)

# Construct transfer function >>> tf = vr.ColorTransferFunction((mi - 2, ma + 2)) # Sample transfer function with 5 gaussians. Use new col_bounds keyword. >>> tf.add_layers(5, w=0.05, col_bounds=(mi + 1, ma), colormap=”nipy_spectral”)

# Create the camera object >>> cam = vr.Camera(c, L, W, (N, N), transfer_function=tf, ds=ds)

# Ray cast, and save the image. >>> image = cam.snapshot(fn=”my_rendering.png”)

annotate(ax, enhance=True, label_fmt=None)[source]
comm = None
draw()[source]
draw_box(im, le, re, color=None)[source]

Draws a box on an existing volume rendering.

Draws a box defined by a left and right edge by modifying an existing volume rendering

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • le (Numpy ndarray) – Left corner of the box

  • re (Numpy ndarray) – Right corner of the box

  • color (array like, optional) – Color of the box (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_box(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_box.png")
draw_coordinate_vectors(im, length=0.05, thickness=1)[source]

Draws three coordinate vectors in the corner of a rendering.

Modifies an existing image to have three lines corresponding to the coordinate directions colored by {x,y,z} = {r,g,b}. Currently only functional for plane-parallel volume rendering.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • length (float, optional) – The length of the lines, as a fraction of the image size. Default : 0.05

  • thickness (int, optional) – Thickness in pixels of the line to be drawn.

Returns:

  • None

  • Modifies

  • ——–

  • im (The original image.)

Examples

>>> im = cam.snapshot()
>>> cam.draw_coordinate_vectors(im)
>>> im.write_png("render_with_grids.png")
draw_domain(im, alpha=0.3)[source]

Draws domain edges on an existing volume rendering.

Draws a white wireframe on the domain edges.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the wireframe being drawn. Used to control how bright the lines are with respect to the image. Default : 0.3

Returns:

nim – A new image with the domain lines drawn

Return type:

Numpy ndarray

Examples

>>> im = cam.snapshot()
>>> nim = cam.draw_domain(im)
>>> write_bitmap(nim, "render_with_domain_boundary.png")
draw_grids(im, alpha=0.3, cmap=None, min_level=None, max_level=None)[source]

Draws Grids on an existing volume rendering.

By mapping grid level to a color, draws edges of grids on a volume rendering using the camera orientation.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the grids being drawn. Used to control how bright the grid lines are with respect to the image. Default : 0.3

  • cmap (string, optional) – Colormap to be used mapping grid levels to colors.

  • min_level (int, optional) – Optional parameter to specify the min level grid boxes to overplot on the image.

  • max_level (int, optional) – Optional parameters to specify the max level grid boxes to overplot on the image.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.add_grids(im)
>>> write_bitmap(im, "render_with_grids.png")
draw_line(im, x0, x1, color=None)[source]

Draws a line on an existing volume rendering. Given starting and ending positions x0 and x1, draws a line on a volume rendering using the camera orientation.

Parameters:
  • im (ImageArray or 2D ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • x0 (YTArray or ndarray) – Starting coordinate. If passed in as an ndarray, assumed to be in code units.

  • x1 (YTArray or ndarray) – Ending coordinate, in simulation coordinates. If passed in as an ndarray, assumed to be in code units.

  • color (array like, optional) – Color of the line (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_line(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_line.png")
finalize_image(image)[source]
get_dependencies(fields)
get_information()[source]
get_sampler(args, kwargs)[source]
get_sampler_args(image)[source]
initialize_source()[source]
look_at(new_center, north_vector=None)[source]

Change the view direction based on a new focal point.

This will recalculate all the necessary vectors and vector planes to orient the image plane so that it points at a new location.

Parameters:
  • new_center (array_like) – The new “center” of the view port – the focal point for the camera.

  • north_vector (array_like, optional) – The “up” direction for the plane of rays. If not specific, calculated automatically.

move_to(final, n_steps, final_width=None, exponential=False, clip_ratio=None)[source]

Loop over a look_at

This will yield n_steps snapshots until the current view has been moved to a final center of final with a final width of final_width.

Parameters:
  • final (array_like) – The final center to move to after n_steps

  • n_steps (int) – The number of look_at snapshots to make.

  • final_width (float or array_like, optional) – Specifies the final width after n_steps. Useful for moving and zooming at the same time.

  • exponential (boolean) – Specifies whether the move/zoom transition follows an exponential path toward the destination or linear

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.move_to([0.2, 0.3, 0.6], 10)):
...     iw.write_bitmap(snapshot, "move_%04i.png" % i)
new_image()[source]
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

pitch(theta)[source]

Rotate by a given angle about the horizontal axis

Pitch the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to pitch the view.

Examples

>>> cam.pitch(np.pi / 4)
project_to_plane(pos, res=None)[source]
roll(theta)[source]

Rotate by a given angle about the view normal axis

Roll the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to roll the view.

Examples

>>> cam.roll(np.pi / 4)
rotate(theta, rot_vector=None)[source]

Rotate by a given angle

Rotate the view. If rot_vector is None, rotation will occur around the north_vector.

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around north_vector

Examples

>>> cam.rotate(np.pi / 4)
rotation(theta, n_steps, rot_vector=None, clip_ratio=None)[source]

Loop over rotate, creating a rotation

This will yield n_steps snapshots until the current view has been rotated by an angle theta

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • n_steps (int) – The number of look_at snapshots to make.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around the original north_vector

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.rotation(np.pi, 10)):
...     iw.write_bitmap(snapshot, "rotation_%04i.png" % i)
save_annotated(fn, image, enhance=True, dpi=100, clear_fig=True, label_fmt=None)[source]

Save an image with the transfer function represented as a colorbar.

Parameters:
  • fn (str) – The output filename

  • image (ImageArray) – The image to annotate

  • enhance (bool, optional) – Enhance the contrast (default: True)

  • dpi (int, optional) – Dots per inch in the output image (default: 100)

  • clear_fig (bool, optional) – Reset the figure (through matplotlib.pyplot.clf()) before drawing. Setting this to false can allow us to overlay the image onto an existing figure

  • label_fmt (str, optional) – A format specifier (e.g., label_fmt=”%.2g”) to use in formatting the data values that label the transfer function colorbar.

save_image(image, fn=None, clip_ratio=None, transparent=False)[source]
set_default_light_dir()[source]
set_default_light_rgba()[source]
show(clip_ratio=None)[source]

This will take a snapshot and display the resultant image in the IPython notebook.

If yt is being run from within an IPython session, and it is able to determine this, this function will snapshot and send the resultant image to the IPython notebook for display.

If yt can’t determine if it’s inside an IPython session, it will raise YTNotInsideNotebook.

Parameters:

clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> cam.show()
show_mpl(im, enhance=True, clear_fig=True)[source]
show_tf()[source]
snapshot(fn=None, clip_ratio=None, double_check=False, num_threads=0, transparent=False)[source]

Ray-cast the camera.

This method instructs the camera to take a snapshot – i.e., call the ray caster – based on its current settings.

Parameters:
  • fn (string, optional) – If supplied, the image will be saved out to this before being returned. Scaling will be to the maximum value.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

  • double_check (bool, optional) – Optionally makes sure that the data contains only valid entries. Used for debugging.

  • num_threads (int, optional) – If supplied, will use ‘num_threads’ number of OpenMP threads during the rendering. Defaults to 0, which uses the environment variable OMP_NUM_THREADS.

  • transparent (bool, optional) – Optionally saves out the 4-channel rgba image, which can appear empty if the alpha channel is low everywhere. Default: False

Returns:

image – An (N,M,3) array of the final returned values, in float64 form.

Return type:

array

switch_orientation(normal_vector=None, north_vector=None)[source]

Change the view direction based on any of the orientation parameters.

This will recalculate all the necessary vectors and vector planes related to an orientable object.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

switch_view(normal_vector=None, width=None, center=None, north_vector=None)[source]

Change the view based on any of the view parameters.

This will recalculate the orientation and width based on any of normal_vector, width, center, and north_vector.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • width (float or array of floats, optional) – The new width. Can be a single value W -> [W,W,W] or an array [W1, W2, W3] (left/right, top/bottom, front/back)

  • center (array_like, optional) – Specifies the new center.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

update_view_from_matrix(mat)[source]
yaw(theta)[source]

Rotate by a given angle about the vertical axis

Yaw the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to yaw the view.

Examples

>>> cam.yaw(np.pi / 4)
zoom(factor)[source]

Change the distance to the focal point.

This will zoom the camera in by some factor toward the focal point, along the current view direction, modifying the left/right and up/down extents as well.

Parameters:

factor (float) – The factor by which to reduce the distance to the focal point.

Notes

You will need to call snapshot() again to get a new image.

zoomin(final, n_steps, clip_ratio=None)[source]

Loop over a zoomin and return snapshots along the way.

This will yield n_steps snapshots until the current view has been zooming in to a final factor of final.

Parameters:
  • final (float) – The zoom factor, with respect to current, desired at the end of the sequence.

  • n_steps (int) – The number of zoom snapshots to make.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.zoomin(100.0, 10)):
...     iw.write_bitmap(snapshot, "zoom_%04i.png" % i)
class yt.visualization.volume_rendering.old_camera.FisheyeCamera(center, radius, fov, resolution, transfer_function=None, fields=None, sub_samples=5, log_fields=None, volume=None, ds=None, no_ghost=False, rotation=None, use_light=False)[source]

Bases: Camera

annotate(ax, enhance=True, label_fmt=None)
comm = None
draw()
draw_box(im, le, re, color=None)

Draws a box on an existing volume rendering.

Draws a box defined by a left and right edge by modifying an existing volume rendering

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • le (Numpy ndarray) – Left corner of the box

  • re (Numpy ndarray) – Right corner of the box

  • color (array like, optional) – Color of the box (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_box(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_box.png")
draw_coordinate_vectors(im, length=0.05, thickness=1)

Draws three coordinate vectors in the corner of a rendering.

Modifies an existing image to have three lines corresponding to the coordinate directions colored by {x,y,z} = {r,g,b}. Currently only functional for plane-parallel volume rendering.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • length (float, optional) – The length of the lines, as a fraction of the image size. Default : 0.05

  • thickness (int, optional) – Thickness in pixels of the line to be drawn.

Returns:

  • None

  • Modifies

  • ——–

  • im (The original image.)

Examples

>>> im = cam.snapshot()
>>> cam.draw_coordinate_vectors(im)
>>> im.write_png("render_with_grids.png")
draw_domain(im, alpha=0.3)

Draws domain edges on an existing volume rendering.

Draws a white wireframe on the domain edges.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the wireframe being drawn. Used to control how bright the lines are with respect to the image. Default : 0.3

Returns:

nim – A new image with the domain lines drawn

Return type:

Numpy ndarray

Examples

>>> im = cam.snapshot()
>>> nim = cam.draw_domain(im)
>>> write_bitmap(nim, "render_with_domain_boundary.png")
draw_grids(im, alpha=0.3, cmap=None, min_level=None, max_level=None)

Draws Grids on an existing volume rendering.

By mapping grid level to a color, draws edges of grids on a volume rendering using the camera orientation.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the grids being drawn. Used to control how bright the grid lines are with respect to the image. Default : 0.3

  • cmap (string, optional) – Colormap to be used mapping grid levels to colors.

  • min_level (int, optional) – Optional parameter to specify the min level grid boxes to overplot on the image.

  • max_level (int, optional) – Optional parameters to specify the max level grid boxes to overplot on the image.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.add_grids(im)
>>> write_bitmap(im, "render_with_grids.png")
draw_line(im, x0, x1, color=None)

Draws a line on an existing volume rendering. Given starting and ending positions x0 and x1, draws a line on a volume rendering using the camera orientation.

Parameters:
  • im (ImageArray or 2D ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • x0 (YTArray or ndarray) – Starting coordinate. If passed in as an ndarray, assumed to be in code units.

  • x1 (YTArray or ndarray) – Ending coordinate, in simulation coordinates. If passed in as an ndarray, assumed to be in code units.

  • color (array like, optional) – Color of the line (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_line(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_line.png")
finalize_image(image)[source]
get_dependencies(fields)
get_information()[source]
get_sampler(args, kwargs)
get_sampler_args(image)[source]
initialize_source()
look_at(new_center, north_vector=None)

Change the view direction based on a new focal point.

This will recalculate all the necessary vectors and vector planes to orient the image plane so that it points at a new location.

Parameters:
  • new_center (array_like) – The new “center” of the view port – the focal point for the camera.

  • north_vector (array_like, optional) – The “up” direction for the plane of rays. If not specific, calculated automatically.

move_to(final, n_steps, final_width=None, exponential=False, clip_ratio=None)

Loop over a look_at

This will yield n_steps snapshots until the current view has been moved to a final center of final with a final width of final_width.

Parameters:
  • final (array_like) – The final center to move to after n_steps

  • n_steps (int) – The number of look_at snapshots to make.

  • final_width (float or array_like, optional) – Specifies the final width after n_steps. Useful for moving and zooming at the same time.

  • exponential (boolean) – Specifies whether the move/zoom transition follows an exponential path toward the destination or linear

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.move_to([0.2, 0.3, 0.6], 10)):
...     iw.write_bitmap(snapshot, "move_%04i.png" % i)
new_image()[source]
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

pitch(theta)

Rotate by a given angle about the horizontal axis

Pitch the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to pitch the view.

Examples

>>> cam.pitch(np.pi / 4)
project_to_plane(pos, res=None)
roll(theta)

Rotate by a given angle about the view normal axis

Roll the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to roll the view.

Examples

>>> cam.roll(np.pi / 4)
rotate(theta, rot_vector=None)

Rotate by a given angle

Rotate the view. If rot_vector is None, rotation will occur around the north_vector.

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around north_vector

Examples

>>> cam.rotate(np.pi / 4)
rotation(theta, n_steps, rot_vector=None, clip_ratio=None)

Loop over rotate, creating a rotation

This will yield n_steps snapshots until the current view has been rotated by an angle theta

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • n_steps (int) – The number of look_at snapshots to make.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around the original north_vector

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.rotation(np.pi, 10)):
...     iw.write_bitmap(snapshot, "rotation_%04i.png" % i)
save_annotated(fn, image, enhance=True, dpi=100, clear_fig=True, label_fmt=None)

Save an image with the transfer function represented as a colorbar.

Parameters:
  • fn (str) – The output filename

  • image (ImageArray) – The image to annotate

  • enhance (bool, optional) – Enhance the contrast (default: True)

  • dpi (int, optional) – Dots per inch in the output image (default: 100)

  • clear_fig (bool, optional) – Reset the figure (through matplotlib.pyplot.clf()) before drawing. Setting this to false can allow us to overlay the image onto an existing figure

  • label_fmt (str, optional) – A format specifier (e.g., label_fmt=”%.2g”) to use in formatting the data values that label the transfer function colorbar.

save_image(image, fn=None, clip_ratio=None, transparent=False)
set_default_light_dir()
set_default_light_rgba()
show(clip_ratio=None)

This will take a snapshot and display the resultant image in the IPython notebook.

If yt is being run from within an IPython session, and it is able to determine this, this function will snapshot and send the resultant image to the IPython notebook for display.

If yt can’t determine if it’s inside an IPython session, it will raise YTNotInsideNotebook.

Parameters:

clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> cam.show()
show_mpl(im, enhance=True, clear_fig=True)
show_tf()
snapshot(fn=None, clip_ratio=None, double_check=False, num_threads=0, transparent=False)

Ray-cast the camera.

This method instructs the camera to take a snapshot – i.e., call the ray caster – based on its current settings.

Parameters:
  • fn (string, optional) – If supplied, the image will be saved out to this before being returned. Scaling will be to the maximum value.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

  • double_check (bool, optional) – Optionally makes sure that the data contains only valid entries. Used for debugging.

  • num_threads (int, optional) – If supplied, will use ‘num_threads’ number of OpenMP threads during the rendering. Defaults to 0, which uses the environment variable OMP_NUM_THREADS.

  • transparent (bool, optional) – Optionally saves out the 4-channel rgba image, which can appear empty if the alpha channel is low everywhere. Default: False

Returns:

image – An (N,M,3) array of the final returned values, in float64 form.

Return type:

array

switch_orientation(normal_vector=None, north_vector=None)

Change the view direction based on any of the orientation parameters.

This will recalculate all the necessary vectors and vector planes related to an orientable object.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

switch_view(normal_vector=None, width=None, center=None, north_vector=None)

Change the view based on any of the view parameters.

This will recalculate the orientation and width based on any of normal_vector, width, center, and north_vector.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • width (float or array of floats, optional) – The new width. Can be a single value W -> [W,W,W] or an array [W1, W2, W3] (left/right, top/bottom, front/back)

  • center (array_like, optional) – Specifies the new center.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

update_view_from_matrix(mat)
yaw(theta)

Rotate by a given angle about the vertical axis

Yaw the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to yaw the view.

Examples

>>> cam.yaw(np.pi / 4)
zoom(factor)

Change the distance to the focal point.

This will zoom the camera in by some factor toward the focal point, along the current view direction, modifying the left/right and up/down extents as well.

Parameters:

factor (float) – The factor by which to reduce the distance to the focal point.

Notes

You will need to call snapshot() again to get a new image.

zoomin(final, n_steps, clip_ratio=None)

Loop over a zoomin and return snapshots along the way.

This will yield n_steps snapshots until the current view has been zooming in to a final factor of final.

Parameters:
  • final (float) – The zoom factor, with respect to current, desired at the end of the sequence.

  • n_steps (int) – The number of zoom snapshots to make.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.zoomin(100.0, 10)):
...     iw.write_bitmap(snapshot, "zoom_%04i.png" % i)
class yt.visualization.volume_rendering.old_camera.HEALpixCamera(center, radius, nside, transfer_function=None, fields=None, sub_samples=5, log_fields=None, volume=None, ds=None, use_kd=True, no_ghost=False, use_light=False, inner_radius=10)[source]

Bases: Camera

annotate(ax, enhance=True, label_fmt=None)
comm = None
draw()
draw_box(im, le, re, color=None)

Draws a box on an existing volume rendering.

Draws a box defined by a left and right edge by modifying an existing volume rendering

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • le (Numpy ndarray) – Left corner of the box

  • re (Numpy ndarray) – Right corner of the box

  • color (array like, optional) – Color of the box (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_box(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_box.png")
draw_coordinate_vectors(im, length=0.05, thickness=1)

Draws three coordinate vectors in the corner of a rendering.

Modifies an existing image to have three lines corresponding to the coordinate directions colored by {x,y,z} = {r,g,b}. Currently only functional for plane-parallel volume rendering.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • length (float, optional) – The length of the lines, as a fraction of the image size. Default : 0.05

  • thickness (int, optional) – Thickness in pixels of the line to be drawn.

Returns:

  • None

  • Modifies

  • ——–

  • im (The original image.)

Examples

>>> im = cam.snapshot()
>>> cam.draw_coordinate_vectors(im)
>>> im.write_png("render_with_grids.png")
draw_domain(im, alpha=0.3)

Draws domain edges on an existing volume rendering.

Draws a white wireframe on the domain edges.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the wireframe being drawn. Used to control how bright the lines are with respect to the image. Default : 0.3

Returns:

nim – A new image with the domain lines drawn

Return type:

Numpy ndarray

Examples

>>> im = cam.snapshot()
>>> nim = cam.draw_domain(im)
>>> write_bitmap(nim, "render_with_domain_boundary.png")
draw_grids(im, alpha=0.3, cmap=None, min_level=None, max_level=None)

Draws Grids on an existing volume rendering.

By mapping grid level to a color, draws edges of grids on a volume rendering using the camera orientation.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the grids being drawn. Used to control how bright the grid lines are with respect to the image. Default : 0.3

  • cmap (string, optional) – Colormap to be used mapping grid levels to colors.

  • min_level (int, optional) – Optional parameter to specify the min level grid boxes to overplot on the image.

  • max_level (int, optional) – Optional parameters to specify the max level grid boxes to overplot on the image.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.add_grids(im)
>>> write_bitmap(im, "render_with_grids.png")
draw_line(im, x0, x1, color=None)

Draws a line on an existing volume rendering. Given starting and ending positions x0 and x1, draws a line on a volume rendering using the camera orientation.

Parameters:
  • im (ImageArray or 2D ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • x0 (YTArray or ndarray) – Starting coordinate. If passed in as an ndarray, assumed to be in code units.

  • x1 (YTArray or ndarray) – Ending coordinate, in simulation coordinates. If passed in as an ndarray, assumed to be in code units.

  • color (array like, optional) – Color of the line (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_line(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_line.png")
finalize_image(image)[source]
get_dependencies(fields)
get_information()[source]
get_sampler(args, kwargs)
get_sampler_args(image)[source]
initialize_source()
look_at(new_center, north_vector=None)

Change the view direction based on a new focal point.

This will recalculate all the necessary vectors and vector planes to orient the image plane so that it points at a new location.

Parameters:
  • new_center (array_like) – The new “center” of the view port – the focal point for the camera.

  • north_vector (array_like, optional) – The “up” direction for the plane of rays. If not specific, calculated automatically.

move_to(final, n_steps, final_width=None, exponential=False, clip_ratio=None)

Loop over a look_at

This will yield n_steps snapshots until the current view has been moved to a final center of final with a final width of final_width.

Parameters:
  • final (array_like) – The final center to move to after n_steps

  • n_steps (int) – The number of look_at snapshots to make.

  • final_width (float or array_like, optional) – Specifies the final width after n_steps. Useful for moving and zooming at the same time.

  • exponential (boolean) – Specifies whether the move/zoom transition follows an exponential path toward the destination or linear

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.move_to([0.2, 0.3, 0.6], 10)):
...     iw.write_bitmap(snapshot, "move_%04i.png" % i)
new_image()[source]
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

pitch(theta)

Rotate by a given angle about the horizontal axis

Pitch the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to pitch the view.

Examples

>>> cam.pitch(np.pi / 4)
project_to_plane(pos, res=None)
roll(theta)

Rotate by a given angle about the view normal axis

Roll the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to roll the view.

Examples

>>> cam.roll(np.pi / 4)
rotate(theta, rot_vector=None)

Rotate by a given angle

Rotate the view. If rot_vector is None, rotation will occur around the north_vector.

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around north_vector

Examples

>>> cam.rotate(np.pi / 4)
rotation(theta, n_steps, rot_vector=None, clip_ratio=None)

Loop over rotate, creating a rotation

This will yield n_steps snapshots until the current view has been rotated by an angle theta

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • n_steps (int) – The number of look_at snapshots to make.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around the original north_vector

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.rotation(np.pi, 10)):
...     iw.write_bitmap(snapshot, "rotation_%04i.png" % i)
save_annotated(fn, image, enhance=True, dpi=100, clear_fig=True, label_fmt=None)

Save an image with the transfer function represented as a colorbar.

Parameters:
  • fn (str) – The output filename

  • image (ImageArray) – The image to annotate

  • enhance (bool, optional) – Enhance the contrast (default: True)

  • dpi (int, optional) – Dots per inch in the output image (default: 100)

  • clear_fig (bool, optional) – Reset the figure (through matplotlib.pyplot.clf()) before drawing. Setting this to false can allow us to overlay the image onto an existing figure

  • label_fmt (str, optional) – A format specifier (e.g., label_fmt=”%.2g”) to use in formatting the data values that label the transfer function colorbar.

save_image(image, fn=None, clim=None, label=None)[source]
set_default_light_dir()
set_default_light_rgba()
show(clip_ratio=None)

This will take a snapshot and display the resultant image in the IPython notebook.

If yt is being run from within an IPython session, and it is able to determine this, this function will snapshot and send the resultant image to the IPython notebook for display.

If yt can’t determine if it’s inside an IPython session, it will raise YTNotInsideNotebook.

Parameters:

clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> cam.show()
show_mpl(im, enhance=True, clear_fig=True)
show_tf()
snapshot(fn=None, clip_ratio=None, double_check=False, num_threads=0, clim=None, label=None)[source]

Ray-cast the camera.

This method instructs the camera to take a snapshot – i.e., call the ray caster – based on its current settings.

Parameters:
  • fn (string, optional) – If supplied, the image will be saved out to this before being returned. Scaling will be to the maximum value.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Returns:

image – An (N,M,3) array of the final returned values, in float64 form.

Return type:

array

switch_orientation(normal_vector=None, north_vector=None)

Change the view direction based on any of the orientation parameters.

This will recalculate all the necessary vectors and vector planes related to an orientable object.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

switch_view(normal_vector=None, width=None, center=None, north_vector=None)

Change the view based on any of the view parameters.

This will recalculate the orientation and width based on any of normal_vector, width, center, and north_vector.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • width (float or array of floats, optional) – The new width. Can be a single value W -> [W,W,W] or an array [W1, W2, W3] (left/right, top/bottom, front/back)

  • center (array_like, optional) – Specifies the new center.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

update_view_from_matrix(mat)
yaw(theta)

Rotate by a given angle about the vertical axis

Yaw the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to yaw the view.

Examples

>>> cam.yaw(np.pi / 4)
zoom(factor)

Change the distance to the focal point.

This will zoom the camera in by some factor toward the focal point, along the current view direction, modifying the left/right and up/down extents as well.

Parameters:

factor (float) – The factor by which to reduce the distance to the focal point.

Notes

You will need to call snapshot() again to get a new image.

zoomin(final, n_steps, clip_ratio=None)

Loop over a zoomin and return snapshots along the way.

This will yield n_steps snapshots until the current view has been zooming in to a final factor of final.

Parameters:
  • final (float) – The zoom factor, with respect to current, desired at the end of the sequence.

  • n_steps (int) – The number of zoom snapshots to make.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.zoomin(100.0, 10)):
...     iw.write_bitmap(snapshot, "zoom_%04i.png" % i)
class yt.visualization.volume_rendering.old_camera.InteractiveCamera(center, normal_vector, width, resolution, transfer_function=None, north_vector=None, steady_north=False, volume=None, fields=None, log_fields=None, sub_samples=5, ds=None, min_level=None, max_level=None, no_ghost=True, data_source=None, use_light=False)[source]

Bases: Camera

annotate(ax, enhance=True, label_fmt=None)
clear_frames()[source]
comm = None
draw()
draw_box(im, le, re, color=None)

Draws a box on an existing volume rendering.

Draws a box defined by a left and right edge by modifying an existing volume rendering

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • le (Numpy ndarray) – Left corner of the box

  • re (Numpy ndarray) – Right corner of the box

  • color (array like, optional) – Color of the box (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_box(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_box.png")
draw_coordinate_vectors(im, length=0.05, thickness=1)

Draws three coordinate vectors in the corner of a rendering.

Modifies an existing image to have three lines corresponding to the coordinate directions colored by {x,y,z} = {r,g,b}. Currently only functional for plane-parallel volume rendering.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • length (float, optional) – The length of the lines, as a fraction of the image size. Default : 0.05

  • thickness (int, optional) – Thickness in pixels of the line to be drawn.

Returns:

  • None

  • Modifies

  • ——–

  • im (The original image.)

Examples

>>> im = cam.snapshot()
>>> cam.draw_coordinate_vectors(im)
>>> im.write_png("render_with_grids.png")
draw_domain(im, alpha=0.3)

Draws domain edges on an existing volume rendering.

Draws a white wireframe on the domain edges.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the wireframe being drawn. Used to control how bright the lines are with respect to the image. Default : 0.3

Returns:

nim – A new image with the domain lines drawn

Return type:

Numpy ndarray

Examples

>>> im = cam.snapshot()
>>> nim = cam.draw_domain(im)
>>> write_bitmap(nim, "render_with_domain_boundary.png")
draw_grids(im, alpha=0.3, cmap=None, min_level=None, max_level=None)

Draws Grids on an existing volume rendering.

By mapping grid level to a color, draws edges of grids on a volume rendering using the camera orientation.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the grids being drawn. Used to control how bright the grid lines are with respect to the image. Default : 0.3

  • cmap (string, optional) – Colormap to be used mapping grid levels to colors.

  • min_level (int, optional) – Optional parameter to specify the min level grid boxes to overplot on the image.

  • max_level (int, optional) – Optional parameters to specify the max level grid boxes to overplot on the image.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.add_grids(im)
>>> write_bitmap(im, "render_with_grids.png")
draw_line(im, x0, x1, color=None)

Draws a line on an existing volume rendering. Given starting and ending positions x0 and x1, draws a line on a volume rendering using the camera orientation.

Parameters:
  • im (ImageArray or 2D ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • x0 (YTArray or ndarray) – Starting coordinate. If passed in as an ndarray, assumed to be in code units.

  • x1 (YTArray or ndarray) – Ending coordinate, in simulation coordinates. If passed in as an ndarray, assumed to be in code units.

  • color (array like, optional) – Color of the line (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_line(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_line.png")
finalize_image(image)
frames: list[ImageArray] = []
get_dependencies(fields)
get_information()
get_sampler(args, kwargs)
get_sampler_args(image)
initialize_source()
look_at(new_center, north_vector=None)

Change the view direction based on a new focal point.

This will recalculate all the necessary vectors and vector planes to orient the image plane so that it points at a new location.

Parameters:
  • new_center (array_like) – The new “center” of the view port – the focal point for the camera.

  • north_vector (array_like, optional) – The “up” direction for the plane of rays. If not specific, calculated automatically.

move_to(final, n_steps, final_width=None, exponential=False, clip_ratio=None)

Loop over a look_at

This will yield n_steps snapshots until the current view has been moved to a final center of final with a final width of final_width.

Parameters:
  • final (array_like) – The final center to move to after n_steps

  • n_steps (int) – The number of look_at snapshots to make.

  • final_width (float or array_like, optional) – Specifies the final width after n_steps. Useful for moving and zooming at the same time.

  • exponential (boolean) – Specifies whether the move/zoom transition follows an exponential path toward the destination or linear

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.move_to([0.2, 0.3, 0.6], 10)):
...     iw.write_bitmap(snapshot, "move_%04i.png" % i)
new_image()
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

pitch(theta)

Rotate by a given angle about the horizontal axis

Pitch the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to pitch the view.

Examples

>>> cam.pitch(np.pi / 4)
project_to_plane(pos, res=None)
roll(theta)

Rotate by a given angle about the view normal axis

Roll the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to roll the view.

Examples

>>> cam.roll(np.pi / 4)
rotate(theta, rot_vector=None)

Rotate by a given angle

Rotate the view. If rot_vector is None, rotation will occur around the north_vector.

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around north_vector

Examples

>>> cam.rotate(np.pi / 4)
rotation(theta, n_steps, rot_vector=None)[source]

Loop over rotate, creating a rotation

This will yield n_steps snapshots until the current view has been rotated by an angle theta

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • n_steps (int) – The number of look_at snapshots to make.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around the original north_vector

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.rotation(np.pi, 10)):
...     iw.write_bitmap(snapshot, "rotation_%04i.png" % i)
save(fn)[source]
save_annotated(fn, image, enhance=True, dpi=100, clear_fig=True, label_fmt=None)

Save an image with the transfer function represented as a colorbar.

Parameters:
  • fn (str) – The output filename

  • image (ImageArray) – The image to annotate

  • enhance (bool, optional) – Enhance the contrast (default: True)

  • dpi (int, optional) – Dots per inch in the output image (default: 100)

  • clear_fig (bool, optional) – Reset the figure (through matplotlib.pyplot.clf()) before drawing. Setting this to false can allow us to overlay the image onto an existing figure

  • label_fmt (str, optional) – A format specifier (e.g., label_fmt=”%.2g”) to use in formatting the data values that label the transfer function colorbar.

save_frames(basename, clip_ratio=None)[source]
save_image(image, fn=None, clip_ratio=None, transparent=False)
set_default_light_dir()
set_default_light_rgba()
show(clip_ratio=None)

This will take a snapshot and display the resultant image in the IPython notebook.

If yt is being run from within an IPython session, and it is able to determine this, this function will snapshot and send the resultant image to the IPython notebook for display.

If yt can’t determine if it’s inside an IPython session, it will raise YTNotInsideNotebook.

Parameters:

clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> cam.show()
show_mpl(im, enhance=True, clear_fig=True)
show_tf()
snapshot(fn=None, clip_ratio=None)[source]

Ray-cast the camera.

This method instructs the camera to take a snapshot – i.e., call the ray caster – based on its current settings.

Parameters:
  • fn (string, optional) – If supplied, the image will be saved out to this before being returned. Scaling will be to the maximum value.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

  • double_check (bool, optional) – Optionally makes sure that the data contains only valid entries. Used for debugging.

  • num_threads (int, optional) – If supplied, will use ‘num_threads’ number of OpenMP threads during the rendering. Defaults to 0, which uses the environment variable OMP_NUM_THREADS.

  • transparent (bool, optional) – Optionally saves out the 4-channel rgba image, which can appear empty if the alpha channel is low everywhere. Default: False

Returns:

image – An (N,M,3) array of the final returned values, in float64 form.

Return type:

array

switch_orientation(normal_vector=None, north_vector=None)

Change the view direction based on any of the orientation parameters.

This will recalculate all the necessary vectors and vector planes related to an orientable object.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

switch_view(normal_vector=None, width=None, center=None, north_vector=None)

Change the view based on any of the view parameters.

This will recalculate the orientation and width based on any of normal_vector, width, center, and north_vector.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • width (float or array of floats, optional) – The new width. Can be a single value W -> [W,W,W] or an array [W1, W2, W3] (left/right, top/bottom, front/back)

  • center (array_like, optional) – Specifies the new center.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

update_view_from_matrix(mat)
yaw(theta)

Rotate by a given angle about the vertical axis

Yaw the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to yaw the view.

Examples

>>> cam.yaw(np.pi / 4)
zoom(factor)

Change the distance to the focal point.

This will zoom the camera in by some factor toward the focal point, along the current view direction, modifying the left/right and up/down extents as well.

Parameters:

factor (float) – The factor by which to reduce the distance to the focal point.

Notes

You will need to call snapshot() again to get a new image.

zoomin(final, n_steps)[source]

Loop over a zoomin and return snapshots along the way.

This will yield n_steps snapshots until the current view has been zooming in to a final factor of final.

Parameters:
  • final (float) – The zoom factor, with respect to current, desired at the end of the sequence.

  • n_steps (int) – The number of zoom snapshots to make.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.zoomin(100.0, 10)):
...     iw.write_bitmap(snapshot, "zoom_%04i.png" % i)
class yt.visualization.volume_rendering.old_camera.MosaicCamera(center, normal_vector, width, resolution, transfer_function=None, north_vector=None, steady_north=False, volume=None, fields=None, log_fields=None, sub_samples=5, ds=None, use_kd=True, l_max=None, no_ghost=True, tree_type='domain', expand_factor=1.0, le=None, re=None, nimx=1, nimy=1, procs_per_wg=None, preload=True, use_light=False)[source]

Bases: Camera

annotate(ax, enhance=True, label_fmt=None)
build_volume(volume, fields, log_fields, l_max, no_ghost, tree_type, le, re)[source]
comm = None
draw()
draw_box(im, le, re, color=None)

Draws a box on an existing volume rendering.

Draws a box defined by a left and right edge by modifying an existing volume rendering

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • le (Numpy ndarray) – Left corner of the box

  • re (Numpy ndarray) – Right corner of the box

  • color (array like, optional) – Color of the box (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_box(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_box.png")
draw_coordinate_vectors(im, length=0.05, thickness=1)

Draws three coordinate vectors in the corner of a rendering.

Modifies an existing image to have three lines corresponding to the coordinate directions colored by {x,y,z} = {r,g,b}. Currently only functional for plane-parallel volume rendering.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • length (float, optional) – The length of the lines, as a fraction of the image size. Default : 0.05

  • thickness (int, optional) – Thickness in pixels of the line to be drawn.

Returns:

  • None

  • Modifies

  • ——–

  • im (The original image.)

Examples

>>> im = cam.snapshot()
>>> cam.draw_coordinate_vectors(im)
>>> im.write_png("render_with_grids.png")
draw_domain(im, alpha=0.3)

Draws domain edges on an existing volume rendering.

Draws a white wireframe on the domain edges.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the wireframe being drawn. Used to control how bright the lines are with respect to the image. Default : 0.3

Returns:

nim – A new image with the domain lines drawn

Return type:

Numpy ndarray

Examples

>>> im = cam.snapshot()
>>> nim = cam.draw_domain(im)
>>> write_bitmap(nim, "render_with_domain_boundary.png")
draw_grids(im, alpha=0.3, cmap=None, min_level=None, max_level=None)

Draws Grids on an existing volume rendering.

By mapping grid level to a color, draws edges of grids on a volume rendering using the camera orientation.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the grids being drawn. Used to control how bright the grid lines are with respect to the image. Default : 0.3

  • cmap (string, optional) – Colormap to be used mapping grid levels to colors.

  • min_level (int, optional) – Optional parameter to specify the min level grid boxes to overplot on the image.

  • max_level (int, optional) – Optional parameters to specify the max level grid boxes to overplot on the image.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.add_grids(im)
>>> write_bitmap(im, "render_with_grids.png")
draw_line(im, x0, x1, color=None)

Draws a line on an existing volume rendering. Given starting and ending positions x0 and x1, draws a line on a volume rendering using the camera orientation.

Parameters:
  • im (ImageArray or 2D ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • x0 (YTArray or ndarray) – Starting coordinate. If passed in as an ndarray, assumed to be in code units.

  • x1 (YTArray or ndarray) – Ending coordinate, in simulation coordinates. If passed in as an ndarray, assumed to be in code units.

  • color (array like, optional) – Color of the line (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_line(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_line.png")
finalize_image(image)
get_dependencies(fields)
get_information()
get_sampler(args, kwargs)
get_sampler_args(image)
initialize_source()
look_at(new_center, north_vector=None)

Change the view direction based on a new focal point.

This will recalculate all the necessary vectors and vector planes to orient the image plane so that it points at a new location.

Parameters:
  • new_center (array_like) – The new “center” of the view port – the focal point for the camera.

  • north_vector (array_like, optional) – The “up” direction for the plane of rays. If not specific, calculated automatically.

move_to(final, n_steps, final_width=None, exponential=False, clip_ratio=None)

Loop over a look_at

This will yield n_steps snapshots until the current view has been moved to a final center of final with a final width of final_width.

Parameters:
  • final (array_like) – The final center to move to after n_steps

  • n_steps (int) – The number of look_at snapshots to make.

  • final_width (float or array_like, optional) – Specifies the final width after n_steps. Useful for moving and zooming at the same time.

  • exponential (boolean) – Specifies whether the move/zoom transition follows an exponential path toward the destination or linear

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.move_to([0.2, 0.3, 0.6], 10)):
...     iw.write_bitmap(snapshot, "move_%04i.png" % i)
new_image()[source]
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

pitch(theta)

Rotate by a given angle about the horizontal axis

Pitch the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to pitch the view.

Examples

>>> cam.pitch(np.pi / 4)
project_to_plane(pos, res=None)
reduce_images(im_dict)[source]
roll(theta)

Rotate by a given angle about the view normal axis

Roll the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to roll the view.

Examples

>>> cam.roll(np.pi / 4)
rotate(theta, rot_vector=None)

Rotate by a given angle

Rotate the view. If rot_vector is None, rotation will occur around the north_vector.

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around north_vector

Examples

>>> cam.rotate(np.pi / 4)
rotation(theta, n_steps, rot_vector=None, clip_ratio=None)

Loop over rotate, creating a rotation

This will yield n_steps snapshots until the current view has been rotated by an angle theta

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • n_steps (int) – The number of look_at snapshots to make.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around the original north_vector

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.rotation(np.pi, 10)):
...     iw.write_bitmap(snapshot, "rotation_%04i.png" % i)
save_annotated(fn, image, enhance=True, dpi=100, clear_fig=True, label_fmt=None)

Save an image with the transfer function represented as a colorbar.

Parameters:
  • fn (str) – The output filename

  • image (ImageArray) – The image to annotate

  • enhance (bool, optional) – Enhance the contrast (default: True)

  • dpi (int, optional) – Dots per inch in the output image (default: 100)

  • clear_fig (bool, optional) – Reset the figure (through matplotlib.pyplot.clf()) before drawing. Setting this to false can allow us to overlay the image onto an existing figure

  • label_fmt (str, optional) – A format specifier (e.g., label_fmt=”%.2g”) to use in formatting the data values that label the transfer function colorbar.

save_image(image, fn=None, clip_ratio=None, transparent=False)
set_default_light_dir()
set_default_light_rgba()
show(clip_ratio=None)

This will take a snapshot and display the resultant image in the IPython notebook.

If yt is being run from within an IPython session, and it is able to determine this, this function will snapshot and send the resultant image to the IPython notebook for display.

If yt can’t determine if it’s inside an IPython session, it will raise YTNotInsideNotebook.

Parameters:

clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> cam.show()
show_mpl(im, enhance=True, clear_fig=True)
show_tf()
snapshot(fn=None, clip_ratio=None, double_check=False, num_threads=0)[source]

Ray-cast the camera.

This method instructs the camera to take a snapshot – i.e., call the ray caster – based on its current settings.

Parameters:
  • fn (string, optional) – If supplied, the image will be saved out to this before being returned. Scaling will be to the maximum value.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

  • double_check (bool, optional) – Optionally makes sure that the data contains only valid entries. Used for debugging.

  • num_threads (int, optional) – If supplied, will use ‘num_threads’ number of OpenMP threads during the rendering. Defaults to 0, which uses the environment variable OMP_NUM_THREADS.

  • transparent (bool, optional) – Optionally saves out the 4-channel rgba image, which can appear empty if the alpha channel is low everywhere. Default: False

Returns:

image – An (N,M,3) array of the final returned values, in float64 form.

Return type:

array

switch_orientation(normal_vector=None, north_vector=None)

Change the view direction based on any of the orientation parameters.

This will recalculate all the necessary vectors and vector planes related to an orientable object.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

switch_view(normal_vector=None, width=None, center=None, north_vector=None)

Change the view based on any of the view parameters.

This will recalculate the orientation and width based on any of normal_vector, width, center, and north_vector.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • width (float or array of floats, optional) – The new width. Can be a single value W -> [W,W,W] or an array [W1, W2, W3] (left/right, top/bottom, front/back)

  • center (array_like, optional) – Specifies the new center.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

update_view_from_matrix(mat)
yaw(theta)

Rotate by a given angle about the vertical axis

Yaw the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to yaw the view.

Examples

>>> cam.yaw(np.pi / 4)
zoom(factor)

Change the distance to the focal point.

This will zoom the camera in by some factor toward the focal point, along the current view direction, modifying the left/right and up/down extents as well.

Parameters:

factor (float) – The factor by which to reduce the distance to the focal point.

Notes

You will need to call snapshot() again to get a new image.

zoomin(final, n_steps, clip_ratio=None)

Loop over a zoomin and return snapshots along the way.

This will yield n_steps snapshots until the current view has been zooming in to a final factor of final.

Parameters:
  • final (float) – The zoom factor, with respect to current, desired at the end of the sequence.

  • n_steps (int) – The number of zoom snapshots to make.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.zoomin(100.0, 10)):
...     iw.write_bitmap(snapshot, "zoom_%04i.png" % i)
class yt.visualization.volume_rendering.old_camera.PerspectiveCamera(*args, **kwargs)[source]

Bases: Camera

A viewpoint into a volume, for perspective volume rendering.

The camera represents the eye of an observer, which will be used to generate ray-cast volume renderings of the domain. The rays start from the camera and end on the image plane, which generates a perspective view.

Note: at the moment, this results in a left-handed coordinate system view

Parameters:
  • center (array_like) – The location of the camera

  • normal_vector (array_like) – The vector from the camera position to the center of the image plane

  • width (float or list of floats) – width[0] and width[1] give the width and height of the image plane, and width[2] gives the depth of the image plane (distance between the camera and the center of the image plane). The view angles thus become: 2 * arctan(0.5 * width[0] / width[2]) in horizontal direction 2 * arctan(0.5 * width[1] / width[2]) in vertical direction

  • class) ((The following parameters are identical with the definitions in Camera) –

  • resolution (int or list of ints) – The number of pixels in each direction.

  • transfer_function (yt.visualization.volume_rendering.TransferFunction) – The transfer function used to map values to colors in an image. If not specified, defaults to a ProjectionTransferFunction.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

  • steady_north (bool, optional) – Boolean to control whether to normalize the north_vector by subtracting off the dot product of it and the normal vector. Makes it easier to do rotations along a single axis. If north_vector is specified, is switched to True. Default: False

  • volume (yt.extensions.volume_rendering.AMRKDTree, optional) – The volume to ray cast through. Can be specified for finer-grained control, but otherwise will be automatically generated.

  • fields (list of fields, optional) – This is the list of fields we want to volume render; defaults to Density.

  • log_fields (list of bool, optional) – Whether we should take the log of the fields before supplying them to the volume rendering mechanism.

  • sub_samples (int, optional) – The number of samples to take inside every cell per ray.

  • ds (Dataset) – For now, this is a require parameter! But in the future it will become optional. This is the dataset to volume render.

  • use_kd (bool, optional) – Specifies whether or not to use a kd-Tree framework for the Homogenized Volume and ray-casting. Default to True.

  • max_level (int, optional) – Specifies the maximum level to be rendered. Also specifies the maximum level used in the kd-Tree construction. Defaults to None (all levels), and only applies if use_kd=True.

  • no_ghost (bool, optional) – Optimization option. If True, homogenized bricks will extrapolate out from grid instead of interpolating from ghost zones that have to first be calculated. This can lead to large speed improvements, but at a loss of accuracy/smoothness in resulting image. The effects are less notable when the transfer function is smooth and broad. Default: True

  • data_source (data container, optional) – Optionally specify an arbitrary data source to the volume rendering. All cells not included in the data source will be ignored during ray casting. By default this will get set to ds.all_data().

annotate(ax, enhance=True, label_fmt=None)
comm = None
draw()
draw_box(im, le, re, color=None)

Draws a box on an existing volume rendering.

Draws a box defined by a left and right edge by modifying an existing volume rendering

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • le (Numpy ndarray) – Left corner of the box

  • re (Numpy ndarray) – Right corner of the box

  • color (array like, optional) – Color of the box (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_box(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_box.png")
draw_coordinate_vectors(im, length=0.05, thickness=1)

Draws three coordinate vectors in the corner of a rendering.

Modifies an existing image to have three lines corresponding to the coordinate directions colored by {x,y,z} = {r,g,b}. Currently only functional for plane-parallel volume rendering.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • length (float, optional) – The length of the lines, as a fraction of the image size. Default : 0.05

  • thickness (int, optional) – Thickness in pixels of the line to be drawn.

Returns:

  • None

  • Modifies

  • ——–

  • im (The original image.)

Examples

>>> im = cam.snapshot()
>>> cam.draw_coordinate_vectors(im)
>>> im.write_png("render_with_grids.png")
draw_domain(im, alpha=0.3)

Draws domain edges on an existing volume rendering.

Draws a white wireframe on the domain edges.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the wireframe being drawn. Used to control how bright the lines are with respect to the image. Default : 0.3

Returns:

nim – A new image with the domain lines drawn

Return type:

Numpy ndarray

Examples

>>> im = cam.snapshot()
>>> nim = cam.draw_domain(im)
>>> write_bitmap(nim, "render_with_domain_boundary.png")
draw_grids(im, alpha=0.3, cmap=None, min_level=None, max_level=None)

Draws Grids on an existing volume rendering.

By mapping grid level to a color, draws edges of grids on a volume rendering using the camera orientation.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the grids being drawn. Used to control how bright the grid lines are with respect to the image. Default : 0.3

  • cmap (string, optional) – Colormap to be used mapping grid levels to colors.

  • min_level (int, optional) – Optional parameter to specify the min level grid boxes to overplot on the image.

  • max_level (int, optional) – Optional parameters to specify the max level grid boxes to overplot on the image.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.add_grids(im)
>>> write_bitmap(im, "render_with_grids.png")
draw_line(im, x0, x1, color=None)

Draws a line on an existing volume rendering. Given starting and ending positions x0 and x1, draws a line on a volume rendering using the camera orientation.

Parameters:
  • im (ImageArray or 2D ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • x0 (YTArray or ndarray) – Starting coordinate. If passed in as an ndarray, assumed to be in code units.

  • x1 (YTArray or ndarray) – Ending coordinate, in simulation coordinates. If passed in as an ndarray, assumed to be in code units.

  • color (array like, optional) – Color of the line (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_line(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_line.png")
finalize_image(image)[source]
get_dependencies(fields)
get_information()
get_sampler(args, kwargs)
get_sampler_args(image)[source]
initialize_source()
look_at(new_center, north_vector=None)

Change the view direction based on a new focal point.

This will recalculate all the necessary vectors and vector planes to orient the image plane so that it points at a new location.

Parameters:
  • new_center (array_like) – The new “center” of the view port – the focal point for the camera.

  • north_vector (array_like, optional) – The “up” direction for the plane of rays. If not specific, calculated automatically.

move_to(final, n_steps, final_width=None, exponential=False, clip_ratio=None)

Loop over a look_at

This will yield n_steps snapshots until the current view has been moved to a final center of final with a final width of final_width.

Parameters:
  • final (array_like) – The final center to move to after n_steps

  • n_steps (int) – The number of look_at snapshots to make.

  • final_width (float or array_like, optional) – Specifies the final width after n_steps. Useful for moving and zooming at the same time.

  • exponential (boolean) – Specifies whether the move/zoom transition follows an exponential path toward the destination or linear

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.move_to([0.2, 0.3, 0.6], 10)):
...     iw.write_bitmap(snapshot, "move_%04i.png" % i)
new_image()
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

pitch(theta)

Rotate by a given angle about the horizontal axis

Pitch the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to pitch the view.

Examples

>>> cam.pitch(np.pi / 4)
project_to_plane(pos, res=None)[source]
roll(theta)

Rotate by a given angle about the view normal axis

Roll the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to roll the view.

Examples

>>> cam.roll(np.pi / 4)
rotate(theta, rot_vector=None)

Rotate by a given angle

Rotate the view. If rot_vector is None, rotation will occur around the north_vector.

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around north_vector

Examples

>>> cam.rotate(np.pi / 4)
rotation(theta, n_steps, rot_vector=None, clip_ratio=None)

Loop over rotate, creating a rotation

This will yield n_steps snapshots until the current view has been rotated by an angle theta

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • n_steps (int) – The number of look_at snapshots to make.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around the original north_vector

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.rotation(np.pi, 10)):
...     iw.write_bitmap(snapshot, "rotation_%04i.png" % i)
save_annotated(fn, image, enhance=True, dpi=100, clear_fig=True, label_fmt=None)

Save an image with the transfer function represented as a colorbar.

Parameters:
  • fn (str) – The output filename

  • image (ImageArray) – The image to annotate

  • enhance (bool, optional) – Enhance the contrast (default: True)

  • dpi (int, optional) – Dots per inch in the output image (default: 100)

  • clear_fig (bool, optional) – Reset the figure (through matplotlib.pyplot.clf()) before drawing. Setting this to false can allow us to overlay the image onto an existing figure

  • label_fmt (str, optional) – A format specifier (e.g., label_fmt=”%.2g”) to use in formatting the data values that label the transfer function colorbar.

save_image(image, fn=None, clip_ratio=None, transparent=False)
set_default_light_dir()
set_default_light_rgba()
show(clip_ratio=None)

This will take a snapshot and display the resultant image in the IPython notebook.

If yt is being run from within an IPython session, and it is able to determine this, this function will snapshot and send the resultant image to the IPython notebook for display.

If yt can’t determine if it’s inside an IPython session, it will raise YTNotInsideNotebook.

Parameters:

clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> cam.show()
show_mpl(im, enhance=True, clear_fig=True)
show_tf()
snapshot(fn=None, clip_ratio=None, double_check=False, num_threads=0, transparent=False)

Ray-cast the camera.

This method instructs the camera to take a snapshot – i.e., call the ray caster – based on its current settings.

Parameters:
  • fn (string, optional) – If supplied, the image will be saved out to this before being returned. Scaling will be to the maximum value.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

  • double_check (bool, optional) – Optionally makes sure that the data contains only valid entries. Used for debugging.

  • num_threads (int, optional) – If supplied, will use ‘num_threads’ number of OpenMP threads during the rendering. Defaults to 0, which uses the environment variable OMP_NUM_THREADS.

  • transparent (bool, optional) – Optionally saves out the 4-channel rgba image, which can appear empty if the alpha channel is low everywhere. Default: False

Returns:

image – An (N,M,3) array of the final returned values, in float64 form.

Return type:

array

switch_orientation(normal_vector=None, north_vector=None)

Change the view direction based on any of the orientation parameters.

This will recalculate all the necessary vectors and vector planes related to an orientable object.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

switch_view(normal_vector=None, width=None, center=None, north_vector=None)

Change the view based on any of the view parameters.

This will recalculate the orientation and width based on any of normal_vector, width, center, and north_vector.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • width (float or array of floats, optional) – The new width. Can be a single value W -> [W,W,W] or an array [W1, W2, W3] (left/right, top/bottom, front/back)

  • center (array_like, optional) – Specifies the new center.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

update_view_from_matrix(mat)
yaw(theta, rot_center)[source]

Rotate by a given angle about the vertical axis through the point center. This is accomplished by rotating the focal point and then setting the looking vector to point to the center.

Yaw the view.

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to yaw the view.

  • rot_center (a tuple (x, y, z)) – The point to rotate about

Examples

>>> cam.yaw(np.pi / 4, (0.0, 0.0, 0.0))
zoom(factor)

Change the distance to the focal point.

This will zoom the camera in by some factor toward the focal point, along the current view direction, modifying the left/right and up/down extents as well.

Parameters:

factor (float) – The factor by which to reduce the distance to the focal point.

Notes

You will need to call snapshot() again to get a new image.

zoomin(final, n_steps, clip_ratio=None)

Loop over a zoomin and return snapshots along the way.

This will yield n_steps snapshots until the current view has been zooming in to a final factor of final.

Parameters:
  • final (float) – The zoom factor, with respect to current, desired at the end of the sequence.

  • n_steps (int) – The number of zoom snapshots to make.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.zoomin(100.0, 10)):
...     iw.write_bitmap(snapshot, "zoom_%04i.png" % i)
class yt.visualization.volume_rendering.old_camera.ProjectionCamera(center, normal_vector, width, resolution, field, weight=None, volume=None, no_ghost=False, north_vector=None, ds=None, interpolated=False, method='integrate')[source]

Bases: Camera

annotate(ax, enhance=True, label_fmt=None)
comm = None
draw()
draw_box(im, le, re, color=None)

Draws a box on an existing volume rendering.

Draws a box defined by a left and right edge by modifying an existing volume rendering

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • le (Numpy ndarray) – Left corner of the box

  • re (Numpy ndarray) – Right corner of the box

  • color (array like, optional) – Color of the box (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_box(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_box.png")
draw_coordinate_vectors(im, length=0.05, thickness=1)

Draws three coordinate vectors in the corner of a rendering.

Modifies an existing image to have three lines corresponding to the coordinate directions colored by {x,y,z} = {r,g,b}. Currently only functional for plane-parallel volume rendering.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • length (float, optional) – The length of the lines, as a fraction of the image size. Default : 0.05

  • thickness (int, optional) – Thickness in pixels of the line to be drawn.

Returns:

  • None

  • Modifies

  • ——–

  • im (The original image.)

Examples

>>> im = cam.snapshot()
>>> cam.draw_coordinate_vectors(im)
>>> im.write_png("render_with_grids.png")
draw_domain(im, alpha=0.3)

Draws domain edges on an existing volume rendering.

Draws a white wireframe on the domain edges.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the wireframe being drawn. Used to control how bright the lines are with respect to the image. Default : 0.3

Returns:

nim – A new image with the domain lines drawn

Return type:

Numpy ndarray

Examples

>>> im = cam.snapshot()
>>> nim = cam.draw_domain(im)
>>> write_bitmap(nim, "render_with_domain_boundary.png")
draw_grids(im, alpha=0.3, cmap=None, min_level=None, max_level=None)

Draws Grids on an existing volume rendering.

By mapping grid level to a color, draws edges of grids on a volume rendering using the camera orientation.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the grids being drawn. Used to control how bright the grid lines are with respect to the image. Default : 0.3

  • cmap (string, optional) – Colormap to be used mapping grid levels to colors.

  • min_level (int, optional) – Optional parameter to specify the min level grid boxes to overplot on the image.

  • max_level (int, optional) – Optional parameters to specify the max level grid boxes to overplot on the image.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.add_grids(im)
>>> write_bitmap(im, "render_with_grids.png")
draw_line(im, x0, x1, color=None)

Draws a line on an existing volume rendering. Given starting and ending positions x0 and x1, draws a line on a volume rendering using the camera orientation.

Parameters:
  • im (ImageArray or 2D ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • x0 (YTArray or ndarray) – Starting coordinate. If passed in as an ndarray, assumed to be in code units.

  • x1 (YTArray or ndarray) – Ending coordinate, in simulation coordinates. If passed in as an ndarray, assumed to be in code units.

  • color (array like, optional) – Color of the line (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_line(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_line.png")
finalize_image(image)[source]
get_dependencies(fields)
get_information()
get_sampler(args, kwargs)[source]
get_sampler_args(image)[source]
initialize_source()[source]
look_at(new_center, north_vector=None)

Change the view direction based on a new focal point.

This will recalculate all the necessary vectors and vector planes to orient the image plane so that it points at a new location.

Parameters:
  • new_center (array_like) – The new “center” of the view port – the focal point for the camera.

  • north_vector (array_like, optional) – The “up” direction for the plane of rays. If not specific, calculated automatically.

move_to(final, n_steps, final_width=None, exponential=False, clip_ratio=None)

Loop over a look_at

This will yield n_steps snapshots until the current view has been moved to a final center of final with a final width of final_width.

Parameters:
  • final (array_like) – The final center to move to after n_steps

  • n_steps (int) – The number of look_at snapshots to make.

  • final_width (float or array_like, optional) – Specifies the final width after n_steps. Useful for moving and zooming at the same time.

  • exponential (boolean) – Specifies whether the move/zoom transition follows an exponential path toward the destination or linear

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.move_to([0.2, 0.3, 0.6], 10)):
...     iw.write_bitmap(snapshot, "move_%04i.png" % i)
new_image()
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

pitch(theta)

Rotate by a given angle about the horizontal axis

Pitch the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to pitch the view.

Examples

>>> cam.pitch(np.pi / 4)
project_to_plane(pos, res=None)
roll(theta)

Rotate by a given angle about the view normal axis

Roll the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to roll the view.

Examples

>>> cam.roll(np.pi / 4)
rotate(theta, rot_vector=None)

Rotate by a given angle

Rotate the view. If rot_vector is None, rotation will occur around the north_vector.

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around north_vector

Examples

>>> cam.rotate(np.pi / 4)
rotation(theta, n_steps, rot_vector=None, clip_ratio=None)

Loop over rotate, creating a rotation

This will yield n_steps snapshots until the current view has been rotated by an angle theta

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • n_steps (int) – The number of look_at snapshots to make.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around the original north_vector

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.rotation(np.pi, 10)):
...     iw.write_bitmap(snapshot, "rotation_%04i.png" % i)
save_annotated(fn, image, enhance=True, dpi=100, clear_fig=True, label_fmt=None)

Save an image with the transfer function represented as a colorbar.

Parameters:
  • fn (str) – The output filename

  • image (ImageArray) – The image to annotate

  • enhance (bool, optional) – Enhance the contrast (default: True)

  • dpi (int, optional) – Dots per inch in the output image (default: 100)

  • clear_fig (bool, optional) – Reset the figure (through matplotlib.pyplot.clf()) before drawing. Setting this to false can allow us to overlay the image onto an existing figure

  • label_fmt (str, optional) – A format specifier (e.g., label_fmt=”%.2g”) to use in formatting the data values that label the transfer function colorbar.

save_image(image, fn=None, clip_ratio=None)[source]
set_default_light_dir()
set_default_light_rgba()
show(clip_ratio=None)

This will take a snapshot and display the resultant image in the IPython notebook.

If yt is being run from within an IPython session, and it is able to determine this, this function will snapshot and send the resultant image to the IPython notebook for display.

If yt can’t determine if it’s inside an IPython session, it will raise YTNotInsideNotebook.

Parameters:

clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> cam.show()
show_mpl(im, enhance=True, clear_fig=True)
show_tf()
snapshot(fn=None, clip_ratio=None, double_check=False, num_threads=0)[source]

Ray-cast the camera.

This method instructs the camera to take a snapshot – i.e., call the ray caster – based on its current settings.

Parameters:
  • fn (string, optional) – If supplied, the image will be saved out to this before being returned. Scaling will be to the maximum value.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

  • double_check (bool, optional) – Optionally makes sure that the data contains only valid entries. Used for debugging.

  • num_threads (int, optional) – If supplied, will use ‘num_threads’ number of OpenMP threads during the rendering. Defaults to 0, which uses the environment variable OMP_NUM_THREADS.

  • transparent (bool, optional) – Optionally saves out the 4-channel rgba image, which can appear empty if the alpha channel is low everywhere. Default: False

Returns:

image – An (N,M,3) array of the final returned values, in float64 form.

Return type:

array

switch_orientation(normal_vector=None, north_vector=None)

Change the view direction based on any of the orientation parameters.

This will recalculate all the necessary vectors and vector planes related to an orientable object.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

switch_view(normal_vector=None, width=None, center=None, north_vector=None)

Change the view based on any of the view parameters.

This will recalculate the orientation and width based on any of normal_vector, width, center, and north_vector.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • width (float or array of floats, optional) – The new width. Can be a single value W -> [W,W,W] or an array [W1, W2, W3] (left/right, top/bottom, front/back)

  • center (array_like, optional) – Specifies the new center.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

update_view_from_matrix(mat)
yaw(theta)

Rotate by a given angle about the vertical axis

Yaw the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to yaw the view.

Examples

>>> cam.yaw(np.pi / 4)
zoom(factor)

Change the distance to the focal point.

This will zoom the camera in by some factor toward the focal point, along the current view direction, modifying the left/right and up/down extents as well.

Parameters:

factor (float) – The factor by which to reduce the distance to the focal point.

Notes

You will need to call snapshot() again to get a new image.

zoomin(final, n_steps, clip_ratio=None)

Loop over a zoomin and return snapshots along the way.

This will yield n_steps snapshots until the current view has been zooming in to a final factor of final.

Parameters:
  • final (float) – The zoom factor, with respect to current, desired at the end of the sequence.

  • n_steps (int) – The number of zoom snapshots to make.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.zoomin(100.0, 10)):
...     iw.write_bitmap(snapshot, "zoom_%04i.png" % i)
class yt.visualization.volume_rendering.old_camera.SphericalCamera(*args, **kwargs)[source]

Bases: Camera

annotate(ax, enhance=True, label_fmt=None)
comm = None
draw()
draw_box(im, le, re, color=None)

Draws a box on an existing volume rendering.

Draws a box defined by a left and right edge by modifying an existing volume rendering

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • le (Numpy ndarray) – Left corner of the box

  • re (Numpy ndarray) – Right corner of the box

  • color (array like, optional) – Color of the box (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_box(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_box.png")
draw_coordinate_vectors(im, length=0.05, thickness=1)

Draws three coordinate vectors in the corner of a rendering.

Modifies an existing image to have three lines corresponding to the coordinate directions colored by {x,y,z} = {r,g,b}. Currently only functional for plane-parallel volume rendering.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • length (float, optional) – The length of the lines, as a fraction of the image size. Default : 0.05

  • thickness (int, optional) – Thickness in pixels of the line to be drawn.

Returns:

  • None

  • Modifies

  • ——–

  • im (The original image.)

Examples

>>> im = cam.snapshot()
>>> cam.draw_coordinate_vectors(im)
>>> im.write_png("render_with_grids.png")
draw_domain(im, alpha=0.3)

Draws domain edges on an existing volume rendering.

Draws a white wireframe on the domain edges.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the wireframe being drawn. Used to control how bright the lines are with respect to the image. Default : 0.3

Returns:

nim – A new image with the domain lines drawn

Return type:

Numpy ndarray

Examples

>>> im = cam.snapshot()
>>> nim = cam.draw_domain(im)
>>> write_bitmap(nim, "render_with_domain_boundary.png")
draw_grids(im, alpha=0.3, cmap=None, min_level=None, max_level=None)

Draws Grids on an existing volume rendering.

By mapping grid level to a color, draws edges of grids on a volume rendering using the camera orientation.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the grids being drawn. Used to control how bright the grid lines are with respect to the image. Default : 0.3

  • cmap (string, optional) – Colormap to be used mapping grid levels to colors.

  • min_level (int, optional) – Optional parameter to specify the min level grid boxes to overplot on the image.

  • max_level (int, optional) – Optional parameters to specify the max level grid boxes to overplot on the image.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.add_grids(im)
>>> write_bitmap(im, "render_with_grids.png")
draw_line(im, x0, x1, color=None)

Draws a line on an existing volume rendering. Given starting and ending positions x0 and x1, draws a line on a volume rendering using the camera orientation.

Parameters:
  • im (ImageArray or 2D ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • x0 (YTArray or ndarray) – Starting coordinate. If passed in as an ndarray, assumed to be in code units.

  • x1 (YTArray or ndarray) – Ending coordinate, in simulation coordinates. If passed in as an ndarray, assumed to be in code units.

  • color (array like, optional) – Color of the line (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_line(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_line.png")
finalize_image(image)[source]
get_dependencies(fields)
get_information()
get_sampler(args, kwargs)
get_sampler_args(image)[source]
initialize_source()
look_at(new_center, north_vector=None)

Change the view direction based on a new focal point.

This will recalculate all the necessary vectors and vector planes to orient the image plane so that it points at a new location.

Parameters:
  • new_center (array_like) – The new “center” of the view port – the focal point for the camera.

  • north_vector (array_like, optional) – The “up” direction for the plane of rays. If not specific, calculated automatically.

move_to(final, n_steps, final_width=None, exponential=False, clip_ratio=None)

Loop over a look_at

This will yield n_steps snapshots until the current view has been moved to a final center of final with a final width of final_width.

Parameters:
  • final (array_like) – The final center to move to after n_steps

  • n_steps (int) – The number of look_at snapshots to make.

  • final_width (float or array_like, optional) – Specifies the final width after n_steps. Useful for moving and zooming at the same time.

  • exponential (boolean) – Specifies whether the move/zoom transition follows an exponential path toward the destination or linear

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.move_to([0.2, 0.3, 0.6], 10)):
...     iw.write_bitmap(snapshot, "move_%04i.png" % i)
new_image()
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

pitch(theta)

Rotate by a given angle about the horizontal axis

Pitch the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to pitch the view.

Examples

>>> cam.pitch(np.pi / 4)
project_to_plane(pos, res=None)
roll(theta)

Rotate by a given angle about the view normal axis

Roll the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to roll the view.

Examples

>>> cam.roll(np.pi / 4)
rotate(theta, rot_vector=None)

Rotate by a given angle

Rotate the view. If rot_vector is None, rotation will occur around the north_vector.

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around north_vector

Examples

>>> cam.rotate(np.pi / 4)
rotation(theta, n_steps, rot_vector=None, clip_ratio=None)

Loop over rotate, creating a rotation

This will yield n_steps snapshots until the current view has been rotated by an angle theta

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • n_steps (int) – The number of look_at snapshots to make.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around the original north_vector

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.rotation(np.pi, 10)):
...     iw.write_bitmap(snapshot, "rotation_%04i.png" % i)
save_annotated(fn, image, enhance=True, dpi=100, clear_fig=True, label_fmt=None)

Save an image with the transfer function represented as a colorbar.

Parameters:
  • fn (str) – The output filename

  • image (ImageArray) – The image to annotate

  • enhance (bool, optional) – Enhance the contrast (default: True)

  • dpi (int, optional) – Dots per inch in the output image (default: 100)

  • clear_fig (bool, optional) – Reset the figure (through matplotlib.pyplot.clf()) before drawing. Setting this to false can allow us to overlay the image onto an existing figure

  • label_fmt (str, optional) – A format specifier (e.g., label_fmt=”%.2g”) to use in formatting the data values that label the transfer function colorbar.

save_image(image, fn=None, clip_ratio=None, transparent=False)
set_default_light_dir()
set_default_light_rgba()
show(clip_ratio=None)

This will take a snapshot and display the resultant image in the IPython notebook.

If yt is being run from within an IPython session, and it is able to determine this, this function will snapshot and send the resultant image to the IPython notebook for display.

If yt can’t determine if it’s inside an IPython session, it will raise YTNotInsideNotebook.

Parameters:

clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> cam.show()
show_mpl(im, enhance=True, clear_fig=True)
show_tf()
snapshot(fn=None, clip_ratio=None, double_check=False, num_threads=0, transparent=False)

Ray-cast the camera.

This method instructs the camera to take a snapshot – i.e., call the ray caster – based on its current settings.

Parameters:
  • fn (string, optional) – If supplied, the image will be saved out to this before being returned. Scaling will be to the maximum value.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

  • double_check (bool, optional) – Optionally makes sure that the data contains only valid entries. Used for debugging.

  • num_threads (int, optional) – If supplied, will use ‘num_threads’ number of OpenMP threads during the rendering. Defaults to 0, which uses the environment variable OMP_NUM_THREADS.

  • transparent (bool, optional) – Optionally saves out the 4-channel rgba image, which can appear empty if the alpha channel is low everywhere. Default: False

Returns:

image – An (N,M,3) array of the final returned values, in float64 form.

Return type:

array

switch_orientation(normal_vector=None, north_vector=None)

Change the view direction based on any of the orientation parameters.

This will recalculate all the necessary vectors and vector planes related to an orientable object.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

switch_view(normal_vector=None, width=None, center=None, north_vector=None)

Change the view based on any of the view parameters.

This will recalculate the orientation and width based on any of normal_vector, width, center, and north_vector.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • width (float or array of floats, optional) – The new width. Can be a single value W -> [W,W,W] or an array [W1, W2, W3] (left/right, top/bottom, front/back)

  • center (array_like, optional) – Specifies the new center.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

update_view_from_matrix(mat)
yaw(theta)

Rotate by a given angle about the vertical axis

Yaw the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to yaw the view.

Examples

>>> cam.yaw(np.pi / 4)
zoom(factor)

Change the distance to the focal point.

This will zoom the camera in by some factor toward the focal point, along the current view direction, modifying the left/right and up/down extents as well.

Parameters:

factor (float) – The factor by which to reduce the distance to the focal point.

Notes

You will need to call snapshot() again to get a new image.

zoomin(final, n_steps, clip_ratio=None)

Loop over a zoomin and return snapshots along the way.

This will yield n_steps snapshots until the current view has been zooming in to a final factor of final.

Parameters:
  • final (float) – The zoom factor, with respect to current, desired at the end of the sequence.

  • n_steps (int) – The number of zoom snapshots to make.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.zoomin(100.0, 10)):
...     iw.write_bitmap(snapshot, "zoom_%04i.png" % i)
class yt.visualization.volume_rendering.old_camera.StereoPairCamera(original_camera, relative_separation=0.005)[source]

Bases: Camera

annotate(ax, enhance=True, label_fmt=None)
comm = None
draw()
draw_box(im, le, re, color=None)

Draws a box on an existing volume rendering.

Draws a box defined by a left and right edge by modifying an existing volume rendering

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • le (Numpy ndarray) – Left corner of the box

  • re (Numpy ndarray) – Right corner of the box

  • color (array like, optional) – Color of the box (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_box(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_box.png")
draw_coordinate_vectors(im, length=0.05, thickness=1)

Draws three coordinate vectors in the corner of a rendering.

Modifies an existing image to have three lines corresponding to the coordinate directions colored by {x,y,z} = {r,g,b}. Currently only functional for plane-parallel volume rendering.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • length (float, optional) – The length of the lines, as a fraction of the image size. Default : 0.05

  • thickness (int, optional) – Thickness in pixels of the line to be drawn.

Returns:

  • None

  • Modifies

  • ——–

  • im (The original image.)

Examples

>>> im = cam.snapshot()
>>> cam.draw_coordinate_vectors(im)
>>> im.write_png("render_with_grids.png")
draw_domain(im, alpha=0.3)

Draws domain edges on an existing volume rendering.

Draws a white wireframe on the domain edges.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the wireframe being drawn. Used to control how bright the lines are with respect to the image. Default : 0.3

Returns:

nim – A new image with the domain lines drawn

Return type:

Numpy ndarray

Examples

>>> im = cam.snapshot()
>>> nim = cam.draw_domain(im)
>>> write_bitmap(nim, "render_with_domain_boundary.png")
draw_grids(im, alpha=0.3, cmap=None, min_level=None, max_level=None)

Draws Grids on an existing volume rendering.

By mapping grid level to a color, draws edges of grids on a volume rendering using the camera orientation.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the grids being drawn. Used to control how bright the grid lines are with respect to the image. Default : 0.3

  • cmap (string, optional) – Colormap to be used mapping grid levels to colors.

  • min_level (int, optional) – Optional parameter to specify the min level grid boxes to overplot on the image.

  • max_level (int, optional) – Optional parameters to specify the max level grid boxes to overplot on the image.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.add_grids(im)
>>> write_bitmap(im, "render_with_grids.png")
draw_line(im, x0, x1, color=None)

Draws a line on an existing volume rendering. Given starting and ending positions x0 and x1, draws a line on a volume rendering using the camera orientation.

Parameters:
  • im (ImageArray or 2D ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • x0 (YTArray or ndarray) – Starting coordinate. If passed in as an ndarray, assumed to be in code units.

  • x1 (YTArray or ndarray) – Ending coordinate, in simulation coordinates. If passed in as an ndarray, assumed to be in code units.

  • color (array like, optional) – Color of the line (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_line(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_line.png")
finalize_image(image)
get_dependencies(fields)
get_information()
get_sampler(args, kwargs)
get_sampler_args(image)
initialize_source()
look_at(new_center, north_vector=None)

Change the view direction based on a new focal point.

This will recalculate all the necessary vectors and vector planes to orient the image plane so that it points at a new location.

Parameters:
  • new_center (array_like) – The new “center” of the view port – the focal point for the camera.

  • north_vector (array_like, optional) – The “up” direction for the plane of rays. If not specific, calculated automatically.

move_to(final, n_steps, final_width=None, exponential=False, clip_ratio=None)

Loop over a look_at

This will yield n_steps snapshots until the current view has been moved to a final center of final with a final width of final_width.

Parameters:
  • final (array_like) – The final center to move to after n_steps

  • n_steps (int) – The number of look_at snapshots to make.

  • final_width (float or array_like, optional) – Specifies the final width after n_steps. Useful for moving and zooming at the same time.

  • exponential (boolean) – Specifies whether the move/zoom transition follows an exponential path toward the destination or linear

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.move_to([0.2, 0.3, 0.6], 10)):
...     iw.write_bitmap(snapshot, "move_%04i.png" % i)
new_image()
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

pitch(theta)

Rotate by a given angle about the horizontal axis

Pitch the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to pitch the view.

Examples

>>> cam.pitch(np.pi / 4)
project_to_plane(pos, res=None)
roll(theta)

Rotate by a given angle about the view normal axis

Roll the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to roll the view.

Examples

>>> cam.roll(np.pi / 4)
rotate(theta, rot_vector=None)

Rotate by a given angle

Rotate the view. If rot_vector is None, rotation will occur around the north_vector.

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around north_vector

Examples

>>> cam.rotate(np.pi / 4)
rotation(theta, n_steps, rot_vector=None, clip_ratio=None)

Loop over rotate, creating a rotation

This will yield n_steps snapshots until the current view has been rotated by an angle theta

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • n_steps (int) – The number of look_at snapshots to make.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around the original north_vector

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.rotation(np.pi, 10)):
...     iw.write_bitmap(snapshot, "rotation_%04i.png" % i)
save_annotated(fn, image, enhance=True, dpi=100, clear_fig=True, label_fmt=None)

Save an image with the transfer function represented as a colorbar.

Parameters:
  • fn (str) – The output filename

  • image (ImageArray) – The image to annotate

  • enhance (bool, optional) – Enhance the contrast (default: True)

  • dpi (int, optional) – Dots per inch in the output image (default: 100)

  • clear_fig (bool, optional) – Reset the figure (through matplotlib.pyplot.clf()) before drawing. Setting this to false can allow us to overlay the image onto an existing figure

  • label_fmt (str, optional) – A format specifier (e.g., label_fmt=”%.2g”) to use in formatting the data values that label the transfer function colorbar.

save_image(image, fn=None, clip_ratio=None, transparent=False)
set_default_light_dir()
set_default_light_rgba()
show(clip_ratio=None)

This will take a snapshot and display the resultant image in the IPython notebook.

If yt is being run from within an IPython session, and it is able to determine this, this function will snapshot and send the resultant image to the IPython notebook for display.

If yt can’t determine if it’s inside an IPython session, it will raise YTNotInsideNotebook.

Parameters:

clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> cam.show()
show_mpl(im, enhance=True, clear_fig=True)
show_tf()
snapshot(fn=None, clip_ratio=None, double_check=False, num_threads=0, transparent=False)

Ray-cast the camera.

This method instructs the camera to take a snapshot – i.e., call the ray caster – based on its current settings.

Parameters:
  • fn (string, optional) – If supplied, the image will be saved out to this before being returned. Scaling will be to the maximum value.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

  • double_check (bool, optional) – Optionally makes sure that the data contains only valid entries. Used for debugging.

  • num_threads (int, optional) – If supplied, will use ‘num_threads’ number of OpenMP threads during the rendering. Defaults to 0, which uses the environment variable OMP_NUM_THREADS.

  • transparent (bool, optional) – Optionally saves out the 4-channel rgba image, which can appear empty if the alpha channel is low everywhere. Default: False

Returns:

image – An (N,M,3) array of the final returned values, in float64 form.

Return type:

array

split()[source]
switch_orientation(normal_vector=None, north_vector=None)

Change the view direction based on any of the orientation parameters.

This will recalculate all the necessary vectors and vector planes related to an orientable object.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

switch_view(normal_vector=None, width=None, center=None, north_vector=None)

Change the view based on any of the view parameters.

This will recalculate the orientation and width based on any of normal_vector, width, center, and north_vector.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • width (float or array of floats, optional) – The new width. Can be a single value W -> [W,W,W] or an array [W1, W2, W3] (left/right, top/bottom, front/back)

  • center (array_like, optional) – Specifies the new center.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

update_view_from_matrix(mat)
yaw(theta)

Rotate by a given angle about the vertical axis

Yaw the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to yaw the view.

Examples

>>> cam.yaw(np.pi / 4)
zoom(factor)

Change the distance to the focal point.

This will zoom the camera in by some factor toward the focal point, along the current view direction, modifying the left/right and up/down extents as well.

Parameters:

factor (float) – The factor by which to reduce the distance to the focal point.

Notes

You will need to call snapshot() again to get a new image.

zoomin(final, n_steps, clip_ratio=None)

Loop over a zoomin and return snapshots along the way.

This will yield n_steps snapshots until the current view has been zooming in to a final factor of final.

Parameters:
  • final (float) – The zoom factor, with respect to current, desired at the end of the sequence.

  • n_steps (int) – The number of zoom snapshots to make.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.zoomin(100.0, 10)):
...     iw.write_bitmap(snapshot, "zoom_%04i.png" % i)
class yt.visualization.volume_rendering.old_camera.StereoSphericalCamera(*args, **kwargs)[source]

Bases: Camera

annotate(ax, enhance=True, label_fmt=None)
comm = None
draw()
draw_box(im, le, re, color=None)

Draws a box on an existing volume rendering.

Draws a box defined by a left and right edge by modifying an existing volume rendering

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • le (Numpy ndarray) – Left corner of the box

  • re (Numpy ndarray) – Right corner of the box

  • color (array like, optional) – Color of the box (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_box(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_box.png")
draw_coordinate_vectors(im, length=0.05, thickness=1)

Draws three coordinate vectors in the corner of a rendering.

Modifies an existing image to have three lines corresponding to the coordinate directions colored by {x,y,z} = {r,g,b}. Currently only functional for plane-parallel volume rendering.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • length (float, optional) – The length of the lines, as a fraction of the image size. Default : 0.05

  • thickness (int, optional) – Thickness in pixels of the line to be drawn.

Returns:

  • None

  • Modifies

  • ——–

  • im (The original image.)

Examples

>>> im = cam.snapshot()
>>> cam.draw_coordinate_vectors(im)
>>> im.write_png("render_with_grids.png")
draw_domain(im, alpha=0.3)

Draws domain edges on an existing volume rendering.

Draws a white wireframe on the domain edges.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the wireframe being drawn. Used to control how bright the lines are with respect to the image. Default : 0.3

Returns:

nim – A new image with the domain lines drawn

Return type:

Numpy ndarray

Examples

>>> im = cam.snapshot()
>>> nim = cam.draw_domain(im)
>>> write_bitmap(nim, "render_with_domain_boundary.png")
draw_grids(im, alpha=0.3, cmap=None, min_level=None, max_level=None)

Draws Grids on an existing volume rendering.

By mapping grid level to a color, draws edges of grids on a volume rendering using the camera orientation.

Parameters:
  • im (Numpy ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • alpha (float, optional) – The alpha value for the grids being drawn. Used to control how bright the grid lines are with respect to the image. Default : 0.3

  • cmap (string, optional) – Colormap to be used mapping grid levels to colors.

  • min_level (int, optional) – Optional parameter to specify the min level grid boxes to overplot on the image.

  • max_level (int, optional) – Optional parameters to specify the max level grid boxes to overplot on the image.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.add_grids(im)
>>> write_bitmap(im, "render_with_grids.png")
draw_line(im, x0, x1, color=None)

Draws a line on an existing volume rendering. Given starting and ending positions x0 and x1, draws a line on a volume rendering using the camera orientation.

Parameters:
  • im (ImageArray or 2D ndarray) – Existing image that has the same resolution as the Camera, which will be painted by grid lines.

  • x0 (YTArray or ndarray) – Starting coordinate. If passed in as an ndarray, assumed to be in code units.

  • x1 (YTArray or ndarray) – Ending coordinate, in simulation coordinates. If passed in as an ndarray, assumed to be in code units.

  • color (array like, optional) – Color of the line (r, g, b, a). Defaults to white.

Return type:

None

Examples

>>> im = cam.snapshot()
>>> cam.draw_line(im, np.array([0.1, 0.2, 0.3]), np.array([0.5, 0.6, 0.7]))
>>> write_bitmap(im, "render_with_line.png")
finalize_image(image)
get_dependencies(fields)
get_information()
get_sampler(args, kwargs)
get_sampler_args(image)[source]
initialize_source()
look_at(new_center, north_vector=None)

Change the view direction based on a new focal point.

This will recalculate all the necessary vectors and vector planes to orient the image plane so that it points at a new location.

Parameters:
  • new_center (array_like) – The new “center” of the view port – the focal point for the camera.

  • north_vector (array_like, optional) – The “up” direction for the plane of rays. If not specific, calculated automatically.

move_to(final, n_steps, final_width=None, exponential=False, clip_ratio=None)

Loop over a look_at

This will yield n_steps snapshots until the current view has been moved to a final center of final with a final width of final_width.

Parameters:
  • final (array_like) – The final center to move to after n_steps

  • n_steps (int) – The number of look_at snapshots to make.

  • final_width (float or array_like, optional) – Specifies the final width after n_steps. Useful for moving and zooming at the same time.

  • exponential (boolean) – Specifies whether the move/zoom transition follows an exponential path toward the destination or linear

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.move_to([0.2, 0.3, 0.6], 10)):
...     iw.write_bitmap(snapshot, "move_%04i.png" % i)
new_image()
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

pitch(theta)

Rotate by a given angle about the horizontal axis

Pitch the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to pitch the view.

Examples

>>> cam.pitch(np.pi / 4)
project_to_plane(pos, res=None)
roll(theta)

Rotate by a given angle about the view normal axis

Roll the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to roll the view.

Examples

>>> cam.roll(np.pi / 4)
rotate(theta, rot_vector=None)

Rotate by a given angle

Rotate the view. If rot_vector is None, rotation will occur around the north_vector.

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around north_vector

Examples

>>> cam.rotate(np.pi / 4)
rotation(theta, n_steps, rot_vector=None, clip_ratio=None)

Loop over rotate, creating a rotation

This will yield n_steps snapshots until the current view has been rotated by an angle theta

Parameters:
  • theta (float, in radians) – Angle (in radians) by which to rotate the view.

  • n_steps (int) – The number of look_at snapshots to make.

  • rot_vector (array_like, optional) – Specify the rotation vector around which rotation will occur. Defaults to None, which sets rotation around the original north_vector

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.rotation(np.pi, 10)):
...     iw.write_bitmap(snapshot, "rotation_%04i.png" % i)
save_annotated(fn, image, enhance=True, dpi=100, clear_fig=True, label_fmt=None)

Save an image with the transfer function represented as a colorbar.

Parameters:
  • fn (str) – The output filename

  • image (ImageArray) – The image to annotate

  • enhance (bool, optional) – Enhance the contrast (default: True)

  • dpi (int, optional) – Dots per inch in the output image (default: 100)

  • clear_fig (bool, optional) – Reset the figure (through matplotlib.pyplot.clf()) before drawing. Setting this to false can allow us to overlay the image onto an existing figure

  • label_fmt (str, optional) – A format specifier (e.g., label_fmt=”%.2g”) to use in formatting the data values that label the transfer function colorbar.

save_image(image, fn=None, clip_ratio=None, transparent=False)
set_default_light_dir()
set_default_light_rgba()
show(clip_ratio=None)

This will take a snapshot and display the resultant image in the IPython notebook.

If yt is being run from within an IPython session, and it is able to determine this, this function will snapshot and send the resultant image to the IPython notebook for display.

If yt can’t determine if it’s inside an IPython session, it will raise YTNotInsideNotebook.

Parameters:

clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> cam.show()
show_mpl(im, enhance=True, clear_fig=True)
show_tf()
snapshot(fn=None, clip_ratio=None, double_check=False, num_threads=0, transparent=False)[source]

Ray-cast the camera.

This method instructs the camera to take a snapshot – i.e., call the ray caster – based on its current settings.

Parameters:
  • fn (string, optional) – If supplied, the image will be saved out to this before being returned. Scaling will be to the maximum value.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

  • double_check (bool, optional) – Optionally makes sure that the data contains only valid entries. Used for debugging.

  • num_threads (int, optional) – If supplied, will use ‘num_threads’ number of OpenMP threads during the rendering. Defaults to 0, which uses the environment variable OMP_NUM_THREADS.

  • transparent (bool, optional) – Optionally saves out the 4-channel rgba image, which can appear empty if the alpha channel is low everywhere. Default: False

Returns:

image – An (N,M,3) array of the final returned values, in float64 form.

Return type:

array

switch_orientation(normal_vector=None, north_vector=None)

Change the view direction based on any of the orientation parameters.

This will recalculate all the necessary vectors and vector planes related to an orientable object.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

switch_view(normal_vector=None, width=None, center=None, north_vector=None)

Change the view based on any of the view parameters.

This will recalculate the orientation and width based on any of normal_vector, width, center, and north_vector.

Parameters:
  • normal_vector (array_like, optional) – The new looking vector.

  • width (float or array of floats, optional) – The new width. Can be a single value W -> [W,W,W] or an array [W1, W2, W3] (left/right, top/bottom, front/back)

  • center (array_like, optional) – Specifies the new center.

  • north_vector (array_like, optional) – The ‘up’ direction for the plane of rays. If not specific, calculated automatically.

update_view_from_matrix(mat)
yaw(theta)

Rotate by a given angle about the vertical axis

Yaw the view.

Parameters:

theta (float, in radians) – Angle (in radians) by which to yaw the view.

Examples

>>> cam.yaw(np.pi / 4)
zoom(factor)

Change the distance to the focal point.

This will zoom the camera in by some factor toward the focal point, along the current view direction, modifying the left/right and up/down extents as well.

Parameters:

factor (float) – The factor by which to reduce the distance to the focal point.

Notes

You will need to call snapshot() again to get a new image.

zoomin(final, n_steps, clip_ratio=None)

Loop over a zoomin and return snapshots along the way.

This will yield n_steps snapshots until the current view has been zooming in to a final factor of final.

Parameters:
  • final (float) – The zoom factor, with respect to current, desired at the end of the sequence.

  • n_steps (int) – The number of zoom snapshots to make.

  • clip_ratio (float, optional) – If supplied, the ‘max_val’ argument to write_bitmap will be handed clip_ratio * image.std()

Examples

>>> for i, snapshot in enumerate(cam.zoomin(100.0, 10)):
...     iw.write_bitmap(snapshot, "zoom_%04i.png" % i)
yt.visualization.volume_rendering.old_camera.corners(left_edge, right_edge)[source]
yt.visualization.volume_rendering.old_camera.get_corners(le, re)[source]
yt.visualization.volume_rendering.old_camera.off_axis_projection(ds, center, normal_vector, width, resolution, field, weight=None, volume=None, no_ghost=False, interpolated=False, north_vector=None, method='integrate')[source]

Project through a dataset, off-axis, and return the image plane.

This function will accept the necessary items to integrate through a volume at an arbitrary angle and return the integrated field of view to the user. Note that if a weight is supplied, it will multiply the pre-interpolated values together, then create cell-centered values, then interpolate within the cell to conduct the integration.

Parameters:
  • ds (Dataset) – This is the dataset to volume render.

  • center (array_like) – The current ‘center’ of the view port – the focal point for the camera.

  • normal_vector (array_like) – The vector between the camera position and the center.

  • width (float or list of floats) – The current width of the image. If a single float, the volume is cubical, but if not, it is left/right, top/bottom, front/back

  • resolution (int or list of ints) – The number of pixels in each direction.

  • field (string) – The field to project through the volume

  • weight (optional, default None) – If supplied, the field will be pre-multiplied by this, then divided by the integrated value of this field. This returns an average rather than a sum.

  • volume (yt.extensions.volume_rendering.AMRKDTree, optional) – The volume to ray cast through. Can be specified for finer-grained control, but otherwise will be automatically generated.

  • no_ghost (bool, optional) – Optimization option. If True, homogenized bricks will extrapolate out from grid instead of interpolating from ghost zones that have to first be calculated. This can lead to large speed improvements, but at a loss of accuracy/smoothness in resulting image. The effects are less notable when the transfer function is smooth and broad. Default: True

  • interpolated (optional, default False) – If True, the data is first interpolated to vertex-centered data, then tri-linearly interpolated along the ray. Not suggested for quantitative studies.

  • method (string) –

    The method of projection. Valid methods are:

    ”integrate” with no weight_field specified : integrate the requested field along the line of sight.

    ”integrate” with a weight_field specified : weight the requested field by the weighting field and integrate along the line of sight.

    ”sum” : This method is the same as integrate, except that it does not multiply by a path length when performing the integration, and is just a straight summation of the field along the given axis. WARNING: This should only be used for uniform resolution grid datasets, as other datasets may result in unphysical images.

Returns:

image – An (N,N) array of the final integrated values, in float64 form.

Return type:

array

Examples

>>> image = off_axis_projection(
...     ds, [0.5, 0.5, 0.5], [0.2, 0.3, 0.4], 0.2, N, "temperature", "density"
... )
>>> write_image(np.log10(image), "offaxis.png")
yt.visualization.volume_rendering.old_camera.plot_allsky_healpix(image, nside, fn, label='', rotation=None, take_log=True, resolution=512, cmin=None, cmax=None)[source]