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.

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.

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 \([0,\pi]\) for a three-element vector in Cartesian coordinates.

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].

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.

[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.

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.

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.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]\).

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=[])

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

o2sclpy.wrap_line(line: str, ncols=79)

From a string ‘line’, create a list of strings which adds return characters in order to attempt to ensure each line is less than or equal to ncols characters long. This function also respects explicit carriage returns, ensuring they force a new line independent of the line length. This function uses the ‘length_without_colors()’ function above, to ensure VT100 formatting sequences aren’t included in the count.

Other O₂sclpy variables

o2sclpy.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'])]

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

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

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

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

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

o2sclpy.version = '0.929a1'

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?)