#!/usr/bin/python # # Get sequence of focussing images and # compute the best focus value # # This variant uses Fatkhullin's AndorAPI2 library # to control Andor IXon Ultra EMCCD camera # The script uses TCP-socket Python API to control focus # of the SAO RAS Zeiss-1000 telescope # from OBSUTILS import focussing_app import sys import argparse as ap import subprocess as sp import numpy as np import socket def set_focus(foc_val): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect(("ztcs.sao.ru", 4444)) sock.send("goto={:g}".format(foc_val)) resp = sock.recv(20) if resp != "OK": sock.close() return 1 sock.close() return 0 # # Assumes Andor IXon EMCCD server is listenning UNIX socket on localhost # def get_image(filename, exp_time): cmd = ["ixonultra_cmdclient", "-A", "CCD", "-T", "{:g}".format(exp_time), filename] ret = sp.run(cmd, stdout=sp.PIPE, stderr=sp.PIPE) return ret.returncode if __name__ == "__main__": parser = ap.ArgumentParser( prog="{}".format(pl.Path(sys.argv[0]).name), description="Zeiss-1000 and Andor Ixon EMCCD hardware: focussing sequence implementation.", ) ret = focussing_app(parser, set_focus, get_image) sys.exit(ret)