Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 60eba629 authored by perdereau's avatar perdereau
Browse files

Merge branch 'master' of https://gitlab.in2p3.fr/cosmotools/CAMEL

ndent pbs
parents 0338a016 533f81d2
......@@ -540,9 +540,10 @@ def hist2d( chain, par1, par2, *args, **kwargs):
H = nd.gaussian_filter( H, nsmooth)
npts = 5.
plt.imshow( H.T, origin='bottom', **kwargs)
plt.xticks(np.arange(npts+1)/npts*bins,["%4.2f" % i for i in np.linspace(extent[0][0],extent[0][1],npts+1)])
plt.yticks(np.arange(npts+1)/npts*bins,["%4.2f" % i for i in np.linspace(extent[1][0],extent[1][1],npts+1)])
# plt.imshow( H.T, origin='bottom', **kwargs)
# plt.xticks(np.arange(npts+1)/npts*bins,["%4.2f" % i for i in np.linspace(extent[0][0],extent[0][1],npts+1)])
# plt.yticks(np.arange(npts+1)/npts*bins,["%4.2f" % i for i in np.linspace(extent[1][0],extent[1][1],npts+1)])
plt.pcolormesh( X, Y, H.T, **kwargs)
plt.xlabel(parname.get(par1,par1))
plt.ylabel(parname.get(par2,par2))
......@@ -1345,6 +1346,23 @@ class prof:
v,p = self.get()
self._p = p
self.ymin = min(p)
def write( self, filename):
params = [self.parname]+list(np.extract( self._params(self._s[0])!=self.parname, self._params(self._s[0])))
param_line = " ".join( params)+"\n"
f=open( filename,'w')
f.write(param_line)
# print(param_line)
for val in self._s:
data = self._point_minimum( val)
# print( " ".join([str(data[p]) for p in params]))
f.write( " ".join([str(data[p]) for p in params])+"\n")
f.close()
def _writeBestFit(self, dir, f):
#Extract Bestfit from logfile
......@@ -1387,7 +1405,26 @@ class prof:
newf.close()
def point_minimum( self, val, verbose=False):
def point_allfits( self, val, par='chi2'):
"""
Get all fit chi2 at a given value from multi-Minimize runs
"""
import os
path, dirs, files = os.walk("%s/%s_%s" % (self.dbdir,self.parname,val)).next()
files = [f for f in files if f.startswith("best")]
nmin = len(files)
allfits = []
for f in np.sort(files):
#read all parameters
fname= "%s/%s_%s/%s" % (self.dbdir,self.parname,val,f)
if os.stat(fname).st_size !=0:
bftmp = read_bestfit( "%s/%s_%s/%s" % (self.dbdir,self.parname,val,f))
allfits.append( bftmp[par])
return( allfits)
def _point_minimum( self, val, verbose=False):
"""
Get minimum at a given value from multi-Minimize runs
"""
......@@ -1412,7 +1449,24 @@ class prof:
bf = bftmp
return( bf)
def _params( self, val):
"""
Returns list of parameters in the fit
"""
import os
path, dirs, files = os.walk("%s/%s_%s" % (self.dbdir,self.parname,val)).next()
files = [f for f in files if f.startswith("best")]
#read all parameters
fname= "%s/%s_%s/%s" % (self.dbdir,self.parname,val,files[0])
f = open( fname, 'r')
params = np.array( f.readline().split(), dtype=str)
return( params)
def get( self, par='chi2'):
"""
Return profile likelihood
......@@ -1429,9 +1483,10 @@ class prof:
"""
p = []
for val in self._s:
p.append( self.point_minimum( val)[par])
p.append( self._point_minimum( val)[par])
return( self._v, p)
def fit( self, method='cubic', order=3, deltaMax=np.inf, upper=False, CL=None, bounds=None):
"""
Fit the profile with different models
......@@ -1583,7 +1638,7 @@ class prof:
if extent==None:
extent = (self._v[0],self._v[-1])
ax.plot(self._v,self._p-self.ymin,'ok', color=color,marker=marker)
ax.plot(self._v,self._p-self.ymin,color=color,marker=marker,linestyle='')
ax.set_xlabel(parname.get(self._nameforclass,self._nameforclass),fontsize=fontsize)
ax.set_ylabel("$\chi^2-\chi^2_{min}$",fontsize=fontsize)
......
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