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:
FieldModelDatasetSubclass of
FieldModelDatasetfor 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"- t0
datetimeor 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
FieldModelinstances.- 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:
ValueErrorIf the glob pattern matches non .out files.
FileNotFoundErrorIf 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.strptimewith the providedtimestamp_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
FieldModelwith one timestep
- instance of
- __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 with length equal to len(self)
Methods Documentation