Commit de622b13 authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles

switch to unsio module

parent 651e6ad7
Pipeline #697 failed with stages
......@@ -9,6 +9,7 @@
# python
*.pyc
\#*
# Compiled Object files
*.slo
......
#!/usr/bin/python
# unsio
from py_unsio import *
from unsio import *
import numpy as np
# cnd line
import sys, getopt,os.path
......
......@@ -6,7 +6,7 @@ from __future__ import print_function
# save stars particles to density field for displaying with glnemo2
# MANDATORY
from py_unsio import * # import py_unsio package (UNSIO)
from unsio import * # import unsio package (UNSIO)
import numpy as np # arrays are treated as numpy arrays
import math
import argparse
......
......@@ -6,7 +6,7 @@ from __future__ import print_function
# save stars particles to density field for displaying with glnemo2
# MANDATORY
from py_unsio import * # import py_unsio package (UNSIO)
from unsio import * # import unsio package (UNSIO)
import numpy as np # arrays are treated as numpy arrays
import math
import argparse
......
......@@ -12,7 +12,7 @@ import numpy as np # arrays are treated as numpy arrays
import os.path
#dirname, filename = os.path.split(os.path.abspath(__file__))
#sys.path.append(dirname+'../modules/') # trick to find modules directory
from py_unsio import *
from unsio import *
import copy
import tempfile
#from IPython import embed
......
......@@ -16,8 +16,8 @@
# unsio module loading
# ==> do not forget to update PYTHONPATH environment variable with
# py_unsio location path
from py_unsio import *
# unsio location path
from unsio import *
import numpy as np
# cmd line
......
#!/usr/bin/env python
from py_unsio import *
from unsio import *
import numpy as np
import argparse
......
......@@ -3,7 +3,7 @@
import yt
import numpy as np
import sys
from py_unsio import *
from unsio import *
from yt.data_objects.particle_filters import add_particle_filter
import math
import argparse
......
......@@ -6,7 +6,7 @@
# MANDATORY
from py_unsio import * # import py_unsio package (UNSIO)
from unsio import * # import unsio package (UNSIO)
import numpy as np # arrays are treated as numpy arrays
import math
import argparse
......
#!/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
import argparse
import os,glob
import errno
#from uns_simu import *
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
dbname=None
# help
parser = argparse.ArgumentParser(description="Link snapshot snapshot on continue MDF simulations",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# options
parser.add_argument('simname', help='simulation name path')
parser.add_argument('contdir', help='continuation sim dir')
parser.add_argument('--verbose',help='verbose mode on', dest="verbose", action="store_true", default=False)
# parse
args = parser.parse_args()
# start main funciton
process(args)
# -----------------------------------------------------
# process, is the core function
dirname="/rudata/mdf"
def process(args):
for ff in sorted(glob.glob(args.contdir+"/"+args.simname+"/SNAPS/snapshot*")):
try:
ff2,ext=ff.split(".")
except:
pass
base=os.path.basename(ff)
name,id=base.split("_")
try:
id,dummy=id.split(".")
except:
pass
target=dirname+"/"+args.simname+"/SNAPS/"+args.simname+"_"+id
if not os.path.islink(target):
print("target ",target)
print("ff =",ff)
try:
os.symlink(ff,target)
except OSError as e:
if e.errno == errno.EEXIST:
try:
os.remove(target)
os.symlink(ff,target)
except:
print("unable to remove ",target)
else:
raise e
# -----------------------------------------------------
# process, is the core function
def process1(args):
snap_list = sorted(glob.glob(args.snapshot+'_?'))
snap_list = snap_list+sorted(glob.glob(args.snapshot+'_??'))
snap_list = snap_list+sorted(glob.glob(args.snapshot+'_???'))
snap_list = snap_list+sorted(glob.glob(args.snapshot+'_????'))
snap_list = snap_list+sorted(glob.glob(args.snapshot+'_?????'))
cpt=0
for mysnap in snap_list:
mylink="snapshot_"+str(cpt)
if not os.path.islink(mylink):
print(mysnap,"snapshot_"+str(cpt))
os.symlink(mysnap,mylink)
cpt=cpt+1
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
#!/usr/bin/env python
import sys
from uns_simu import *
from 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="Build continuation fro MDF",
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', default=False)
# parse
args = parser.parse_args()
# start main funciton
process(args)
# -----------------------------------------------------
# process, is the core function
def process(args):
pass
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
......@@ -6,7 +6,7 @@
# save stars particles to density field for displaying with glnemo2
# MANDATORY
from py_unsio import * # import py_unsio package (UNSIO)
from unsio import * # import unsio package (UNSIO)
import numpy as np # arrays are treated as numpy arrays
import math
import argparse
......
......@@ -5,7 +5,7 @@ import sys
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
#from py_unstools import * # import py_unstools package
from py_unsio import *
from unsio import *
from uns_simu import *
from general.ctools import *
import argparse
......
......@@ -3,7 +3,7 @@ from __future__ import print_function
import sys
import numpy as np
from py_unsio import *
from unsio import *
import argparse
......
......@@ -6,7 +6,7 @@ from __future__ import print_function
# save stars particles to density field for displaying with glnemo2
# MANDATORY
from py_unsio import * # import py_unsio package (UNSIO)
from unsio import * # import unsio package (UNSIO)
import numpy as np # arrays are treated as numpy arrays
import math
import argparse
......
......@@ -9,7 +9,7 @@ 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
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
from simulations.cuns_analysis import *
......
......@@ -5,7 +5,7 @@ import sys
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
#from py_unstools import * # import py_unstools package
from py_unsio import *
from unsio import *
from uns_simu import *
import argparse
......
......@@ -2,7 +2,7 @@
from __future__ import print_function
import sys
from py_unsio import * # import py_unsio package (UNSIO)
from unsio import * # import unsio package (UNSIO)
import argparse
......
......@@ -6,7 +6,7 @@
# save stars particles born before/after a specific time
# MANDATORY
from py_unsio import * # import py_unsio package (UNSIO)
from unsio import * # import unsio package (UNSIO)
import numpy as np # arrays are treated as numpy arrays
import math
import argparse
......
......@@ -2,7 +2,7 @@
from __future__ import print_function
import sys
from py_unsio import * # import py_unsio package (UNSIO)
from unsio import * # import unsio package (UNSIO)
import argparse
import time
......
......@@ -5,7 +5,7 @@ from __future__ import print_function
# save stars particles to density field for displaying with glnemo2
# MANDATORY
from py_unsio import * # import py_unsio package (UNSIO)
from unsio import * # import unsio package (UNSIO)
import numpy as np # arrays are treated as numpy arrays
import math
import argparse
......
......@@ -6,7 +6,7 @@
# save gas particles temperature to density field for displaying with glnemo2
# MANDATORY
from py_unsio import * # import py_unsio package (UNSIO)
from unsio import * # import unsio package (UNSIO)
import numpy as np # arrays are treated as numpy arrays
import math
import argparse
......
#!/usr/bin/env python
from __future__ import print_function
import numpy as np
import os,time
import sys
import argparse,textwrap
import scipy.ndimage as ndi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
# help
parser = argparse.ArgumentParser(description="Test grid",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--out', help="if blank display on screen, else on given file ",default="",type=str)
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('--contour',help='toggle contour display',dest="contour", action="store_true", default=False)
parser.add_argument('--cmap', help="color map (see mathplotlib colormap)",default="jet")
parser.add_argument('--verbose',help='verbose mode',dest="verbose", action="store_true", default=False)
# parse
args = parser.parse_args()
# 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')
try:
fullProcess(out=args.out,sigma=args.sigma,cmap=args.cmap,noxz=args.noxz, contour=args.contour)
except Exception as x :
print (x.message,file=sys.stderr)
except KeyboardInterrupt:
sys.exit()
#
#
#
def fullProcess(out,sigma,noxz=False, contour=False, cmap="jet",ncols=3):
import matplotlib.colors
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
t0=time.clock()
sigma_ori=sigma
# set up grid display
nrows=2
if noxz: # no XZ projection
nrows=1
ncols=ncols
# compute aspect ratio
mydpi=80
if nrows<ncols:
inches=19
#inches = 1920./mydpi # 1920
w=inches
h=inches*nrows/ncols
else: # nrows>ncols
inches = 1080./mydpi
w=inches*ncols/nrows
h=inches
print("w/h=",w,h,w*mydpi,h*mydpi)
# specify figure dimensions
fig=plt.figure(figsize=(w,h),dpi=mydpi)
#fig=plt.figure(figsize=(w,h))
print ("FIG DPI =",fig.dpi)
# create grid
gs = gridspec.GridSpec(nrows, ncols)#,wspace=0,hspace=0)#height_ratios=h,width_ratios=w)
for r in range(nrows):
for c in range(ncols):
ax = plt.subplot(gs[r, c])
ax.set(aspect=1)
zz=np.random.random((102,102))
qq=ndi.gaussian_filter(zz,sigma=1.6,order=0)
im = ax.imshow(qq, norm = matplotlib.colors.LogNorm(), cmap=cmap)
plt.contour(qq,cmap="Paired")
ax.set_xticks([])
ax.set_yticks([])
if r != nrows-1:
ax.set_xticks([])
if c!=0:
ax.set_yticks([])
ax.set_xticklabels("Hey")
fig.subplots_adjust(hspace=0.,wspace=0.)
fig.subplots_adjust(hspace=0.,wspace=0.)
print("Overall time [%.3f] sec"%(time.clock()-t0),file=sys.stderr)
if (out==''):
plt.show()
else:
outfile=out
print (">> ",outfile)
plt.savefig(outfile, bbox_inches=0,dpi=fig.dpi)
plt.close(fig)
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
......@@ -5,8 +5,8 @@ import sys
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
#from py_unstools import * # import py_unstools package
from py_unsio import *
from uns_simu import *
#from unsio import *
#from uns_simu import *
import argparse
import os
......
......@@ -5,6 +5,7 @@ from uns_simu import *
from 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
......@@ -14,7 +15,7 @@ def commandLine():
fastcod=True
threshold=10000
# help
parser = argparse.ArgumentParser(description="Convert enzo simulation to gdget2",
parser = argparse.ArgumentParser(description="Compute COD on simulation",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# options
parser.add_argument('simname', help='Simulation name')
......
#!/usr/bin/env python
import sys
from uns_simu import *
from 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="Extract halo from multiple MDF halo simulation",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# options
parser.add_argument('simname', help='Simulation name')
parser.add_argument('haloN', help='Selected component')
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):
pass
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
......@@ -16,8 +16,8 @@
from __future__ import print_function
# unsio module loading
# ==> do not forget to update PYTHONPATH environment variable with
# py_unsio location path
from py_unsio import *
# unsio location path
from unsio import *
import numpy as np
# cmd line
......
# unsio
from py_unsio import *
from unsio import *
import numpy as np
# cnd line
import sys, getopt
......
......@@ -2,7 +2,7 @@
from __future__ import print_function
import sys
from py_unsio import * # import py_unsio package (UNSIO)
from unsio import * # import unsio package (UNSIO)
import numpy as np
import argparse
#from IPython import embed
......
......@@ -7,7 +7,7 @@
from __future__ import print_function
# MANDATORY
from py_unsio import * # import py_unsio package (UNSIO)
from unsio import * # import unsio package (UNSIO)
import numpy as np # arrays are treated as numpy arrays
import math
import argparse
......
#!/usr/bin/python
#!/usr/bin/env python
from __future__ import print_function
import sys
from uns_simu import *
......@@ -8,7 +8,12 @@ from ctree import *
from multiprocessing import Process, Lock,Pool
import multiprocessing
import Queue # necessary to raise Queue.Empty signal
is_py2 = sys.version[0] == '2'
if is_py2:
import Queue as Queue
else:
import queue as Queue
#import Queue # necessary to raise Queue.Empty signal
import time
import os
import signal
......@@ -41,7 +46,7 @@ class CCod:
# ----
#
# constructor
def __init__(self,simname,analysis=None,cod_dir_name=None,dbname=None,verbose=False,verbose_debug=False):
def __init__(self,simname,analysis=None,cod_dir_name=None,cod_base=None,dbname=None,threshold=None,verbose=False,verbose_debug=False):
"""
simname must be a UNS simulation belonging to a uns sqlite3 database.
infos regarding to simname simulation are loaded into privates variables
......@@ -49,6 +54,9 @@ class CCod:
self.__vdebug=verbose_debug
self.__verbose=verbose
if threshold is not None:
self.__ctree_threshold =threshold
if cod_dir_name is not None:
self.__COD_DIR_NAME=cod_dir_name
......
......@@ -2,7 +2,7 @@
from __future__ import print_function
#from py_unstools import * # import py_unstools package
from py_unsio import *
import unsio
from uns_simu import *
from cfalcon import *
from ccod import *
......@@ -37,11 +37,11 @@ class CSnapshot:
if float32:
if self.__vdebug:
print("32 bits",simname,select,times,verbose,type(simname),type(select))
self.__uns=CunsIn(simname,select,times,verbose)
self.__uns=unsio.CunsIn(simname,select,times,verbose)
else:
if self.__vdebug:
print("64 bits",simname,select,times,verbose)
self.__uns=CunsInD(simname,select,times,verbose)
self.__uns=unsio.CunsInD(simname,select,times,verbose)
if not self.__uns.isValid():
raise RuntimeError("UNS not valid")
else:
......
#!/usr/bin/env python
from __future__ import print_function
from uns_simu import *
#from uns_simu import *
import os,sys
import numpy as np
import tempfile
import py_unsio as unsio
import unsio as unsio
from csnapshot import *
import subprocess
......@@ -211,4 +211,34 @@ class CTestunsio:
self.__compareModel(unstype=mm,single=self.__single)