Snapshot

Snapshot class

class arepy.files.snap(fileName, **opt)

Snapshot class

Parameters
  • fileName (str) – Path to the snapshot file

  • initChem (dict) – Chemistry initialization settings

  • sinkOpt (dict) – Sink particle file settings

Returns

Snapshot object

Snapshot class is used to extract some data from the Arepo or sink snapshots and it can be called within any Python script as follwos:

>>> import arepy as apy
>>> snap = apy.files.snap('./snap_001.hdf5')
setHeader(name, value=None, s=0)

Set header values

Parameters
  • name (str) – Name of the header parameter

  • value – Value of the header parameter

  • s (int) – Index of a partial snapshot file.

getHeader(names=None, s=0)

Get header properties

Parameters
  • names (list[str]) – List of header properties.

  • s (int) – Index of a partial snapshot file.

Returns

Property values

setProperty(name, data, ids=None, ptype=0, s=0)

Set a particle property

Parameters
  • name (str) – Name of the parameter

  • data – Dataset of the parameter

  • ids (list[bool]) – Particle selector list

  • ptype (int) – Particle type

  • s (int) – Index of a partial snapshot file.

getProperty(props, ids=None, ptype=0, dictionary=False)

Get particle properties

Parameters
  • props (list(prop)) – Snapshot properties.

  • ids (list(bool)) – Particle selector list.

  • ptype (int) – Default particle type.

  • dictionary (bool) – Return property values as dictionary only.

Returns

Property values

Examples:

  1. Properties that do not need any additional settings can be called only using their name. Calling only a single property will return only values of the property:

    >>> snap.getProperty('Masses')
    
    [23.43, 34.23, 12.0, ...]
    
  2. Properties that need additional settings besides ‘name’, ‘ptype’ and ‘ids’ have to be called using a dictionary:

    >>> snap.getProperty({
    >>>     'name': 'SelectSphere',
    >>>     'center': [0.5,0.5,0.5],
    >>>     'radius': 0.2
    >>> })
    
    [True, False, False, ...]
    
  3. It is also possible to query for a list of properties. In this case the results will be given in a form of a dictionary like this:

    >>> snap.getProperty([
    >>>     'FormationOrder','Masses',
    >>>     {'name':'SelectFormationOrder','forder':[3,10,11]}
    >>> ])
    
    {'FormationOrder': [3, 23, 33, ...],
     'Masses':  [23.43, 34.23, 12.0, ...],
     'SelectFormationOrder': [True, False, False, ...]}
    
  4. It might be sometimes advantageous to return dictionaries also for single properties:

    >>> snap.getProperty('Masses', dictionary=True)
    
    {'Masses': [23.43, 34.23, 12.0, ...]}
    
  5. Property types can be set globally. The following example wil select masses and velocities of the sink particles only:

    >>> snap.getProperty([
    >>>     'Masses','ParticleIDs'
    >>> ], ptype=5)
    
    {'Masses': [23.43, 34.23, 12.0, ...],
     'ParticleIDs': [23, 233, 0, ...]}
    
  6. Property types can be also specified for each property individually. The following example will select masses of the gas particles, but velocities of the sink particles:

    >>> snap.getProperty([
    >>>     'Masses',
    >>>     {'name':'ParticleIDs', 'ptype':5}
    >>> ])
    
    {'Masses': [23.43, 34.23, 12.0, ...],
     'ParticleIDs': [13, 35, 22, ...]}
    
  7. If two properties in the list have a same name one has to be altered using a ‘key’ parameter:

    >>> snap.getProperty([
    >>>     'Masses',
    >>>     {'name':'Masses', 'ptype':5, 'key': 'SinkMasses'}
    >>> ])
    
    {'Masses': [23.43, 34.23, 12.0, ...],
     'SinkMasses': [13.23, 35.23, 22.0, ...]}
    
  8. It is also possible to directly input a property class:

    >>> properties = apy.files.properties(['Masses','Velocities'])
    >>> snap.getProperty(properties)
    
    {'Masses': [23.43, 34.23, 12.0, ...],
     'Velocities': [[23.34,26.6,834.3], [35.23, 22.0, 340,2], ...]}
    
  9. Note that some properties return subsets of values:

    >>> snap.getProperty({
    >>>     'name':'RegionSphere', 'center': [0.5]*3, 'radius': 0.5,
    >>>     'p': ['Masses','ParticleIDs']
    >>> })
                                                                                                                
    {'Masses': [23.43, 34.23, 12.0, ...],                                                                                                           
     'ParticleIDs': [13, 35, 22, ...]}         
    
    >>> snap.getProperty([
    >>>     'Velocities',
    >>>     {'name':'RegionSphere', 'center': [0.5]*3, 'radius': 0.5, 
    >>>      'p': ['Masses','ParticleIDs']},
    >>> )
                                                                                                                
    {'RegionSphere': {'Masses': [23.43, 34.23, 12.0, ...],
                      'ParticleIDs': [13, 35, 22, ...]},
     'Velocities': [[23.34,26.6,834.3], [35.23, 22.0, 340,2], ...]}   
    

Properties class

class arepy.files.properties(props=None, ptype=0)

List of snapshot properties

Parameters
  • props – Single property or list of properties

  • ptype (int) – Default particle type

Key props

prop or list[prop]

add(props)

Add a new property to the list

Parameters

props – Single property or list of properties

Key props

prop or list[prop]

getData(dictionary=False)

Get properties as a list or dictionary

Parameters

dictionary (bool) – Return single property in a dictionary

Returns

Property list or a dictionary

Rkey

list or dict

getWithout(key, values)

Get properties with some specific key/values

Parameters
  • key (str) – Property setting

  • values – Values to keep

Keys key

list[str] or str

Returns

New object of self without some properties

getComplex(add=None)

Select complex properties

Parameters

add (prop) – New properties to add

Returns

New object only with complex properties

getSimple(add=None)

Select simple properties

Parameters

add (prop) – New Properties to add

Returns

New object only with simple properties