Class yt_plot_base

class o2sclpy.yt_plot_base

A base class with simplifications for plots generated in yt

text2(tx, ty, textstr, **kwargs)

A wrapper for plot_base::yt() which ensures that the yt transformations are done

yt_ann = []

Annotations for yt renders. This list is controlled by the ‘yt-ann’ command.

yt_arrow(point1, point2, color=[1.0, 1.0, 1.0, 0.5], n_lines=40, frac_length=0.05, radius=0.0125, coords='user', keyname='o2sclpy_arrow')

Plot an arrow in a yt volume visualization.

yt_box(point1, point2, color=[1.0, 1.0, 1.0, 0.5], coords='user', keyname='o2sclpy_box')

Create a box in a yt visualization.

yt_camera = 0

The yt camera object

yt_check_backend()

For yt, check that we’re using the Agg backend, and print out an error message if we are not.

yt_create_camera(ds)

Create the yt camera object using the class variables yt_resolution, yt_position, and yt_focus, with a camera width based on the domain width of ds.

yt_create_scene()

Create the yt scene object and set yt_created_scene to True.

yt_created_camera = False

If true, then the yt camera object has been created

yt_created_scene = False

If true, then the yt scene object has been created

yt_data_sources = []

Current list of yt data source objects

yt_def_vol()

Create a default yt volume source for rendering other objects

yt_del_source(keyname)

Delete a yt source

o2sclpy has to keep track of the sources for two reasons (i) to make sure volme sources refer to valid memory and (ii) to be able to move text objects between renders in an animation. Thus, this function is required to remove a source from both the yt scene and from the internal o2sclpy lists.

yt_filter = ''

Filter for yt images.

yt_focus = 'default'

yt camera focus as a string.

yt_line(point1, point2, color=[1.0, 1.0, 1.0, 0.5], coords='user', keyname='o2sclpy_line')

Documentation for o2graph command yt-line:

Plot a line in a yt volume visualization.

Command-line arguments: x1 y1 z1 x2 y2 z2 [kwargs]

Plot a line between point (x1,y1,z1) and (x2,y2,z2) in a yt visualization. Possible kwargs are color=[1.0,1.0,1.0,0.5] coords=’user’ and keyname=’o2sclpy_line’. The possible values for coords are ‘user’, which refers the user-specified coordinate system, and ‘internal’, which is always between (0,0,0) and (1,1,1). See o2graph -help colors for information on the color kwarg.

If the x, y, and z limits have not yet been set, then this command uses the line coordinates to set them. If the x coordinates of the endpoints are equal to x0 and the x limits have not yet been set, then the x limits are x0-1 and x0+1. Similarly for the y and z coordinates. If a yt scene has noet yet been created, then an empty volume and scene will be created.

o2graph -set xlo 0 -set xhi 2 -set ylo 0 -set yhi 2 -set zhi 0 -set zhi 2 -yt-line 0.2 1.0 0.0 1.0 1.0 2.0 color=#FF0000 -yt-line 1.0 1.0 2.0 1.8 1.0 0.0 “color=(0,0,1)” -yt-line 0.6 1.0 1.0 1.4 1.0 1.0 “color=xkcd:rose” -set yt_sigma_clip 1 -yt-path yaw 100 1.0 -yt-render “/tmp/ytl_*.png” mov_fname=yt_line.mp4

yt_north = 'default'

yt camera north vector string.

yt_path = []

yt animation path (default []), as list of lists.

yt_plot_axis(xval=1.0, yval=1.0, zval=1.0, color=[1.0, 1.0, 1.0, 0.5], coords='internal', keyname='o2sclpy_axis')

Documentation for o2graph command yt-axis:

Add an axis to the yt volume.

Command-line arguments: [kwargs]

This command plots an axis from the origin to the three points [0,0,xval], [0,yval,0], and [0,0,zval]. The values xval, yval, and zval are keyword arguments which default to 1.0. The keyword argument color=[1,1,1,0.5] specifies the color of the axis arrows. The keyword argument coords specifies the coordinate system. Use coords=user for the user-based coordinate system and coords=internal (the default) for the internal coordinate system. The final keyword argument keyname=o2sclpy_axis is the name for the yt object.

Note that it is often most convenient to create the first volume source (e.g. either with yt-add-vol or``yt-scatter``) to set the scaling of the user-based coordinate system before using the yt-axis command.

This function creates a PointSource at the origin and then three arrows pointing from the origin along the x-, y-, and z-axes. The specified color is used for the origin and all three arrows. The arrows are constructed with one main LineSource and then several smaller LineSource objects in a conical shape to create the arrow heads.

yt_point(point1, rad, color=[1.0, 1.0, 1.0, 0.5], coords='user', keyname='o2sclpy_point')

Plot a point in a yt volume visualization.

yt_position = 'default'

yt camera position as a string.

yt_resolution = (512, 512)

