Commit 16a094fe authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles

Update readme with python example

parent 37d2c3b0
Pipeline #1481 passed with stages
in 4 minutes and 27 seconds
......@@ -27,12 +27,50 @@ pip install python-unsio
```
## Usage
- example : load gas and stars component of an UNS compliant snapshot
```python
import unsio.input as unsi
import unsio.input as uns_in
# we instantiate object
x=unsi.CUNS_IN()
myfile="snashot.000"
my_in=uns_in.CUNS_IN(myfile,"gas,stars")
# load snapshot
if my_in.nextFrame():
# 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")
# read time
status,timex=my_in.getData("time")
```
- example : save previously loaded data in gadget3 format
```python
import unsio.output as uns_out
# we instantiate object
myoutfile="snapshot.g3"
my_out=uns_out.CUNS_OUT(myoutfile,"gadget3")
# prepare data to be saved
# set time
status=my_out.setData(timex,"time")
# set positions for stars
status=my_out.setData(poss,"stars","pos")
# set positions for gas
status=my_out.setData(posg,"gas","pos")
# set density for gas
status=my_out.setData(rho,"gas","rho")
# save on disk
my_out.save()
# close
my_out.close()
```
## License
UNSIO is open source and released under the terms of the [CeCILL2 Licence](http://www.cecill.info/licences/Licence_CeCILL_V2-en.html)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment