yt.frontends.exodus_ii.simulation_handling module

class yt.frontends.exodus_ii.simulation_handling.ExodusIISimulation(simulation_directory, find_outputs=False)[source]

Bases: yt.data_objects.time_series.DatasetSeries

Initialize an ExodusII Simulation object.

Upon creation, the input directoy is searched for valid ExodusIIDatasets. The get_time_series can be used to generate a DatasetSeries object.

simulation_directory : str
The directory that contain the simulation data.


>>> import yt
>>> sim = yt.simulation("demo_second", "ExodusII")
>>> sim.get_time_series()
>>> for ds in sim:
...     print ds.current_time
eval(tasks, obj=None)
from_filenames(filenames, parallel=True, setup_function=None, **kwargs)

Create a time series from either a filename pattern or a list of filenames.

This method provides an easy way to create a DatasetSeries, given a set of filenames or a pattern that matches them. Additionally, it can set the parallelism strategy.

  • filenames (list or pattern) – This can either be a list of filenames (such as [“DD0001/DD0001”, “DD0002/DD0002”]) or a pattern to match, such as “DD*/DD*.index”). If it’s the former, they will be loaded in order. The latter will be identified with the glob module and then sorted.
  • 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 or an integer, it will be iterated with 1 or that integer number of processors assigned to each parameter file provided to the loop.
  • setup_function (callable, accepts a ds) – This function will be called whenever a dataset is loaded.


>>> def print_time(ds):
...     print ds.current_time
>>> ts = DatasetSeries.from_filenames(
...     "GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0[0-6][0-9]0",
...      setup_function = print_time)
>>> for ds in ts:
...     SlicePlot(ds, "x", "Density").save()
from_output_log(output_log, line_prefix='DATASET WRITTEN', parallel=True)
get_time_series(parallel=False, setup_function=None)[source]

Instantiate a DatasetSeries object for a set of outputs.

If no additional keywords given, a DatasetSeries object will be created with all potential datasets created by the simulation.

Fine-level filtering is currently not implemented.

particle_trajectories(indices, fields=None, suppress_logging=False)

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

  • 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


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

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.


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", "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("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", "Density").save()