def LTAOpsfcube(lambs, seeing, aperture): '''Function that creates a 3D spatial E-ELT LTAO PSF datacube by interpolating between parameters of several analytical functions. Parameters are stored in datafiles and are accessed by code. Inputs: lambs: Array of wavelengths corresponding to [start_wave, end_wave, del_wave]. seeing: FWHM value of the seeing. Value must be between 0.67" and 0.95" (21-12-13). aperture: List containing [diameter of telescope, obscuration ratio] Output: psfcube: PSF cube of same spectral length as wavelength array ''' print 'Generating LTAO PSF cube' ks = 1 box = [0.4, 2.5, 0.6, 1.5] ###Load data from text file - wavelengths = vals[:,0] #vals = n.loadtxt(psf_path+'LTAO/LTAOdata.txt', delimiter=',') vals = n.loadtxt(os.path.join(psf_path, 'LTAO/LTAOdata.txt'), delimiter=',') #Seeing values see_vals = n.array([0.67, 0.95]) params = [] #Interpolate for all height parameters (oh = 1, 12, 23, 34; mh = 3, 14, 25, 36; lh = 6, 17, 28, 39; m2h = 9, 20, 31, 42) ohvals = n.array([vals[:, 1], vals[:, 11]]) ohinterp = s.RectBivariateSpline(vals[:, 0], see_vals, ohvals.transpose(), kx=ks, ky=ks, bbox=box) yoh = ohinterp(lambs, seeing) mhvals = n.array([vals[:, 2], vals[:, 12]]) mhinterp = s.RectBivariateSpline(vals[:, 0], see_vals, mhvals.transpose(), kx=ks, ky=ks, bbox=box) ymh = mhinterp(lambs, seeing) lhvals = n.array([vals[:, 5], vals[:, 15]]) lhinterp = s.RectBivariateSpline(vals[:, 0], see_vals, lhvals.transpose(), kx=ks, ky=ks, bbox=box) ylh = lhinterp(lambs, seeing) m2hvals = n.array([vals[:, 8], vals[:, 18]]) m2hinterp = s.RectBivariateSpline(vals[:, 0], see_vals, m2hvals.transpose(), kx=ks, ky=ks, bbox=box) ym2h = m2hinterp(lambs, seeing) params.append(yoh) params.append(ymh) params.append(ylh) params.append(ym2h) #Fit 6th order polynomial to Moffat (seeing) width and Lorentzian width parameters and then interpolate for i in n.array([3, 7]): p1, pn1 = curve_fit(x6, vals[:, 0], vals[:, i]) p2, pn2 = curve_fit(x6, vals[:, 0], vals[:, i + 10]) yp1 = x6(vals[:, 0], p1[0], p1[1], p1[2], p1[3], p1[4], p1[5], p1[6]) yp2 = x6(vals[:, 0], p2[0], p2[1], p2[2], p2[3], p2[4], p2[5], p2[6]) yps = n.array([yp1, yp2]) pinterp = s.RectBivariateSpline(vals[:, 0], see_vals, yps.transpose(), kx=ks, ky=ks, bbox=box) ys = pinterp(lambs, seeing) params.append(ys) #Fit 1st order polynomial to Moffat (seeing) shape, Lorentz position for i in n.array([4, 6]): p1, pn1 = curve_fit(x1, vals[:, 0], vals[:, i]) p2, pn2 = curve_fit(x1, vals[:, 0], vals[:, i + 10]) yp1 = x1(vals[:, 0], p1[0], p1[1]) yp2 = x1(vals[:, 0], p2[0], p2[1]) yps = n.array([yp1, yp2]) pinterp = s.RectBivariateSpline(vals[:, 0], see_vals, yps.transpose(), kx=ks, ky=ks, bbox=box) ys = pinterp(lambs, seeing) params.append(ys) #Interpolate for Moffat (core) width and shape as these are (effectively) step functions for i in n.array([9, 10]): yps = n.array([vals[:, i], vals[:, i + 10]]) pinterp = s.RectBivariateSpline(vals[:, 0], see_vals, yps.transpose(), kx=ks, ky=ks, bbox=box) ys = pinterp(lambs, seeing) params.append(ys) #Airy width directly proportional to wavelength: width [mas] = (lambda[m]/(pi*D))*206265000. yows = lambs * 1.E-6 * 206265000. / (n.pi * aperture[0]) params.append(yows) #params = [oh, mh, lh, m2h, mw, lw, mq, lp, m2w, m2q, ow] pdict = { 'oh': params[0], 'ow': params[10], 'mh': params[1], 'mw': params[4], 'mq': params[6], 'lh': params[2], 'lp': params[7], 'lw': params[5], 'm2h': params[3], 'm2w': params[8], 'm2q': params[9] } return pdict
def LTAOpsfcube(lambs, seeing, aperture): '''Function that creates a 3D spatial E-ELT LTAO PSF datacube by interpolating between parameters of several analytical functions. Parameters are stored in datafiles and are accessed by code. Inputs: lambs: Array of wavelengths corresponding to [start_wave, end_wave, del_wave]. seeing: FWHM value of the seeing. Value must be between 0.67" and 0.95" (21-12-13). aperture: List containing [diameter of telescope, obscuration ratio] Output: psfcube: PSF cube of same spectral length as wavelength array ''' print 'Generating LTAO PSF cube' ks = 1 box = [0.4,2.5,0.6,1.5] ###Load data from text file - wavelengths = vals[:,0] #vals = n.loadtxt(psf_path+'LTAO/LTAOdata.txt', delimiter=',') vals = n.loadtxt(os.path.join(psf_path,'LTAO/LTAOdata.txt'), delimiter=',') #Seeing values see_vals = n.array([0.67, 0.95]) params= [] #Interpolate for all height parameters (oh = 1, 12, 23, 34; mh = 3, 14, 25, 36; lh = 6, 17, 28, 39; m2h = 9, 20, 31, 42) ohvals = n.array([vals[:,1], vals[:,11]]) ohinterp = s.RectBivariateSpline(vals[:,0], see_vals, ohvals.transpose(),kx=ks, ky=ks, bbox=box) yoh = ohinterp(lambs, seeing) mhvals = n.array([vals[:,2], vals[:,12]]) mhinterp = s.RectBivariateSpline(vals[:,0], see_vals, mhvals.transpose(),kx=ks, ky=ks, bbox=box) ymh = mhinterp(lambs, seeing) lhvals = n.array([vals[:,5], vals[:,15]]) lhinterp = s.RectBivariateSpline(vals[:,0], see_vals, lhvals.transpose(),kx=ks, ky=ks, bbox=box) ylh = lhinterp(lambs, seeing) m2hvals = n.array([vals[:,8], vals[:,18]]) m2hinterp = s.RectBivariateSpline(vals[:,0], see_vals, m2hvals.transpose(),kx=ks, ky=ks, bbox=box) ym2h = m2hinterp(lambs, seeing) params.append(yoh) params.append(ymh) params.append(ylh) params.append(ym2h) #Fit 6th order polynomial to Moffat (seeing) width and Lorentzian width parameters and then interpolate for i in n.array([3, 7]): p1, pn1 = curve_fit(x6, vals[:,0], vals[:,i]) p2, pn2 = curve_fit(x6, vals[:,0], vals[:,i+10]) yp1 = x6(vals[:,0], p1[0], p1[1], p1[2], p1[3], p1[4], p1[5], p1[6]) yp2 = x6(vals[:,0], p2[0], p2[1], p2[2], p2[3], p2[4], p2[5], p2[6]) yps = n.array([yp1, yp2]) pinterp = s.RectBivariateSpline(vals[:,0], see_vals, yps.transpose(), kx=ks, ky=ks, bbox=box) ys = pinterp(lambs, seeing) params.append(ys) #Fit 1st order polynomial to Moffat (seeing) shape, Lorentz position for i in n.array([4, 6]): p1, pn1 = curve_fit(x1, vals[:,0], vals[:,i]) p2, pn2 = curve_fit(x1, vals[:,0], vals[:,i+10]) yp1 = x1(vals[:,0], p1[0], p1[1]) yp2 = x1(vals[:,0], p2[0], p2[1]) yps = n.array([yp1, yp2]) pinterp = s.RectBivariateSpline(vals[:,0], see_vals, yps.transpose(), kx=ks, ky=ks, bbox=box) ys = pinterp(lambs, seeing) params.append(ys) #Interpolate for Moffat (core) width and shape as these are (effectively) step functions for i in n.array([9, 10]): yps = n.array([vals[:,i], vals[:,i+10]]) pinterp = s.RectBivariateSpline(vals[:,0], see_vals, yps.transpose(), kx=ks, ky=ks, bbox=box) ys = pinterp(lambs, seeing) params.append(ys) #Airy width directly proportional to wavelength: width [mas] = (lambda[m]/(pi*D))*206265000. yows = lambs*1.E-6*206265000./(n.pi*aperture[0]) params.append(yows) #params = [oh, mh, lh, m2h, mw, lw, mq, lp, m2w, m2q, ow] pdict = {'oh':params[0], 'ow':params[10], 'mh':params[1], 'mw':params[4], 'mq':params[6], 'lh':params[2], 'lp':params[7], 'lw':params[5], 'm2h':params[3], 'm2w':params[8], 'm2q':params[9]} return pdict
def SCAOpsfcube(lambs, seeing, aperture): '''Function that creates a 3D spatial E-ELT SCAO PSF datacube by interpolating between parameters of several analytical functions. Parameters are stored in datafiles and are accessed by code. Inputs: lambs: Array of wavelengths. seeing: FWHM value of the seeing at 500nm (V-band). Value must be between 0.67" and 1.10". aperture: List containing [diameter of telescope, obscuration ratio] Output: psfcube: PSF cube of same spectral length as wavelength array ''' print 'Generating SCAO PSF cube' ks = 1 box = [0.4, 2.5, 0.6, 1.5] ###Load data from text file - wavelengths = vals[:,0] #vals = n.loadtxt('/Users/SimonZ/Data/Sim_data/PSFs/SCAOdata.txt', delimiter=',') #vals = n.loadtxt(psf_path+'SCAO/SCAOdata.txt', delimiter=',') vals = n.loadtxt(os.path.join(psf_path, 'SCAO/SCAOdata.txt'), delimiter=',') #Seeing values see_vals = n.array([0.67, 0.85, 0.95, 1.10]) params = [] #Interpolate for all height parameters (oh = 1, 12, 23, 34; mh = 3, 14, 25, 36; lh = 6, 17, 28, 39; m2h = 9, 20, 31, 42) ohvals = n.array([vals[:, 1], vals[:, 12], vals[:, 23], vals[:, 34]]) ohinterp = s.RectBivariateSpline(vals[:, 0], see_vals, ohvals.transpose(), kx=ks, ky=ks, bbox=box) yoh = ohinterp(lambs, seeing) mhvals = n.array([vals[:, 3], vals[:, 14], vals[:, 25], vals[:, 36]]) mhinterp = s.RectBivariateSpline(vals[:, 0], see_vals, mhvals.transpose(), kx=ks, ky=ks, bbox=box) ymh = mhinterp(lambs, seeing) lhvals = n.array([vals[:, 6], vals[:, 17], vals[:, 28], vals[:, 39]]) lhinterp = s.RectBivariateSpline(vals[:, 0], see_vals, lhvals.transpose(), kx=ks, ky=ks, bbox=box) ylh = lhinterp(lambs, seeing) m2hvals = n.array([vals[:, 9], vals[:, 20], vals[:, 31], vals[:, 42]]) m2hinterp = s.RectBivariateSpline(vals[:, 0], see_vals, m2hvals.transpose(), kx=ks, ky=ks, bbox=box) ym2h = m2hinterp(lambs, seeing) params.append(yoh) params.append(ymh) params.append(ylh) params.append(ym2h) #Fit 6th order polynomial to Moffat (seeing) width and Lorentzian width parameters and then interpolate for i in n.array([4, 8]): p1, pn1 = curve_fit(x6, vals[:, 0], vals[:, i]) p2, pn2 = curve_fit(x6, vals[:, 0], vals[:, i + 11]) p3, pn3 = curve_fit(x6, vals[:, 0], vals[:, i + 22]) p4, pn4 = curve_fit(x6, vals[:, 0], vals[:, i + 33]) yp1 = x6(vals[:, 0], p1[0], p1[1], p1[2], p1[3], p1[4], p1[5], p1[6]) yp2 = x6(vals[:, 0], p2[0], p2[1], p2[2], p2[3], p2[4], p2[5], p2[6]) yp3 = x6(vals[:, 0], p3[0], p3[1], p3[2], p3[3], p3[4], p3[5], p3[6]) yp4 = x6(vals[:, 0], p4[0], p4[1], p4[2], p4[3], p4[4], p4[5], p4[6]) yps = n.array([yp1, yp2, yp3, yp4]) pinterp = s.RectBivariateSpline(vals[:, 0], see_vals, yps.transpose(), kx=ks, ky=ks, bbox=box) ys = pinterp(lambs, seeing) params.append(ys) #Fit 1st order polynomial to Airy width, Moffat (seeing) shape, Lorentz position, Moffat(core) width for i in n.array([2, 5, 7, 10]): p1, pn1 = curve_fit(x1, vals[:, 0], vals[:, i]) p2, pn2 = curve_fit(x1, vals[:, 0], vals[:, i + 11]) p3, pn3 = curve_fit(x1, vals[:, 0], vals[:, i + 22]) p4, pn4 = curve_fit(x1, vals[:, 0], vals[:, i + 33]) yp1 = x1(vals[:, 0], p1[0], p1[1]) yp2 = x1(vals[:, 0], p2[0], p2[1]) yp3 = x1(vals[:, 0], p3[0], p3[1]) yp4 = x1(vals[:, 0], p4[0], p4[1]) yps = n.array([yp1, yp2, yp3, yp4]) pinterp = s.RectBivariateSpline(vals[:, 0], see_vals, yps.transpose(), kx=ks, ky=ks, bbox=box) ys = pinterp(lambs, seeing) params.append(ys) #Fit 2nd order polynomial to Moffat (core) shape for i in n.array([11]): p1, pn1 = curve_fit(x2, vals[:, 0], vals[:, i]) p2, pn2 = curve_fit(x2, vals[:, 0], vals[:, i + 11]) p3, pn3 = curve_fit(x2, vals[:, 0], vals[:, i + 22]) p4, pn4 = curve_fit(x2, vals[:, 0], vals[:, i + 33]) yp1 = x2(vals[:, 0], p1[0], p1[1], p1[2]) yp2 = x2(vals[:, 0], p2[0], p2[1], p2[2]) yp3 = x2(vals[:, 0], p3[0], p3[1], p3[2]) yp4 = x2(vals[:, 0], p4[0], p4[1], p4[2]) yps = n.array([yp1, yp2, yp3, yp4]) pinterp = s.RectBivariateSpline(vals[:, 0], see_vals, yps.transpose(), kx=ks, ky=ks, bbox=box) ys = pinterp(lambs, seeing) params.append(ys) #params = [oh, mh, lh, m2h, mw, lw, ow, mq, lp, m2w, m2q] pdict = { 'oh': params[0], 'ow': params[6], 'mh': params[1], 'mw': params[4], 'mq': params[7], 'lh': params[2], 'lp': params[8], 'lw': params[5], 'm2h': params[3], 'm2w': params[9], 'm2q': params[10] } return pdict
def SCAOpsfcube(lambs, seeing, aperture): '''Function that creates a 3D spatial E-ELT SCAO PSF datacube by interpolating between parameters of several analytical functions. Parameters are stored in datafiles and are accessed by code. Inputs: lambs: Array of wavelengths. seeing: FWHM value of the seeing at 500nm (V-band). Value must be between 0.67" and 1.10". aperture: List containing [diameter of telescope, obscuration ratio] Output: psfcube: PSF cube of same spectral length as wavelength array ''' print 'Generating SCAO PSF cube' ks = 1 box = [0.4,2.5,0.6,1.5] ###Load data from text file - wavelengths = vals[:,0] #vals = n.loadtxt('/Users/SimonZ/Data/Sim_data/PSFs/SCAOdata.txt', delimiter=',') #vals = n.loadtxt(psf_path+'SCAO/SCAOdata.txt', delimiter=',') vals = n.loadtxt(os.path.join(psf_path,'SCAO/SCAOdata.txt'), delimiter=',') #Seeing values see_vals = n.array([0.67, 0.85, 0.95, 1.10]) params= [] #Interpolate for all height parameters (oh = 1, 12, 23, 34; mh = 3, 14, 25, 36; lh = 6, 17, 28, 39; m2h = 9, 20, 31, 42) ohvals = n.array([vals[:,1], vals[:,12], vals[:,23], vals[:,34]]) ohinterp = s.RectBivariateSpline(vals[:,0], see_vals, ohvals.transpose(),kx=ks, ky=ks, bbox=box) yoh = ohinterp(lambs, seeing) mhvals = n.array([vals[:,3], vals[:,14], vals[:,25], vals[:,36]]) mhinterp = s.RectBivariateSpline(vals[:,0], see_vals, mhvals.transpose(),kx=ks, ky=ks, bbox=box) ymh = mhinterp(lambs, seeing) lhvals = n.array([vals[:,6], vals[:,17], vals[:,28], vals[:,39]]) lhinterp = s.RectBivariateSpline(vals[:,0], see_vals, lhvals.transpose(),kx=ks, ky=ks, bbox=box) ylh = lhinterp(lambs, seeing) m2hvals = n.array([vals[:,9], vals[:,20], vals[:,31], vals[:,42]]) m2hinterp = s.RectBivariateSpline(vals[:,0], see_vals, m2hvals.transpose(),kx=ks, ky=ks, bbox=box) ym2h = m2hinterp(lambs, seeing) params.append(yoh) params.append(ymh) params.append(ylh) params.append(ym2h) #Fit 6th order polynomial to Moffat (seeing) width and Lorentzian width parameters and then interpolate for i in n.array([4, 8]): p1, pn1 = curve_fit(x6, vals[:,0], vals[:,i]) p2, pn2 = curve_fit(x6, vals[:,0], vals[:,i+11]) p3, pn3 = curve_fit(x6, vals[:,0], vals[:,i+22]) p4, pn4 = curve_fit(x6, vals[:,0], vals[:,i+33]) yp1 = x6(vals[:,0], p1[0], p1[1], p1[2], p1[3], p1[4], p1[5], p1[6]) yp2 = x6(vals[:,0], p2[0], p2[1], p2[2], p2[3], p2[4], p2[5], p2[6]) yp3 = x6(vals[:,0], p3[0], p3[1], p3[2], p3[3], p3[4], p3[5], p3[6]) yp4 = x6(vals[:,0], p4[0], p4[1], p4[2], p4[3], p4[4], p4[5], p4[6]) yps = n.array([yp1, yp2, yp3, yp4]) pinterp = s.RectBivariateSpline(vals[:,0], see_vals, yps.transpose(), kx=ks, ky=ks, bbox=box) ys = pinterp(lambs, seeing) params.append(ys) #Fit 1st order polynomial to Airy width, Moffat (seeing) shape, Lorentz position, Moffat(core) width for i in n.array([2, 5, 7, 10]): p1, pn1 = curve_fit(x1, vals[:,0], vals[:,i]) p2, pn2 = curve_fit(x1, vals[:,0], vals[:,i+11]) p3, pn3 = curve_fit(x1, vals[:,0], vals[:,i+22]) p4, pn4 = curve_fit(x1, vals[:,0], vals[:,i+33]) yp1 = x1(vals[:,0], p1[0], p1[1]) yp2 = x1(vals[:,0], p2[0], p2[1]) yp3 = x1(vals[:,0], p3[0], p3[1]) yp4 = x1(vals[:,0], p4[0], p4[1]) yps = n.array([yp1, yp2, yp3, yp4]) pinterp = s.RectBivariateSpline(vals[:,0], see_vals, yps.transpose(), kx=ks, ky=ks, bbox=box) ys = pinterp(lambs, seeing) params.append(ys) #Fit 2nd order polynomial to Moffat (core) shape for i in n.array([11]): p1, pn1 = curve_fit(x2, vals[:,0], vals[:,i]) p2, pn2 = curve_fit(x2, vals[:,0], vals[:,i+11]) p3, pn3 = curve_fit(x2, vals[:,0], vals[:,i+22]) p4, pn4 = curve_fit(x2, vals[:,0], vals[:,i+33]) yp1 = x2(vals[:,0], p1[0], p1[1], p1[2]) yp2 = x2(vals[:,0], p2[0], p2[1], p2[2]) yp3 = x2(vals[:,0], p3[0], p3[1], p3[2]) yp4 = x2(vals[:,0], p4[0], p4[1], p4[2]) yps = n.array([yp1, yp2, yp3, yp4]) pinterp = s.RectBivariateSpline(vals[:,0], see_vals, yps.transpose(), kx=ks, ky=ks, bbox=box) ys = pinterp(lambs, seeing) params.append(ys) #params = [oh, mh, lh, m2h, mw, lw, ow, mq, lp, m2w, m2q] pdict = {'oh':params[0], 'ow':params[6], 'mh':params[1], 'mw':params[4], 'mq':params[7], 'lh':params[2], 'lp':params[8], 'lw':params[5], 'm2h':params[3], 'm2w':params[9], 'm2q':params[10]} return pdict