...
 
Commits (4)
......@@ -9,6 +9,8 @@
# ide
*.tags*
# linux
.nfs*
#swig
py/unsio/py_unsio.py
......
......@@ -27,33 +27,34 @@ pip install python-unsio
```
## Usage
- example : load gas and stars components of an UNS supported file format
- In the example below, we load a RAMSES simulation and we save it in GADGET3 file format
```python
import unsio.input as uns_in
import unsio.input as uns_in # unsio reading module
myfile="/home/jcl/output_00004" # input RAMSES simulation
# we instantiate object
myfile="snashot.000"
my_in=uns_in.CUNS_IN(myfile,"gas,stars")
# load snapshot
if my_in.nextFrame():
my_in=uns_in.CUNS_IN(myfile,"gas,stars") # We select components GAS and STARS
#
# Reading
#
if my_in.nextFrame(): # load snapshot
# 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
# read time simulation
status,timex=my_in.getData("time")
#
# Writing
#
import unsio.output as uns_out # unsio writing module
```
- example : save previously loaded data in gadget3 format
```python
import unsio.output as uns_out
myoutfile="snapshot.g3" # output file name
# we instantiate object
myoutfile="snapshot.g3"
my_out=uns_out.CUNS_OUT(myoutfile,"gadget3")
my_out=uns_out.CUNS_OUT(myoutfile,"gadget3") # select gadget3 output format
# prepare data to be saved
# set time
......@@ -65,14 +66,18 @@ status=my_out.setData(posg,"gas","pos")
# set density for gas
status=my_out.setData(rho,"gas","rho")
# save on disk
# write on file system
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)
## Webpage
PLease visit : https://projets.lam.fr/projects/unsio
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)
......@@ -230,7 +230,7 @@ class CUNS_IN:
print ("array=",tag,data_type)
if tag is None: # only one value
tab_value_F=["time"]
tab_value_I=["nbody","nsel"]
tab_value_I=["nbody","nsel","ngas","nstars","ndisk","nhalo","nbulge","nbndry","nvarh"]
ok=0
ret_data=np.zeros(1,dtype=data_type)
data=0
......
#!/usr/bin/env python
#
# In the example below, we load a RAMSES simulation that
# we save in gadget3 file format
#
import unsio.input as uns_in # unsio reading module
myfile="/home/jcl/output_00004" # input RAMSES simulation
# we instantiate object
my_in=uns_in.CUNS_IN(myfile,"gas,stars") # We select components GAS and STARS
#
# Reading
#
if my_in.nextFrame(): # load snapshot
# 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 simulation
status,timex=my_in.getData("time")
#
# Writing
#
import unsio.output as uns_out # unsio writing module
myoutfile="snapshot.g3" # output file name
# we instantiate object
my_out=uns_out.CUNS_OUT(myoutfile,"gadget3") # select gadget3 output format
# 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")
# write on file system
my_out.save()
# close
my_out.close()
......@@ -48,7 +48,7 @@ class build_py(_build_py, object):
#
MAJOR = '0'
MINOR = '9'
MICRO = '3rc4'
MICRO = '3rc5'
VERSION = '%s.%s.%s' % (MAJOR, MINOR, MICRO)
#
......