Other O₂sclpy objects

O2sclpy

Variables base_list, param_list, yt_param_list, extra_list are not listed here because their auto-docs are too long.

Other O₂sclpy functions

o2sclpy.arrow(x1, y1, z1, x2, y2, z2, r=0, tail_ratio=0.9, n_theta=20, head_width=3)

Create a set of vertices and triangular faces for an arrow.

The tail a cylinder with radius r beginning at (x1,y1,z1) and the head is a cone with radius 2r with a point at (x2,y2,z2). The variable tail_ratio specifies the length of the cylinder divided by the distance between point 1 and point 2. The argument n_theta specifies the number of vertices in the azimuthal direction. If r is zero or negative, then it is set to the length of the arrow divided by 80.

This function returns a set of three lists, the first is the vertices (a list of size n_theta times nine), the second is the vertex normals (a list of size n_theta times nine), and the third are the faces a list of size n_theta times three). The normal vectors always point out away from the axis, except for the single vertex at the head of the arrow, which points in the direction of the arrow.

o2sclpy.build_o2scl(verbose=1, release=True)

This function attempts to automatically build O2scl using homebrew on OSX and snap on Linux.

This function is in link_o2scl.py.

o2sclpy.change_phi(v, phi_new)

Modify the azimuthal angle of a Cartesian vector, effectively rotating it around the z axis. The first two entries of v are modified.

This function is in utils.py.

o2sclpy.cmap_to_png(cmap: str, png_file: str, verbose: int = 0)

Convert a cmap to a png file which is 2 pixels high and 256 pixels wide and store it in png_file.

o2sclpy.cross(x, y, norm=False)

Return the cross product between two vectors

If norm is True, then normalize the cross product to unity before returning it.

This function is in utils.py.

o2sclpy.default_plot(left_margin=0.14, bottom_margin=0.12, right_margin=0.04, top_margin=0.04, fontsize=16, fig_size_x=6.0, fig_size_y=6.0, ticks_in=False, rt_ticks=False, editor=False)
o2sclpy.dist3(x, y)

Return the length of the vector representing the difference of two three-element Cartesian vectors, x, and y.

o2sclpy.force_bytes(obj)

This function returns the bytes object corresponding to obj in case it is a string using UTF-8.

o2sclpy.force_string(obj)

This function returns the bytes object corresponding to obj in case it is a string using UTF-8.

o2sclpy.get_azi_angle(v)

Return the azimuthal angle in \([-\pi,\pi]\) for a two- or three-element vector in Cartesian coordinates (the third element is ignored).

This function is in utils.py.

o2sclpy.get_str_array(dset)

Extract a string array from O2scl HDF5 dataset dset as a python list

This function is in utils.py.

o2sclpy.icosphere(x, y, z, r, n_subdiv: int = 0, phi_cut=[0, 0])

Construct the vertices and faces of an icosphere centered at (x,y,z) with radius r

This function is based on material from [1]. The icosphere is constructed from the corners of three golden rectangles aligned along the axes.

This function returns a set of three lists, the first is the vertices, the second are the vertex normals, and the third are the faces. The normal vectors always point outwards.

The phi_cut keyword argument does not yet work.

[1] https://danielsieger.com/blog/2021/03/27/generating-spheres.html

o2sclpy.if_yt_then_Agg(backend: str, argv)

Determine if yt commands are present, and if found, then automatically convert to the Agg backend.

o2sclpy.is_number(s: str)

Return true if ‘s’ is likely a number

o2sclpy.latex_to_png(tex: str, png_file: str, verbose: int = 0, packages=[])

A simple routine to convert a LaTeX string to a png image.

Math mode is not assumed, so equations may need to be surrounded by dollar signs. A temporary file is created, and then that file is processed by pdflatex and then the output is renamed to the filename specified by the user with mv.

The standalone LaTeX package is used to make png, and the default background is transparent, but the antialiasing used to render the equations means that only white backgrounds work without creating edge effects. The additional LaTeX packages listed in packages are loaded with the usepackage LaTeX command. A common use-case is to load the color package to get colored LaTeX output.

