README.md 2.87 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
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
8 9
among terabytes of hard disks.

LAMBERT Jean-charles's avatar
updates  
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
fix CI  
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 29 30 31 32
## to get some docstring help
```console
pydoc(unsio.input)
pydoc(unsio.output)
```
LAMBERT Jean-charles's avatar
updates  
LAMBERT Jean-charles committed
33
## Usage
LAMBERT Jean-charles's avatar
updates  
LAMBERT Jean-charles committed
34

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

LAMBERT Jean-charles's avatar
updates  
LAMBERT Jean-charles committed
37
```python
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
38
import unsio.input as uns_in  # unsio reading module
LAMBERT Jean-charles's avatar
updates  
LAMBERT Jean-charles committed
39

LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
40
myfile="/home/jcl/output_00004" # input RAMSES simulation
LAMBERT Jean-charles's avatar
fix CI  
LAMBERT Jean-charles committed
41
# we instantiate a CUNS_IN object
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
42 43 44 45 46
my_in=uns_in.CUNS_IN(myfile,"gas,stars") # We select components GAS and STARS
#
# Reading
#
if my_in.nextFrame(): # load snapshot
47 48 49 50 51 52
  # 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
53
  # read time simulation
54
  status,timex=my_in.getData("time")
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
55 56 57 58
#
# Writing
#
import unsio.output as uns_out # unsio writing module
59

LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
60
myoutfile="snapshot.g3" # output file name
LAMBERT Jean-charles's avatar
fix CI  
LAMBERT Jean-charles committed
61
# we instantiate a CUNS_OUT object
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
62
my_out=uns_out.CUNS_OUT(myoutfile,"gadget3") # select gadget3 output format
63 64 65 66

# prepare data to be saved
# set time
status=my_out.setData(timex,"time")
LAMBERT Jean-charles's avatar
fix CI  
LAMBERT Jean-charles committed
67
# set stars positions
68
status=my_out.setData(poss,"stars","pos")
LAMBERT Jean-charles's avatar
fix CI  
LAMBERT Jean-charles committed
69
# set gas positions
70
status=my_out.setData(posg,"gas","pos")
LAMBERT Jean-charles's avatar
fix CI  
LAMBERT Jean-charles committed
71
# set gas densities
72 73
status=my_out.setData(rho,"gas","rho")

LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
74
# write on file system
75 76 77
my_out.save()
# close
my_out.close()
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
78

79 80
```

LAMBERT Jean-charles's avatar
updates  
LAMBERT Jean-charles committed
81 82 83
## 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
84
## Webpage
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
85
PLease visit :
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
86 87 88
- [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)