Ejemplo n.º 1
0
    def __init__(self,local=True,channel='left',size=199,rin=30,rout=60,pathRDI='RDI_python'):
        """
        Class attributes:
            - pathRDI
            - pathRoot
            - pathSparta
            - targets: a list with all targets
            - pathOut_targets: a dictionary with the reduction folder of the targets
            - size: the size of the images we work with
            - channel: the channel we work with (left, right, sum)
            - rin: the inner radius for the correlation
            - rout: the outer radius for the correlation
            - frames_nb: a dictionnary with the number of frames of each target
            - dist_center: an array of shape (size,size) with the distance from the center
            - frames_starta_index:  a dictionnary where keys are target names and values are
                                    the index at which the target starts in the master correlation matrix
            - mask_correlation: an boolean array of shape (size,size) contain 1 for pixels to be used in the correlation
            - total_frames: the total number of frames including all targets
            - correlation_matrix: the large correlation matrix
        """        
        if local:
            self.pathRoot = '/diskb/Data/survey_disk'
            self.pathSparta = '/diskb/Data/sparta'
            self.targets = self.list_targets()
        else:
            self.pathRoot = '/Volumes/SHARDDS_data/survey_disk'
            self.pathSparta = '/Volumes/SHARDDS_data/sparta'
            self.targets = ['HD60491','HD71722','HD218340','HD14082B','HD182681']
        self.pathRDI = os.path.join(self.pathRoot,'../'+pathRDI)

        self.size = size
        self.channel=channel
        self.rin=rin
        self.rout=rout
        self.frames_nb = {}
        self.frames_start_index = {}
        self.frames_start_index_list = np.ndarray((len(self.targets)),dtype=int)       
        self.dist_center = distance_array([self.size,self.size],verbose=False)
#        self.mask_correlation = np.ndarray((self.size,self.size),dtype=int)*0
#        self.mask_correlation[np.logical_and(self.dist_center<rout,self.dist_center>rin)]=1
        self.mask_correlation = np.logical_and(self.dist_center<rout,self.dist_center>rin)
        self.pathOut_targets = {}
        
        total_frames = 0
        for id_target,target_name in enumerate(self.targets):
            pathTarget = os.path.join(self.pathRoot,target_name)
            pathOut = os.path.join(pathTarget,'pipeline')       
            self.pathOut_targets[target_name] = pathOut
            self.frames_start_index[target_name]=total_frames
            self.frames_start_index_list[id_target]=total_frames
            derot_angles = fits.getdata(os.path.join(pathOut,'{0:s}_derotation_angles_O.fits'.format(target_name)))
            nb_frames= len(derot_angles)
            total_frames = total_frames+nb_frames
            self.frames_nb[target_name]=nb_frames
            print('Reading files in {0:s} ({1:d} frames)'.format(target_name,nb_frames))
        self.total_frames = total_frames
        self.correlation_matrix = np.ndarray((total_frames,total_frames),dtype=float)*0.
Ejemplo n.º 2
0
 def __init__(self,channel='left',size=199,rin=30,rout=60,pathRDI='RDI_python'):
     """
     Constructor of the class
     
     Input:
         - size: the size of the images we work with. Default: 199
         - channel: the channel we work with (left, right, sum). Defaut: left
         - rin: the inner radius for the correlation. Defaut: 30
         - rout: the outer radius for the correlation. Defaut: 60
         - pathRDI: the relative path where the correlation matrix is saved. 
                    Default: pathRoot/../pathRDI
     """        
     self.pathRoot = '/Volumes/SHARDDS/Data/survey_disk'
     self.pathSparta = '/Volumes/SHARDDS/Data/sparta'
     self.targets = self.list_targets()
     self.pathRDI = os.path.join(self.pathRoot,'../'+pathRDI)
     self.size = size
     self.channel=channel
     self.rin=rin
     self.rout=rout
     self.frames_nb = {}
     self.frames_start_index = {}
     self.frames_start_index_list = np.ndarray((len(self.targets)),dtype=int)       
     self.dist_center = distance_array([self.size,self.size],verbose=False)
     self.mask_correlation = np.logical_and(self.dist_center<rout,self.dist_center>rin)
     self.pathOut_targets = {}
     
     total_frames = 0
     for id_target,target_name in enumerate(self.targets):
         pathTarget = os.path.join(self.pathRoot,target_name)
         pathOut = os.path.join(pathTarget,'pipeline')       
         self.pathOut_targets[target_name] = pathOut
         self.frames_start_index[target_name]=total_frames
         self.frames_start_index_list[id_target]=total_frames
         derot_angles = fits.getdata(os.path.join(pathOut,'{0:s}_derotation_angles_O.fits'.format(target_name)))
         nb_frames= len(derot_angles)
         total_frames = total_frames+nb_frames
         self.frames_nb[target_name]=nb_frames
         print('Reading files in {0:s} ({1:d} frames)'.format(target_name,nb_frames))
     self.total_frames = total_frames
     self.correlation_matrix = np.ndarray((total_frames,total_frames),dtype=float)*0.