The destination file png_file will be silently overwritten if it is already present.

o2sclpy.latex_prism(x1, y1, z1, x2, y2, z2, latex, wdir, png_file, mat_name, dir='x', end_mat='white', verbose=0)

Create a rectangular prism with textures from a png created by a LaTeX string on four sides.

This function returns four objects: the vertices, the faces, the texture uv coordinates, and the material object

The variable dir is either ‘x’, ‘y’, or ‘z’, depending on the orientation of the prism. For the ‘x’ direction, the xy and xz faces have textures from the LaTeX object, and the yz faces are set to the end material specified in end_mat. The normal vectors for all six faces point outside the prism.

o2sclpy.length_without_colors(strt: str)

Compute the length of strt, ignoring characters which correspond to VT100 formatting sequences

o2sclpy.mag3(x)

Return the length of a three-element Cartesian vector x.

o2sclpy.norm3(x)

Normalize the three-element Cartesian vector x.

This function is in utils.py.

o2sclpy.parallelogram(x1, y1, z1, x2, y2, z2, x3, y3, z3, mat_name='', verbose=0, force_rect=False)

Create the vertices, faces, and norms for a 3d visualization of a parallelogram.

Points 1, 2, and 3 should be the lower-left corner, the lower-right corner, and the upper-left corner, respectively. These three points define the first triangular face, and the second triangular face is formed from the lower-right corner, the upper-left corner, and the upper-right corner (which is automatically computed from the user-specified points).

If force_rect=True, then the third coordinate of the parallelogram is modified to make sure the two adjacent sides are orthogonal.

Internally, the parallelogram is represented by two triangular faces and four vertices.

o2sclpy.parse_arguments(argv, verbose=0)

Old command-line parser (this is currently unused and it’s not clear if it will be useful in the future).

This function is in utils.py.

o2sclpy.png_power_two(png_input: str, png_output: str, bgcolor=[0, 0, 0, 0], verbose: int = 0, flatten: bool = False, resize: bool = True)

Read a PNG image from png_input, resize it to ensure the width and height are both a power of two, and store the resulting file in png_output.

This function returns a tuple of four numbers, the width and height of the usable part of the image and the width and height of the full image. The latter two numbers are always a power of two.

This function uses the Pillow python package to determine the original width and height and perform the resizing. If the width and height are already both a power of two, then the file is simply copied, unless the input and output filenames are the same, in which case this function does nothing. If the input and output filenames are the same, and the width and height are not a power of two, then this function will throw an exception to help prevent the user from inadvertently overwriting the original file. This function always overwrites the output file when the input and output filenames are different.

When resize is True, the image is resized to fit the new width and height. When resize is False, then the original image is centered in the new canvas, and the canvas is filled with the background color.

If flatten is True and bgcolor[3] is non-zero, then any pixels with alpha=0 are replaced with bgcolor. This is particularly useful for pngs created by the latex_to_png() function.

The background color argument should consist of integers from 0 to 255. The default background color is transparent black.

If verbose is greater than 1, then several details are written to stdout.

o2sclpy.rect_to_spher(v)

Convert a three-element Cartesian vector to spherical coordinates and return a three-element vector containing the radius, the azimuthal angle, and the polar angle (in that order). The azimuthal angle is always in the range \([-\pi,\pi]\) and the polar angle is always in the range \([0,\pi]\).

This function is in utils.py.

o2sclpy.remove_spaces(string: str)

Remove spaces at the beginning specified string and return the result.

This function is in utils.py.

o2sclpy.renorm(x, r)

Take the three-element Cartesian vector x, and rescale it to ensure that its length is equal to r.

o2sclpy.screenify_py(tlist, ncols: int = 79)

Desc

o2sclpy.string_equal_dash(str1: str, str2: str)

Desc

o2sclpy.string_to_color(str_in: str)

Convert a string to a color, either (r,g,b) to an RGB color or [r,g,b,a] to an RGBA color.

o2sclpy.string_to_dict(s)

Convert a string to a dictionary, with extra processing for colors, subdictionaries, and matplotlib keyword arguments which are expected to have integer or floating point values.

