- Notifications
You must be signed in to change notification settings - Fork0
cmaureir/gadget-snapshot-reader
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
GADGET is a cosmological SPH andN-body code, written byVolker Springel.
Since this code is widely used by the cosmological community,and considering the growth of Python use among scientist,Patrick Brem decided to write asimple script to read the snapshot and be able to access the data.
I decided to improve his code, and add more features, to provide a nice/simplemodule to deal with the GADGET binary snapshots.
Be aware, the project is stillunder development.
To use this module, you can install is using thesetup.py.
python setup.py install --user
You can visit theexamples directory to see a couple of ways to useGSR.
For a simple transformation from the gadget-binary fileto ascii, you can do the following:
fromgsrimport*snap=Snapshot(filename)snap.to_ascii()
Every ascii file is generated using the following order:
| id | mass | posx | posy | posz | velx | vely | velz | u | rho |
It is possible to process more parameters, just enabling them in theconstructor call, for example:
- snap = Snapshot(filename, enable_potential = True)
Extra options are:
- enable_potential
- enable_accelerations
- enable_entropy_production
- enable_timesteps
- enable_density
- enable_smoothing_lenght
If you want to print certain information from the snapshotby type:
particle_type=5# From GADGET, only 0, 1, 2, 3, 4, 5snap.print_data_by_type(particle_type)
To use the data from the snapshot, it is possible to geta list with all the information of a particle type:
particle_type=5data=snap.get_data_by_type(particle_type)
which will return a dictionary with the following structure:
{'id':[id0,id1, ...],'mass':[mass0,mass1, ...],'pos':[[pos0x,pos0y,pos0z], [pos1x,pos1y,pos2z]],'vel':[[vel0x,vel0y,vel0z], [vel1x,vel1y,vel1z], ...]]if the requested type is0 (Gas) the dictionary will also include the Internal energyu and the Densityrho.
Since the project is still under development, a lot of feature are missing,and will be really nice if you can collaborate, asking for a new functionallityor even submitting a pull request to improve the code.
About
Python module to read binary snapshots from Gadget
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Languages
- Python100.0%