galaximview.readsnapshot module

galaximview.readsnapshot.inds_of_p_types(nbytype)[source]

Returns indexes of particles corresponding to the 6 Gadget-2 types.

Parameters

nbytype (ndarray) – Number of particles by type.

Returns

indexes of different types

Return type

(ndarray,ndarray,ndarray,ndarray,ndarray,ndarray)

galaximview.readsnapshot.read_gadget(fname, gadget2_header=True, ntypes=6, ics=False, has_pot=False, has_accel=False, has_dtentr=False, has_tstp=False, store_pot=False, store_accel=False, store_dtentr=False, store_tstp=False)[source]

Reads a Gadget-1/Gadget-2 file and fills a dictionary.

Parameters
  • fname (str) – path to snapshot

  • gadget2_header (bool, default = True) – True if classic Gdget-2 header (default in Gadget-2, option in Gadget-4).

  • ntypes (int, optional) – See ~readsnapshot.read_gadget_header

  • ics (bool, default = False) – True if initial conditions file, with limited number of blocks.

  • has_pot (bool, default = False) – True if snapshot contains gravitational potential block.

  • has_accel (bool, default = False) – True if snapshot contains accelerations block.

  • has_dtentr (bool, default = False) – True if snapshot contains variation of entropy block.

  • has_tstp (bool, default = False) – True if snapshot contains time steps block.

  • store_pot (bool, default = False) – True if one wants to store gravitational potential block (if existing).

  • store_accel (bool, default = False) – True if one wants to store accelerations block (if existing).

  • store_dtentr (bool, default = False) – True if one wants to store variation of entropy block (if existing).

  • store_tstp (bool, default = False) – (Default value = False)

Returns

Data dictionary.

Return type

dict

galaximview.readsnapshot.read_gadget_header(fortranfile, gadget2_header=True, ntypes=6)[source]

Read a Gadget header for Legacy1 and Legacy2 (Gadget/Gadget-2 and Gadget-2 with strings formats, respectively).

Parameters
  • fortranfile (FortranFile) – FortranFile whose heade ris read here.

  • gadget2_header (bool, default = True) – True if classic Gdget-2 header (default in Gadget-2, option in Gadget-4).

  • ntypes (int, default = 6) – Number of particles types. Always set to 6 in Gadget-2 but set in the Makefile in Gadget-4. * To read Gadget-2 simulations, this parameter here should be kept to 6. * To read Gadget-4 simulations, ntypes here should be set to the value given in the Makefile of the simulation, even if GADGET2_HEADER is set in the Makefile, because in this case, even if the arrays of particle numbers and masses contain 6 values, they are not initialised to zero, which can cause reading errors.

galaximview.readsnapshot.read_gadget_str(fname, gadget2_header=True, ntypes=6, store_pot=False, store_accel=False, store_dtentr=False, store_tstp=False)[source]

Reads Gadget-2 file of type legacyformat2,, with blocks preceded by header strrings, and fills a dictionary.

Parameters
  • fname (str) – path to snapshot

  • gadget2_header (bool, default = True) – True if classic Gdget-2 header (default in Gadget-2, option in Gadget-4).

  • ntypes (int, optional) – See ~readsnapshot.read_gadget_header

  • store_pot (bool, default = False) – True if one wants to store gravitational potential block (if existing).

  • store_accel (bool, default = False) – True if one wants to store accelerations block (if existing).

  • store_dtentr (bool, default = False) – True if one wants to store variation of entropy block (if existing).

  • store_tstp (bool, default = False) – (Default value = False)

Returns

Data dictionary.

Return type

dict

galaximview.readsnapshot.read_hdf5(fname)[source]

Reads a HDF5 snapshot file.

Parameters

fname (str) –

Notes

Consitency with Gadget-2 output hdf5 files has not been checked because of problems with running Gadget-2 with the right HDF5 library.

Returns

Data dictionary.

Return type

dict

galaximview.readsnapshot.read_single_snapshot(fname, input_type='G1/G2', gadget2_header=True, ntypes=6, ics=False, has_pot=False, has_accel=False, has_dtentr=False, has_tstp=False, store_pot=False, store_accel=False, store_dtentr=False, store_tstp=False)[source]

Read a snapshot for one simulation time output.

Parameters
  • fname (str) – path to snapshot

  • input_type ({'G1/G2', 'G2_str', 'G4_hdf5'}) – Snapshot data type, ‘G1/G2’ for usual Gadget-2 format.

  • gadget2_header (bool, optional `) – Used if snapshot is of ‘G1/G2’ or ‘G2_str’ type. See ~readsnapshot.read_gadget

  • ntypes (int, optional) – Used if snapshot is of ‘G1/G2’ or ‘G2_str’ type. See ~readsnapshot.read_gadget_header

  • ics (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • has_pot (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • has_accel (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • has_dtentr (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • has_tstp (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • store_pot (bool, optional) – Used if snapshot is of ‘G1/G2’ type or ‘G2_str’ type. See ~readsnapshot.read_gadget

  • store_accel (bool, optional) – Used if snapshot is of ‘G1/G2’ type or ‘G2_str’ type. See ~readsnapshot.read_gadget

  • store_dtentr (bool, optional) – Used if snapshot is of ‘G1/G2’ type or ‘G2_str’ type. See ~readsnapshot.read_gadget

  • store_tstp (bool, optional) – Used if snapshot is of ‘G1/G2’ type or ‘G2_str’ type. See ~readsnapshot.read_gadget

Returns

Data dictionary.

Return type

dict

galaximview.readsnapshot.read_snapshot(fname, input_type='G1/G2', gadget2_header=True, ntypes=6, multiple_snaps=False, ics=False, has_pot=False, has_accel=False, has_dtentr=False, has_tstp=False, store_pot=False, store_accel=False, store_dtentr=False, store_tstp=False)[source]

Read snapshot(s) for one simulation time output.

Parameters
  • fname (str) – path to snapshot

  • input_type ({'G1/G2', 'G2_str', 'G4_hdf5'}) – Snapshot data type, ‘G1/G2’ for usual Gadget-2 format.

  • gadget2_header (bool, optional) – Used if snapshot is of ‘G1/G2’ or ‘G2_str’ type. See ~readsnapshot.read_gadget

  • ntypes (int, optional) – Used if snapshot is of ‘G1/G2’ or ‘G2_str’ type. See ~readsnapshot.read_gadget

  • multiple_snaps (bool, default = False) – True if several snapshots per simulation time output.

  • ics (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • has_pot (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • has_accel (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • has_dtentr (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • has_tstp (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • store_pot (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • store_accel (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • store_dtentr (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • store_tstp (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

Returns

Data dictionary.

Return type

dict

galaximview.readsnapshot.read_sub_snapshots(fname, input_type='G1/G2', gadget2_header=True, ntypes=6, ics=False, has_pot=False, has_accel=False, has_dtentr=False, has_tstp=False, store_pot=False, store_accel=False, store_dtentr=False, store_tstp=False)[source]

Read multiple snapshots corresponding to one simulation time output.

Parameters
  • fname (str) – path to snapshot

  • input_type ({'G1/G2', 'G2_str', 'G4_hdf5'}) – Snapshot data type, ‘G1/G2’ for usual Gadget-2 format.

  • gadget2_header (bool, optional `) – Used if snapshot is of ‘G1/G2’ or ‘G2_str’ type. See ~readsnapshot.read_gadget

  • ntypes (int, optional) – Used if snapshot is of ‘G1/G2’ or ‘G2_str’ type. See ~readsnapshot.read_gadget

  • ics (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • has_pot (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • has_accel (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • has_dtentr (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • has_tstp (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • store_pot (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • store_accel (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • store_dtentr (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

  • store_tstp (bool, optional) – Used if snapshot is of ‘G1/G2’ type. See ~readsnapshot.read_gadget

Returns

Data dictionary.

Return type

dict