with open('save.pkl', 'wb') as handle: pickle.dump(plotdata, handle, protocol=pickle.HIGHEST_PROTOCOL) # for cont in plotdata[:,2]: # plt.plot(rad_samp,cont) # print plotdata # print plotdata[:,2] # Plotting plotdata = np.array(plotdata) rad_samp = np.linspace(0, tp.platescale / 1000. * plotdata.shape[2], plotdata.shape[2]) fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(14, 3.4)) for thruput in plotdata[:, 0]: axes[0].plot(rad_samp, thruput) for noise in plotdata[:, 1]: axes[1].plot(rad_samp, noise) for cont in plotdata[:, 2]: axes[2].plot(rad_samp, cont) for ax in axes: ax.set_yscale('log') ax.set_xlabel('Radial Separation') ax.tick_params(direction='in', which='both', right=True, top=True) axes[0].set_ylabel('Throughput') axes[1].set_ylabel('Noise') axes[2].set_ylabel('5$\sigma$ Contrast') axes[2].legend(['RDI', 'ADI', 'SDI', 'DSI', 'SSD']) compare_images(maps, logAmp=True) plt.show()
width=1, titles=r'$I$', annos=['Before Coron.', 'After Coron.'], logAmp=True) plt.show(block=True) tp.detector = 'MKIDs' tp.w_bins = 12 if __name__ == '__main__': mkid = gpd.run()[0, :] compare_images(mkid[::2], vmax=200, logAmp=True, vmin=1, title=r'$I (cts)$', annos=[ 'MKIDs 800 nm', '940 nm', '1080 nm', '1220 nm', '1360 nm', '1500 nm' ]) quicklook_im(np.mean(mkid[5:-1], axis=0), anno='MEDIS J Band', vmax=400, axis=None, title=r'$I (cts)$', logAmp=True, label='e') fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(9, 3.8)) labels = ['Ideal', 'MKID'] # images = [ideal,mkid] titles = ['A.U.', 'cts']
tp.rot_rate = 4.5 # deg/s iop.hyperFile = iop.datadir + '/ADIHyper.pkl' ADI_hypercube = read.get_integ_hypercube(plot=False) #/ap.numframes # star_phots = np.ones((len(ADI_hypercube))) * star_phot algo_dict = {} angle_list = -1 * np.arange(0, num_exp * tp.rot_rate * cp.frame_time, tp.rot_rate * cp.frame_time) print angle_list.shape method_out = eval_method(ADI_hypercube[:, 0], pca.pca, angle_list, algo_dict) plotdata.append(method_out[0]) maps.append(method_out[1]) quicklook_im(method_out[1]) # annos = ['ADI', 'RDI'] compare_images([maps[1], maps[0]], logAmp=True, scale=1e3, annos=annos) # # # # SDI # tp.rot_rate = 0 # deg/s # tp.nwsamp = 8 # iop.hyperFile = iop.datadir + '/SDIHyper.pkl' # wsamples = np.linspace(tp.band[0], tp.band[1], tp.nwsamp) # scale_list = tp.band[0] / wsamples # SDI_hypercube = read.get_integ_hypercube(plot=False) # tp.nwsamp = 1 # algo_dict = {'scale_list': scale_list} # ap.exposure_time = 1 # # datacube = read.med_collapse(SDI_hypercube) # datacube = (read.take_exposure(SDI_hypercube)/ap.numframes)[0] # # star_phots = star_phot # angle_list = np.zeros((len(SDI_hypercube[0])))
tp.NCPA_type = None#'Static' tp.CPA_type = 'Amp' # tp.CPA_type = 'test' # tp.CPA_type = None#'Static'#'test' ap.lods = [[2, 0]] # initial location (no rotation) tp.active_null = True tp.speckle_kill = True iop.hyperFile = iop.datadir + '/amp_abs2.pkl' # tp.active_modulate = True perfect_hypercube = read.get_integ_hypercube(plot=False) # /ap.numframes quicklook_im(np.sum(perfect_hypercube[:, 0], axis=0), axis=None, title=r' $I / I^{*}$', anno='Integration') loop_frames(perfect_hypercube[::20, 0]) # compare_images([perfect_hypercube[0,0],perfect_hypercube[10,0],perfect_hypercube[100,0],perfect_hypercube[1000,0]], logAmp=True) annos = ['Frame: 0', 'Frame: 20', 'Frame: 500', 'Frame: 2000'] compare_images( [perfect_hypercube[0, 0], perfect_hypercube[20, 0], perfect_hypercube[500, 0], perfect_hypercube[-1, 0]], logAmp=True, title='A.U', annos= annos) # Perfect tp.detector = 'ideal'#'MKIDs' # tp.use_ao = False tp.use_atmos = False tp.NCPA_type = None#'Static' tp.CPA_type = None#'Static' tp.active_null = False iop.hyperFile = iop.datadir + '/perfect.pkl' # tp.active_modulate = True perfect_hypercube = read.get_integ_hypercube(plot=False) # /ap.numframes # quicklook_im(np.sum(perfect_hypercube[:, 0], axis=0), axis=None, title=r' $I_r / I^{*}$', anno='Integration') # loop_frames(perfect_hypercube[:, 0])
# Plotting dprint(np.shape(plotdata)) plotdata = np.array(plotdata) # rad_samp = np.linspace(0,tp.platescale/1000.*mp.array_size[0]/2,plotdata.shape[2]) rad_samp = plotdata[:, 3][0] fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(14, 3.4)) for thruput in plotdata[:, 0]: axes[0].plot(rad_samp, thruput) for noise in plotdata[:, 1]: axes[1].plot(rad_samp, noise) for cont in plotdata[:, 2]: axes[2].plot(rad_samp, cont) for ax in axes: ax.set_yscale('log') ax.set_xlabel('Radial Separation') ax.tick_params(direction='in', which='both', right=True, top=True) axes[0].set_ylabel('Throughput') axes[1].set_ylabel('Noise') axes[2].set_ylabel('5$\sigma$ Contrast') axes[2].legend(['Exp.', 'RDI', 'RDI DSI', 'RDI DSI SDI']) compare_images( maps, logAmp=True, vmin=0.01, vmax=100, # vmins = [0.1,0.1,0.1,0.1], vmaxs = [100,100,0.5,0.5], annos=['Exp.', 'RDI', 'RDI DSI', 'RDI DSI SDI']) # , # titles=[r' $I / I^{*}$', r' $I / I^{*}$', r' $I_L / I^{*}$', r' $I_L / I^{*}$']) # quicklook_im(maps[0], logAmp=True, vmin = 0.01, vmax = 1) plt.show()
starphot=star_phot, algo=pca.pca, debug=True) # from vip_hci import pca # loop_frames(hypercube[:,0]) ADI = pca.pca( hypercube[:, 0], angle_list=-1 * np.arange(0, num_exp * tp.rot_rate * cp.frame_time, tp.rot_rate * cp.frame_time) ) #, scale_list=np.ones((len(hypercube[:,0]))), mask_center_px=None) quicklook_im(ADI) ADI = ADI.reshape(1, 128, 128) wsamples = np.linspace(tp.band[0], tp.band[1], tp.nwsamp) scale_list = tp.band[0] / wsamples print scale_list, scale_list[-1], 'SL', 1. / scale_list[-1] wframe = clipped_zoom(hypercube[0, 0], 1. / scale_list[-1]) quicklook_im(wframe) wframe = wframe.reshape(1, 128, 128) cube = np.vstack((hypercube[0, [0, -1]], wframe, SDI)) # cube = np.dstack((hypercube[0,0],wframe,hypercube[0,-1],SDI)).transpose() annos = [ '$\lambda_0$=860 nm', '$\lambda_8=$1250 nm', '$\lambda_0$ Scaled', 'SDI Residual' ] print 'change titles to bottom left text in figure white' # view_datacube(cube, logAmp=True,) compare_images(cube, logAmp=True, annos=annos)
axes[0].plot(rad_samp, thruput) for noise in plotdata[:, 1]: axes[1].plot(rad_samp, noise) for cont in plotdata[:, 2]: axes[2].plot(rad_samp, cont) for ax in axes: ax.set_yscale('log') ax.set_xlabel('Radial Separation') ax.tick_params(direction='in', which='both', right=True, top=True) axes[0].set_ylabel('Throughput') axes[1].set_ylabel('Noise') axes[2].set_ylabel('5$\sigma$ Contrast') axes[2].legend(R_sigs) maps = np.array(maps) compare_images(maps, logAmp=True, scale=1e1) #[[0,1,-1]] plt.show() plt.plot(R_sigs, plotdata[:, 2, 16]) plt.show() # # ***** pixel yield ***** # # import copy # orig_psf_template = copy.deepcopy(psf_template) # # yields = np.logspace(0, 1.7, 3) # # Rs = [50] # yields = [0.8,0.9,0.95,0.99,0.999]#[0.05,0.2,0.4,0.8,0.995]#[0.99995,0.4]#0.4,0.8, # mp.R_mean = 50 # # import Detector