Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
LAMBERT Jean-charles
unsio
Commits
16a094fe
Commit
16a094fe
authored
Sep 06, 2019
by
LAMBERT Jean-charles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update readme with python example
parent
37d2c3b0
Pipeline
#1481
passed with stages
in 4 minutes and 27 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
2 deletions
+40
-2
README.md
README.md
+40
-2
No files found.
README.md
View file @
16a094fe
...
...
@@ -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
uns
i
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment