Example #1
0
 def FindClusterPosition(self, clusterID):
     """ this will find the weighted average of the cluster position
       """
     # compute the imageArray of just the cluster
     clusterArray = self.imageArray * self.clusterMask[:, :, clusterID]
     # now use the cluster_position class to do the computation
     positionInfo = cluster_position.cluster_position(clusterArray)
     # and get the info
     mean = positionInfo.mean
     variance = positionInfo.variance
     # done, return
     return (mean, variance)
Example #2
0
 def FindClusterPosition(self,clusterID):
     """ this will find the weighted average of the cluster position
     """
     # compute the imageArray of just the cluster 
     clusterArray=self.imageArray*self.clusterMask[:,:,clusterID]
     # now use the cluster_position class to do the computation
     positionInfo=cluster_position.cluster_position(clusterArray)
     # and get the info
     mean = positionInfo.mean
     variance = positionInfo.variance          
     # done, return
     return (mean,variance)
Example #3
0
      def DoCluster(self,data):
        #extract data from picture into numpy array
        x_size = 512
        y_size = 512
        X = range(x_size)
        Y = range(y_size)
        size = x_size*y_size
        Z = range(size)


        # This is where the new code begins
        # data = background subtracted dat

        out = ndimage.gaussian_filter(data, 7)
        threshold = get_threshold(out)

        data -= threshold[0]+3*threshold[1]
        out -= threshold[0]+3*threshold[1]
        out[out<0] = 0
        data[data<0] = 0 # also zero out these pixels, to avoid problems with cluster position finding 
        clusters = get_clusters(out,0.5*threshold[1])
        for cluster in clusters:
            integral = 0
            count = 0
            smooth_integral = 0
            maximum = 0
            maximum_smooth = 0
            pixels = cluster.size
            for coord in cluster:
		        smooth_integral+=out[coord[0]][coord[1]]
		        if maximum < data[coord[0]][coord[1]]:
			        maximum = data[coord[0]][coord[1]]
		        if maximum_smooth < out[coord[0]][coord[1]]:
			        maximum_smooth = out[coord[0]][coord[1]]
		        if data[coord[0]][coord[1]]>0.5*threshold[1]:
			        integral+=data[coord[0]][coord[1]]
			        count+=1
            self.cluster_integral.append(integral)
            self.cluster_pixels.append(count)
            self.cluster_smooth_integral.append(smooth_integral)
            self.cluster_smooth_pixels.append(pixels)
            self.cluster_max.append(maximum)
            self.cluster_smooth_max.append(maximum_smooth)
            self.threshold.append(threshold[1])   
            self.threshold_mean.append(threshold[0])         
            # add in a few more variables
            self.clusterFrac.append(integral/data.sum())
            self.avgPixelCount.append(integral/count)
        # also determine the position of the clusters (new code -MCR)
        for cluster in clusters:
              # first setup a clusterArray by zeroing out the data array
              clusterArray=data*0.
              # loop over all points in the cluster
              for coord in cluster:  
                    clusterArray[coord[0]][coord[1]]=data[coord[0]][coord[1]]   # pull value from data array
              # now use clusterArray to compute position and other info
              positionInfo=cluster_position.cluster_position(clusterArray)
              # and get the info                                                                                                                                                                             
              mean = positionInfo.mean
              variance = positionInfo.variance
              self.clusterPosition.append(mean)
              self.clusterPositionVariance.append(variance)
        return