Skip to content

Commit

Permalink
add --time-ref= option
Browse files Browse the repository at this point in the history
  • Loading branch information
lathuili-home committed Jun 18, 2024
1 parent c9a1818 commit cd6b210
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 29 deletions.
19 changes: 11 additions & 8 deletions pyTools/gen_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,20 @@ def failure(self):
def md5Param(self):
return self._md5Param

def checkScriptPath(self,fpath):
def checkScriptPath(self,fpath,hardFailure=True):
if os.path.isfile(fpath) and os.access(fpath, os.X_OK):
return os.path.abspath(fpath)
else:
print("Invalid Cmd:"+str(sys.argv))
if os.path.isfile(fpath) and not os.access(fpath, os.X_OK):
print(fpath + " should be executable")
if not os.path.isfile(fpath):
print(fpath + " is not a file")
self.usageCmd()
self.failure()
if hardFailure:
print("Invalid Cmd:"+str(sys.argv))
if os.path.isfile(fpath) and not os.access(fpath, os.X_OK):
print(fpath + " should be executable")
if not os.path.isfile(fpath):
print(fpath + " is not a file")
self.usageCmd()
self.failure()
else:
return None

def readOneOption(self,strOption, attribut,conv_type ,key_name, argv_name, acceptedValue, addAttributTab, parse):
value=False
Expand Down
73 changes: 52 additions & 21 deletions pyTools/verrou_plot_stat
Original file line number Diff line number Diff line change
Expand Up @@ -217,27 +217,31 @@ def verrou_extract_paraview_time(extract_time, rep, listOfStat):
return [float(x) for x in (subprocess.getoutput(extract_time +" "+ repName)).split("\n")]
return extractLoopOverComputation(rep,listOfStat, getTimeData)

def getExtractTimeData(extract_time,repName):
res=[x for x in (subprocess.getoutput(extract_time +" "+ repName)).split("\n")]
name=None
if res[0].startswith("#"):
name=(res[0].replace("#","")).strip()
res=res[1:]
if len(res[0].split(" "))==1:
res=[(i,float(res[i])) for i in range(len(res))]
if name==None:
name=("index","value")
else:
name=("index",name)
return (name,res)
if len(res[0].split(" "))==2:
for i in range(len(res)):
tupleXY=res[i].split(" ")
res[i]=(float(tupleXY[0]), float(tupleXY[1]))
if name==None:
name="index\tvalue"
return (name.split("\t"),res)
print("debug getExtractTimeData: ",res)

def verrou_extract_time(extract_time, rep, listOfStat):
def getTimeData(repName):
res=[x for x in (subprocess.getoutput(extract_time +" "+ repName)).split("\n")]
name=None
if res[0].startswith("#"):
name=(res[i].replace("#","")).strip()
res=res[1:]
if len(res[0].split(" "))==1:
res=[(i,float(res[i])) for i in range(len(res))]
if name==None:
name=("index","value")
else:
name=("index",name)
return (name,res)
if len(res[0].split(" "))==2:
for i in range(len(res)):
tupleXY=res[i].split(" ")
res[i]=(float(tupleXY[0]), float(tupleXY[1]))
if name==None:
name="index\tvalue"
return (name.split("\t"),res)
return getExtractTimeData(extract_time,repName)
return extractLoopOverComputation(rep,listOfStat, getTimeData)


Expand Down Expand Up @@ -482,6 +486,20 @@ def plot_time(data, conf):

ax.plot(nearestX, errorTab, "o", color=lineColor[index], label=roundingMode)
index+=1
if conf._timeRef!=None:
refError=None
labelRef="ref"
if conf.lambdaTimeRef!=None:
refError=[abs((nearestY[i]- conf.lambdaTimeRef(nearestX[i]))/conf.lambdaTimeRef(nearestX[i])) for i in range(nbTimeIndex) ]
if conf.time_ref_script!=None:
(nameRef,tabRef)=getExtractTimeData(conf.time_ref_script, os.path.join(conf.repName(), "det", "nearest","dd.run0"))
if nameRef!=None:
labelRef=nameRef[1]
refX=[x[0] for x in tabRef]
refY=[x[1] for x in tabRef]
refError=[abs(refY[iTime] - nearestY[iTime])/ abs(refY[iTime]) for iTime in range(len(refX))]

ax.plot(nearestX, refError, "+", color=lineColor[index], label=labelRef)

ax.set_yscale("log",base=10)
ax.set_ylabel("verrou error estimation")
Expand Down Expand Up @@ -687,6 +705,7 @@ class config_stat(gen_config.gen_config):
self.addRegistry("_time", "bool", "TIME", ["--time","-t"], False)
self.addRegistry("_logScalX", "bool", "LOGSCALX", ["--log-scalx"], False)
self.addRegistry("_timeVal", "bool", "TIMEVAL", ["--time-val"], False)
self.addRegistry("_timeRef", "string", "TIMEREF", ["--time-ref="], None)

self.addRegistry("_timeParaview", "bool", "TIME_PARAVIEW", ["--paraview_time"], False)
self.addRegistry("_pattern", "string", "PATTERN", ["--specific-pattern="], [], additive=True, docStr="pattern of rep (useful to plot histogramm without run.sh)")
Expand Down Expand Up @@ -759,8 +778,20 @@ class config_stat(gen_config.gen_config):
self.failure()
self._runScript=self.exec_arg[0]
self._extractTimeScript=self.exec_arg[1]


if self._timeRef!=None:
time_ref_script=self.checkScriptPath(self._timeRef,False)
if time_ref_script!=None:
self.time_ref_script=time_ref_script
self.lambdaTimeRef=None
else:
lambdaTimeRef=eval("lambda x: "+self._timeRef)
try:
test=float(lambdaTimeRef(1))
self.lambdaTimeRef=lambdaTimeRef
self.time_ref_script=None
except:
print(self._timeRef+ "should be a valid executable or x lambda expression")
self.failure()

def check(self):
if len(self._pattern)!=0 and (self._isMontecarlo==True or self._nbSample!=None or self._time==True):
Expand Down

0 comments on commit cd6b210

Please sign in to comment.