コード例 #1
0
 def grab_current_flatmap(self):
     """get the current flatmap, move it to this computer, 
     return it as an array"""
     current_flatmap_path = self.getstatus()['hodm_map']
     stdout, stderr = subprocess.Popen(
                         ['scp', 
                          '[email protected]:'+
                          current_flatmap_path, 
                          self.localoutputdir], 
                          stdout=subprocess.PIPE).communicate()
     for s in [stdout, stderr]:
         if s is not None:
             print(s)
     fmapfile = os.path.join(self.localoutputdir,current_flatmap_path.split('/')[-1])
     current_flatmap = flatmapfunctions.convert_hodm_telem(flatmapfunctions.load_flatmap(fmapfile))
     
     return current_flatmap
コード例 #2
0
    def load_new_flatmap(self, fmap,
                         fmap_filename = 'hodm_sn_temp',
                         fmapdir_p3k = '/p3k/tables/hodm_map/'):
        try:
            flatmapfunctions.make_hmap(self.localoutputdir+fmap_filename,fmap)	
        except:
            print("Warning: converting flatmap to 1d")
            flatmapfunctions.make_hmap(self.localoutputdir+fmap_filename,
                    flatmapfunctions.convert_hodm_telem(fmap))

        stdout, stderr = subprocess.Popen(
                        ['scp', 
                         self.localoutputdir+fmap_filename,
                         '[email protected]:'+fmapdir_p3k],
                         stdout=subprocess.PIPE).communicate()
        for s in [stdout, stderr]:
            if s is not None:
                print(s)
        status=self.safesend2('hwfp hodm_map='+fmapdir_p3k+fmap_filename)
        #self.safesend2('hwfp dm=on')
        #while not self.getstatus()['dm'] == '0':
        #    self.safesend2('hwfp dm=off')
        pass
コード例 #3
0
ファイル: MAIN.py プロジェクト: lbusoni/MEDIS
    phases = config['NULLING']['phases']
    cx = round(im_params['centerx'])
    cy = round(im_params['centery'])
    
    #Simulator
    #pharo = hardware.fake_pharo()
    
    #Real thing
    pharo = hardware.PHARO_COM('PHARO', 
                configfile = hardwareconfigfile)
    #LOAD P3K HERE
    p3k = hardware.P3K_COM('P3K_COM', configfile = hardwareconfigfile)
    #LOAD CURRENT FLATMAP 
    initial_flatmap = np.zeros((66, 66)) 
    initial_flatmap = p3k.grab_current_flatmap()
    status = p3k.load_new_flatmap(fmap.convert_hodm_telem(initial_flatmap))
    
    im = pharo.take_src_return_imagedata(exptime=4)#works, tested
    #bck = pre.combine_quadrants(pf.open('/data1/home/aousr/Desktop/speckle_nulling/pharoflatsdarks/medbackground.fits'))
    bck2=pf.open('/data1/home/aousr/Desktop/speckle_nulling/pharoflatsdarks_mb/medbackground.fits')[0].data
    #im = pre.equalize_image(im, bkgd=bck )
    im = im-bck2
    #im = pre.combine_quadrants(pf.open('/data1/home/aousr/Desktop/speckle_nulling/pharoimages/ph0186.fits'))


    #Replacing Mike's CV2 speckle detection with simple max search and gaussian fit 
    #speckleslist = detect_speckles.detect_speckles(im, configfile = configfilename)
    #speckleobjects = [speckle(im, contour, im_params) for contour in speckleslist]
    

    speckle_positions, speckle_amplitude = detect_speckles.detect_speckles2(im, configfile = configfilename, configspecfile=configspecfile)
コード例 #4
0
ファイル: Calibration_SCC_V0.py プロジェクト: lbusoni/MEDIS
    # fichier de parametres pour PK3 et Pharo
    hardwareconfigfile = 'speckle_instruments_scc.ini'

    # initialisation de Pharo
    # Real thing
    pharo = hardware.PHARO_COM('PHARO', configfile=hardwareconfigfile)

    # LOAD P3K HERE
    # initialisation de P3k
    p3k = hardware.P3K_COM('P3K_COM', configfile=hardwareconfigfile)

    # LOAD and APPLY a flatmap
    initial_flatmap = np.zeros((66, 66))
    initial_flatmap = p3k.grab_current_flatmap()
    # We apply to the DM the initial flatmap
    status = p3k.load_new_flatmap(fmap.convert_hodm_telem(initial_flatmap))

    #READ Image before any correction
    im_flat = np.zeros((1024, 1024))
    im_flat = pharo.take_src_return_imagedata(exptime)  #works, tested
    #ipdb.set_trace()

    Freq_num = 0
    while Freq_num < len(freq):
        Freq_selected = freq[Freq_num]
        Ampl_selected = ampl[Freq_num]

        # Met au bon format si nécessaire
        if type(Freq_selected) is int:
            Freq_selected = [Freq_selected]
            Ampl_selected = [Ampl_selected]
