PkdGrav-snapshot
Input/output of PkdGrav particle snapshots
This Python library reads and writes particle snapshots in the Tipsy format. Files of this type are typically produced by PkdGrav at each time step of a cosmological N-body simulation. The snapshot files contain information such as mass, position, velocity… of gas, dark-matter, and star particles.
Installation
Install the package directly from the Git repo:
❯ pip install git+https://cosmo-gitlab.phys.ethz.ch/john.hennig/PkdGrav-snapshot.git
Usage
To read particle data from a PkdGrav snapshot file:
import pkdsnap
(gas, dm, star, time) = pkdsnap.read('snapshot.tipsy')
This returns gas, dm (dark matter), and star particles as Pandas data
frames as well as the simulation time of the snapshot as a
number. The data frames correspond to the struct fields of the PkdGrav
file format as documented in the section "Tipsy Format" of the PkdGrav
documentation.
Note that PkdGrav does not typically use the .tipsy file extension. For a
simulation with output name (achOutName) "results", the files would be named
like results.00140, wherein 140 is the time step.
Given Pandas data frames of the same column structure as returned by read(),
particle data can be written to a PkdGrav snapshot file with:
pkdsnap.write('snapshot.tipsy', gas=gas, dm=dm, star=star, time=0.01)
For example (made-up numbers, not necessarily physical):
from pandas import DataFrame
gas = DataFrame({
'm': [ 0.00001 ],
'x': [ -0.5 ],
'y': [ -0.5 ],
'z': [ -0.5 ],
'vx': [ -0.02 ],
'vy': [ +0.03 ],
'vz': [ +0.01 ],
'ρ': [ 0.1 ],
'T': [ 4.2 ],
'hs': [ 9.5 ],
'μ': [ 0.1 ],
'φ': [ 0.1 ],
})
dm = DataFrame({
'm': [ 0.00002 , 0.00002 ],
'x': [ -0.1 , +0.5 ],
'y': [ -0.4 , +0.2 ],
'z': [ +0.1 , +0.4 ],
'vx': [ -0.02 , +0.03 ],
'vy': [ +0.03 , +0.00 ],
'vz': [ -0.00 , +0.02 ],
'ε': [ 0.0006 , 0.0006 ],
'φ': [ -0.053 , -0.053 ],
})
star = DataFrame({
'm': [ 0.00003 , 0.00003 , 0.00003 ],
'x': [ -0.4 , +0.3 , +0.5 ],
'y': [ +0.5 , +0.1 , -0.2 ],
'z': [ -0.5 , +0.2 , -0.1 ],
'vx': [ -0.02 , +0.03 , +0.04 ],
'vy': [ +0.01 , +0.02 , -0.01 ],
'vz': [ +0.03 , -0.01 , -0.04 ],
'μ': [ 0.1 , 0.1 , 0.1 ],
'tf': [ 12.1 , 12.2 , 12.3 ],
'ε': [ 0.0006 , 0.0006 , 0.0006 ],
'φ': [ -0.053 , -0.053 , -0.053 ],
})
Particle data may also be appended to an existing Tipsy file:
pkdsnap.append('snapshot.tipsy', dm=more_dm_particles)
Note, however, that this only works if the existing file contains only particles of the same type as those to be appended.
Metadata
Release files for PkdGrav-snapshot 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pkdgrav_snapshot-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for pkdgrav_snapshot-1.0.0-py3-none-any.whl |
Release files / pkdgrav_snapshot-1.0.0-py3-none-any.whl
| Download URL | pkdgrav_snapshot-1.0.0-py3-none-any.whl |
|---|---|
| Size | 19.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de5c08043bf423c053716233fe5310d7d76778078c9baff0ec06e455bbae3324
|
|
BLAKE2b-256 checksum How to use checksums |
e19e2bcabec15e8feb03cb0f9eaa1634286dbd1e431c9a8c8603fd05d7d4297c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for PkdGrav-snapshot 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.