In [1]:
import numpy as np
import matplotlib
import matplotlib.pyplot as plt

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 [2]:
%load_ext autoreload
%autoreload 2
%matplotlib widget

In [3]:
flwo_wfs = WFSFactory(wfs="flwo15")



In [4]:
%cd ~/MMT/FLWO/60inch/


/Users/tim/MMT/FLWO/60inch

In [26]:
#flwo_wfs.cen_sigma = 3.
file = "1221.star.m2p69.fits"
slopes = flwo_wfs.measure_slopes(file, plot=True)
slopes['figures']['slopes'].show()



In [27]:
zresults = flwo_wfs.fit_wavefront(slopes, plot=True)
zvec = zresults['zernike']
print(zresults['residual_rms'])
print(zvec.pretty_print())
#print(zvec)
zresults['resid_plot'].show()


2949.459324594836 nm
Fringe Coefficients
 Z02:         734.7 ±   442 nm 	 X Tilt (1, 1)
 Z03:        -355.7 ±   400 nm 	 Y Tilt (1, -1)
 Z04:         -6082 ±   178 nm 	 Defocus (2, 0)
 Z05:         446.5 ±   293 nm 	 Primary Astig at 45° (2, -2)
 Z06:        -81.97 ±   300 nm 	 Primary Astig at 0° (2, 2)
 Z07:          -738 ±   221 nm 	 Primary Y Coma (3, -1)
 Z08:         656.7 ±   262 nm 	 Primary X Coma (3, 1)
 Z09:           740 ±   314 nm 	 Y Trefoil (3, -3)
 Z10:        -290.3 ±   275 nm 	 X Trefoil (3, 3)
 Z11:         794.9 ±   165 nm 	 Primary Spherical (4, 0)
 Z12:        -818.9 ±   244 nm 	 Secondary Astigmatism at 0° (4, 2)
 Z13:         275.6 ±   204 nm 	 Secondary Astigmatism at 45° (4, -2)
 Z14:         906.1 ±   323 nm 	 X Tetrafoil (4, 4)
 Z15:          -432 ±   289 nm 	 Y Tetrafoil (4, -4)
 Z16:          16.7 ±   224 nm 	 Secondary X Coma (5, 1)
 Z17:        -294.1 ±   187 nm 	 Secondary Y Coma (5, -1)
 Z18:         115.2 ±   193 nm 	 Secondary X Trefoil (5, 3)
 Z19:         595.9 ±   198 nm 	 Secondary Y Trefoil (5, -3)
 Z20:        -208.3 ±   295 nm 	 X Pentafoil (5, 5)
 Z21:        -30.18 ±   292 nm 	 Y Pentafoil (5, -5)
 Z22:        -157.8 ±   134 nm 	 Secondary Spherical (6, 0)

Total RMS: 	 3594 nm


In [25]:
zvec.fringe_bar_chart(max_c=2000*u.nm).show()



In [ ]:
mask = mk_wfs_mask(slopes['data'][29:415,85:456])

In [ ]:
plt.imshow(mask, origin='lower')
plt.show()

In [ ]:
zvec.fringe_bar_chart(max_c=500*u.nm).savefig("zernikes.pdf")

In [ ]:
500**-0.2 / 700**-0.2

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

In [ ]: