yt.data_objects.time_series module

class yt.data_objects.time_series.AnalysisTaskProxy(time_series)[source]

Bases: object

keys()[source]
class yt.data_objects.time_series.DatasetSeries(outputs, *args, **kwargs)[source]

Bases: object

The DatasetSeries object is a container of multiple datasets, allowing easy iteration and computation on them.

DatasetSeries objects are designed to provide easy ways to access, analyze, parallelize and visualize multiple datasets sequentially. This is primarily expressed through iteration, but can also be constructed via analysis tasks (see Time Series Analysis).

Note that contained datasets are lazily loaded and weakly referenced. This means that in order to perform follow-up operations on data it’s best to define handles on these datasets during iteration.

Parameters:
  • outputs (list of filenames, or pattern) – A list of filenames, for instance [“DD0001/DD0001”, “DD0002/DD0002”], or a glob pattern (i.e. containing wildcards ‘[]?!*’) such as “DD*/DD*.index”. In the latter case, results are sorted automatically. Filenames and patterns can be of type str, os.Pathlike or bytes.

  • parallel (True, False or int) – This parameter governs the behavior when .piter() is called on the resultant DatasetSeries object. If this is set to False, the time series will not iterate in parallel when .piter() is called. If this is set to either True, one processor will be allocated for each iteration of the loop. If this is set to an integer, the loop will be parallelized over this many workgroups. It the integer value is less than the total number of available processors, more than one processor will be allocated to a given loop iteration, causing the functionality within the loop to be run in parallel.

  • setup_function (callable, accepts a ds) – This function will be called whenever a dataset is loaded.

  • mixed_dataset_types (True or False, default False) – Set to True if the DatasetSeries will load different dataset types, set to False if loading dataset of a single type as this will result in a considerable speed up from not having to figure out the dataset type.

Examples

>>> ts = DatasetSeries(
...     "GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0[0-6][0-9]0"
... )
>>> for ds in ts:
...     SlicePlot(ds, "x", ("gas", "density")).save()
...
>>> def print_time(ds):
...     print(ds.current_time)
...
>>> ts = DatasetSeries(
...     "GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0[0-6][0-9]0",
...     setup_function=print_time,
... )
...
>>> for ds in ts:
...     SlicePlot(ds, "x", ("gas", "density")).save()
eval(tasks, obj=None)[source]
classmethod from_output_log(output_log, line_prefix='DATASET WRITTEN', parallel=True)[source]
property outputs
particle_trajectories(indices, fields=None, suppress_logging=False, ptype=None)[source]

Create a collection of particle trajectories in time over a series of datasets.

Parameters:
  • indices (array_like) – An integer array of particle indices whose trajectories we want to track. If they are not sorted they will be sorted.

  • fields (list of strings, optional) – A set of fields that is retrieved when the trajectory collection is instantiated. Default: None (will default to the fields ‘particle_position_x’, ‘particle_position_y’, ‘particle_position_z’)

  • suppress_logging (boolean) – Suppress yt’s logging when iterating over the simulation time series. Default: False

  • ptype (str, optional) – Only use this particle type. Default: None, which uses all particle type.

Examples

>>> my_fns = glob.glob("orbit_hdf5_chk_00[0-9][0-9]")
>>> my_fns.sort()
>>> fields = [
...     ("all", "particle_position_x"),
...     ("all", "particle_position_y"),
...     ("all", "particle_position_z"),
...     ("all", "particle_velocity_x"),
...     ("all", "particle_velocity_y"),
...     ("all", "particle_velocity_z"),
... ]
>>> ds = load(my_fns[0])
>>> init_sphere = ds.sphere(ds.domain_center, (0.5, "unitary"))
>>> indices = init_sphere[("all", "particle_index")].astype("int64")
>>> ts = DatasetSeries(my_fns)
>>> trajs = ts.particle_trajectories(indices, fields=fields)
>>> for t in trajs:
...     print(
...         t[("all", "particle_velocity_x")].max(),
...         t[("all", "particle_velocity_x")].min(),
...     )

Notes

This function will fail if there are duplicate particle ids or if some of the particle disappear.

piter(storage=None, dynamic=False)[source]

Iterate over time series components in parallel.

This allows you to iterate over a time series while dispatching individual components of that time series to different processors or processor groups. If the parallelism strategy was set to be multi-processor (by “parallel = N” where N is an integer when the DatasetSeries was created) this will issue each dataset to an N-processor group. For instance, this would allow you to start a 1024 processor job, loading up 100 datasets in a time series and creating 8 processor groups of 128 processors each, each of which would be assigned a different dataset. This could be accomplished as shown in the examples below. The storage option is as seen in parallel_objects() which is a mechanism for storing results of analysis on an individual dataset and then combining the results at the end, so that the entire set of processors have access to those results.

Note that supplying a store changes the iteration mechanism; see below.

Parameters:
  • storage (dict) – This is a dictionary, which will be filled with results during the course of the iteration. The keys will be the dataset indices and the values will be whatever is assigned to the result attribute on the storage during iteration.

  • dynamic (boolean) – This governs whether or not dynamic load balancing will be enabled. This requires one dedicated processor; if this is enabled with a set of 128 processors available, only 127 will be available to iterate over objects as one will be load balancing the rest.

Examples

Here is an example of iteration when the results do not need to be stored. One processor will be assigned to each dataset.

>>> ts = DatasetSeries("DD*/DD*.index")
>>> for ds in ts.piter():
...     SlicePlot(ds, "x", ("gas", "density")).save()
...

