SwmfOutFieldModelDataset

class disco.readers.SwmfOutFieldModelDataset(glob_pattern, t0=None, cache_regrid=True, cache_regrid_dir='same_dir', B0=<Quantity 31000. nT>, plasma_params=False, r_inner=<Quantity 15945250. m>, verbose=1, grid_downsample=2)[source]

Bases: FieldModelDataset

Subclass of FieldModelDataset for delayed reading of SWMF Output in .out Format.

Examples

Load a dataset from a glob pattern matching .out files

>>> from disco import SwmfOutFieldModelDataset
>>> dataset = SwmfOutFieldModelDataset(
...     "/home/ubuntu/simulation_output/*.out",
... )

Load a dataset but set t = 0 to a specific datetime in the dataset (if not specified, the first timestep in the globbed files will be used).

>>> from datetime import datetime
>>> from disco import SwmfOutFieldModelDataset
>>> dataset = SwmfOutFieldModelDataset(
...     "/home/ubuntu/simulation_output/*.out",
...     t0=datetime(2023, 1, 5, 0, 0, 0),
... )

Create an instance of SwmfOutFieldModelDataset

Parameters:
glob_patternstr

Pattern such as "simulation_output/*.out"

t0datetime or scalar with time units

Initial time for dataset. If filenames have a full date in them, pass a datetime If filenames have a relative time, pass a scalar with units of time. If None, the first timestamp in the globbed files will be used.

cache_regridbool

If True, the regridded data will be cached on disk for faster access If False, the regridding will be done every time __getitem__ is called.

cache_regrid_dirstr

Directory to cache regridded data. If ‘same_dir’, it will use the same directory as the glob files.

B0scalar with units (magnetic field strength)

Internal model to use in returned FieldModel instances.

plasma_paramsbool

If True, the dataset will also load plasma parameters (density, temperature, etc.) from the .out files.

verboseint

Verbosity level for output. Set to 0 for no output

Raises:
ValueError

If the glob pattern matches non .out files.

FileNotFoundError

If the glob pattern does not match any files.

Notes

The glob pattern must match at least one .out files, and all files must have the same timestamp format.

The timestamps are parsed from the filenames, so they must be in a format that can be parsed by datetime.strptime with the provided timestamp_parser.

__getitem__(index)[source]

Return field model for current index of the simulation dataset.

Parameters:
indexint

timestamp index, >= 0 and less then len(self)

Returns:
instance of FieldModel with one timestep
__len__()[source]

Return length of the dataset in number of indices.

Returns:
integer number of timesteps

Methods Summary

get_cache_file(index)

Get the cache file path for the given index.

get_time_axis()

Get time axis with length equal to len(self)

Methods Documentation

get_cache_file(index)[source]

Get the cache file path for the given index.

Parameters:
indexint

Index of the file to get the cache file for.

Returns:
Path to the cache file for given timestep index.
get_time_axis()[source]

Get time axis with length equal to len(self)

Returns:
array with units of time, and size equal to len(self)