API Reference¶
Plots and the Plotting Interface¶
SlicePlot and ProjectionPlot¶
|
A dispatch class for |
|
Creates a slice plot from a dataset |
|
Creates an off axis slice plot from a dataset |
|
A dispatch class for |
|
Creates a projection plot from a dataset |
|
Creates an off axis projection plot from a dataset |
|
A container for a single PlotWindow matplotlib figure and axes |
|
A plotting mechanism based around the concept of a window into a data source. |
|
Creates a plot of a 2D dataset |
ProfilePlot and PhasePlot¶
|
Create a 1d profile plot from a data source or from a list of profile objects. |
|
Create a 2d profile (phase) plot from a data source or from profile object created with yt.data_objects.profiles.create_profile. |
|
A container for a single matplotlib figure and axes for a PhasePlot |
Particle Plots¶
|
Creates a particle plot from a dataset |
|
Create a 2d particle phase plot from a data source or from a yt.data_objects.profiles.ParticleProfile object. |
|
A factory function for |
Fixed Resolution Pixelization¶
|
This accepts a 2D data object, such as a Projection or Slice, and implements a protocol for generating a pixelized, fixed-resolution image buffer. |
|
This object is a subclass of |
|
This object is a subclass of |
This object is a subclass of |
Writing FITS images¶
|
|
|
Generate a FITSImageData of an on-axis slice. |
|
Generate a FITSImageData of an on-axis projection. |
|
Generate a FITSImageData of an off-axis slice. |
|
Generate a FITSImageData of an off-axis projection. |
|
Generate a FITSImageData of an on-axis projection of a particle field. |
Data Sources¶
Physical Objects¶
These are the objects that act as physical selections of data, describing a region in space. These are not typically addressed directly; see Available Objects for more information.
Base Classes¶
These will almost never need to be instantiated on their own.
|
Generic YTDataContainer container. |
|
|
|
|
|
|
|
|
|
Returns an instance of YTSelectionContainer3D, or prepares one. |
Selection Objects¶
These objects are defined by some selection method or mechanism. Most are geometric.
|
A 0-dimensional object defined by a single point |
|
This is an orthogonal ray cast through the entire domain, at a specific coordinate. |
|
This is an arbitrarily-aligned ray cast through the entire domain, at a specific coordinate. |
|
This is a data object corresponding to a slice through the simulation domain. |
|
This is a data object corresponding to an oblique slice through the simulation domain. |
|
By providing a center, a normal, a radius and a height we can define a cylinder of any proportion. |
|
A 3D region of data with an arbitrary center. |
|
By selecting an arbitrary object_list, we can act on those grids. |
|
A sphere of points defined by a center and a radius. |
|
By providing a center,*A*,*B*,*C*,*e0*,*tilt* we can define a ellipsoid of any proportion. |
|
This is a data object designed to allow individuals to apply logical operations to fields and filter as a result of those cuts. |
|
|
|
|
|
|
|
|
|
Construction Objects¶
These objects typically require some effort to build. Often this means integrating through the simulation in some way, or creating some large or expensive set of intermediate data.
|
This is a streamline, which is a set of points defined as being parallel to some vector field. |
|
This is a data object corresponding to a line integral through the simulation domain. |
|
A 3D region with all data extracted to a single, specified resolution. |
|
A 3D region with arbitrary bounds and dimensions. |
|
A 3D region with all data extracted and interpolated to a single, specified resolution. |
|
This surface object identifies isocontours on a cell-by-cell basis, with no consideration of global connectedness, and returns the vertices of the Triangles in that isocontour. |
Time Series Objects¶
These are objects that either contain and represent or operate on series of datasets.
|
The DatasetSeries object is a container of multiple datasets, allowing easy iteration and computation on them. |
|
|
|
|
|
|
|
|
|
A collection of particle trajectories in time over a series of datasets. |
Geometry Handlers¶
These objects generate an “index” into multiresolution data.
|
The base index class |
|
The index class for patch and block AMR datasets. |
|
The Index subclass for oct AMR datasets |
|
The Index subclass for particle datasets |
|
The Index subclass for unstructured and hexahedral mesh datasets. |
Units¶
yt’s symbolic unit handling system is now based on the external library unyt. In complement, Dataset objects support the following methods to build arrays and scalars with physical dimensions.
Converts an array into a |
|
Converts an scalar into a |
Frontends¶
AMRVAC¶
|
A class to populate AMRVACHierarchy.grids, setting parent/children relations. |
|
|
|
|
|
|
|
|
|
Read one or more parfiles, and return a unified f90nml.Namelist object. |
ARTIO¶
|
|
|
|
|
|
|
|
|
|
|
Athena¶
|
|
|
|
|
|
|
|
|
AMReX/Boxlib¶
|
|
|
|
|
This class is a stripped down class that simply reads and parses filename, without looking at the Boxlib index. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CfRadial¶
|
|
|
|
|
|
|
|
Chombo¶
|
|
|
|
|
|
|
|
|
|
|
|
|
Enzo¶
|
|
|
Class representing a single Enzo Grid instance. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Enzo-specific output, set at a fixed time. |
|
|
|
|
|
|
|
|
|
Initialize an Enzo Simulation object. |
FITS¶
|
|
|
|
|
|
|
|
|
FLASH¶
|
|
|
|
|
|
|
|
|
GDF¶
|
|
|
|
|
|
|
Halo Catalogs¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Data file class for the YTHaloCatalogDataset. |
|
Dataset class for halo catalogs made with yt. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MOAB¶
|
|
|
|
|
|
|
|
|
|
|
|
OpenPMD¶
|
Represents chunk of data on-disk. |
|
Defines which fields and particles are created and read from disk. |
|
Contains all the required information of a single iteration of the simulation. |
|
Specifies which fields from the dataset yt should know about. |
|
|
|
Transforms an openPMD unitDimension into a string. |
|
Determines whether a group or dataset in the HDF5 file is constant. |
|
Grabs a dataset component from a group as a whole or sliced. |
RAMSES¶
|
|
|
|
|
|
|
|
|
|
|
SPH and Particle Codes¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Stream¶
|
|
|
Class representing a single In-memory Grid instance. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ytdata¶
|
Dataset for saved geometric data containers. |
|
Dataset for saved slices and projections. |
|
Dataset for saved covering grids, arbitrary grids, and FRBs. |
|
|
|
|
|
Dataset for general array data. |
|
|
|
|
|
Dataset for saved profile objects. |
|
Dataset for saved clump-finder data. |
|
|
|
|
|
|
Loading Data¶
|
Load a Dataset or DatasetSeries object. |
|
Load a uniform grid of data into yt as a |
|
Load a set of grids of data into yt as a |
|
Load a set of particles into yt as a |
|
Load an octree mask into yt. |
|
Load a hexahedral mesh of data into yt as a |
|
Load an unstructured mesh of data into yt as a |
|
Load sample data with yt. |
Derived Datatypes¶
Profiles and Histograms¶
These types are used to sum data up and either return that sum or return an
average. Typically they are more easily used through the ProfilePlot
PhasePlot
interface. We also provide the create_profile
function
to create these objects in a uniform manner.
|
The profile object class |
|
An object that represents a 1D profile. |
|
An object that represents a 2D profile. |
|
An object that represents a 2D profile. |
|
An object that represents a deposited 2D profile. |
|
Create a 1, 2, or 3D profile object. |
Clump Finding¶
The Clump
object and associated functions can be used for identification
of topologically disconnected structures, i.e., clump finding.
|
|
|
Adds an entry to clump_info list and tells children to do the same. |
|
Add a validating function to determine whether the clump should be kept. |
|
Export clump tree to a reloadable yt dataset. |
|
|
|
|
|
X-ray Emission Fields¶
This can be used to create derived fields of X-ray emission in different energy bands.
|
Class for making X-ray emissivity fields. |
|
Create X-ray emissivity fields for a given energy range. |
Field Types¶
|
This is a generic field container. |
|
This is the base class used to describe a cell-by-cell derived field. |
|
A |
A |
|
|
A |
|
A |
|
A |
Field Functions¶
|
Add a new field, along with supplemental metadata, to the list of available fields. |
|
Dataset-specific call to add_field |
|
Add a new deposited particle field |
|
Add a new mesh sampling particle field |
|
Add gradient fields. |
|
Add SPH fields for the specified particle type. |
Particle Filters¶
|
Create a new particle filter in the global namespace of filters |
|
A decorator that adds a new particle filter |
Image Handling¶
For volume renderings and fixed resolution buffers the image object returned is
an ImageArray
object, which has useful functions for image saving and
writing to bitmaps.
|
A custom Numpy ndarray used for images. |
Volume Rendering¶
See also 3D Visualization and Volume Rendering.
Here are the primary entry points and the main classes involved in the Scene infrastructure:
|
Create a simple volume rendering of a data source. |
|
Set up a scene object with sensible defaults for use in volume rendering. |
|
Project through a dataset, off-axis, and return the image plane. |
|
A virtual landscape for a volume rendering. |
|
A representation of a point of view into a Scene. |
|
A KDTree for AMR data. |
The different kinds of sources:
Base Class for Render Sources. |
|
|
A class for rendering data from a volumetric data source |
|
A rendering source of opaque points in the scene. |
|
A render source for a sequence of opaque line segments. |
|
A render source for a box drawn with line segments. |
|
A render source for drawing grids in a scene. |
|
Draw coordinate vectors on the scene. |
|
A source for unstructured mesh data. |
The different kinds of transfer functions:
|
A transfer function governs the transmission of emission and absorption through a volume. |
|
A complete set of transfer functions for standard color-mapping. |
|
A transfer function that defines a simple projection. |
|
This sets up a planck function for multivariate emission and absorption. |
|
This object constructs a set of field tables that allow for multiple field variables to control the integration through a volume. |
A transfer function helper. |
The different kinds of lenses:
|
A Lens is used to define the set of rays for rendering. |
The lens for orthographic projections. |
|
A lens for viewing a scene with a set of rays within an opening angle. |
|
A lens that includes two sources for perspective rays, for 3D viewing |
|
A lens for dome-based renderings |
|
A lens for cylindrical-spherical projection. |
|
A lens for a stereo cylindrical-spherical projection. |
Streamlining¶
See also Streamlines: Tracking the Trajectories of Tracers in your Data.
|
A collection of streamlines that flow through the volume |
Image Writing¶
These functions are all used for fast writing of images directly to disk, without calling matplotlib. This can be very useful for high-cadence outputs where colorbars are unnecessary or for volume rendering.
|
Write an image with different color channels corresponding to different quantities. |
|
Write out a bitmapped image directly to a PNG file. |
|
Write a projection or volume rendering to disk with a variety of pretty parameters such as limits, title, colorbar, etc. |
|
Write out a floating point array directly to a PNG file, scaling it and applying a colormap. |
|
|
|
|
|
Scale an image ([NxNxM] where M = 1-4) to be uint8 and values scaled from [0,255]. |
We also provide a module that is very good for generating EPS figures, particularly with complicated layouts.
|
|
|
Wrapper for DualEPS routines to create a figure directly from a yt plot. |
|
Convenience routine to create a multi-panel figure from yt plots or JPEGs. |
|
Wrapper for multiplot that takes a yt PlotWindow |
|
Returns a dict that describes a colorbar. |
Derived Quantities¶
See Processing Objects: Derived Quantities.
|
|
|
|
|
Calculates the weight average of a field or fields. |
|
Calculates the angular momentum vector, using gas (grid-based) and/or particles. |
|
Calculates the bulk velocity, using gas and/or particles. |
|
Calculates the center of mass, using gas and/or particles. |
|
Calculates the min and max value of a field or list of fields. |
|
Calculates the maximum value plus the x, y, and z position of the maximum. |
|
Calculates the minimum value plus the x, y, and z position of the minimum. |
|
Calculates the dimensionless spin parameter. |
|
Calculates the total mass of the object. |
|
Calculates the sum of the field or fields. |
|
Calculates the weight average of a field or fields. |
Callback List¶
See also Plot Modifications: Overplotting Contours, Velocities, Particles, and More.
|
Clear callbacks from the plot. |
|
Overplot arrow(s) pointing at position(s) for highlighting specific features. |
|
Annotate cell edges. |
|
Take a list of clumps and plot them as a set of contours. |
|
Add contours in field to the plot. |
|
Get a quiver plot on top of a cutting plane, using field_x and field_y, skipping every factor datapoint in the discretization. |
|
Draws grids on an existing PlotWindow object. |
|
Overplot a line with endpoints at p1 and p2. |
|
Adds a 'quiver' plot of magnetic field to the plot, skipping all but every factor datapoint. |
|
Overplot marker(s) at a position(s) for highlighting specific features. |
|
Adds particle positions, based on a thick slab along axis with a width along the line of sight. |
|
Adds a 'quiver' plot to any plot, using the field_x and field_y from the associated data, skipping every factor pixels. |
|
Adds a line representing the projected path of a ray across the plot. |
|
Annotates the scale of the plot at a specified location in the image (either in a preset corner, or by specifying (x,y) image coordinates with the pos argument. |
|
Overplot a circle with designated center and radius with optional text. |
|
Plot streamlines using matplotlib.axes.Axes.streamplot |
|
Overplot text on the plot at a specified position. |
|
Annotates the timestamp and/or redshift of the data output at a specified location in the image (either in a present corner, or by specifying (x,y) image coordinates with the x_pos, y_pos arguments. |
|
Accepts a title and adds it to the plot |
|
Intended for representing a slice of a triangular faceted geometry in a slice plot. |
|
Adds a 'quiver' plot of velocity to the plot, skipping all but every factor datapoint. |
Colormap Functions¶
See also Colormaps.
|
Adds a colormap to the colormaps available in yt for this session |
|
This generates a custom colormap based on the colors and spacings you provide. |
|
Displays the colormaps available to yt. |
Function List¶
|
Export a set of field arrays to a reloadable yt dataset. |
|
Export a data object to a reloadable yt dataset. |
|
all_data is a wrapper to the Region object for creating a region which covers the entire simulation domain. |
|
box is a wrapper to the Region object for creating a region without having to specify a center value. |
|
Forces a plugin file to be parsed. |
|
This returns a progressbar of the most appropriate type, given a title and a maxval. |
|
Takes secs and returns a nicely formatted string |
|
Placed inside a function, this will insert an IPython interpreter at that current location. |
|
This function returns True if it is on the root processor of the topcomm and False otherwise. |
|
Grabbed from Python Cookbook / matplotlib.cbook. |
|
Create an iterator for field names, specified as single strings or tuples(fname, ftype) alike. |
|
|
|
This function accepts a func, a set of args and kwargs and then only on the root processor calls the function. |
|
This is a traceback handler that knows how to paste to the pastebin. |
|
This decorator inserts a pdb session on top of the call-stack into a function. |
|
This function is used as a decorate on a function to have the calling stack printed whenever that function is entered. |
|
This is a decorator that, when used, will only call the function on the root processor. |
|
Decorator for seeing how long a given function takes, depending on whether or not the global 'yt.time_functions' config parameter is set. |
|
|
|
This method is used inside a script to turn on MPI parallelism, via mpi4py. |
|
This decorator blocks on entry and exit of a function. |
|
This function dispatches components of an iterable to different processors. |
|
If we are not run in parallel, this function passes the input back as output; otherwise, the function gets called. |
|
This decorator blocks and calls the function on the root processor, but does not broadcast results to the other processors. |
|
This is a decorator that broadcasts the result of computation on a single processor to all other processors. |
|
This is typically only used by derived field functions, but it returns parameters used to generate fields. |
|
Here we set up dictionaries that get passed up and down and ultimately to derived fields. |
Math Utilities¶
|
Assuming periodicity, find the periodic position within the domain. |
|
Find the Euclidean periodic distance between two sets of points. |
|
Find the Euclidean distance between two points. |
|
Rotates the elements of an array around an axis by some angle. |
|
Rotates and translates data into a new reference frame to make calculations easier. |
|
Computes the rotational velocity for some data around an axis. |
|
Computes the parallel velocity for some data around an axis. |
|
Computes the radial velocity for some data around an axis. |
|
Compute the radius for some data around an axis in cylindrical coordinates. |
|
Find two complementary orthonormal vectors to a given vector. |
|
Compute the quartile values (25% and 75%) along the specified axis in the same way that the numpy.median calculates the median (50%) value alone a specified axis. |
|
Given an angle theta and a 3D vector rot_vector, this routine computes the rotation matrix corresponding to rotating theta radians about rot_vector. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Miscellaneous Types¶
|
|
|
This class is designed to be a semi-persistent storage for parameter files. |
|
This is a generalized class that accepts a list of objects and then attempts to intelligently iterate over them. |
|
|
|
This takes an object, pobj, that implements ParallelAnalysisInterface, and then does its thing, calling initialize and finalize on the object. |
Cosmology Calculator¶
|
Create a cosmology calculator to compute cosmological distances and times. |
The distance corresponding to c / h, where c is the speed of light and h is the Hubble parameter in units of 1 / time. |
|
|
The comoving distance along the line of sight to on object at redshift, z_f, viewed at a redshift, z_i. |
|
When multiplied by some angle, the distance between two objects observed at redshift, z_f, with an angular separation given by that angle, viewed by an observer at redshift, z_i (Hogg 1999). |
|
"The comoving volume is the volume measure in which number densities of non-evolving objects locked into Hubble flow are constant with redshift." -- Hogg (1999) |
|
Following Hogg (1999), the angular diameter distance is 'the ratio of an object's physical transverse size to its angular size in radians.' |
|
The proper transverse distance between two points at redshift z_f observed at redshift z_i per unit of angular separation. |
|
The distance that would be inferred from the inverse-square law of light and the measured flux and luminosity of the observed object. |
|
The difference in the age of the Universe between the redshift interval z_i to z_f. |
The density required for closure of the Universe at a given redshift in the proper frame. |
|
The value of the Hubble parameter at a given redshift. |
|
The ratio between the Hubble parameter at a given redshift and redshift zero. |
|
|
Compute the redshift for a given age of the Universe. |
|
Compute the age of the Universe for a given redshift. |
This function computes the additional term that enters the expansion factor when using non-standard dark energy. |
Testing Infrastructure¶
The core set of testing functions are re-exported from NumPy, and are deprecated (prefer using numpy.testing directly).
|
Raises an AssertionError if two array_like objects are not equal. |
|
Raises an AssertionError if two items are not equal up to desired precision. |
|
Raises an AssertionError if two items are not equal up to significant digits. |
|
Raises an AssertionError if two objects are not equal up to desired precision. |
|
Raises an AssertionError if two objects are not equal. |
|
Raises an AssertionError if two array_like objects are not ordered by less than. |
|
Test if two strings are equal. |
|
Compare two arrays relatively to their spacing. |
|
Raises an AssertionError if two objects are not equal up to desired tolerance. |
|
Fail unless an exception of class exception_class is thrown by callable when invoked with arguments args and keyword arguments kwargs. |
unyt.testing also provides some specialized functions for comparing arrays in a units-aware fashion.
Finally, yt provides the following functions:
|
|
|
Creates two numpy arrays representing the left and right bounds of an AMR grid as well as an array for the AMR level of each cell. |
|
expand_keywords is a means for testing all possible keyword arguments in the nosetests. |
|
|
|
|
|
|
|
|
|
|
|
create a toy dataset that puts a sphere at (0,0,0), a single cube on +x, two cubes on +y, and three cubes on +z in a domain from [-1*scale,1*scale]**3. |
Returns an in-memory SPH dataset useful for testing |
|
|
Returns an in-memory SPH dataset useful for testing |
|
These are for the pytest infrastructure:
|
Handles initialization, generation, and saving of answer test result hashes. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This test is typically used once per geometry or coordinates type. |
|
|
|
|