Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.mrao.cam.ac.uk/~bn204/alma/sweng/wvrserve.html
Дата изменения: Mon Apr 4 13:47:51 2016 Дата индексирования: Sun Apr 10 09:41:34 2016 Кодировка: ISO8859-5 Поисковые слова: п п п п п п п п п п п п п п п п п п п п п п п п п р п р п р п р п р п р п р п р п р п р п р п р п р п |
The program wvrretrieve
which can be used to retrieve atmospheric
water vapour and optionally estimate excess continuum at 183 GHz is
quite computationally intensive. At the same time, too high a loading
of the ALMA control computers should be avoided as the may not handle
these gracefully.
For this reason I implemented a very simple server/client arrangement so that the control computers can call the wvrretrieve program on another computer (obvious candidate being osf-red) fetch the results from there. This arrangement is used in the new, experimental on-line plotter for pwv and cloud estimate.
This arrangement is described here if:
The arrangement consist of (obviously) two parts.
One one machine is the server, this is where the heavy computation is
done and CPU load is not too high a concern. In our case this machine
is osf-red
. Since the computation is done on this machine, this is
where the wvrretrieve
program must be installed, which it indeed
it is.
On the server machine the wvrserve.py
script is run. This creates
the server and listens for requests for pwv computation on
port 8000.
On the client side, one simply connects to port 8000 of osf-red
and asks for a computation given WVR readings; the result is then
returned.
The implementation uses the XMLRPC protocol as implemented in the Python SimpleXMLRPCServer module.
This module makes it extremely to make any function available over the
XMLRPC protocol. In this case we make only one function available,
named wvrretrieve
. This Python function in turn calls the
stand-alone executable of the same name by using the subprocess
module.
The use of the client is described elsewhere. To use the server, it
needs just to be started, with the path adjusted so that it can see
the wvrretrieve
executable.
On osf-red, an example invocation is:
PATH=/users/bnikolic/p/wvr-0-16-b2/bin/:$PATH python wvrserve.py
Note that for full functionality version of 0.16 of wvr software should be used (in this case we are using 0.16-beta-2 version).
wvrserve.py
ТЖThis is the full listing:
# Bojan Nikolic <b.nikolic@mrao.cam.ac.uk>
#
# This file is part of LibAIR
"""
A very simple wrapper that turns the wvrretrieve process into an
XMLRPC server
"""
import string
import subprocess
from SimpleXMLRPCServer import SimpleXMLRPCServer
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
# Restrict to a particular path.
class RequestHandler(SimpleXMLRPCRequestHandler):
rpc_paths = ('/RPC2',)
# Create server
server = SimpleXMLRPCServer(("osf-red.aiv.alma.cl", 8000),
requestHandler=RequestHandler)
def wvrretrieve(TObs1, TObs2, TObs3, TObs4,
el):
p=subprocess.Popen(["wvrretrieve",
str(TObs1),
str(TObs2),
str(TObs3),
str(TObs4),
"--elevation",
str(el),
"--cont"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,)
sout, serr=p.communicate()
res={}
for l in sout.split("\n"):
ld=string.split(l)
if len(ld)==0:
continue
if ld[0]=="c:":
res["c"]=float(ld[1])
res["c_err"]=float(ld[3])
if ld[0]=="tau183:":
res["tau183"]=float(ld[1])
res["tau183_err"]=float(ld[3])
if ld[0]=="evidence:":
res["evidence"]=float(ld[1])
return res
server.register_function(wvrretrieve)
# Run the server's main loop
server.serve_forever()