This demonstrates how one might store results:

>>> def print_time(ds):
...     print(ds.current_time)
...
>>> ts = DatasetSeries("DD*/DD*.index", setup_function=print_time)
...
>>> my_storage = {}
>>> for sto, ds in ts.piter(storage=my_storage):
...     v, c = ds.find_max(("gas", "density"))
...     sto.result = (v, c)
...
>>> for i, (v, c) in sorted(my_storage.items()):
...     print("% 4i  %0.3e" % (i, v))
...

This shows how to dispatch 4 processors to each dataset:

>>> ts = DatasetSeries("DD*/DD*.index", parallel=4)
>>> for ds in ts.piter():
...     ProjectionPlot(ds, "x", ("gas", "density")).save()
...
class yt.data_objects.time_series.DatasetSeriesObject(time_series, data_object_name, *args, **kwargs)[source]

Bases: object

eval(tasks)[source]
get(ds)[source]
class yt.data_objects.time_series.SimulationTimeSeries(outputs, *args, **kwargs)[source]

Bases: DatasetSeries, ABC

property arr
eval(tasks, obj=None)
classmethod from_output_log(output_log, line_prefix='DATASET WRITTEN', parallel=True)
property outputs
particle_trajectories(indices, fields=None, suppress_logging=False, ptype=None)

Create a collection of particle trajectories in time over a series of datasets.

Parameters:
  • indices (array_like) – An integer array of particle indices whose trajectories we want to track. If they are not sorted they will be sorted.

  • fields (list of strings, optional) – A set of fields that is retrieved when the trajectory collection is instantiated. Default: None (will default to the fields ‘particle_position_x’, ‘particle_position_y’, ‘particle_position_z’)

  • suppress_logging (boolean) – Suppress yt’s logging when iterating over the simulation time series. Default: False

  • ptype (str, optional) – Only use this particle type. Default: None, which uses all particle type.

Examples

>>> my_fns = glob.glob("orbit_hdf5_chk_00[0-9][0-9]")
>>> my_fns.sort()
>>> fields = [
...     ("all", "particle_position_x"),
...     ("all", "particle_position_y"),
...     ("all", "particle_position_z"),
...     ("all", "particle_velocity_x"),
...     ("all", "particle_velocity_y"),
...     ("all", "particle_velocity_z"),
... ]
>>> ds = load(my_fns[0])
>>> init_sphere = ds.sphere(ds.domain_center, (0.5, "unitary"))
>>> indices = init_sphere[("all", "particle_index")].astype("int64")
>>> ts = DatasetSeries(my_fns)
>>> trajs = ts.particle_trajectories(indices, fields=fields)
>>> for t in trajs:
...     print(
...         t[("all", "particle_velocity_x")].max(),
...         t[("all", "particle_velocity_x")].min(),
...     )

Notes

This function will fail if there are duplicate particle ids or if some of the particle disappear.

piter(storage=None, dynamic=False)

Iterate over time series components in parallel.

This allows you to iterate over a time series while dispatching individual components of that time series to different processors or processor groups. If the parallelism strategy was set to be multi-processor (by “parallel = N” where N is an integer when the DatasetSeries was created) this will issue each dataset to an N-processor group. For instance, this would allow you to start a 1024 processor job, loading up 100 datasets in a time series and creating 8 processor groups of 128 processors each, each of which would be assigned a different dataset. This could be accomplished as shown in the examples below. The storage option is as seen in parallel_objects() which is a mechanism for storing results of analysis on an individual dataset and then combining the results at the end, so that the entire set of processors have access to those results.

Note that supplying a store changes the iteration mechanism; see below.

Parameters:
  • storage (dict) – This is a dictionary, which will be filled with results during the course of the iteration. The keys will be the dataset indices and the values will be whatever is assigned to the result attribute on the storage during iteration.

  • dynamic (boolean) – This governs whether or not dynamic load balancing will be enabled. This requires one dedicated processor; if this is enabled with a set of 128 processors available, only 127 will be available to iterate over objects as one will be load balancing the rest.

Examples

Here is an example of iteration when the results do not need to be stored. One processor will be assigned to each dataset.

>>> ts = DatasetSeries("DD*/DD*.index")
>>> for ds in ts.piter():
...     SlicePlot(ds, "x", ("gas", "density")).save()
...

This demonstrates how one might store results:

>>> def print_time(ds):
...     print(ds.current_time)
...
>>> ts = DatasetSeries("DD*/DD*.index", setup_function=print_time)
...
>>> my_storage = {}
>>> for sto, ds in ts.piter(storage=my_storage):
...     v, c = ds.find_max(("gas", "density"))
...     sto.result = (v, c)
...
>>> for i, (v, c) in sorted(my_storage.items()):
...     print("% 4i  %0.3e" % (i, v))
...

This shows how to dispatch 4 processors to each dataset:

>>> ts = DatasetSeries("DD*/DD*.index", parallel=4)
>>> for ds in ts.piter():
...     ProjectionPlot(ds, "x", ("gas", "density")).save()
...
print_key_parameters()[source]

Print out some key parameters for the simulation.

property quan
class yt.data_objects.time_series.TimeSeriesParametersContainer(data_object)[source]

Bases: object

class yt.data_objects.time_series.TimeSeriesQuantitiesContainer(data_object, quantities)[source]

Bases: object

yt.data_objects.time_series.get_ds_prop(propname)[source]