the serveur will be in maintenance mode Thursday February 25 from 7:00 to 12:00 ( git and registry will be unreacheable)

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

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
#
......
#!/usr/bin/python
#!/usr/bin/env python
from __future__ import print_function
import sys
......
#!/usr/bin/python
#!/usr/bin/env python
#
......
#!/usr/bin/env python
import sys
import unsio.output as u_out
import unsio.input as u_in
import argparse
import numpy as np
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
dbname=None
ncores=None
# help
parser = argparse.ArgumentParser(description="Change masses and velocities from mdf IC",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# options
parser.add_argument('input', help='Simulation name')
parser.add_argument('output', help=' output file')
parser.add_argument('mass_f', help='mass factor value',type=float)
parser.add_argument('--dbname',help='UNS database file name', default=dbname)
parser.add_argument('--verbose',help='verbose mode', default=False)
# parse
args = parser.parse_args()
# start main funciton
process(args)
def readAndWrite(comp,tag,uns_snap,outsnap,mass_f,verbose):
ok,data=uns_snap.getData(comp,tag)
if verbose:
print("Type :",data.dtype," tag=",tag)
if ok:
print(" ",tag,end="")
if tag=="mass":
data=data*mass_f
if tag=="vel":
data=data*(mass_f**0.5)
# save array
outsnap.setData(data,comp,tag)
# -----------------------------------------------------
# process, is the core function
def process(args):
uns_snap=u_in.CUNS_IN(args.input,"all",verbose_debug=args.verbose)
ok_load = uns_snap.nextFrame()
ok,timex=uns_snap.getData("time")
# open for writing snapshot
outsnap=u_out.CUNS_OUT(args.output,uns_snap.getInterfaceType())
print ("Time :",timex)
if ok_load:
for comp in (["halo","gas","stars","disk","bulge"]):
print("COMP [%s]"%comp,end="")
for tag in (["pos","vel","mass","id","rho","hsml","acc","pot","u"]):
readAndWrite(comp,tag,uns_snap,outsnap,args.mass_f,args.verbose)
print("\n")
outsnap.save()
else:
print ("unable to load snapshot")
#
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
......@@ -41,15 +41,15 @@ def process(args):
if cod.isMultipleHalo():
print("Muliple halo = ",cod.isMultipleHalo())
uns_snap=csnapshot.CSnapshot(args.input,"halo")
ok = uns_snap.nextFrame()
ok = uns_snap.unsin.nextFrame()
if ok:
select="halo"
ok,timex=uns_snap.getData("time")
ok,timex=uns_snap.unsin.getData("time")
print("timex=",timex,type(timex))
ok,pos=uns_snap.getData(select,"pos")
ok,mass=uns_snap.getData(select,"mass")
ok,vel =uns_snap.getData(select,"vel")
ok,id=uns_snap.getData(select,"id")
ok,pos=uns_snap.unsin.getData(select,"pos")
ok,mass=uns_snap.unsin.getData(select,"mass")
ok,vel =uns_snap.unsin.getData(select,"vel")
ok,id=uns_snap.unsin.getData(select,"id")
ok,mass,pos,vel = cod.getExtractHalo(id,mass,pos,vel,args.haloN)
print(mass,pos,vel)
unso=unsio.CunsOut(args.output,"nemo")
......
......@@ -47,8 +47,8 @@ def process(args):
latest=snap_list[-1]
print("Latest snapshot [%s]\n"%(latest),file=sys.stderr)
s=CSnapshot(latest)
ok=s.nextFrame("I")
ok,t=s.getData("time")
ok=s.unsin.nextFrame("I")
ok,t=s.unsin.getData("time")
if ok:
print("Latest time [%f]\n"%(t),file=sys.stderr)
print("%f"%(t))
......
#!/usr/bin/python
#!/usr/bin/env python
#
......
......@@ -4,13 +4,13 @@ import sys
sys.path.append('/home/jcl/works/GIT/uns_projects/py/modules/')
sys.path.append('/home/jcl/works/GIT/uns_projects/py/modules/simulations')
from uns_simu import *
from ctree import *
from ctree import *
from csnapshot import *
import argparse
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def commandLine():
dbname=None
ncores=None
......@@ -41,13 +41,13 @@ def process(args):
#cod = CCod(inputfile=args.inputfile,verbose_debug=args.verbose,dbname=args.dbname)
#cod.compute(args.select,args.ncores)
uns_snap=CSnapshot(args.inputfile,args.select)
ok=uns_snap.nextFrame("mxv")
ok=uns_snap.unsin.nextFrame("mxv")
if ok:
ok,timex=uns_snap.getData("time")
ok,pos=uns_snap.getData(args.select,"pos")
#ok,vel=uns_snap.getData(args.select,"vel")
ok,mass=uns_snap.getData(args.select,"mass")
ok,timex=uns_snap.unsin.getData("time")
ok,pos=uns_snap.unsin.getData(args.select,"pos")
#ok,vel=uns_snap.unsin.getData(args.select,"vel")
ok,mass=uns_snap.unsin.getData(args.select,"mass")
ctree=CTree(pos,None,mass,time=timex)
print("Time = ",timex)
......
......@@ -75,10 +75,10 @@ class C2dpgplot:
"""
# try to load positions
ok,pos=uns_snap.getData(select,"pos")
ok,pos=uns_snap.unsin.getData(select,"pos")
if ok:
# load time
ok,time=uns_snap.getData("time")
ok,time=uns_snap.unsin.getData("time")
# build range vector
nrange=np.empty([3,2],dtype='f')
......@@ -97,7 +97,7 @@ class C2dpgplot:
# properties
if prop != "":
ok,weight=uns_snap.getData(select,prop)
ok,weight=uns_snap.unsin.getData(select,prop)
if not ok:
print("No properties [%s] for the selection"%(prop))
else:
......@@ -119,14 +119,14 @@ class C2dpgplot:
legend=legend+sitf[itf]
# com
if com:
ok,mass=uns_snap.getData(select,"mass")
ok,mass=uns_snap.unsin.getData(select,"mass")
if mass.size<1:
mass=np.ones(pos.size/3)
uns_snap.center(pos,None,mass,center=True)
print("center pos=",pos)
# print file name ?
if pfname:
filename=uns_snap.getFileName()
filename=uns_snap.unsin.getFileName()
else:
filename=""
# color bar
......@@ -141,7 +141,8 @@ class C2dpgplot:
#print(pos.size,outdev,no,weight)
#print(outdev,no,pos,nrange,title,comp_prop,filename,time.item(),xy,xz,zy,\
# True,weight,psort,hsml,itf,cb,legend,cmap)
self.__c.compute_image(outdev,no,pos,nrange,title,comp_prop,filename,time.item(),xy,xz,zy,\
print("TIME =",time,type(time))
self.__c.compute_image(outdev,no,pos,nrange,title,comp_prop,filename,time,xy,xz,zy,\
True,weight,psort,hsml,itf,cb,legend,cmap)
else:
......@@ -180,7 +181,7 @@ def process(args):
import unsiotools.simulations.csnapshot as csnap
try:
uns=csnap.CSnapshot(args.snapshot,args.component,verbose_debug=args.verbose)
ok=uns.nextFrame("")
ok=uns.unsin.nextFrame("")
if ok:
c=c2dpg.C2dpgplot()
c.draw(uns_snap=uns,select=args.component,outdev=args.dev,rrange=args.range,\
......@@ -189,6 +190,8 @@ def process(args):
print ("[%s] is not a UNS snapshot ..."%(simname))
except Exception as x :
print (x)
#import traceback
#traceback.print_exc(file=sys.stdout)
# -----------------------------------------------------
......
......@@ -129,7 +129,7 @@ class C2dplot:
data=analysis
uns_snap=data.uns_snap # link to UNS object
ok,time=uns_snap.getData("time")
ok,time=uns_snap.unsin.getData("time")
if self.__vdebug:
print("Core [%d] time <%f>"%(data.core_id,time))
if not contour:
......@@ -138,7 +138,7 @@ class C2dplot:
my_dir=self.__movie_dir_contour
t_file=my_dir+"/.time_completed"
if not self.__checkTimeExist(time,t_file): # time not computed yet
filename=uns_snap.getFileName()
filename=uns_snap.unsin.getFileName()
basefile=os.path.basename(filename)
no=int(basefile.split("_")[1]) # compute no
out=my_dir+"/frame"
......@@ -356,7 +356,7 @@ class C2dplot:
print("Simulation name from merger [%s]\n"%(simname))
print("SELF.__ANALYSIS = <%s>"%(self.__analysis))
cod=CCod(simname,verbose_debug=self.__vdebug)
ok,time=self.__uns.getData("time")
ok,time=self.__uns.unsin.getData("time")
cod_base=None
if self.__analysis is not None:
if hasattr(self.__analysis,"cod_dir"):
......@@ -424,7 +424,7 @@ class C2dplot:
comp=component.split(",")
ok,timex=uns.getData("time")
ok,timex=uns.unsin.getData("time")
if self.__vdebug:
print ("Loading time : " , time.clock()-t0)
......@@ -486,7 +486,7 @@ class C2dplot:
# create grid
gs = gridspec.GridSpec(nrows, ncols,wspace=0,hspace=0)#height_ratios=h,width_ratios=w)
#print(gs.get_width_ratios(),gs.get_height_ratios(),gs.get_grid_positions(fig))
fig.suptitle(os.path.basename(uns.getFileName())+" - time : %.03f"%(timex))
fig.suptitle(os.path.basename(uns.unsin.getFileName())+" - time : %.03f"%(timex))
for r in range(nrows):
for c in range(ncols):
......@@ -532,20 +532,20 @@ class C2dplot:
comp=component
# get data
ok,pos=uns.getData(comp,"pos") # positions
ok,pos=uns.unsin.getData(comp,"pos") # positions
if self.__vdebug:
print("return getpos :",ok)
if ok:
# get data
ok,rho=uns.getData(comp,"rho") # rho
ok,rho=uns.unsin.getData(comp,"rho") # rho
if not ok:
rho=np.ones(int(pos.size/3))
# get data