yt.data_objects.time_series.DatasetSeries.from_filenames

classmethod DatasetSeries.from_filenames(filenames, parallel=True, setup_function=None, **kwargs)[source]

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.

Parameters:

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.

Examples

>>> 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()