Ejemplo n.º 3
0
HD22179_2nd_epoch contains only the PSF. Investigate why. I classified it in bad

"""

channels = ['left', 'right']
size_psf = 200
for id_target, target_name in enumerate(targets):
    if target_name != 'HD105':
        continue
    pathTarget = os.path.join(pathRoot, target_name)
    pathRaw = os.path.join(pathTarget, 'raw')
    pathOut = os.path.join(pathTarget, 'pipeline')

    #%%
    size = 799
    distarr = im.distance_array((size, size))
    mask = np.logical_and(distarr > 100, distarr < 350)
    for ichannel, channel in enumerate(channels):
        cube = fits.getdata(
            os.path.join(
                pathOut,
                'HD105_{0:d}x{0:d}_{1:s}_O.fits'.format(size, channel)))
        header = fits.getheader(
            os.path.join(
                pathOut,
                'HD105_{0:d}x{0:d}_{1:s}_O.fits'.format(size, channel)))
        parang = fits.getdata(os.path.join(pathOut, 'HD105_parang_O.fits'))
        derot_angles = fits.getdata(
            os.path.join(pathOut, 'HD105_derotation_angles_O.fits'))

        nimg = cube.shape[0]
Ejemplo n.º 4
0
                print('You chose a 2D contrast map')                
        #ppf is the percent point function (inverse of cdf - percentiles)
        if curve1d:
            return t.ppf(confidenceLevel, nbResels-1)*np.sqrt(1.+1./nbResels)/sigma
        else:
            return t.ppf(confidenceLevel, nbResels-2)*np.sqrt(1.+1./(nbResels-1))/sigma                        
            
if __name__ == '__main__':

    import matplotlib.pyplot as plt
    from image_tools import distance_array

    sigma = 3    
    size=10
#    fake_img = np.random.normal(np.random.randint(-5,5),np.random.rand(),(size,size))
    fake_img = distance_array((size,size))#,centerx=size/2.-0.5,centery=size/2.-0.5)
#    fake_img = distance_array((size,size))


    plt.figure(0)
    plt.imshow(fake_img,origin='lower')
    plt.colorbar()
    
#    rd=Radial_data(fake_img,xvect=np.arange(-size/2,size/2.)+0.5,yvect=np.arange(-size/2,size/2.)+0.5)
    rd=Radial_data(fake_img)

    # example of use 
    plt.figure(1)
    plt.plot(rd.r,rd.mean,'ro',label='Mean')
    plt.plot(rd.r,rd.std,'g:',label='Std')
    plt.plot([0,size/2.*np.sqrt(2)],[0,size/2.*np.sqrt(2)],'b-',label='y=x')
Ejemplo n.º 5
0
        #ppf is the percent point function (inverse of cdf - percentiles)
        if curve1d:
            return t.ppf(confidenceLevel, nbResels-1)*np.sqrt(1.+1./nbResels)/sigma
        else:
            return t.ppf(confidenceLevel, nbResels-2)*np.sqrt(1.+1./(nbResels-1))/sigma                        
            
if __name__ == '__main__':

    import matplotlib.pyplot as plt
    from image_tools import distance_array

    sigma = 3    
    size=10
#    fake_img = np.random.normal(np.random.randint(-5,5),np.random.rand(),(size,size))
#    fake_img = distance_array((size,size),centerx=size/2.-0.5,centery=size/2.-0.5)
    fake_img = distance_array((size,size))


    plt.figure(0)
    plt.imshow(fake_img,origin='lower')
    plt.colorbar()
    
#    rd=Radial_data(fake_img,xvect=np.arange(-size/2,size/2.)+0.5,yvect=np.arange(-size/2,size/2.)+0.5)
    rd=Radial_data(fake_img)

    # example of use 
    plt.figure(1)
    plt.plot(rd.r,rd.mean,'ro',label='Mean')
    plt.plot(rd.r,rd.std,'g:',label='Std')
    plt.plot([0,size/2.*np.sqrt(2)],[0,size/2.*np.sqrt(2)],'b-',label='y=x')
    plt.xlabel('Separaton in px')