Commit 7ead176e authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles
Browse files

many updates

parent b2542a24
......@@ -65,4 +65,42 @@ namespace uns_proj {
}; // end of class
} // namespace
extern "C" {
// fortran wrapper, parameters
// IN[integer] rot : 0 no rotate, 1 along X axis, 2 along y axis
// IN[integer] nbody : #bodies
// IN[real4] time
// IN[real4 array] pos, vel, mass
// IN[integer array] id
// IN[float] dmin (%density min)
// IN[float] dmax (%density max)
// IN[integer] move_to_cod : 0 or 1 to move to cod
// for mdf (stars, set move_to_cod=0 is you use rectify before)
// set dmin=75, dmax=90
bool rotate_bar_(const int * rot, const int * nbody,
float * pos, float * vel, float * mass,
int *id,
float * dmin, float *dmax, const int * mvcod) {
float * hsml=NULL;
float * rho=NULL;
uns_proj::CBar * bar = new uns_proj::CBar(*nbody,pos, vel,mass,rho,hsml,id);
float phi;
if (*dmin<0 || *dmax<0)
phi=bar->computeAngle(*mvcod);
else
phi=bar->computeAngle((*dmin)/100.,(*dmax)/100.,true);
if (*rot==1) {
bar->rotateOnX(phi);
}
if (*rot==2) {
bar->rotateOnY(phi);
}
delete bar;
return true;
}
}
#endif // CBAR_H
......@@ -182,5 +182,34 @@ extern "C" {
return uns_proj::CRectify::snapTransform(*nbody,*time,pos,vel,filename,*status);
}
// fortran wrapper, parameters
// IN[integer] nbody : #bodies
// IN[real4] time
// IN[real4 array] pos, vel, mass, rho
// IN[integer] use_rho : 0 or 1 to compute density
// IN[character] cod_file
//OUT[character] rectfile (eigens vectors values)
// IN[float] cuting_radius
// IN[float] dmin (%density min)
// IN[float] dmax (%density max)
// for mdf (stars, set use_rho=0 and set a cuting_radius,
// then rho,dmin,dmax are not used, can be 0)
bool rectify_full_(const int * nbody,const float * time,
float * pos, float * vel, float * mass, float * rho,
int * use_rho,const char * cod_file, const char * rect_file,
float * radius, float * dmin, float * dmax,
const int len_cod, const int len_rect) {
std::string mycodf=jclut::CSnaptools::fixFortran(cod_file,len_cod);
std::string myrectf=jclut::CSnaptools::fixFortran(rect_file,len_rect);
// Rectify object
uns_proj::CRectify * crectify = new uns_proj::CRectify();
bool status=crectify->rectify(*nbody,*time,pos,vel,mass,rho,*use_rho,true,mycodf,
myrectf,*radius,*dmin,*dmax);
delete crectify;
return status;
}
}
#endif // CRECTIFY_H
#!/usr/bin/python
#!/usr/bin/env python
# unsio
from unsio import *
......
#!/usr/bin/python
#!/usr/bin/env python
#
......
#!/usr/bin/python
#
#!/usr/bin/env python
#
from __future__ import print_function
#
#
# save stars particles to density field for displaying with glnemo2
# MANDATORY
from unsio import * # import unsio package (UNSIO)
from unsio.input import * # import unsio package (UNSIO)
import numpy as np # arrays are treated as numpy arrays
import math
import argparse
......@@ -26,9 +26,9 @@ class snap:
hsml = None
rho = None
metal = None
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def commandLine():
dt=3
f_hsml=0.0001
......@@ -38,9 +38,9 @@ def commandLine():
parser.add_argument('output', help="NEMO output file ")
parser.add_argument('--dt', help="save particles:[age > time-time*dt%%],(time=current time)",default=dt,type=float)
parser.add_argument('--hsml', help='hsml value',type=float,default=f_hsml)
#parser.add_argument('time', help="time of reference to keep stars particles")
args = parser.parse_args()
......@@ -60,7 +60,7 @@ def selectAges(snap,dt,f_hsml): #,times):
# rescale pos
snap.pos = snap.pos[select]
snap.pos = np.reshape(snap.pos,snap.pos.size) # flatten the array (mandatory for unsio)
# rescale vel
snap.vel = snap.vel[select]
snap.vel = np.reshape(snap.vel,snap.vel.size) # flatten the array (mandatory for unsio)
......@@ -70,46 +70,46 @@ def selectAges(snap,dt,f_hsml): #,times):
# rescale ages
snap.ages = snap.ages[select]
# hsml
snap.hsml=np.zeros(snap.ages.size,dtype='float32')
snap.hsml += f_hsml
# -----------------------------------------------------
# compute, is the core function
def process(simname,out,dt,hsml): #,times):
components="stars"
components="stars"
verbose=False
#timef=float(times)
# Create a UNSIO object
uns = CunsIn(simname,components,"all",verbose)
uns = CUNS_IN(simname,components,"all",verbose)
# bits="I" # select properties, particles Identities only here
# get file name
# sim_name=uns.getFileName()
print ("simname=",simname, " out=",out,file=sys.stderr)
# load frame
ok=uns.nextFrame("")
#print ok
if (ok) :
ok,snap.ages = uns.getArrayF("stars","age")
ok,snap.ages = uns.getData("stars","age")
if ( ok ) :
#print "ok ",ok, snap.ages
print ("min=", snap.ages.min()," max=",snap.ages.max(),file=sys.stderr)
#embed()
ok,snap.time = uns.getValueF("time")
ok,snap.pos = uns.getArrayF("stars","pos")
ok,snap.vel = uns.getArrayF("stars","vel")
ok,snap.mass = uns.getArrayF("stars","mass")
ok,snap.time = uns.getData("time")
ok,snap.pos = uns.getData("stars","pos")
ok,snap.vel = uns.getData("stars","vel")
ok,snap.mass = uns.getData("stars","mass")
# select ages according to dt
selectAges(snap,dt,hsml)
# instantiate output object
unso=CunsOut(out,"nemo"); # output file
......@@ -122,11 +122,11 @@ def process(simname,out,dt,hsml): #,times):
unso.setArrayF("all","hsml",snap.hsml) # save hsml
unso.save()
else:
print ("there are no age for stars in this snapshot !!!",file=sys.stderr)
else :
print ("Didn't load anything....",file=sys.stderr)
......
#!/usr/bin/python
#!/usr/bin/env python
#
from __future__ import print_function
......
#!/usr/bin/python
#!/usr/bin/env python
# -----------------------------------------------------------------------
# For more information about how to use UNSIO, visit:
# http://projets.lam.fr/projects/unsio/
......
#!/usr/bin/python
#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
......
#!/usr/bin/python
#!/usr/bin/env python
#
......
#!/usr/bin/python
#!/usr/bin/env python
from __future__ import print_function
import sys
......
#!/usr/bin/python
#!/usr/bin/env python
#
......
#!/usr/bin/python
#!/usr/bin/env python
from __future__ import print_function
import sys
......
#!/usr/bin/python
#!/usr/bin/env python
#
......
#!/usr/bin/python
#!/usr/bin/env python
from __future__ import print_function
import sys
......
#!/usr/bin/python
#!/usr/bin/env python
#
from __future__ import print_function
......
#!/usr/bin/python
#!/usr/bin/env python
import parquet
import json
from math import *
......
#!/usr/bin/python
#!/usr/bin/env python
from __future__ import print_function
import sys
......
#!/usr/bin/python
#!/usr/bin/env python
#
......
#!/usr/bin/python
#!/usr/bin/env python
from __future__ import print_function
import sys
......
#!/usr/bin/python
#!/usr/bin/env python
#
from __future__ import print_function
#
......
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