yt.data_objects.profiles module

Profile classes, to deal with generating and obtaining profiles

class yt.data_objects.profiles.ParticleProfile(data_source, x_field, x_n, x_min, x_max, x_log, y_field, y_n, y_min, y_max, y_log, weight_field=None, deposition='ngp')[source]

Bases: yt.data_objects.profiles.Profile2D

An object that represents a deposited 2D profile. This is like a Profile2D, except that it is intended for particle data. Instead of just binning the particles, the added fields will be deposited onto the mesh using either the nearest-grid-point or cloud-in-cell interpolation kernels.

Parameters:
  • data_source (AMD3DData object) – The data object to be profiled
  • x_field (string field name) – The field to profile as a function of along the x axis.
  • x_n (integer) – The number of bins along the x direction.
  • x_min (float) – The minimum value of the x profile field. If supplied without units, assumed to be in the output units for x_field.
  • x_max (float) – The maximum value of the x profile field. If supplied without units, assumed to be in the output units for x_field.
  • y_field (string field name) – The field to profile as a function of along the y axis
  • y_n (integer) – The number of bins along the y direction.
  • y_min (float) – The minimum value of the y profile field. If supplied without units, assumed to be in the output units for y_field.
  • y_max (float) – The maximum value of the y profile field. If supplied without units, assumed to be in the output units for y_field.
  • weight_field (string field name) – The field to use for weighting. Default is None.
  • deposition (string, optional) – The interpolation kernal to be used for deposition. Valid choices: “ngp” : nearest grid point interpolation “cic” : cloud-in-cell interpolation
accumulation = False
add_fields(fields)

Add fields to profile

Parameters:fields (list of field names) – A list of fields to create profile histograms for
bounds
comm = None
fractional = False
get_dependencies(fields)
items()
keys()
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

plot()

This returns a :class:~yt.visualization.profile_plotter.PhasePlot with the fields that have been added to this object.

save_as_dataset(filename=None)

Export a profile to a reloadable yt dataset.

This function will take a profile and output a dataset containing all relevant fields. 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 plus the type of object, e.g., Profile1D.
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")
>>> ad = ds.all_data()
>>> profile = yt.create_profile(ad, ["density", "temperature"],
...                            "cell_mass", weight_field=None,
...                             n_bins=(128, 128))
>>> fn = profile.save_as_dataset()
>>> prof_ds = yt.load(fn)
>>> print (prof_ds.data["cell_mass"])
(128, 128)
>>> print (prof_ds.data["x"].shape) # x bins as 1D array
(128,)
>>> print (prof_ds.data["density"]) # x bins as 2D array
(128, 128)
>>> p = yt.PhasePlot(prof_ds.data, "density", "temperature",
...                  "cell_mass", weight_field=None)
>>> p.save()
set_field_unit(field, new_unit)

Sets a new unit for the requested field

Parameters:
  • field (string or field tuple) – The name of the field that is to be changed.
  • new_unit (string or Unit object) – The name of the new unit.
set_x_unit(new_unit)

Sets a new unit for the x field

Parameters:new_unit (string or Unit object) – The name of the new unit.
set_y_unit(new_unit)

Sets a new unit for the y field

Parameters:new_unit (string or Unit object) – The name of the new unit.
variance
class yt.data_objects.profiles.Profile1D(data_source, x_field, x_n, x_min, x_max, x_log, weight_field=None)[source]

Bases: yt.data_objects.profiles.ProfileND

An object that represents a 1D profile.

Parameters:
  • data_source (AMD3DData object) – The data object to be profiled
  • x_field (string field name) – The field to profile as a function of
  • x_n (integer) – The number of bins along the x direction.
  • x_min (float) – The minimum value of the x profile field. If supplied without units, assumed to be in the output units for x_field.
  • x_max (float) – The maximum value of the x profile field. If supplied without units, assumed to be in the output units for x_field.
  • x_log (boolean) – Controls whether or not the bins for the x field are evenly spaced in linear (False) or log (True) space.
  • weight_field (string field name) – The field to weight the profiled fields by.
add_fields(fields)

Add fields to profile

Parameters:fields (list of field names) – A list of fields to create profile histograms for
bounds
comm = None
get_dependencies(fields)
items()
keys()
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

plot()[source]

This returns a :class:~yt.visualization.profile_plotter.ProfilePlot with the fields that have been added to this object.

save_as_dataset(filename=None)

Export a profile to a reloadable yt dataset.

This function will take a profile and output a dataset containing all relevant fields. 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 plus the type of object, e.g., Profile1D.
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")
>>> ad = ds.all_data()
>>> profile = yt.create_profile(ad, ["density", "temperature"],
...                            "cell_mass", weight_field=None,
...                             n_bins=(128, 128))
>>> fn = profile.save_as_dataset()
>>> prof_ds = yt.load(fn)
>>> print (prof_ds.data["cell_mass"])
(128, 128)
>>> print (prof_ds.data["x"].shape) # x bins as 1D array
(128,)
>>> print (prof_ds.data["density"]) # x bins as 2D array
(128, 128)
>>> p = yt.PhasePlot(prof_ds.data, "density", "temperature",
...                  "cell_mass", weight_field=None)
>>> p.save()
set_field_unit(field, new_unit)

Sets a new unit for the requested field

Parameters:
  • field (string or field tuple) – The name of the field that is to be changed.
  • new_unit (string or Unit object) – The name of the new unit.
set_x_unit(new_unit)[source]

Sets a new unit for the x field

Parameters:new_unit (string or Unit object) – The name of the new unit.
variance
class yt.data_objects.profiles.Profile1DFromDataset(ds)[source]

Bases: yt.data_objects.profiles.ProfileNDFromDataset, yt.data_objects.profiles.Profile1D

A 1D profile object loaded from a ytdata dataset.

add_fields(fields)

Add fields to profile

Parameters:fields (list of field names) – A list of fields to create profile histograms for
bounds
comm = None
get_dependencies(fields)
items()
keys()
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

plot()

This returns a :class:~yt.visualization.profile_plotter.ProfilePlot with the fields that have been added to this object.

save_as_dataset(filename=None)

Export a profile to a reloadable yt dataset.

This function will take a profile and output a dataset containing all relevant fields. 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 plus the type of object, e.g., Profile1D.
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")
>>> ad = ds.all_data()
>>> profile = yt.create_profile(ad, ["density", "temperature"],
...                            "cell_mass", weight_field=None,
...                             n_bins=(128, 128))
>>> fn = profile.save_as_dataset()
>>> prof_ds = yt.load(fn)
>>> print (prof_ds.data["cell_mass"])
(128, 128)
>>> print (prof_ds.data["x"].shape) # x bins as 1D array
(128,)
>>> print (prof_ds.data["density"]) # x bins as 2D array
(128, 128)
>>> p = yt.PhasePlot(prof_ds.data, "density", "temperature",
...                  "cell_mass", weight_field=None)
>>> p.save()
set_field_unit(field, new_unit)

Sets a new unit for the requested field

Parameters:
  • field (string or field tuple) – The name of the field that is to be changed.
  • new_unit (string or Unit object) – The name of the new unit.
set_x_unit(new_unit)

Sets a new unit for the x field

Parameters:new_unit (string or Unit object) – The name of the new unit.
variance
class yt.data_objects.profiles.Profile2D(data_source, x_field, x_n, x_min, x_max, x_log, y_field, y_n, y_min, y_max, y_log, weight_field=None)[source]

Bases: yt.data_objects.profiles.ProfileND

An object that represents a 2D profile.

Parameters:
  • data_source (AMD3DData object) – The data object to be profiled
  • x_field (string field name) – The field to profile as a function of along the x axis.
  • x_n (integer) – The number of bins along the x direction.
  • x_min (float) – The minimum value of the x profile field. If supplied without units, assumed to be in the output units for x_field.
  • x_max (float) – The maximum value of the x profile field. If supplied without units, assumed to be in the output units for x_field.
  • x_log (boolean) – Controls whether or not the bins for the x field are evenly spaced in linear (False) or log (True) space.
  • y_field (string field name) – The field to profile as a function of along the y axis
  • y_n (integer) – The number of bins along the y direction.
  • y_min (float) – The minimum value of the y profile field. If supplied without units, assumed to be in the output units for y_field.
  • y_max (float) – The maximum value of the y profile field. If supplied without units, assumed to be in the output units for y_field.
  • y_log (boolean) – Controls whether or not the bins for the y field are evenly spaced in linear (False) or log (True) space.
  • weight_field (string field name) – The field to weight the profiled fields by.
add_fields(fields)

Add fields to profile

Parameters:fields (list of field names) – A list of fields to create profile histograms for
bounds
comm = None
get_dependencies(fields)
items()
keys()
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

plot()[source]

This returns a :class:~yt.visualization.profile_plotter.PhasePlot with the fields that have been added to this object.

save_as_dataset(filename=None)

Export a profile to a reloadable yt dataset.

This function will take a profile and output a dataset containing all relevant fields. 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 plus the type of object, e.g., Profile1D.
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")
>>> ad = ds.all_data()
>>> profile = yt.create_profile(ad, ["density", "temperature"],
...                            "cell_mass", weight_field=None,
...                             n_bins=(128, 128))
>>> fn = profile.save_as_dataset()
>>> prof_ds = yt.load(fn)
>>> print (prof_ds.data["cell_mass"])
(128, 128)
>>> print (prof_ds.data["x"].shape) # x bins as 1D array
(128,)
>>> print (prof_ds.data["density"]) # x bins as 2D array
(128, 128)
>>> p = yt.PhasePlot(prof_ds.data, "density", "temperature",
...                  "cell_mass", weight_field=None)
>>> p.save()
set_field_unit(field, new_unit)

Sets a new unit for the requested field

Parameters:
  • field (string or field tuple) – The name of the field that is to be changed.
  • new_unit (string or Unit object) – The name of the new unit.
set_x_unit(new_unit)[source]

Sets a new unit for the x field

Parameters:new_unit (string or Unit object) – The name of the new unit.
set_y_unit(new_unit)[source]

Sets a new unit for the y field

Parameters:new_unit (string or Unit object) – The name of the new unit.
variance
class yt.data_objects.profiles.Profile2DFromDataset(ds)[source]

Bases: yt.data_objects.profiles.ProfileNDFromDataset, yt.data_objects.profiles.Profile2D

A 2D profile object loaded from a ytdata dataset.

add_fields(fields)

Add fields to profile

Parameters:fields (list of field names) – A list of fields to create profile histograms for
bounds
comm = None
get_dependencies(fields)
items()
keys()
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

plot()

This returns a :class:~yt.visualization.profile_plotter.PhasePlot with the fields that have been added to this object.

save_as_dataset(filename=None)

Export a profile to a reloadable yt dataset.

This function will take a profile and output a dataset containing all relevant fields. 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 plus the type of object, e.g., Profile1D.
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")
>>> ad = ds.all_data()
>>> profile = yt.create_profile(ad, ["density", "temperature"],
...                            "cell_mass", weight_field=None,
...                             n_bins=(128, 128))
>>> fn = profile.save_as_dataset()
>>> prof_ds = yt.load(fn)
>>> print (prof_ds.data["cell_mass"])
(128, 128)
>>> print (prof_ds.data["x"].shape) # x bins as 1D array
(128,)
>>> print (prof_ds.data["density"]) # x bins as 2D array
(128, 128)
>>> p = yt.PhasePlot(prof_ds.data, "density", "temperature",
...                  "cell_mass", weight_field=None)
>>> p.save()
set_field_unit(field, new_unit)

Sets a new unit for the requested field

Parameters:
  • field (string or field tuple) – The name of the field that is to be changed.
  • new_unit (string or Unit object) – The name of the new unit.
set_x_unit(new_unit)

Sets a new unit for the x field

Parameters:new_unit (string or Unit object) – The name of the new unit.
set_y_unit(new_unit)

Sets a new unit for the y field

Parameters:new_unit (string or Unit object) – The name of the new unit.
variance
class yt.data_objects.profiles.Profile3D(data_source, x_field, x_n, x_min, x_max, x_log, y_field, y_n, y_min, y_max, y_log, z_field, z_n, z_min, z_max, z_log, weight_field=None)[source]

Bases: yt.data_objects.profiles.ProfileND

An object that represents a 2D profile.

Parameters:
  • data_source (AMD3DData object) – The data object to be profiled
  • x_field (string field name) – The field to profile as a function of along the x axis.
  • x_n (integer) – The number of bins along the x direction.
  • x_min (float) – The minimum value of the x profile field. If supplied without units, assumed to be in the output units for x_field.
  • x_max (float) – The maximum value of the x profile field. If supplied without units, assumed to be in the output units for x_field.
  • x_log (boolean) – Controls whether or not the bins for the x field are evenly spaced in linear (False) or log (True) space.
  • y_field (string field name) – The field to profile as a function of along the y axis
  • y_n (integer) – The number of bins along the y direction.
  • y_min (float) – The minimum value of the y profile field. If supplied without units, assumed to be in the output units for y_field.
  • y_max (float) – The maximum value of the y profile field. If supplied without units, assumed to be in the output units for y_field.
  • y_log (boolean) – Controls whether or not the bins for the y field are evenly spaced in linear (False) or log (True) space.
  • z_field (string field name) – The field to profile as a function of along the z axis
  • z_n (integer) – The number of bins along the z direction.
  • z_min (float) – The minimum value of the z profile field. If supplied without units, assumed to be in the output units for z_field.
  • z_max (float) – The maximum value of thee z profile field. If supplied without units, assumed to be in the output units for z_field.
  • z_log (boolean) – Controls whether or not the bins for the z field are evenly spaced in linear (False) or log (True) space.
  • weight_field (string field name) – The field to weight the profiled fields by.
add_fields(fields)

Add fields to profile

Parameters:fields (list of field names) – A list of fields to create profile histograms for
bounds
comm = None
get_dependencies(fields)
items()
keys()
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

save_as_dataset(filename=None)

Export a profile to a reloadable yt dataset.

This function will take a profile and output a dataset containing all relevant fields. 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 plus the type of object, e.g., Profile1D.
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")
>>> ad = ds.all_data()
>>> profile = yt.create_profile(ad, ["density", "temperature"],
...                            "cell_mass", weight_field=None,
...                             n_bins=(128, 128))
>>> fn = profile.save_as_dataset()
>>> prof_ds = yt.load(fn)
>>> print (prof_ds.data["cell_mass"])
(128, 128)
>>> print (prof_ds.data["x"].shape) # x bins as 1D array
(128,)
>>> print (prof_ds.data["density"]) # x bins as 2D array
(128, 128)
>>> p = yt.PhasePlot(prof_ds.data, "density", "temperature",
...                  "cell_mass", weight_field=None)
>>> p.save()
set_field_unit(field, new_unit)

Sets a new unit for the requested field

Parameters:
  • field (string or field tuple) – The name of the field that is to be changed.
  • new_unit (string or Unit object) – The name of the new unit.
set_x_unit(new_unit)[source]

Sets a new unit for the x field

Parameters:new_unit (string or Unit object) – The name of the new unit.
set_y_unit(new_unit)[source]

Sets a new unit for the y field

Parameters:new_unit (string or Unit object) – The name of the new unit.
set_z_unit(new_unit)[source]

Sets a new unit for the z field

Parameters:new_unit (string or Unit object) – The name of the new unit.
variance
class yt.data_objects.profiles.Profile3DFromDataset(ds)[source]

Bases: yt.data_objects.profiles.ProfileNDFromDataset, yt.data_objects.profiles.Profile3D

A 2D profile object loaded from a ytdata dataset.

add_fields(fields)

Add fields to profile

Parameters:fields (list of field names) – A list of fields to create profile histograms for
bounds
comm = None
get_dependencies(fields)
items()
keys()
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

save_as_dataset(filename=None)

Export a profile to a reloadable yt dataset.

This function will take a profile and output a dataset containing all relevant fields. 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 plus the type of object, e.g., Profile1D.
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")
>>> ad = ds.all_data()
>>> profile = yt.create_profile(ad, ["density", "temperature"],
...                            "cell_mass", weight_field=None,
...                             n_bins=(128, 128))
>>> fn = profile.save_as_dataset()
>>> prof_ds = yt.load(fn)
>>> print (prof_ds.data["cell_mass"])
(128, 128)
>>> print (prof_ds.data["x"].shape) # x bins as 1D array
(128,)
>>> print (prof_ds.data["density"]) # x bins as 2D array
(128, 128)
>>> p = yt.PhasePlot(prof_ds.data, "density", "temperature",
...                  "cell_mass", weight_field=None)
>>> p.save()
set_field_unit(field, new_unit)

Sets a new unit for the requested field

Parameters:
  • field (string or field tuple) – The name of the field that is to be changed.
  • new_unit (string or Unit object) – The name of the new unit.
set_x_unit(new_unit)

Sets a new unit for the x field

Parameters:new_unit (string or Unit object) – The name of the new unit.
set_y_unit(new_unit)

Sets a new unit for the y field

Parameters:new_unit (string or Unit object) – The name of the new unit.
set_z_unit(new_unit)

Sets a new unit for the z field

Parameters:new_unit (string or Unit object) – The name of the new unit.
variance
class yt.data_objects.profiles.ProfileFieldAccumulator(n_fields, size)[source]

Bases: object

class yt.data_objects.profiles.ProfileND(data_source, weight_field=None)[source]

Bases: yt.utilities.parallel_tools.parallel_analysis_interface.ParallelAnalysisInterface

The profile object class

add_fields(fields)[source]

Add fields to profile

Parameters:fields (list of field names) – A list of fields to create profile histograms for
comm = None
get_dependencies(fields)
items()[source]
keys()[source]
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

save_as_dataset(filename=None)[source]

Export a profile to a reloadable yt dataset.

