yt.visualization.fixed_resolution module¶
- class yt.visualization.fixed_resolution.CylindricalFixedResolutionBuffer(data_source, radius, buff_size, antialias=True, *, filters=None)[source]¶
Bases:
FixedResolutionBuffer
This object is a subclass of
yt.visualization.fixed_resolution.FixedResolutionBuffer
that supports non-aligned input data objects, primarily cutting planes.- convert_distance_x(distance)¶
This function converts code-space distance into pixel-space distance in the x-coordinate.
- Parameters:
distance (array_like) – This is x-distance in code-space you would like to convert.
- Returns:
output – The return value is the distance in the y-pixel coordinates.
- Return type:
array_like
- convert_distance_y(distance)¶
This function converts code-space distance into pixel-space distance in the y-coordinate.
- Parameters:
distance (array_like) – This is y-distance in code-space you would like to convert.
- Returns:
output – The return value is the distance in the x-pixel coordinates.
- Return type:
array_like
- convert_to_pixel(coords)¶
This function converts coordinates in code-space to pixel-space.
- Parameters:
coords (sequence of array_like) – This is (x_coord, y_coord). Because of the way the math is done, these can both be arrays.
- Returns:
output – This returns px_coord, py_coord
- Return type:
sequence of array_like
- export_dataset(fields=None, nprocs=1)¶
Export a set of pixelized fields to an in-memory dataset that can be analyzed as any other in yt. Unit information and other parameters (e.g., geometry, current_time, etc.) will be taken from the parent dataset.
- Parameters:
fields (list of strings, optional) – These fields will be pixelized and output. If “None”, the keys of the FRB will be used.
nprocs (integer, optional) – If greater than 1, will create this number of subarrays out of data
Examples
>>> import yt >>> ds = yt.load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150") >>> slc = ds.slice(2, 0.0) >>> frb = slc.to_frb((500.0, "kpc"), 500) >>> ds2 = frb.export_dataset( ... fields=[("gas", "density"), ("gas", "temperature")], nprocs=32 ... )
- export_hdf5(filename, fields=None)¶
Export a set of fields to a set of HDF5 datasets.
This function will export any number of fields into datasets in a new HDF5 file.
- Parameters:
filename (string) – This file will be opened in “append” mode.
fields (list of strings) – These fields will be pixelized and output.
- get_image(key, /) ImageArray ¶
- get_mask(key, /) np.ndarray[Any, np.dtype[np.bool_]] | None ¶
Return the boolean array associated with an image with the same key.
Elements set to True indicate pixels that were updated by a pixelisation routine
- keys()¶
- property limits¶
- render(item)¶
- save_as_dataset(filename=None, fields=None)¶
Export a fixed resolution buffer to a reloadable yt dataset.
This function will take a fixed resolution buffer and output a dataset containing either the fields presently existing or fields given in the
fields
list. The resulting dataset can be reloaded as a yt dataset.- Parameters:
filename (str, optional) – The name of the file to be written. If None, the name will be a combination of the original dataset and the type of data container.
fields (list of strings or tuples, optional) – If this is supplied, it is the list of fields to be saved to disk. If not supplied, all the fields that have been queried will be saved.
- Returns:
filename – The name of the file that has been created.
- Return type:
Examples
>>> import yt >>> ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046") >>> proj = ds.proj(("gas", "density"), "x", weight_field=("gas", "density")) >>> frb = proj.to_frb(1.0, (800, 800)) >>> fn = frb.save_as_dataset(fields=[("gas", "density")]) >>> ds2 = yt.load(fn) >>> print(ds2.data["gas", "density"]) [[ 1.25025353e-30 1.25025353e-30 1.25025353e-30 ..., 7.90820691e-31 7.90820691e-31 7.90820691e-31] [ 1.25025353e-30 1.25025353e-30 1.25025353e-30 ..., 7.90820691e-31 7.90820691e-31 7.90820691e-31] [ 1.25025353e-30 1.25025353e-30 1.25025353e-30 ..., 7.90820691e-31 7.90820691e-31 7.90820691e-31] ..., [ 1.55834239e-30 1.55834239e-30 1.55834239e-30 ..., 8.51353199e-31 8.51353199e-31 8.51353199e-31] [ 1.55834239e-30 1.55834239e-30 1.55834239e-30 ..., 8.51353199e-31 8.51353199e-31 8.51353199e-31] [ 1.55834239e-30 1.55834239e-30 1.55834239e-30 ..., 8.51353199e-31 8.51353199e-31 8.51353199e-31]] g/cm**3
- set_unit(field, unit, equivalency=None, equivalency_kwargs=None)¶
Sets a new unit for the requested field
- Parameters:
field (string or field tuple) – The name of the field that is to be changed.
unit (string or Unit object) – The name of the new unit.
equivalency (string, optional) – If set, the equivalency to use to convert the current units to the new requested unit. If None, the unit conversion will be done without an equivalency
equivalency_kwargs (string, optional) – Keyword arguments to be passed to the equivalency. Only used if
equivalency
is set.
- setup_filters()¶
- to_fits_data(fields=None, other_keys=None, length_unit=None, **kwargs)¶
Export the fields in this FixedResolutionBuffer instance to a FITSImageData instance.
This will export a set of FITS images of either the fields specified or all the fields already in the object.
- Parameters:
fields (list of strings) – These fields will be pixelized and output. If “None”, the keys of the FRB will be used.
other_keys (dictionary, optional) – A set of header keys and values to write into the FITS header.
length_unit (string, optional) – the length units that the coordinates are written in. The default is to use the default length unit of the dataset.
- class yt.visualization.fixed_resolution.FixedResolutionBuffer(data_source, bounds, buff_size, antialias=True)[source]¶
Bases:
object
This accepts a 2D data object, such as a Projection or Slice, and implements a protocol for generating a pixelized, fixed-resolution image buffer.
yt stores 2D AMR data internally as a set of 2D coordinates and the half-width of individual pixels. Converting this to an image buffer requires a deposition step, where individual variable-resolution pixels are deposited into a buffer of some resolution, to create an image. This object is an interface to that pixelization step: it can deposit multiple fields. It acts as a standard YTDataContainer object, such that dict-style access returns an image of a given field.
- Parameters:
data_source (
yt.data_objects.construction_data_containers.YTQuadTreeProj
) – oryt.data_objects.selection_data_containers.YTSlice
This is the source to be pixelized, which can be a projection, slice or cutting plane.bounds (sequence of floats) – Bounds are the min and max in the image plane that we want our image to cover. It’s in the order of (xmin, xmax, ymin, ymax), where the coordinates are all in the appropriate code units.
buff_size (sequence of ints) – The size of the image to generate.
antialias (boolean) – This can be true or false. It determines whether or not sub-pixel rendering is used during data deposition.
periodic (boolean) – This can be true or false, and governs whether the pixelization will span the domain boundaries.
filters (list of FixedResolutionBufferFilter objects (optional))
Examples
To make a projection and then several images, you can generate a single FRB and then access multiple fields:
>>> proj = ds.proj(0, ("gas", "density")) >>> frb1 = FixedResolutionBuffer(proj, (0.2, 0.3, 0.4, 0.5), (1024, 1024)) >>> print(frb1["gas", "density"].max()) 1.0914e-9 g/cm**3 >>> print(frb1["gas", "temperature"].max()) 104923.1 K
- convert_distance_x(distance)[source]¶
This function converts code-space distance into pixel-space distance in the x-coordinate.
- Parameters:
distance (array_like) – This is x-distance in code-space you would like to convert.
- Returns:
output – The return value is the distance in the y-pixel coordinates.
- Return type:
array_like
- convert_distance_y(distance)[source]¶
This function converts code-space distance into pixel-space distance in the y-coordinate.
- Parameters:
distance (array_like) – This is y-distance in code-space you would like to convert.
- Returns:
output – The return value is the distance in the x-pixel coordinates.
- Return type:
array_like
- convert_to_pixel(coords)[source]¶
This function converts coordinates in code-space to pixel-space.
- Parameters:
coords (sequence of array_like) – This is (x_coord, y_coord). Because of the way the math is done, these can both be arrays.
- Returns:
output – This returns px_coord, py_coord
- Return type:
sequence of array_like
- export_dataset(fields=None, nprocs=1)[source]¶
Export a set of pixelized fields to an in-memory dataset that can be analyzed as any other in yt. Unit information and other parameters (e.g., geometry, current_time, etc.) will be taken from the parent dataset.
- Parameters:
fields (list of strings, optional) – These fields will be pixelized and output. If “None”, the keys of the FRB will be used.
nprocs (integer, optional) – If greater than 1, will create this number of subarrays out of data
Examples
>>> import yt >>> ds = yt.load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150") >>> slc = ds.slice(2, 0.0) >>> frb = slc.to_frb((500.0, "kpc"), 500) >>> ds2 = frb.export_dataset( ... fields=[("gas", "density"), ("gas", "temperature")], nprocs=32 ... )
- export_hdf5(filename, fields=None)[source]¶
Export a set of fields to a set of HDF5 datasets.
This function will export any number of fields into datasets in a new HDF5 file.
- Parameters:
filename (string) – This file will be opened in “append” mode.
fields (list of strings) – These fields will be pixelized and output.
- get_image(key, /) ImageArray [source]¶
- get_mask(key, /) np.ndarray[Any, np.dtype[np.bool_]] | None [source]¶
Return the boolean array associated with an image with the same key.
Elements set to True indicate pixels that were updated by a pixelisation routine
- property limits¶
- save_as_dataset(filename=None, fields=None)[source]¶
Export a fixed resolution buffer to a reloadable yt dataset.
This function will take a fixed resolution buffer and output a dataset containing either the fields presently existing or fields given in the
fields
list. The resulting dataset can be reloaded as a yt dataset.- Parameters:
filename (str, optional) – The name of the file to be written. If None, the name will be a combination of the original dataset and the type of data container.
fields (list of strings or tuples, optional) – If this is supplied, it is the list of fields to be saved to disk. If not supplied, all the fields that have been queried will be saved.
- Returns:
filename – The name of the file that has been created.
- Return type:
Examples
>>> import yt >>> ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046") >>> proj = ds.proj(("gas", "density"), "x", weight_field=("gas", "density")) >>> frb = proj.to_frb(1.0, (800, 800)) >>> fn = frb.save_as_dataset(fields=[("gas", "density")]) >>> ds2 = yt.load(fn) >>> print(ds2.data["gas", "density"]) [[ 1.25025353e-30 1.25025353e-30 1.25025353e-30 ..., 7.90820691e-31 7.90820691e-31 7.90820691e-31] [ 1.25025353e-30 1.25025353e-30 1.25025353e-30 ..., 7.90820691e-31 7.90820691e-31 7.90820691e-31] [ 1.25025353e-30 1.25025353e-30 1.25025353e-30 ..., 7.90820691e-31 7.90820691e-31 7.90820691e-31] ..., [ 1.55834239e-30 1.55834239e-30 1.55834239e-30 ..., 8.51353199e-31 8.51353199e-31 8.51353199e-31] [ 1.55834239e-30 1.55834239e-30 1.55834239e-30 ..., 8.51353199e-31 8.51353199e-31 8.51353199e-31] [ 1.55834239e-30 1.55834239e-30 1.55834239e-30 ..., 8.51353199e-31 8.51353199e-31 8.51353199e-31]] g/cm**3
- set_unit(field, unit, equivalency=None, equivalency_kwargs=None)[source]¶
Sets a new unit for the requested field
- Parameters:
field (string or field tuple) – The name of the field that is to be changed.
unit (string or Unit object) – The name of the new unit.
equivalency (string, optional) – If set, the equivalency to use to convert the current units to the new requested unit. If None, the unit conversion will be done without an equivalency
equivalency_kwargs (string, optional) – Keyword arguments to be passed to the equivalency. Only used if
equivalency
is set.
- to_fits_data(fields=None, other_keys=None, length_unit=None, **kwargs)[source]¶
Export the fields in this FixedResolutionBuffer instance to a FITSImageData instance.
This will export a set of FITS images of either the fields specified or all the fields already in the object.
- Parameters:
fields (list of strings) – These fields will be pixelized and output. If “None”, the keys of the FRB will be used.
other_keys (dictionary, optional) – A set of header keys and values to write into the FITS header.
length_unit (string, optional) – the length units that the coordinates are written in. The default is to use the default length unit of the dataset.
- class yt.visualization.fixed_resolution.OffAxisProjectionFixedResolutionBuffer(data_source, bounds, buff_size, antialias=True, periodic=False, *, filters: list[FixedResolutionBufferFilter] | None = None)[source]¶
Bases:
FixedResolutionBuffer
This object is a subclass of
yt.visualization.fixed_resolution.FixedResolutionBuffer
that supports off axis projections. This calls the volume renderer.- convert_distance_x(distance)¶
This function converts code-space distance into pixel-space distance in the x-coordinate.
- Parameters:
distance (array_like) – This is x-distance in code-space you would like to convert.
- Returns:
output – The return value is the distance in the y-pixel coordinates.
- Return type:
array_like
- convert_distance_y(distance)¶
This function converts code-space distance into pixel-space distance in the y-coordinate.
- Parameters:
distance (array_like) – This is y-distance in code-space you would like to convert.
- Returns:
output – The return value is the distance in the x-pixel coordinates.
- Return type:
array_like
- convert_to_pixel(coords)¶
This function converts coordinates in code-space to pixel-space.
- Parameters:
coords (sequence of array_like) – This is (x_coord, y_coord). Because of the way the math is done, these can both be arrays.
- Returns:
output – This returns px_coord, py_coord
- Return type:
sequence of array_like
- export_dataset(fields=None, nprocs=1)¶
Export a set of pixelized fields to an in-memory dataset that can be analyzed as any other in yt. Unit information and other parameters (e.g., geometry, current_time, etc.) will be taken from the parent dataset.
- Parameters:
fields (list of strings, optional) – These fields will be pixelized and output. If “None”, the keys of the FRB will be used.
nprocs (integer, optional) – If greater than 1, will create this number of subarrays out of data
Examples
>>> import yt >>> ds = yt.load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150") >>> slc = ds.slice(2, 0.0) >>> frb = slc.to_frb((500.0, "kpc"), 500) >>> ds2 = frb.export_dataset( ... fields=[("gas", "density"), ("gas", "temperature")], nprocs=32 ... )
- export_hdf5(filename, fields=None)¶
Export a set of fields to a set of HDF5 datasets.
This function will export any number of fields into datasets in a new HDF5 file.
- Parameters:
filename (string) – This file will be opened in “append” mode.
fields (list of strings) – These fields will be pixelized and output.
- get_image(key, /) ImageArray ¶
- get_mask(key, /) np.ndarray[Any, np.dtype[np.bool_]] | None ¶
Return the boolean array associated with an image with the same key.
Elements set to True indicate pixels that were updated by a pixelisation routine
- keys()¶
- property limits¶
- render(item)¶
- save_as_dataset(filename=None, fields=None)¶
Export a fixed resolution buffer to a reloadable yt dataset.
This function will take a fixed resolution buffer and output a dataset containing either the fields presently existing or fields given in the
fields
list. The resulting dataset can be reloaded as a yt dataset.- Parameters:
filename (str, optional) – The name of the file to be written. If None, the name will be a combination of the original dataset and the type of data container.
fields (list of strings or tuples, optional) – If this is supplied, it is the list of fields to be saved to disk. If not supplied, all the fields that have been queried will be saved.
- Returns:
filename – The name of the file that has been created.
- Return type:
Examples
>>> import yt >>> ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046") >>> proj = ds.proj(("gas", "density"), "x", weight_field=("gas", "density")) >>> frb = proj.to_frb(1.0, (800, 800)) >>> fn = frb.save_as_dataset(fields=[("gas", "density")]) >>> ds2 = yt.load(fn) >>> print(ds2.data["gas", "density"]) [[ 1.25025353e-30 1.25025353e-30 1.25025353e-30 ..., 7.90820691e-31 7.90820691e-31 7.90820691e-31] [ 1.25025353e-30 1.25025353e-30 1.25025353e-30 ..., 7.90820691e-31 7.90820691e-31 7.90820691e-31] [ 1.25025353e-30 1.25025353e-30 1.25025353e-30 ..., 7.90820691e-31 7.90820691e-31 7.90820691e-31] ..., [ 1.55834239e-30 1.55834239e-30 1.55834239e-30 ..., 8.51353199e-31 8.51353199e-31 8.51353199e-31] [ 1.55834239e-30 1.55834239e-30 1.55834239e-30 ..., 8.51353199e-31 8.51353199e-31 8.51353199e-31] [ 1.55834239e-30 1.55834239e-30 1.55834239e-30 ..., 8.51353199e-31 8.51353199e-31 8.51353199e-31]] g/cm**3
- set_unit(field, unit, equivalency=None, equivalency_kwargs=None)¶
Sets a new unit for the requested field
- Parameters:
field (string or field tuple) – The name of the field that is to be changed.
unit (string or Unit object) – The name of the new unit.
equivalency (string, optional) – If set, the equivalency to use to convert the current units to the new requested unit. If None, the unit conversion will be done without an equivalency
equivalency_kwargs (string, optional) – Keyword arguments to be passed to the equivalency. Only used if
equivalency
is set.
- setup_filters()¶
- to_fits_data(fields=None, other_keys=None, length_unit=None, **kwargs)¶
Export the fields in this FixedResolutionBuffer instance to a FITSImageData instance.
This will export a set of FITS images of either the fields specified or all the fields already in the object.
- Parameters:
fields (list of strings) – These fields will be pixelized and output. If “None”, the keys of the FRB will be used.
other_keys (dictionary, optional) – A set of header keys and values to write into the FITS header.
length_unit (string, optional) – the length units that the coordinates are written in. The default is to use the default length unit of the dataset.
- class yt.visualization.fixed_resolution.ParticleImageBuffer(data_source, bounds, buff_size, antialias=True, periodic=False, *, filters=None)[source]¶
Bases:
FixedResolutionBuffer
This object is a subclass of
yt.visualization.fixed_resolution.FixedResolutionBuffer
that supports particle plots. It splats points onto an image buffer.- convert_distance_x(distance)¶
This function converts code-space distance into pixel-space distance in the x-coordinate.
- Parameters:
distance (array_like) – This is x-distance in code-space you would like to convert.
- Returns:
output – The return value is the distance in the y-pixel coordinates.
- Return type:
array_like
- convert_distance_y(distance)¶
This function converts code-space distance into pixel-space distance in the y-coordinate.
- Parameters:
distance (array_like) – This is y-distance in code-space you would like to convert.
- Returns:
output – The return value is the distance in the x-pixel coordinates.
- Return type:
array_like
- convert_to_pixel(coords)¶
This function converts coordinates in code-space to pixel-space.
- Parameters:
coords (sequence of array_like) – This is (x_coord, y_coord). Because of the way the math is done, these can both be arrays.
- Returns:
output – This returns px_coord, py_coord
- Return type:
sequence of array_like
- export_dataset(fields=None, nprocs=1)¶
Export a set of pixelized fields to an in-memory dataset that can be analyzed as any other in yt. Unit information and other parameters (e.g., geometry, current_time, etc.) will be taken from the parent dataset.
- Parameters:
fields (list of strings, optional) – These fields will be pixelized and output. If “None”, the keys of the FRB will be used.
nprocs (integer, optional) – If greater than 1, will create this number of subarrays out of data
Examples
>>> import yt >>> ds = yt.load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150") >>> slc = ds.slice(2, 0.0) >>> frb = slc.to_frb((500.0, "kpc"), 500) >>> ds2 = frb.export_dataset( ... fields=[("gas", "density"), ("gas", "temperature")], nprocs=32 ... )
- export_hdf5(filename, fields=None)¶
Export a set of fields to a set of HDF5 datasets.
This function will export any number of fields into datasets in a new HDF5 file.
- Parameters:
filename (string) – This file will be opened in “append” mode.
fields (list of strings) – These fields will be pixelized and output.
- get_image(key, /) ImageArray ¶
- get_mask(key, /) np.ndarray[Any, np.dtype[np.bool_]] | None ¶
Return the boolean array associated with an image with the same key.
Elements set to True indicate pixels that were updated by a pixelisation routine
- keys()¶
- property limits¶
- render(item)¶
- save_as_dataset(filename=None, fields=None)¶
Export a fixed resolution buffer to a reloadable yt dataset.
This function will take a fixed resolution buffer and output a dataset containing either the fields presently existing or fields given in the
fields
list. The resulting dataset can be reloaded as a yt dataset.- Parameters:
filename (str, optional) – The name of the file to be written. If None, the name will be a combination of the original dataset and the type of data container.
fields (list of strings or tuples, optional) – If this is supplied, it is the list of fields to be saved to disk. If not supplied, all the fields that have been queried will be saved.
- Returns:
filename – The name of the file that has been created.
- Return type:
Examples
>>> import yt >>> ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046") >>> proj = ds.proj(("gas", "density"), "x", weight_field=("gas", "density")) >>> frb = proj.to_frb(1.0, (800, 800)) >>> fn = frb.save_as_dataset(fields=[("gas", "density")]) >>> ds2 = yt.load(fn) >>> print(ds2.data["gas", "density"]) [[ 1.25025353e-30 1.25025353e-30 1.25025353e-30 ..., 7.90820691e-31 7.90820691e-31 7.90820691e-31] [ 1.25025353e-30 1.25025353e-30 1.25025353e-30 ..., 7.90820691e-31 7.90820691e-31 7.90820691e-31] [ 1.25025353e-30 1.25025353e-30 1.25025353e-30 ..., 7.90820691e-31 7.90820691e-31 7.90820691e-31] ..., [ 1.55834239e-30 1.55834239e-30 1.55834239e-30 ..., 8.51353199e-31 8.51353199e-31 8.51353199e-31] [ 1.55834239e-30 1.55834239e-30 1.55834239e-30 ..., 8.51353199e-31 8.51353199e-31 8.51353199e-31] [ 1.55834239e-30 1.55834239e-30 1.55834239e-30 ..., 8.51353199e-31 8.51353199e-31 8.51353199e-31]] g/cm**3
- set_unit(field, unit, equivalency=None, equivalency_kwargs=None)¶
Sets a new unit for the requested field
- Parameters:
field (string or field tuple) – The name of the field that is to be changed.
unit (string or Unit object) – The name of the new unit.
equivalency (string, optional) – If set, the equivalency to use to convert the current units to the new requested unit. If None, the unit conversion will be done without an equivalency
equivalency_kwargs (string, optional) – Keyword arguments to be passed to the equivalency. Only used if
equivalency
is set.
- setup_filters()¶
- to_fits_data(fields=None, other_keys=None, length_unit=None, **kwargs)¶
Export the fields in this FixedResolutionBuffer instance to a FITSImageData instance.
This will export a set of FITS images of either the fields specified or all the fields already in the object.
- Parameters:
fields (list of strings) – These fields will be pixelized and output. If “None”, the keys of the FRB will be used.
other_keys (dictionary, optional) – A set of header keys and values to write into the FITS header.
length_unit (string, optional) – the length units that the coordinates are written in. The default is to use the default length unit of the dataset.