README.md 2.78 KB
Newer Older
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
1 2 3 4 5 6 7
## ABOUT
**UNSIO** (**U**niversal **N**body **S**napshot **I**nput **O**utput) is an API which perform input/output operations in a generic way,
and on different kind of nbody files format (nemo, Gadget binaries 1 and 2, Gadget hdf5, Ramses). By using this API,
a user could write only one analysis program which will work on all known files format supported by UNSIO.
It's not necessary anymore to know how is implemented a file format, UNSIO will do transparently and automatically
all the hard work for you ! With UNSIO, you will spend less time to develop your analysis program.
UNSIO comes with an integrated sqlite3 database which can be used to retrieve automatically all your data
8 9
among terabytes of hard disks.

LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
10 11 12 13 14
## Features

UNSIO can be used from different languages (C,C++,Fortran and Python)

## Supported files format :
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
15 16 17 18 19 20 21 22 23 24 25
* [**NEMO** (read and write)](https://teuben.github.io/nemo/)
* [**GADGET 1** (read)](http://www.mpa-garching.mpg.de/gadget/)
* **GADGET 2** (read an write)
* **GADGET 3/hdf5** (read and write)
* [**RAMSES** (read)](https://bitbucket.org/rteyssie/ramses)
* **List of files** stored in a file
* Simulations stored in **SQLITE3** database


## Installing python wrapper
```console
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
26
pip install python-unsio -U
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
27
```
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
28
## Usage
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
29

LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
30 31
- In the example below, we load a RAMSES simulation and we save it in GADGET3 file format

LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
32
```python
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
33
import unsio.input as uns_in  # unsio reading module
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
34

LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
35
myfile="/home/jcl/output_00004" # input RAMSES simulation
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
36
# we instantiate a CUNS_IN object
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
37 38 39 40 41
my_in=uns_in.CUNS_IN(myfile,"gas,stars") # We select components GAS and STARS
#
# Reading
#
if my_in.nextFrame(): # load snapshot
42 43 44 45 46 47
  # read stars positions
  status,poss=my_in.getData("stars","pos")
  # read gas positions
  status,posg=my_in.getData("gas","pos")
  # read gas densities
  status,rho=my_in.getData("gas","rho")
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
48
  # read time simulation
49
  status,timex=my_in.getData("time")
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
50 51 52 53
#
# Writing
#
import unsio.output as uns_out # unsio writing module
54

LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
55
myoutfile="snapshot.g3" # output file name
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
56
# we instantiate a CUNS_OUT object
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
57
my_out=uns_out.CUNS_OUT(myoutfile,"gadget3") # select gadget3 output format
58 59 60 61

# prepare data to be saved
# set time
status=my_out.setData(timex,"time")
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
62
# set stars positions
63
status=my_out.setData(poss,"stars","pos")
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
64
# set gas positions
65
status=my_out.setData(posg,"gas","pos")
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
66
# set gas densities
67 68
status=my_out.setData(rho,"gas","rho")

LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
69
# write on file system
70 71 72
my_out.save()
# close
my_out.close()
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
73

74 75
```

LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
76 77 78
## License
UNSIO is open source and released under the terms of the [CeCILL2 Licence](http://www.cecill.info/licences/Licence_CeCILL_V2-en.html)

LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
79
## Webpage
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
80 81 82 83
PLease isit :
- [UNSIO project home page](https://projets.lam.fr/projects/unsio)
- [Python reading manual](https://projets.lam.fr/projects/unsio/wiki/PythonReadDataNew)
- [Python writing manual](https://projets.lam.fr/projects/unsio/wiki/PythonWriteDataNew)