This function will take a profile and output a dataset containing all relevant fields. 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 plus the type of object, e.g., Profile1D.
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")
>>> ad = ds.all_data()
>>> profile = yt.create_profile(ad, ["density", "temperature"],
...                            "cell_mass", weight_field=None,
...                             n_bins=(128, 128))
>>> fn = profile.save_as_dataset()
>>> prof_ds = yt.load(fn)
>>> print (prof_ds.data["cell_mass"])
(128, 128)
>>> print (prof_ds.data["x"].shape) # x bins as 1D array
(128,)
>>> print (prof_ds.data["density"]) # x bins as 2D array
(128, 128)
>>> p = yt.PhasePlot(prof_ds.data, "density", "temperature",
...                  "cell_mass", weight_field=None)
>>> p.save()
set_field_unit(field, new_unit)[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.
  • new_unit (string or Unit object) – The name of the new unit.
variance
class yt.data_objects.profiles.ProfileNDFromDataset(ds)[source]

Bases: yt.data_objects.profiles.ProfileND

An ND profile object loaded from a ytdata dataset.

add_fields(fields)

Add fields to profile

Parameters:fields (list of field names) – A list of fields to create profile histograms for
comm = None
get_dependencies(fields)
items()
keys()
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

save_as_dataset(filename=None)

Export a profile to a reloadable yt dataset.

This function will take a profile and output a dataset containing all relevant fields. 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 plus the type of object, e.g., Profile1D.
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")
>>> ad = ds.all_data()
>>> profile = yt.create_profile(ad, ["density", "temperature"],
...                            "cell_mass", weight_field=None,
...                             n_bins=(128, 128))
>>> fn = profile.save_as_dataset()
>>> prof_ds = yt.load(fn)
>>> print (prof_ds.data["cell_mass"])
(128, 128)
>>> print (prof_ds.data["x"].shape) # x bins as 1D array
(128,)
>>> print (prof_ds.data["density"]) # x bins as 2D array
(128, 128)
>>> p = yt.PhasePlot(prof_ds.data, "density", "temperature",
...                  "cell_mass", weight_field=None)
>>> p.save()
set_field_unit(field, new_unit)

Sets a new unit for the requested field

Parameters:
  • field (string or field tuple) – The name of the field that is to be changed.
  • new_unit (string or Unit object) – The name of the new unit.
variance
yt.data_objects.profiles.create_profile(data_source, bin_fields, fields, n_bins=64, extrema=None, logs=None, units=None, weight_field='cell_mass', accumulation=False, fractional=False, deposition='ngp')[source]

Create a 1, 2, or 3D profile object.

The dimensionality of the profile object is chosen by the number of fields given in the bin_fields argument.

Parameters:
  • data_source (YTSelectionContainer Object) – The data object to be profiled.
  • bin_fields (list of strings) – List of the binning fields for profiling.
  • fields (list of strings) – The fields to be profiled.
  • n_bins (int or list of ints) – The number of bins in each dimension. If None, 64 bins for each bin are used for each bin field. Default: 64.
  • extrema (dict of min, max tuples) – Minimum and maximum values of the bin_fields for the profiles. The keys correspond to the field names. Defaults to the extrema of the bin_fields of the dataset. If a units dict is provided, extrema are understood to be in the units specified in the dictionary.
  • logs (dict of boolean values) – Whether or not to log the bin_fields for the profiles. The keys correspond to the field names. Defaults to the take_log attribute of the field.
  • units (dict of strings) – The units of the fields in the profiles, including the bin_fields.
  • weight_field (str or tuple field identifier) – The weight field for computing weighted average for the profile values. If None, the profile values are sums of the data in each bin.
  • accumulation (bool or list of bools) – If True, the profile values for a bin n are the cumulative sum of all the values from bin 0 to n. If -True, the sum is reversed so that the value for bin n is the cumulative sum from bin N (total bins) to n. If the profile is 2D or 3D, a list of values can be given to control the summation in each dimension independently. Default: False.
  • fractional (bool) – If True the profile values are divided by the sum of all the profile data such that the profile represents a probability distribution function.
  • deposition (strings) – Controls the type of deposition used for ParticlePhasePlots. Valid choices are ‘ngp’ and ‘cic’. Default is ‘ngp’. This parameter is ignored the if the input fields are not of particle type.

Examples

Create a 1d profile. Access bin field from profile.x and field data from profile[<field_name>].

>>> ds = load("DD0046/DD0046")
>>> ad = ds.all_data()
>>> profile = create_profile(ad, [("gas", "density")],
...                              [("gas", "temperature"),
...                               ("gas", "velocity_x")])
>>> print (profile.x)
>>> print (profile["gas", "temperature"])
yt.data_objects.profiles.preserve_source_parameters(func)[source]
yt.data_objects.profiles.sanitize_field_tuple_keys(input_dict, data_source)[source]