nbodykit.io.gadget

Classes

Gadget1File(path[, columndefs, hdtype, ptype]) Read snapshot binary files from Volkers Gadget 1/2/3 simulations.
class nbodykit.io.gadget.Gadget1File(path, columndefs=[('Position', ('auto', 3), 'all'), ('GadgetVelocity', ('auto', 3), 'all'), ('ID', 'auto', 'all'), ('Mass', 'auto', None), ('InternalEnergy', 'auto', (0,)), ('Density', 'auto', (0,)), ('SmoothingLength', 'auto', (0,))], hdtype=[('Npart', ('u4', 6)), ('Massarr', ('f8', 6)), ('Time', 'f8'), ('Redshift', 'f8'), ('FlagSfr', 'i4'), ('FlagFeedback', 'i4'), ('Nall', ('u4', 6)), ('FlagCooling', 'i4'), ('NumFiles', 'i4'), ('BoxSize', 'f8'), ('Omega0', 'f8'), ('OmegaLambda', 'f8'), ('HubbleParam', 'f8'), ('FlagAge', 'i4'), ('FlagMetals', 'i4'), ('NallHW', ('u4', 6)), ('flag_entr_ics', 'i4')], ptype=1)[source]

Read snapshot binary files from Volkers Gadget 1/2/3 simulations.

These files are stored column-wise with a format, with a header of size 28 bytes to begin the file.

The columns are:

  • Position : ‘f4’, ‘f8’ precision
    the position data, usually in Kpc/h units.
  • GadgetVelocity : ‘f4’, ‘f8’ precision
    the Gadget 1 velocity, sqrt(a)**-1 v_p. in km/s
  • ID : ‘i8’/’i4’ precision
    integers specfiying the particle ID
Parameters:
  • path (str) – the path to the binary file to load
  • columndefs (list) – a list of triplets (columnname, element_dtype, particle_types)
  • ptype (int) – type of particle of interest.
  • hdtype (list, dtype) – dtype of the header; must define Massarr and Npart

References

https://wwwmpa.mpa-garching.mpg.de/gadget/users-guide.pdf

Attributes

columns A list of the names of the columns in the file.
dtype A numpy.dtype object holding the data types of each column in the file.
ncol The number of data columns in the file.
shape The shape of the file, which defaults to (size, )
size The size of the file, i.e., number of rows

Methods

asarray() Return a view of the file, where the fields of the
get_dask(column[, blocksize]) Return the specified column as a dask array, which
keys() Aliased function to return columns
read(columns, start, stop[, step]) Read the specified column(s) over the given range
read(columns, start, stop, step=1)[source]

Read the specified column(s) over the given range

‘start’ and ‘stop’ should be between 0 and size, which is the total size of the binary file (in particles)

Parameters:
  • columns (str, list of str) – the name of the column(s) to return
  • start (int) – the row integer to start reading at
  • stop (int) – the row integer to stop reading at
  • step (int, optional) – the step size to use when reading; default is 1
Returns:

structured array holding the requested columns over the specified range of rows

Return type:

numpy.array