yt.visualization.fixed_resolution module

Fixed resolution buffer support, along with a primitive image analysis tool.

class yt.visualization.fixed_resolution.CylindricalFixedResolutionBuffer(data_source, radius, buff_size, antialias=True)[source]

Bases: yt.visualization.fixed_resolution.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-coordiante.

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

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.,"kpc"), 500)
>>> ds2 = frb.export_dataset(fields=["density","temperature"], nprocs=32)
export_fits(filename, fields=None, clobber=False, other_keys=None, units='cm')

Export a set of pixelized fields to a FITS file.

This will export a set of FITS images of either the fields specified or all the fields already in the object.

Parameters:
  • filename (string) – The name of the FITS file to be written.
  • fields (list of strings) – These fields will be pixelized and output. If “None”, the keys of the FRB will be used.
  • clobber (boolean) – If the file exists, this governs whether we will overwrite.
  • other_keys (dictionary, optional) – A set of header keys and values to write into the FITS header.
  • units (string, optional) – the length units that the coordinates are written in, default ‘cm’.
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.
keys()
limits
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:

str

Examples

>>> import yt
>>> ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
>>> proj = ds.proj("density", "x", weight_field="density")
>>> frb = proj.to_frb(1.0, (800, 800))
>>> fn = frb.save_as_dataset(fields=["density"])
>>> ds2 = yt.load(fn)
>>> print (ds2.data["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 equivelancy
  • equivalency_kwargs (string, optional) – Keyword arguments to be passed to the equivalency. Only used if equivalency is set.
setup_filters()
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 or yt.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.

Examples

To make a projection and then several images, you can generate a single FRB and then access multiple fields:

>>> proj = ds.proj(0, "density")
>>> frb1 = FixedResolutionBuffer(proj, (0.2, 0.3, 0.4, 0.5),
...                              (1024, 1024))
>>> print frb1["density"].max()
1.0914e-9 g/cm**3
>>> print frb1["temperature"].max()
104923.1 K
convert_distance_x(distance)[source]

This function converts code-space distance into pixel-space distance in the x-coordiante.

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

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.,"kpc"), 500)
>>> ds2 = frb.export_dataset(fields=["density","temperature"], nprocs=32)
export_fits(filename, fields=None, clobber=False, other_keys=None, units='cm')[source]

Export a set of pixelized fields to a FITS file.

This will export a set of FITS images of either the fields specified or all the fields already in the object.

Parameters:
  • filename (string) – The name of the FITS file to be written.
  • fields (list of strings) – These fields will be pixelized and output. If “None”, the keys of the FRB will be used.
  • clobber (boolean) – If the file exists, this governs whether we will overwrite.
  • other_keys (dictionary, optional) – A set of header keys and values to write into the FITS header.
  • units (string, optional) – the length units that the coordinates are written in, default ‘cm’.
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.
keys()[source]
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:

str

Examples

>>> import yt
>>> ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
>>> proj = ds.proj("density", "x", weight_field="density")
>>> frb = proj.to_frb(1.0, (800, 800))
>>> fn = frb.save_as_dataset(fields=["density"])
>>> ds2 = yt.load(fn)
>>> print (ds2.data["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 equivelancy
  • equivalency_kwargs (string, optional) – Keyword arguments to be passed to the equivalency. Only used if equivalency is set.
setup_filters()[source]
class yt.visualization.fixed_resolution.ObliqueFixedResolutionBuffer(*args, **kwargs)[source]

Bases: yt.visualization.fixed_resolution.FixedResolutionBuffer

convert_distance_x(distance)

This function converts code-space distance into pixel-space distance in the x-coordiante.

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

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.,"kpc"), 500)
>>> ds2 = frb.export_dataset(fields=["density","temperature"], nprocs=32)
export_fits(filename, fields=None, clobber=False, other_keys=None, units='cm')

Export a set of pixelized fields to a FITS file.

