In [8]:
import time
from datetime import datetime
import os
import sys
import numpy as np
import ipympl
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
from pathlib import Path
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]:
%cd /Users/tim/MMT/wfsdat/20180209
In [3]:
rootdir = Path(".")
In [5]:
z = ZernikeVector()q
z.load("wfs_ff_cal_img_2018.0209.033646.zernike")
zz = ZernikeVector(modestart=23, **z.coeffs)
zz.rms, z.rms
Out[5]:
In [41]:
files = sorted(list(rootdir.glob("wfs_*.fits")))
ngood = 0
dataframes = []
norm_dataframes = []
for f in files:
full_zern = str(f.stem) + ".zernike"
dtime = datetime.strptime(f.stem, "wfs_ff_cal_img_%Y.%m%d.%H%M%S")
if Path(full_zern).exists():
zv = ZernikeVector()
zv.load(full_zern)
norm_zv = zv.copy()
norm_zv.normalize()
df_zv = pd.DataFrame(zv.coeffs, index=[1])
df_norm = pd.DataFrame(norm_zv.coeffs, index=[1])
df_zv['time'] = dtime
df_norm['time'] = dtime
df_zv['rms'] = zv.rms
df_norm['rms'] = norm_zv.rms
dataframes.append(df_zv)
norm_dataframes.append(df_norm)
In [81]:
zdf = pd.concat(dataframes)
zdf_norm = pd.concat(norm_dataframes)
# create a date-time index so we can group and analyze the data by timestamps
zdf = zdf.set_index(pd.DatetimeIndex(zdf['time'], name='ut'))
zdf_norm = zdf_norm.set_index(pd.DatetimeIndex(zdf_norm['time'], name='ut'))
zdf_trim = zdf[zdf['rms'] < 500.]
In [85]:
plt.close('all')
zdf_trim.plot(y='Z05')
plt.show()
In [ ]: