Commit f0b5c5f1 authored by Daniel Brown's avatar Daniel Brown
Browse files

adding progress bar to parakat.getResults(), better parsig of funcs and...

adding progress bar to parakat.getResults(), better parsig of funcs and changing default fsig name of xbeta/ybeta
parent c749c478
...@@ -101,13 +101,17 @@ class func(Command): ...@@ -101,13 +101,17 @@ class func(Command):
@staticmethod @staticmethod
def parseFinesseText(line, kat): def parseFinesseText(line, kat):
v = line.split(None, 3) v = line.split(None, 3)
v2 = line.split("=", 2)
if "=" in v and len(v) == 4: if "=" in v and len(v) == 4:
v.remove("=") v.remove("=")
return func(v[1], v[2])
if len(v2) == 2:
return func(v2[0].split()[1], v2[1])
else: else:
raise pkex.BasePyKatException("'{0}' not a valid Finesse func command".format(line)) raise pkex.BasePyKatException("'{0}' not a valid Finesse func command".format(line))
return func(v[1], v[2])
......
...@@ -303,8 +303,8 @@ class AbstractMirrorComponent(Component): ...@@ -303,8 +303,8 @@ class AbstractMirrorComponent(Component):
self.__phi = Param("phi", self, SIfloat(phi), canFsig=True, fsig_name="phase") self.__phi = Param("phi", self, SIfloat(phi), canFsig=True, fsig_name="phase")
self.__Rcx = AttrParam("Rcx", self, SIfloat(Rcx)) self.__Rcx = AttrParam("Rcx", self, SIfloat(Rcx))
self.__Rcy = AttrParam("Rcy", self, SIfloat(Rcy)) self.__Rcy = AttrParam("Rcy", self, SIfloat(Rcy))
self.__xbeta = AttrParam("xbeta", self, SIfloat(xbeta), canFsig=True, fsig_name="x") self.__xbeta = AttrParam("xbeta", self, SIfloat(xbeta), canFsig=True, fsig_name="xbeta")
self.__ybeta = AttrParam("ybeta", self, SIfloat(ybeta), canFsig=True, fsig_name="y") self.__ybeta = AttrParam("ybeta", self, SIfloat(ybeta), canFsig=True, fsig_name="ybeta")
self.__mass = AttrParam("mass", self, SIfloat(mass)) self.__mass = AttrParam("mass", self, SIfloat(mass))
self.__Ix = AttrParam("Ix", self, SIfloat(Ix)) self.__Ix = AttrParam("Ix", self, SIfloat(Ix))
self.__Iy = AttrParam("Iy", self, SIfloat(Iy)) self.__Iy = AttrParam("Iy", self, SIfloat(Iy))
......
...@@ -53,7 +53,7 @@ class gauss_param(object): ...@@ -53,7 +53,7 @@ class gauss_param(object):
elif "z" in kwargs and "zr" in kwargs: elif "z" in kwargs and "zr" in kwargs:
q = SIfloat(kwargs["z"]) + 1j * SIfloat(kwargs["zr"]) q = SIfloat(kwargs["z"]) + 1j * SIfloat(kwargs["zr"])
elif "rc" in kwargs and "w" in kwargs: elif "rc" in kwargs and "w" in kwargs:
one_q = 1 / SIfloat(kwargs["rc"]) - 1j * self.__lamda / (math.pi * self.__nr * SIfloat(kwargs["w"])**2) one_q = 1 / SIfloat(kwargs["rc"]) - 1j * SIfloat(wavelength) / (math.pi * SIfloat(nr) * SIfloat(kwargs["w"])**2)
q = 1/one_q q = 1/one_q
else: else:
raise pkex.BasePyKatException("Must specify: z and w0 or z and zr or rc and w or q, to define the beam parameter") raise pkex.BasePyKatException("Must specify: z and w0 or z and zr or rc and w or q, to define the beam parameter")
......
...@@ -24,12 +24,19 @@ Contact at ddb@star.sr.bham.ac.uk ...@@ -24,12 +24,19 @@ Contact at ddb@star.sr.bham.ac.uk
@author: Daniel Brown @author: Daniel Brown
""" """
import IPython
# former syntax depreciated since ipython 4: # former syntax depreciated since ipython 4:
#from IPython.parallel import Client if IPython.version_info[0] <= 3:
from ipyparallel import Client from IPython.parallel import Client
else:
from ipyparallel import Client
import sys import sys
import os import os
from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar
def _run(commands, pwd, **kwargs): def _run(commands, pwd, **kwargs):
import os import os
os.chdir(pwd) os.chdir(pwd)
...@@ -46,8 +53,9 @@ class parakat(object): ...@@ -46,8 +53,9 @@ class parakat(object):
""" """
Uses the ipython clustering for running kat objects in parallel. Uses the ipython clustering for running kat objects in parallel.
To use this you must have installed ipyparallel, for example, with To use this you must have installed ipyparallel, for example, with:
pip install ipyparallel
pip install ipyparallel
Then yoy must start an ipython cluster on your computer. Then yoy must start an ipython cluster on your computer.
From a new terminal use the command: From a new terminal use the command:
...@@ -81,15 +89,20 @@ class parakat(object): ...@@ -81,15 +89,20 @@ class parakat(object):
self._lview = self._rc.load_balanced_view() self._lview = self._rc.load_balanced_view()
self._lview.block = False self._lview.block = False
self._results = [] self._results = []
self._run_count = 0
def run(self, kat, **kwargs): def run(self, kat, **kwargs):
self._results.append(self._lview.apply_async(_run, "".join(kat.generateKatScript()), os.getcwd(), **kwargs)) self._results.append(self._lview.apply_async(_run, "".join(kat.generateKatScript()), os.getcwd(), **kwargs))
self._run_count += 1
def getResults(self): def getResults(self):
out = [] out = []
self._lview.wait(self._results) p = ProgressBar(maxval=self._run_count , widgets=["Parallel jobs: ", Percentage(), Bar()])
while not self._lview.wait(self._results, timeout=0.1):
p.update(self._run_count - self._lview.queue_status()['unassigned'])
for done in self._results: for done in self._results:
out.append(done.get()) out.append(done.get())
......
...@@ -47,7 +47,7 @@ def processRedmineProductionLog(log, output): ...@@ -47,7 +47,7 @@ def processRedmineProductionLog(log, output):
if ext == "zip" or ext == "tar" or ext == "pdf": if ext == "zip" or ext == "tar" or ext == "pdf":
ofile.write("%s %s %s\n" %(file, ip, date)) ofile.write("%s %s %s\n" %(file, ip, date))
print file, ip, date print(file, ip, date)
found = -1 found = -1
......
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