This function is in utils.py.

o2sclpy.string_to_dict2(s, list_of_ints=[], list_of_floats=[], list_of_bools=[], list_of_colors=[])

Convert a string to a dictionary, converting strings to values when necessary.

This function is in utils.py.

Other O₂sclpy variables

o2sclpy.doc_data.cmaps = [('Perceptually uniform sequential', ['viridis', 'plasma', 'inferno', 'magma', 'cividis']), ('Sequential', ['Greys', 'Purples', 'Blues', 'Greens', 'Oranges', 'Reds', 'YlOrBr', 'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu', 'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn', 'BuGn', 'YlGn']), ('Sequential (2)', ['binary', 'gist_yarg', 'gist_gray', 'gray', 'bone', 'pink', 'spring', 'summer', 'autumn', 'winter', 'cool', 'Wistia', 'hot', 'afmhot', 'gist_heat', 'copper']), ('Diverging', ['PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu', 'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic']), ('Cyclic', ['twilight', 'twilight_shifted', 'hsv']), ('Qualitative', ['Pastel1', 'Pastel2', 'Paired', 'Accent', 'Dark2', 'Set1', 'Set2', 'Set3', 'tab10', 'tab20', 'tab20b', 'tab20c']), ('Miscellaneous', ['flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern', 'gnuplot', 'gnuplot2', 'CMRmap', 'cubehelix', 'brg', 'gist_rainbow', 'rainbow', 'jet', 'turbo', 'nipy_spectral', 'gist_ncar'])]

List of cmaps for ‘help cmaps’

o2sclpy.doc_data.extra_types = ['table', 'table3d', 'hist_2d', 'hist', 'double[]', 'int[]', 'size_t[]', 'tensor', 'tensor<int>', 'tensor<size_t>', 'tensor_grid']

List of types which have additional plotting commands

o2sclpy.doc_data.new_cmaps = [('O2sclpy cmaps', ['jet2', 'pastel2', 'reds2', 'greens2', 'blues2'])]

List of new o2sclpy cmaps

o2sclpy.doc_data.version = '0.930'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

Extra class for todo items

class o2sclpy.todo_list

Todo

  • Give an example of yt_filter in the docs

  • Add RGB hex values to ‘colors-near’.

  • Command rect is x1 y1 x2 y2, but ellipse is x1 y1 w h, which is confusing. maybe its better to make them consistent? Or allow the user to choose the format?

  • Also, rectanges by default are done without the axes transformation, which means they don’t change when the plot is zoomed. Maybe allow the user to pick the transformation?

  • An example of ‘python’, ‘exec’, ‘image’, ‘clf’?

  • Create new functions based on yt_render() which are easier called directly from python.

  • Allow the user to name axes in cbar, inset, and subplots.

  • Create a cube plot like Raph(?) showed, where three density plots are shown on the xy xz and yz planes in combination with a volume rendering. This demands taking a density plot and transforming it to a paralellogram with normal matplotlib, using yt for the volume rendering, and then making a yt_filter to add the volume rendering on top of the density plots. See https://matplotlib.org/3.1.0/tutorials/toolkits/axisartist.html for the parallelograms.

  • an example of more complicated yt annotations

  • Finish the ‘moveauto’ path in yt_render()

  • Create a moveauto path which includes a zoom

  • create a vector field command in yt

  • allow the creation of colormaps on the fly?

  • add map to colormap option for yt tf’s

  • Create a system of protected variables and functions using underscores and also create a __repr__() object

  • Ensure yt uses self.font for text objects?

  • Finish den-plot-anim for a tensor_grid objects

  • plot-set for a table3d object to create a sequence of curves for each column or row, or maybe do this as a ‘mult-vector-spec’?

  • Simplify some of the larger functions like o2graph_plotter::plot(), possibly by creating a separate function for each type?

  • Ensure the ‘clf’ command clears the yt objects?

  • New yt_path option to move along a path determined by an o2scl table object?

  • Anti-alias text objects in yt (also anti-alias line sources?)