Resolution for yt rendering (default (512,512))

yt_scene = 0

The yt scene object

yt_sigma_clip = 4.0

The sigma_clip parameter for yt (default 4.0)

yt_text(tx, ty, tz, textstr, textcolor=(1, 1, 1, 0.5), reorient=False, scale=0.6, font=30, keyname='o2sclpy_text', dpi=100, filename='', coords='')

Documentation for o2graph command yt-text:

Add text to the yt volume.

Command-line arguments: <x> <y> <z> <text> [kwargs]

Plot text given in <textstr> in a yt volume visualization at location (tx,ty,tz).

The keyword arguments and their defaults are textcolor=(1,1,1,0.5), reorient=False, scale=0.6, font=30, keyname='o2sclpy_text', dpi=100, filename='', and coords=''.

If coords is empty or user, then the given coordinates are assumed to be in the user coordinate system. If coords is internal, then the coordinates are assumed to be in the internal coordinate system from [0,0,0] to [1,1,1]. If reorient is True, then the during an animation, the text will be redrawn so that it is parallel to the camera. The scale and font parameters are passed on to the yt_text_to_scene() function.

In the future, the plan is to allow tx, ty, and tz to be functions of ‘i’, so the text can be moved. For now tx, ty, and tz are just floating point numbers.

yt_text_objects = []

Current list of yt data source objects

yt_text_to_points(veco, vecx, vecy, text, dpi=100, font=30, textcolor=(1, 1, 1, 0.5), show=False, filename='', facecolor=(0, 0, 0))

Take three 3D vectors ‘veco’ (origin), ‘vecx’ (x direction) and ‘vecy’ (y direction), and a string of text (‘text’), and return a numpy array of shape (6,npoints) which has entries (x,y,z,r,g,b). The values r, g, and b are between 0 and 1.

The alpha value of ‘textcolor’ is also used for the alpha value of the points.

Generally, to increase the point resolution of the text rendering, you increase the dpi parameter by some factor and decrease the scale factor by the same amount. However, be careful because increasing the number of points will slow down the yt rendering considerably.

Note that this function presumes a black background so it cannot handle black text.

Using the default dpi and font size is usually sufficient for lines of text containing about 30 characters. If more characters are required, then font must be decreased and dpi must be increased by the same factor in order to ensure all characters fit in the temporary figure which this function generates.

yt_text_to_scene(loc, text, textcolor=(1, 1, 1, 0.5), scale=0.6, dpi=100, font=30, keyname='o2sclpy_text', filename='')

At location ‘loc’ put text ‘text’ into the scene using specified scale parameter and keyname. This function uses the current yt camera to orient the text so that it is upright and parallel to the camera. Increasing ‘scale’ increase the size of the text and the ‘font’ parameter is passed on to the yt_text_to_points() function.

Generally, to increase the point resolution of the text rendering, you increase the dpi parameter by some factor and decrease the scale factor by the same amount. However, be careful because increasing the number of points will slow down the yt rendering considerably.

Note that this function presumes a black background so it cannot handle black text.

yt_tf = 0

The yt transfer function

yt_trans = 0

Transformation for yt figure annotations

yt_unique_keyname(prefix)

Construct a unique yt keyname by adding integers (beginning with the number 2) to the user-specified prefix.

yt_update_text()

Update the text objects during an animation by removing them from the scene and adding them back.

yt_vol_keynames = []

Current list of volume keynames

yt_vols = []

Current list of volume source objects

yt_volume_bbox = []

Current list of bbox arrays for volume sources

yt_volume_data = []

Current list of data objects for volume sources

yt_width = 'default'

yt camera width as a string.

yt_xtitle(textstr, tx=0.5, ty=-0.1, tz=-0.1, textcolor=(1, 1, 1, 1.0), reorient=False, scale=0.6, font=30, keyname='o2sclpy_text', dpi=100, filename='', coords='internal')

Documentation for o2graph command yt-xtitle:

Add a title to the x axis in yt

Command-line arguments: <x title>

This command uses yt-text to add a title to the x-axis.

yt_ytitle(textstr, tx=-0.1, ty=0.5, tz=-0.1, textcolor=(1, 1, 1, 1.0), reorient=False, scale=0.6, font=30, keyname='o2sclpy_text', dpi=100, filename='', coords='internal')

Documentation for o2graph command yt-ytitle:

Add a title to the y axis in yt

Command-line arguments: <y title>

This command uses yt-text to add a title to the y-axis.

yt_ztitle(textstr, tx=-0.1, ty=-0.1, tz=0.5, textcolor=(1, 1, 1, 1.0), reorient=False, scale=0.6, font=30, keyname='o2sclpy_text', dpi=100, filename='', coords='internal')

Documentation for o2graph command yt-ztitle:

Add a title to the z axis in yt

Command-line arguments: <z title>

This command uses yt-text to add a title to the z-axis.