In [4]:
import time
import os
import sys
import numpy as np
import matplotlib
matplotlib.use('nbagg')
#from matplotlib import style
#style.use('ggplot')
import matplotlib.pyplot as plt

%load_ext autoreload
%autoreload 2

import astropy.units as u
from astropy import stats
from astropy.io import fits
from mmtwfs.wfs import *
from mmtwfs.zernike import ZernikeVector
from mmtwfs.telescope import MMT

In [ ]:
plt.close('all')

f9wfs = WFSFactory(wfs="newf9", nzern=36, pup_offset=[0.0, 0.0], pup_size=550)
f9_file = "/Users/tim/MMT/wfsdat/20170517/manual_wfs_0060.fits"
f9_file = "/Users/tim/MMT/wfsdat/datadir/manual_wfs_0039.fits"
results = f9wfs.measure_slopes(f9_file, 'blue', plot=True)
results['figures']['slopes'].show()

In [ ]:
zresults = f9wfs.fit_wavefront(results, plot=True)
print(zresults['residual_rms'])
print(zresults['zernike'])
zresults['resid_plot'].show()

In [ ]:
zvec = zresults['zernike']
bc = zvec.bar_chart(residual=zresults['residual_rms'])
bc.show()

In [ ]:
foc = f9wfs.calculate_focus(zvec)
cc_x, cc_y = f9wfs.calculate_cc(zvec)

In [ ]:
"Focus: {0:0.1f}  CC_X: {1:0.1f}  CC_Y: {2:0.1f}".format(foc, cc_x, cc_y)

In [ ]:
t, m1f = f9wfs.calculate_primary(zvec, threshold=0.5*zresults['residual_rms'])

In [ ]:
t.show_in_notebook()

In [ ]:
m1f

In [ ]:
import socket

In [ ]:
server = ("hacksaw", 7666)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(server)

In [ ]:
cmd = "get wfs_seeing\n"
sock.sendall(cmd.encode("utf8"))
sock.recv(4096)

In [ ]:
sock.close()

In [ ]:
np.round(np.abs(t['force']).max())

In [ ]:
abs(zvec['Z06'])

In [7]:
d = "/Users/tim/MMT/wfsdat/datadir"
d = d + "/"
d


Out[7]:
'/Users/tim/MMT/wfsdat/datadir/'

In [13]:
import glob
import os
import json

In [12]:
files = glob.glob(d + "*.fits")

In [15]:
for f in files:
    print(os.path.split(f)[1])


manual_wfs_0000.fits
manual_wfs_0001.fits
manual_wfs_0002.fits
tmp.fits

In [17]:
files.sort()
files.reverse()

In [18]:
files


Out[18]:
['/Users/tim/MMT/wfsdat/datadir/tmp.fits',
 '/Users/tim/MMT/wfsdat/datadir/manual_wfs_0002.fits',
 '/Users/tim/MMT/wfsdat/datadir/manual_wfs_0001.fits',
 '/Users/tim/MMT/wfsdat/datadir/manual_wfs_0000.fits']

In [ ]: