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):
@staticmethod
def parseFinesseText(line, kat):
v = line.split(None, 3)
v2 = line.split("=", 2)
if "=" in v and len(v) == 4:
v.remove("=")
return func(v[1], v[2])
if len(v2) == 2:
return func(v2[0].split()[1], v2[1])
else:
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):
self.__phi = Param("phi", self, SIfloat(phi), canFsig=True, fsig_name="phase")
self.__Rcx = AttrParam("Rcx", self, SIfloat(Rcx))
self.__Rcy = AttrParam("Rcy", self, SIfloat(Rcy))
self.__xbeta = AttrParam("xbeta", self, SIfloat(xbeta), canFsig=True, fsig_name="x")
self.__ybeta = AttrParam("ybeta", self, SIfloat(ybeta), canFsig=True, fsig_name="y")
self.__xbeta = AttrParam("xbeta", self, SIfloat(xbeta), canFsig=True, fsig_name="xbeta")
self.__ybeta = AttrParam("ybeta", self, SIfloat(ybeta), canFsig=True, fsig_name="ybeta")
self.__mass = AttrParam("mass", self, SIfloat(mass))
self.__Ix = AttrParam("Ix", self, SIfloat(Ix))
self.__Iy = AttrParam("Iy", self, SIfloat(Iy))
......
......@@ -53,7 +53,7 @@ class gauss_param(object):
elif "z" in kwargs and "zr" in kwargs:
q = SIfloat(kwargs["z"]) + 1j * SIfloat(kwargs["zr"])
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
else:
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
@author: Daniel Brown
"""
import IPython
# former syntax depreciated since ipython 4:
#from IPython.parallel import Client
from ipyparallel import Client
if IPython.version_info[0] <= 3:
from IPython.parallel import Client
else:
from ipyparallel import Client
import sys
import os
from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar
def _run(commands, pwd, **kwargs):
import os
os.chdir(pwd)
......@@ -46,8 +53,9 @@ class parakat(object):
"""
Uses the ipython clustering for running kat objects in parallel.
To use this you must have installed ipyparallel, for example, with
pip install ipyparallel
To use this you must have installed ipyparallel, for example, with:
pip install ipyparallel
Then yoy must start an ipython cluster on your computer.
From a new terminal use the command:
......@@ -81,15 +89,20 @@ class parakat(object):
self._lview = self._rc.load_balanced_view()
self._lview.block = False
self._results = []
self._run_count = 0
def run(self, kat, **kwargs):
self._results.append(self._lview.apply_async(_run, "".join(kat.generateKatScript()), os.getcwd(), **kwargs))
self._run_count += 1
def getResults(self):
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:
out.append(done.get())
......
......@@ -47,7 +47,7 @@ def processRedmineProductionLog(log, output):
if ext == "zip" or ext == "tar" or ext == "pdf":
ofile.write("%s %s %s\n" %(file, ip, date))
print file, ip, date
print(file, ip, date)
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