コード例 #5
0
    hardwareconfigfile = 'speckle_instruments_scc.ini'

    # initialisation de Pharo
    # Real thing
    pharo = hardware.PHARO_COM('PHARO', configfile=hardwareconfigfile)

    # LOAD P3K HERE
    # initialisation de P3k
    p3k = hardware.P3K_COM('P3K_COM', configfile=hardwareconfigfile)

    # Load the flatmap of the DM
    # initial_flatmap = p3k.grab_current_flatmap()
    initial_flatmap = pf.open(FDMC_folder + FDMC_name)[0].data

    # We apply to the DM the initial flatmap
    status = p3k.load_new_flatmap(fmap.convert_hodm_telem(initial_flatmap))

    phdm = initial_flatmap
    #phdm   = np.zeros((66.,66.))

    # On enregistre la commande DM
    DM_commande_save = phdm
    pf.writeto(dirwr + folder_Correction + folder_DM_Com + "Commande_" +
               str(int(0)) + ".fits",
               DM_commande_save,
               clobber=True)

    i = 0
    while i < nb_ite:

        if i > 0:
コード例 #6
0
    hardwareconfigfile = 'speckle_instruments_scc.ini'

    # initialisation de Pharo
    # Real thing
    pharo = hardware.PHARO_COM('PHARO', configfile=hardwareconfigfile)

    # LOAD P3K HERE
    # initialisation de P3k
    p3k = hardware.P3K_COM('P3K_COM', configfile=hardwareconfigfile)

    # LOAD and APPLY a flatmap
    initial_flatmap = np.zeros((66, 66))
    initial_flatmap = p3k.grab_current_flatmap()
    initial_flatmap = initial_flatmap  #+ (-1)*Cube_freq[89,:,:]/4.
    # We apply to the DM the initial flatmap
    status = p3k.load_new_flatmap(fmap.convert_hodm_telem(initial_flatmap))

    #READ Image before any correction

    im_flat = np.zeros((1024, 1024))
    im_flat = pharo.take_src_return_imagedata(exptime)  #works, tested
    #ipdb.set_trace()

    Commande = initial_flatmap
    Image_freq = im_flat[np.newaxis, :, :]
    Image_name = 'Im'
    pf.writeto(dirwr + folder_image + Image_name + ".fits",
               Image_freq,
               clobber=True)

    pf.writeto(dirwr + folder_image + folder_2 + "Im_0.fits",
コード例 #7
0
ファイル: qacits_control_init.py プロジェクト: lbusoni/MEDIS
        img_ref = pre.equalize_image(img_ref, **bgds)
    else:
        img_ref = pre.combine_quadrants(pf.open(ref_filename)) 
        img_ref = img_ref - bgd1
    
    ix_ref , iy_ref = qacits.get_delta_I(img_ref, cx=centerx, cy=centery,
                            quad_width_pix = quad_width_pix,
                            inner_rad_pix = quad_width_pix, 
                            zone_type=zone_type)       
    #ipdb.set_trace()
    
    # Apply sine waves
    if onsky :
        initial_flatmap = np.zeros((66, 66)) 
        initial_flatmap = p3k.grab_current_flatmap()
        status = p3k.load_new_flatmap(FM.convert_hodm_telem(initial_flatmap))
        DMamp = 60
        kvecr = 24
        additionmapx = dmf.make_speckle_kxy(kvecr, 0,DMamp , 0) 
        additionmapy = dmf.make_speckle_kxy(0,kvecr, DMamp, 0) 
        additionmap = additionmapx + additionmapy
        status = p3k.load_new_flatmap(FM.convert_hodm_telem(initial_flatmap + additionmap))
    	
        img_pos = pharo.take_src_return_imagedata()
        img_pos = pre.equalize_image(img_pos, **bgds)

        status = p3k.load_new_flatmap(FM.convert_hodm_telem(initial_flatmap))
    
    else :
        img_pos = pre.combine_quadrants(pf.open(pos_filename)) 
        img_pos = img_pos - bgd1
コード例 #8
0
    # fichier de parametres pour PK3 et Pharo
    hardwareconfigfile = 'speckle_instruments_scc.ini'

    # initialisation de Pharo
    # Real thing
    pharo = hardware.PHARO_COM('PHARO', configfile = hardwareconfigfile)

    # LOAD P3K HERE
    # initialisation de P3k
    p3k   = hardware.P3K_COM('P3K_COM', configfile = hardwareconfigfile)

    # LOAD and APPLY a flatmap
    initial_flatmap = np.zeros((66, 66))
    initial_flatmap = p3k.grab_current_flatmap()
    # We apply to the DM the initial flatmap
    status          = p3k.load_new_flatmap(fmap.convert_hodm_telem(initial_flatmap))

    #READ Image before any correction
    exptime = 4
    im_flat         = np.zeros((1024, 1024))
    im_flat         = pharo.take_src_return_imagedata(exptime) #works, tested
    #ipdb.set_trace()
	

    # We read a cube of frequency
    #hdulist = pf.open(dirwr + 'Freq_DM_map_cube.fits')
    hdulist = pf.open(dirwr + 'Freq_start.fits')
    Cube_freq = hdulist[0].data
    hdulist.close()

    # We initialized the DM Shape to apply