Commit 3b9863b3 authored by jclamber's avatar jclamber

add new py functions

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@177 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent 7bb77977
......@@ -68,6 +68,32 @@
// Parse the original header file
%include "uns.h"
%extend uns::CunsIn {
// getFileName
std::string getFileName() {
std::string ret="";
if ($self->isValid() && $self->snapshot!=NULL ) {
ret=$self->snapshot->getFileName();
}
return ret;
}
// getFileStructure
std::string getFileStructure() {
std::string ret="";
if ($self->isValid() && $self->snapshot!=NULL ) {
ret=$self->snapshot->getFileStructure();
}
return ret;
}
// getInterfaceType
std::string getInterfaceType() {
std::string ret="";
if ($self->isValid() && $self->snapshot!=NULL ) {
ret=$self->snapshot->getInterfaceType();
}
return ret;
}
};
// Extend class
%extend uns::CunsOut {
......
from py_unsio import * # import py_unsio package
import numpy as np # arrays are treated as numpy arrays
import matplotlib.pyplot as plt
import scipy.interpolate
# Step 1 : create UNSIO object
file="/home/jcl/gtr118_1912" # input file (simulation name)
......@@ -14,7 +14,7 @@ while uns.nextFrame(""): # load snapshot
comp="gas"
# Step 3 : get data
ok,pos =uns.getArrayF(comp,"pos") # positions of stars particles
ok,pos =uns.getArrayF(comp,"pos") # positions
# Step 3 : get data
ok,rho =uns.getArrayF(comp,"rho") # gas density
# Step 3 : get data
......@@ -35,7 +35,7 @@ while uns.nextFrame(""): # load snapshot
z = pos[:,2] # z coordinates
if (rho.size > 0) :
#rho = np.log(rho)
rho = np.log(rho)
print
else:
rho = z
......
......@@ -19,7 +19,7 @@ uns=CunsIn(file,"all","all");
ok=uns.nextFrame("")
print ok
# get data
ok,data=uns.getData("gas","pos")
ok,data=uns.getArrayF("gas","pos")
print ok
print data
# reshap 1D to 2D
......@@ -31,7 +31,7 @@ x = data[:,0]
# get col 2 to y
y = data[:,1]
ok,dens=uns.getData("gas","rho")
ok,dens=uns.getArrayF("gas","rho")
print dens.max()
print dens.min()
......
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