Exemplo n.º 1
0
def get_unoccult_hyper(hyperFile = '/RefPSF_wLyotStop.pkl', numframes=1):
    import copy
    tp_orig = copy.copy(tp)
    ap_orig = copy.copy(ap)
    iop_orig = copy.copy(iop)

    # tp.detector = 'ideal'
    ap.companion = False
    iop.hyperFile = iop.datadir + hyperFile
    tp.occulter_type = 'None (Lyot Stop)'
    ap.numframes = numframes
    ap.exposure_time = 1e-3
    # tp.nwsamp = 1
    # tp.w_bins = 1
    print(iop.obsfile, 'obs')
    hypercube = read.get_integ_hypercube()

    tp.__dict__ = tp_orig.__dict__
    ap.__dict__ = ap_orig.__dict__
    iop.__dict__ = iop_orig.__dict__
    return hypercube
Exemplo n.º 2
0
def get_unoccult_perf_psf(plot=False, hyperFile='/IntHyperUnOccult.pkl'):
    import copy
    tp_orig = copy.copy(tp)
    ap_orig = copy.copy(ap)
    iop_orig = copy.copy(iop)

    tp.detector = 'ideal'
    ap.companion = False
    # tp.NCPA_type = 'Wave'

    iop.hyperFile = iop.datadir + '/perfIntHyperUnOccult.pkl'
    tp.occulter_type = 'None'
    num_exp = 1
    ap.exposure_time = 0.001  # 0.001
    ap.numframes = int(num_exp * ap.exposure_time / cp.frame_time)
    tp.use_atmos = False
    tp.nwsamp = 1
    tp.CPA_type = None#'Quasi'# None
    tp.NCPA_type = None#'Wave'# #None
    tp.aber_params = {'CPA': False,
                        'NCPA': False,
                        'QuasiStatic': False,  # or 'Static'
                        'Phase': False,
                        'Amp': False,
                        'n_surfs': 2}
    # Yup this is 'if' is necessary
    hypercube = read.get_integ_hypercube()
    # PSF = hypercube[0,0]
    PSF = (read.take_exposure(hypercube))[0,0]
    if plot:
        quicklook_im(PSF)

    tp.__dict__ = tp_orig.__dict__
    ap.__dict__ = ap_orig.__dict__
    iop.__dict__ = iop_orig.__dict__
    # # print tp.occulter_type

    return PSF
Exemplo n.º 3
0
    psf_template = Analysis.phot.get_unoccult_psf(
        hyperFile='/IntHyperUnOccult.pkl', plot=False)
    # star_phot = np.sum(psf_template)
    star_phot = phot.contrcurve.aperture_flux(psf_template, [64], [64], lod,
                                              1)[0] / ap.numframes
    psf_template = psf_template[:-1, :-1]

    # RDI (for SDI)
    ap.companion = True
    ap.contrast = [1e-5, 1e-6]  # [0.1,0.1]
    ap.lods = [[-2.5, 2.5], [-4.5, 4.5]]
    tp.detector = 'MKIDs'  #'ideal'#
    # iop.hyperFile = iop.datadir + 'far_out1MKIDs7_w6_.pkl'  # 5
    iop.hyperFile = iop.datadir + 'MEC_tar_500_highcount.pkl'  # 5
    # iop.hyperFile = iop.datadir + 'noWnoRollHyperWcomp1000cont_Aug_1stMKIDs2.pkl'#5
    simple_hypercube_1 = read.get_integ_hypercube(plot=False)  #/ap.numframes

    ap.startframe = ap.numframes
    ap.companion = False
    # iop.hyperFile = iop.datadir + 'far_out2MKIDs7_w6_.pkl'  # 5
    iop.hyperFile = iop.datadir + 'MEC_ref_500_highcount.pkl'  # 5
    # iop.hyperFile = iop.datadir + 'noWnoRollHyperWcomp1000cont_Aug_2ndMKIDs2.pkl'#5
    simple_hypercube_2 = read.get_integ_hypercube(plot=False)  #/ap.numframes

    # loop_frames(simple_hypercube_1[::10,0], logAmp=True)
    # loop_frames(simple_hypercube_2[:,0], logAmp=True)
    diff_cube = simple_hypercube_1 - simple_hypercube_2
    # loop_frames(diff_cube[:,0], logAmp=False)
    # quicklook_im(np.mean(diff_cube[:,0],axis=0), logAmp=False)
    # quicklook_im(np.mean(diff_cube[:, 0], axis=0), logAmp=True)
    # quicklook_im(np.median(diff_cube[:, 0], axis=0), logAmp=True)
