Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Python module to read binary snapshots from Gadget

NotificationsYou must be signed in to change notification settings

cmaureir/gadget-snapshot-reader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

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.

Installation

To use this module, you can install is using thesetup.py.

    python setup.py install --user

Examples

You can visit theexamples directory to see a couple of ways to useGSR.

Usage

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.

Feedback

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python100.0%

[8]ページ先頭

©2009-2025 Movatter.jp