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

a lot of progress for py3

parent 7c6fda7d
#!/usr/bin/python
from __future__ import print_function
import sys
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
#from unsiotools.uns_simu import *
from unsiotools.simulations.ccod import *
import argparse
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
dbname=None
ncores=None
pngfile=None
txtfile=None
cod1=None
cod2=None
dmax=1.0
# help
parser = argparse.ArgumentParser(description="Display merging time",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# options
parser.add_argument('simname', help='Simulation name')
parser.add_argument('--dmax', help='max distance of separation (kpc)',default=dmax,type=float)
parser.add_argument('--cod1', help='first cod file',default=cod1)
parser.add_argument('--cod2', help='second cod file',default=cod2)
parser.add_argument('--seger', help='use sergey files',dest="seger",action='store_true',default=False)
#parser.add_argument('--no-seger', help='use base simulation files',dest="seger",action='store_false',default=True)
parser.add_argument('--pngfile', help='png filename, if None interactive plot',default=pngfile)
parser.add_argument('--txtfile', help='merging time filename, if None not saved',default=txtfile)
parser.add_argument('--plot', help='Enable ploting',dest='plot',action='store_true',default=False)
#parser.add_argument('--no-plot', help='Disable ploting',dest='plot',action='store_false',default=True)
parser.add_argument('--dbname',help='UNS database file name', default=dbname)
parser.add_argument('--verbose',help='verbose mode on', dest="verbose", action="store_true", default=False)
parser.add_argument('--saveanalysis',help='save merging time in ANALYSIS directory', dest="store_analysis", action="store_true", default=False)
#parser.add_argument('--no-verbose',help='verbose mode off', dest="verbose", action="store_false", default=True)
# parse
args = parser.parse_args()
if args.pngfile=="None":
args.pngfile=None
# start main funciton
process(args)
# -----------------------------------------------------
# process, is the core function
def process(args):
cod = CCod(simname=args.simname,verbose_debug=args.verbose,dbname=args.dbname)
try:
mt=cod.computeMergingTime(halo_1=args.cod1,halo_2=args.cod2,pngfile=args.pngfile,txtfile=args.txtfile,dmax=args.dmax,seger=args.seger,plot=args.plot,store_analysis=args.store_analysis)
if mt<0.0:
mt=0.0
print("%f\n"%(mt))
except KeyboardInterrupt:
sys.exit()
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
#!/usr/bin/env python
from __future__ import print_function
import sys
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
from unsiotools.simulations.cmovie import *
import argparse
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
dbname=None
# help
parser = argparse.ArgumentParser(description="Build simulation movie after smart analysis",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# options
parser.add_argument('simname', help='Simulation name')
parser.add_argument('--dbname',help='UNS database file name', default=dbname)
parser.add_argument('--verbose',help='verbose mode on', dest="verbose", action="store_true", default=False)
parser.add_argument('--overwrite',help='overwrite file if exist', dest="overwrite", action="store_true", default=False)
parser.add_argument('--ncores', help='#cores used, 0 means all',default=4,type=int)
#parser.add_argument('--no-verbose',help='verbose mode off', dest="verbose", action="store_false", default=True)
# parse
args = parser.parse_args()
# start main funciton
process(args)
# -----------------------------------------------------
# process, is the core function
def process(args):
movie = CMovie(verbose_debug=args.verbose)
try:
movie.buildMovie(args.simname,args.overwrite,args.ncores)
pass
except Exception as x :
print(x.message)
sys.exit()
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
#!/usr/bin/env python
from __future__ import print_function
import sys
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
from simulations.c2dplot import *
import argparse
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
dbname=None
# help
parser = argparse.ArgumentParser(description="Build simulation movie after smart analysis",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# options
parser.add_argument('simname', help='Simulation name')
parser.add_argument('--dbname',help='UNS database file name', default=dbname)
parser.add_argument('--verbose',help='verbose mode on', dest="verbose", action="store_true", default=False)
parser.add_argument('--overwrite',help='overwrite file if exist', dest="overwrite", action="store_true", default=False)
parser.add_argument('--ncores', help='#cores used, 0 means all',default=4,type=int)
#parser.add_argument('--no-verbose',help='verbose mode off', dest="verbose", action="store_false", default=True)
# parse
args = parser.parse_args()
# start main funciton
process(args)
# -----------------------------------------------------
# process, is the core function
def process(args):
movie = C2dplot(verbose_debug=args.verbose)
try:
movie.buildMovie(args.simname,overwrite=args.overwrite,ncores=args.ncores)
pass
except Exception as x :
print(x.message)
sys.exit()
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
#!/usr/bin/env python
from __future__ import print_function
import os,time
import sys
from multiprocessing import Process
import Queue
import multiprocessing
import numpy as np
import argparse
import matplotlib
matplotlib.use('Agg')
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
from unsiotools.simulations.cuns_analysis import *
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
dbname=None
ncores=None
# help
parser = argparse.ArgumentParser(description="Parallel pipeline analysis program",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# options
parser.add_argument('simname', help='Simulation name')
parser.add_argument('script', help='Analysis script')
parser.add_argument('--ncores', help='Use ncores, None means all',default=ncores,type=int)
parser.add_argument('--dbname',help='UNS database file name', default=dbname)
parser.add_argument('--verbose',help='verbose mode', default=False)
print ("Matplotlib backend Using:",matplotlib.get_backend(),file=sys.stderr)
# parse
args = parser.parse_args()
# start main funciton
process(args)
# -----------------------------------------------------
# process, is the core function
def process(args):
try:
analysis=CUnsAnalysis(simname=args.simname, script=args.script,verbose_debug=args.verbose)
except Exception as x :
print (x.message)
else:
analysis.compute(args.ncores)
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
#!/usr/bin/env python
from __future__ import print_function
import numpy as np
import os,time
import sys
import argparse,textwrap
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
from unsiotools.simulations.c2dpgplot import *
from unsiotools.simulations.csnapshot import *
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
# help
parser = argparse.ArgumentParser(description="Compute 2D image using uns_projects c2dpgplot engine",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('snapshot', help="uns input snapshot",default=None)
parser.add_argument('component', help="selected component",default=None)
parser.add_argument('--range', help="plot range (X or -A:B) ",default=35,type=str)
parser.add_argument('--psort', help="sort particles according to properties",default=0,type=int)
parser.add_argument('--prop', help="properties to plot (age,rho)",default="",type=str)
parser.add_argument('--pfname', help="print filename (1:True, 0:False)",default=1,type=int)
parser.add_argument('--cb', help="display color bar (1:True, 0:False)",default=0,type=int)
parser.add_argument('--cmap', help="color map (0:rainbow, 1:heat, 2:gray)",default=0,type=int)
parser.add_argument('--dev', help="pgplot device",default="?")
parser.add_argument('--verbose',help='verbose mode', default=False)
# parse
args = parser.parse_args()
# start main funciton
process(args)
# -----------------------------------------------------
# process, is the core function
def process(args):
try:
uns=CSnapshot(args.snapshot,args.component,verbose_debug=args.verbose)
ok=uns.nextFrame("")
if ok:
print("here 0")
c=C2dpgplot()
#print("here 1")
c.draw(uns_snap=uns,select=args.component,outdev=args.dev,rrange=args.range,\
prop=args.prop,psort=args.psort,pfname=args.pfname,cb=args.cb,cmap=args.cmap)
#print("here 2")
else:
print ("[%s] is not a UNS snapshot ..."%(simname))
except Exception as x :
print (x.message)
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
#!/usr/bin/env python
from __future__ import print_function
import numpy as np
import os,time
import sys
import argparse,textwrap
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/']+sys.path
#from IPython import embed
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
# help
parser = argparse.ArgumentParser(description="Display 2D image from UNS data",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('snapshot', help="uns input snapshot",default=None)
parser.add_argument('component', help="selected component",default=None)
parser.add_argument('--out', help="if blank display on screen, else on given file ",default="",type=str)
parser.add_argument('--range', help="plot range",default=20,type=str)
parser.add_argument('--cmap', help="color map name. You can use a common cmap for all components, or a specific one.\
Syntax is \"component1:cmap1,component2:cmap2\"\
example: stars:Paired,halo:Purples\n \
(to display all colormap available use \"show\" as keyword)",
default="gas:jet,stars:Paired,halo:Accent")
parser.add_argument('--mergers', help="use results from mergers analysis to re-center (ex; @mdf648) to get file automatically from simulation ",default="",type=str)
parser.add_argument('--cod', help="use COD file to re-center, or @sim (ex; @mdf648) to get file automatically from simulation ",default=None)
parser.add_argument('--rect_sim', help="give a simname or a rectify file name to activate rectify",default=None)
parser.add_argument('--rect_comp', help="used component based file, eg 'stars-stars' or 'gas-stars'",default="stars-stars")
parser.add_argument('--rect_dir', help="rectify directory name",default="rectify2")
parser.add_argument('--rect_suffix',help="rectify suffix file name",default="ev")
parser.add_argument('--sigma', help="gaussian sigma ",default=6.,type=float)
parser.add_argument('--noxz',help='no XZ projection',dest="noxz", action="store_true", default=False)
parser.add_argument('--nopart',help='not display particles number',dest="nopart", action="store_true", default=False)
parser.add_argument('--contour',help='toggle iso contour display',dest="contour", action="store_true", default=False)
parser.add_argument('--nc',help='#levels contour',default=20,type=int)
parser.add_argument('--cpt', help="index of the image (out.cpt.jpg)",default=0,type=int)
parser.add_argument('--verbose',help='verbose mode',dest="verbose", action="store_true", default=False)
#parser.print_help()
# parse
args = parser.parse_args()
if args.cmap=="show": # show colormap
import general.ctools as ct
ct.displayColormap()
sys.exit()
# start main funciton
process(args)
# -----------------------------------------------------
# process, is the core function
def process(args):
# select matplotlib backend
if args.out!= "": # non interactive
import matplotlib
matplotlib.use('Agg')
# we import this modules here because
# matplotlib.use() must be done before importing matplotlib.pyplot
import unsiotools.simulations.c2dplot as c2d
import unsiotools.simulations.csnapshot as csnap
try:
cpt = args.cpt
uns=csnap.CSnapshot(args.snapshot,args.component,verbose_debug=args.verbose)
#ok=uns.nextFrame("")
while(uns.nextFrame("")):
c=c2d.C2dplot(verbose_debug=args.verbose)
c.fullProcess(uns=uns,out=args.out,component=args.component,xrange=float(args.range),sigma=args.sigma,
mergers=args.mergers,cmap=args.cmap,cpt=cpt,noxz=args.noxz, contour=args.contour,
nc=args.nc,center_cod=args.cod,nopart=args.nopart,
rect_sim=args.rect_sim,rect_comp=args.rect_comp,rect_dir=args.rect_dir,rect_suffix=args.rect_suffix)
cpt =cpt+1
# else:
# print ("[%s] is not a UNS snapshot ..."%(simname))
except Exception as x :
print (x.message,file=sys.stderr)
except KeyboardInterrupt:
sys.exit()
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
#!/usr/bin/env python
import sys
from unsiotools.uns_simu import *
from unsiotools.simulations.ccod import *
import argparse
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
dbname=None
ncores=None
fastcod=True
threshold=10000
# help
parser = argparse.ArgumentParser(description="Compute COD on simulation",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# options
parser.add_argument('simname', help='Simulation name')
parser.add_argument('select', help='Selected component')
parser.add_argument('--fastcod', help='compute density by selecting particles from octree',default=fastcod)
parser.add_argument('--threshold', help='number of particles used for fastcod (<0 percentage)',default=threshold,type=int)
parser.add_argument('--ncores', help='Use ncores, None means all',default=ncores,type=int)
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)
# -----------------------------------------------------
# process, is the core function
def process(args):
cod = CCod(simname=args.simname,verbose_debug=args.verbose,dbname=args.dbname)
cod.compute(select=args.select,ncores=args.ncores,fastcod=args.fastcod,threshold=args.threshold)
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
#!/usr/bin/env python
from __future__ import print_function
import numpy as np
import os,time
import sys
import argparse,textwrap
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
import unsiotools.simulations.cinert as cinert
#import simulations.csnapshot as csnap
#from unsiotools.simulations.csnapshot import *
#from IPython import embed
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
# help
parser = argparse.ArgumentParser(description="Compute Moment of Inertia on UNS simulation",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('snapshot', help="uns input snapshot",default=None)
parser.add_argument('component', help="selected component",default=None)
parser.add_argument('--outfile', help="output file name",default=None)
parser.add_argument('--ncut', help="#cuts ",default=20,type=int)
parser.add_argument('--fmin', help="fract min ",default=0.1,type=float)
parser.add_argument('--fmax', help="fract max ",default=0.9,type=float)
parser.add_argument('--tree_threshold', help=">0 #particles, <0 percentage of particles ",default=-10.,type=float)
parser.add_argument('--notree_density',help='don''t use tree density',dest="notree", action="store_true", default=False)
parser.add_argument('--cod', help="use COD file to re-center, or @sim (ex; @mdf648) to get file automatically from simulation ",default=None)
parser.add_argument('--nocom', help='dont use com if no COD file requested',dest="nocom", action="store_true", default=False)
parser.add_argument('--nonemo', help='dont use Nemo algorithms (based on snapinert)',dest="nonemo", action="store_true", default=False)
parser.add_argument('--verbose',help='verbose mode',dest="verbose", action="store_true", default=False)
# parse
args = parser.parse_args()
# start main function
process(args)
# -----------------------------------------------------
# process, is the core function
def process(args):
try:
# instantiate CInert object
inert=cinert.CInert(snapshot=args.snapshot,outfile=args.outfile,ncut=args.ncut,
component=args.component,center_file=args.cod,
fract_min=args.fmin,fract_max=args.fmax,com=not args.nocom,
verbose_debug=args.verbose,
tree_density=not args.notree,tree_threshold=args.tree_threshold,nonemo=args.nonemo)
# start full process
inert.fullProcess(args.snapshot,args.component)
except Exception as x :
print (x.message,file=sys.stderr)
except KeyboardInterrupt:
sys.exit()
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
#!/usr/bin/env python
from __future__ import print_function
import numpy as np
import os,time
import sys
import argparse,textwrap
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
import unsiotools.simulations.cplotinert as pmoi
#from IPython import embed
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
# help
parser = argparse.ArgumentParser(description="Display Moment of Inertia results",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('simname', help="uns input simulation name",default=None)
parser.add_argument('--component', help="selected component",default="halo")
parser.add_argument('--ncut', help="#cuts ",default=20,type=int)
parser.add_argument('--outfile', help="output file name",default=None)
parser.add_argument('--nodisp', help='dont display on screen',dest="nodisp", action="store_true", default=False)
parser.add_argument('--noprogress', help='dont display a progress bar',dest="noprogress", action="store_true", default=False)
parser.add_argument('--verbose',help='verbose mode',dest="verbose", action="store_true", default=False)
# parse
args = parser.parse_args()
# start main function
process(args)
# -----------------------------------------------------
# process, is the core function
def process(args):
try:
pinert=pmoi.CPlotInert(args.simname,component=args.component,ncut=args.ncut, progress=not args.noprogress,
disp=not args.nodisp,outfile=args.outfile,verbose_debug=args.verbose)
except Exception as x :
print (x.message,file=sys.stderr)
except KeyboardInterrupt:
sys.exit()
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
......@@ -146,3 +146,52 @@ class C2dpgplot:
else:
print("There is no position in snapshot...")
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
import argparse
# help
parser = argparse.ArgumentParser(description="Compute 2D image using uns_projects c2dpgplot engine",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('snapshot', help="uns input snapshot",default=None)
parser.add_argument('component', help="selected component",default=None)
parser.add_argument('--range', help="plot range (X or -A:B) ",default=35,type=str)
parser.add_argument('--psort', help="sort particles according to properties",default=0,type=int)
parser.add_argument('--prop', help="properties to plot (age,rho)",default="",type=str)
parser.add_argument('--pfname', help="print filename (1:True, 0:False)",default=1,type=int)
parser.add_argument('--cb', help="display color bar (1:True, 0:False)",default=0,type=int)
parser.add_argument('--cmap', help="color map (0:rainbow, 1:heat, 2:gray)",default=0,type=int)
parser.add_argument('--dev', help="pgplot device",default="?")
parser.add_argument('--verbose',help='verbose mode', default=False)
# parse
args = parser.parse_args()
# start main funciton
process(args)
# -----------------------------------------------------
# process, is the core function
def process(args):
import unsiotools.simulations.c2dpgplot as c2dpg
import unsiotools.simulations.csnapshot as csnap
try:
uns=csnap.CSnapshot(args.snapshot,args.component,verbose_debug=args.verbose)
ok=uns.nextFrame("")
if ok:
c=c2dpg.C2dpgplot()
c.draw(uns_snap=uns,select=args.component,outdev=args.dev,rrange=args.range,\
prop=args.prop,psort=args.psort,pfname=args.pfname,cb=args.cb,cmap=args.cmap)
else:
print ("[%s] is not a UNS snapshot ..."%(simname))
except Exception as x :