Exemplo n.º 4
0
plotdata, maps = [], []
if __name__ == '__main__':

    # rad_samp = np.linspace(0,tp.platescale/1000.*40,40)
    # print rad_samp
    # # Get unocculted PSF for intensity
    # psf_template = Analysis.phot.get_unoccult_psf(hyperFile='/IntHyperUnOccult.pkl', plot=False)
    # # star_phot = np.sum(psf_template)
    # star_phot = phot.contrcurve.aperture_flux(psf_template,[64],[64],lod,1)[0]/ap.numframes
    # psf_template = psf_template[:-1,:-1]

    # bunching
    ap.companion = True
    iop.hyperFile = iop.datadir + '/bunchingOldAtmos_ArteficialSpecksDim2sec.pkl'
    bunch_hypercube = read.get_integ_hypercube(plot=False)  # / ap.numframes
    print bunch_hypercube.shape

    loop_frames(bunch_hypercube[:, 0], axis=None)

    def sub_sums_ophion(arr, ncols):
        arr = arr.reshape(1, -1)
        nrows = 1
        h, w = arr.shape
        h = (h // nrows) * nrows
        w = (w // ncols) * ncols
        arr = arr[:h, :w]
        return np.einsum('ijkl->ik', arr.reshape(h // nrows, nrows, -1, ncols))

    full_counts = np.zeros((2, num_exp))
    full_counts[0] = bunch_hypercube[:, 0, 40, 40]
Exemplo n.º 5
0
# ************************ H2RG ****************************
tp.detector = 'H2RG'
tp.NCPA_type = 'Static'  #'Wave'

#  ++++++++ H2RG - Ref_PSF ++++++++
iop.hyperFile = iop.datadir + '/nocomp_BinH2RG_noCoron_hyper.pkl'
tp.occulter_type = 'None'
num_exp = 10
ap.exposure_time = 0.01  #0.001
ap.numframes = int(num_exp * ap.exposure_time / cp.frame_time)
tp.nwsamp = 1
hp.use_readnoise = False
# Yup this is 'if' is necessary
if __name__ == '__main__':
    hypercube = read.get_integ_hypercube(plot=False)
    # view_datacube(hypercube[0], logAmp=False)
    psf_template = hypercube[0, 0]
    psf_template = psf_template[:-1, :-1]
    star_phot = phot.contrcurve.aperture_flux(psf_template, [64], [64], lod,
                                              1)[0] / ap.numframes
#  +++++++++++++++++++++++++++++++

plotdata, maps = [], []
readnoises = [0.1, 1, 5, 10, 30]
for rn in [50]:  #readnoises:
    #  ++++++++ H2RG - Full Obs ++++++
    iop.hyperFile = iop.datadir + '/nocompnorm_BinH2RG_with_coron_hyper_%i.pkl' % rn
    tp.occulter_type = 'Gaussian'
    tp.nwsamp = 10
    hp.readnoise = rn
Exemplo n.º 6
0
    # plot_null()

    # Amplitude
    tp.detector = 'ideal'#'MKIDs'  #
    tp.use_ao = True
    tp.use_atmos = False
    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
Exemplo n.º 7
0
    psf_template = Analysis.phot.get_unoccult_psf(hyperFile='/IntHyperUnOccult.h5', plot=False, numframes=1)
    psf_template = psf_template[0,:,1:,1:]
    dprint((tp.grid_size//2, psf_template.shape))
    # quicklook_im(np.sum(psf_template,axis=0))
    star_phot = phot.contrcurve.aperture_flux(np.sum(psf_template,axis=0),[mp.array_size[0]//2],[mp.array_size[0]//2],lod,1)[0]/1e4#/ap.numframes * 500
    wsamples = np.linspace(tp.band[0], tp.band[1], tp.w_bins)
    scale_list = wsamples/(tp.band[1]-tp.band[0])
    scale_list = scale_list#[::-1]
    algo_dict = {'scale_list': scale_list}

    ap.exposure_time = 0.1  # 0.001

    ap.numframes = int(num_exp * ap.exposure_time / cp.frame_time)
    iop.hyperFile = iop.datadir + 'HR8799_phot_tag%i_tar_%i.h5' % (ap.numframes, np.log10(ap.star_photons))
    dprint(iop.hyperFile)
    orig_hyper = read.get_integ_hypercube(plot=False)[:, :]

    # fast_hyper = fast_hyper[:100]
    # ap.numframes = int(100 * ap.exposure_time / cp.frame_time)
    # dprint(fast_hyper.shape)
    fast_hyper = read.take_exposure(orig_hyper)
    ap.exposure_time = 1  # 0.001
    med_hyper = read.take_exposure(orig_hyper)
    ap.exposure_time = 10#1.0  # 0.001
    slow_hyper = read.take_exposure(orig_hyper)
    ap.exposure_time = 100#1.0  # 0.001
    v_slow_hyper = read.take_exposure(orig_hyper)

    # this is crucial for the PCA
    fast_hyper /= np.sum(fast_hyper) # /ap.numframes
    med_hyper /= np.sum(med_hyper) # /ap.numframes
Exemplo n.º 8
0
    #     noises.append([noise[21], noise[35], noise[50]])
    # noises = np.array(noises)
    # plt.plot(noises[:,0])
    # plt.plot(noises[:,1])
    # plt.plot(noises[:,2])
    # plt.show()


    noises = []
    iop.hyperFile = iop.datadir + '/abertest5noatmosquasispeckle2000_1s.pkl'
    # iop.hyperFile = iop.datadir + '/abertest5noatmosquasispeckle1000_100ms_ideal.pkl'


    import os
    # iop.aberdir = os.path.join(iop.rootdir, 'data/aberrations/180420b/')
    abertest = read.get_integ_hypercube(plot=False)# / ap.numframes
    # print np.shape(abertest)
    # quicklook_im(abertest[-1,0], logAmp=False)
    # loop_frames(abertest[:,0])
    # # print abertest.shape
    #
    # for x in [118,119]:
    #     for y in [9,10]:
    #         corr, ljb, pvalue = acf(abertest[:, 0, x, y], unbiased=False, qstat=True, nlags=len(range(ap.numframes)))
    #         # print abertest[:, 0, 9, 119]
    #         # corr, ljb, pvalue = acf(abertest[:, 0, 9, 119], unbiased=False, qstat=True, nlags=len(range(ap.numframes)))
    #         star_corr = corr
    #         # plt.figure()
    #         plt.plot(star_corr)
    # plt.xscale('log')
    # # plt.show()
Exemplo n.º 9
0
# tp.platescale=10.
tp.platescale = 5.
tp.piston_error = True
# tp.band = np.array([700, 1500])
# tp.nwsamp = 3#7#10#5#5#5#1.#
# tp.w_bins = 8#7#10#5#5#5#1.#
# tp.band = np.array([700, 1800])
tp.band = np.array([700, 1800])
tp.nwsamp = 1  #4#5#3#7#10#5#5#5#1.#
tp.w_bins = 1  #12#8#7#10#5#5#5#1.#

tp.rot_rate = 0  # deg/s
theta = 45
lod = 8.
# iop.aberdir = 'D:/dodkins/MEDIS/data/aberrations/180902/'
# iop.aberdir = 'D:/dodkins/MEDIS/data/aberrations/180420/'
no_sauce = True
dprint(iop.aberdir)

if __name__ == '__main__':
    dprint(iop.aberdir)
    rad_samp = np.linspace(0, tp.platescale / 1000. * 128, 50)
    print(rad_samp)

    ap.companion = True
    iop.hyperFile = iop.datadir + 'HR8799_phot_tag%i_tar_%i.pkl' % (
        num_exp, np.log10(ap.star_photons))
    dprint(iop.aberdir)
    simple_hypercube_1 = read.get_integ_hypercube(
        plot=False)[:, :]  # /ap.numframes