sarracen.read_phantom
- sarracen.read_phantom(filename: str, separate_types: None, ignore_inactive: bool = True) SarracenDataFrame
- sarracen.read_phantom(filename: str, separate_types: Literal['sinks'] = 'sinks', ignore_inactive: bool = True) List[SarracenDataFrame] | SarracenDataFrame
- sarracen.read_phantom(filename: str, separate_types: Literal['all'] = 'all', ignore_inactive: bool = True) List[SarracenDataFrame] | SarracenDataFrame
Read data from a Phantom dump file.
This reads the native binary format of Phantom dump files, which in turn were derived from the binary file format used by sphNG.
Global values stored in the dump file (time step, initial momentum, hfact, Courant factor, etc) are stored within the data frame in the dictionary
params.- Parameters:
filename (str) – Name of the file to be loaded.
separate_types ({None, 'sinks', 'all'}, default='sinks') – Whether to separate different particle types into several dataframes.
Nonereturns all particle types in one data frame. ‘sinks’ separates sink particles into a second dataframe, and ‘all’ returns all particle types in different dataframes.ignore_inactive ({True, False}, default=True) – If True, particles with negative smoothing length will not be read on import. These are typically particles that have been accreted onto a sink particle or are otherwise inactive.
- Return type:
SarracenDataFrame or list of SarracenDataFrame
See also
SarracenDataFrame()A pandas DataFrame with support for SPH data.
Notes
See the Phantom documentation for a full description of the Phantom binary file format.
Examples
By default, SPH particles are grouped into one data frame and sink particles into a second data frame.
>>> import sarracen >>> sdf, sdf_sinks = sarracen.read_phantom('dumpfile_00000')
A dump file containing multiple particle types, say gas + dust + sinks, can be separated into their own data frames by specifying
separate_types='all'.>>> sdf_g, sdf_d, sdf_sinks = sarracen.read_phantom('dumpfile_00000', ... separate_types='all')
Global values are stored in the
paramsdictionary.>>> sdf_g.params {'nparttot': np.int32(100000), 'ntypes': np.int32(8), 'npartoftype': np.int32(100000), 'massoftype': np.float64(5.05e-7) 'time': np.float64(0.05), 'grainsize': np.float64(6.684491978609626e-14), 'graindens': np.float64(5049628.378663718), 'udist': np.float64(14960000000000.0) 'umass': np.float64(1.9891e+33), 'utime': np.float64(5022728.790082334), ... }