This will export a set of FITS images of either the fields specified or all the fields already in the object.

Parameters:
  • filename (string) – The name of the FITS file to be written.
  • fields (list of strings) – These fields will be pixelized and output. If “None”, the keys of the FRB will be used.
  • clobber (boolean) – If the file exists, this governs whether we will overwrite.
  • other_keys (dictionary, optional) – A set of header keys and values to write into the FITS header.
  • units (string, optional) – the length units that the coordinates are written in, default ‘cm’.
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.
keys()
limits
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:

str

Examples

>>> import yt
>>> ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
>>> proj = ds.proj("density", "x", weight_field="density")
>>> frb = proj.to_frb(1.0, (800, 800))
>>> fn = frb.save_as_dataset(fields=["density"])
>>> ds2 = yt.load(fn)
>>> print (ds2.data["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 equivelancy
  • equivalency_kwargs (string, optional) – Keyword arguments to be passed to the equivalency. Only used if equivalency is set.
setup_filters()
class yt.visualization.fixed_resolution.OffAxisProjectionFixedResolutionBuffer(data_source, bounds, buff_size, antialias=True, periodic=False)[source]

Bases: yt.visualization.fixed_resolution.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-coordiante.

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

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.,"kpc"), 500)
>>> ds2 = frb.export_dataset(fields=["density","temperature"], nprocs=32)
export_fits(filename, fields=None, clobber=False, other_keys=None, units='cm')

Export a set of pixelized fields to a FITS file.

This will export a set of FITS images of either the fields specified or all the fields already in the object.

Parameters:
  • filename (string) – The name of the FITS file to be written.
  • fields (list of strings) – These fields will be pixelized and output. If “None”, the keys of the FRB will be used.
  • clobber (boolean) – If the file exists, this governs whether we will overwrite.
  • other_keys (dictionary, optional) – A set of header keys and values to write into the FITS header.
  • units (string, optional) – the length units that the coordinates are written in, default ‘cm’.
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.
keys()
limits
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:

str

Examples

>>> import yt
>>> ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
>>> proj = ds.proj("density", "x", weight_field="density")
>>> frb = proj.to_frb(1.0, (800, 800))
>>> fn = frb.save_as_dataset(fields=["density"])
>>> ds2 = yt.load(fn)
>>> print (ds2.data["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 equivelancy
  • equivalency_kwargs (string, optional) – Keyword arguments to be passed to the equivalency. Only used if equivalency is set.
setup_filters()
class yt.visualization.fixed_resolution.ParticleImageBuffer(data_source, bounds, buff_size, antialias=True, periodic=False)[source]

Bases: yt.visualization.fixed_resolution.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-coordiante.

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

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.,"kpc"), 500)
>>> ds2 = frb.export_dataset(fields=["density","temperature"], nprocs=32)
export_fits(filename, fields=None, clobber=False, other_keys=None, units='cm')

Export a set of pixelized fields to a FITS file.

This will export a set of FITS images of either the fields specified or all the fields already in the object.

Parameters:
  • filename (string) – The name of the FITS file to be written.
  • fields (list of strings) – These fields will be pixelized and output. If “None”, the keys of the FRB will be used.
  • clobber (boolean) – If the file exists, this governs whether we will overwrite.
  • other_keys (dictionary, optional) – A set of header keys and values to write into the FITS header.
  • units (string, optional) – the length units that the coordinates are written in, default ‘cm’.
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.
keys()
limits
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:

str

Examples

>>> import yt
>>> ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
>>> proj = ds.proj("density", "x", weight_field="density")
>>> frb = proj.to_frb(1.0, (800, 800))
>>> fn = frb.save_as_dataset(fields=["density"])
>>> ds2 = yt.load(fn)
>>> print (ds2.data["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 equivelancy
  • equivalency_kwargs (string, optional) – Keyword arguments to be passed to the equivalency. Only used if equivalency is set.
setup_filters()