Beispiel #1
0
def MakeRealResolution(image, noise_image, tr_image, doTopo=False):

    x1 = SumPixel(image[0], noise_image[0], size=LayerPix[0])
    #x1 = np.reshape( x1, tuple( [1] + list(x1.shape) ) )

    x2 = SumPixel(image[1], noise_image[1], size=LayerPix[1])
    #x2 = np.reshape( x2, tuple( [1] + list(x2.shape) ) )

    x3 = SumPixel(image[2], noise_image[2], size=LayerPix[2])
    #x3 = np.reshape( x3, tuple( [1] + list(x3.shape) ) )

    x4 = SumPixel(image[3], noise_image[3], size=LayerPix[3])
    #x4 = np.reshape( x4, tuple( [1] + list(x4.shape) ) )

    x5 = SumPixel(image[4], noise_image[4], size=LayerPix[4])
    #x5 = np.reshape( x5, tuple( [1] + list(x5.shape) ) )

    x6 = SumPixel(image[5], noise_image[5], size=LayerPix[5])
    #x6 = np.reshape( x6, tuple( [1] + list(x6.shape) ) )

    # ----- make the topocluster ------- #
    #topo_im = np.zeros([6, orig_pix, orig_pix])

    if (doTopo):
        Proto = tools_generic.Clustering(
            x1[0:LayerPix[0], 0:LayerPix[0]],
            x2[0:LayerPix[1], 0:LayerPix[1]],
            x3[0:LayerPix[2], 0:LayerPix[2]],
            x4[0:LayerPix[3], 0:LayerPix[3]],
            x5[0:LayerPix[4], 0:LayerPix[4]],
            x6[0:LayerPix[5], 0:LayerPix[5]],
        )

        topo_clus = tools_generic.Assign_Topo(Proto)

        topo_clus = np.array(topo_clus)
        topo_im = topo_clus

        topo_im[np.where(topo_im > 0.)] = 1.

        #topo_im = topo_clus

        x1 = x1 * topo_im[0]
        x2 = x2 * topo_im[1]
        x3 = x3 * topo_im[2]
        x4 = x4 * topo_im[3]
        x5 = x5 * topo_im[4]
        x6 = x6 * topo_im[5]

    x = [x1, x2, x3, x4, x5, x6, tr_image]

    #x.extend( topo_im )

    return np.stack(x, axis=0)
Beispiel #2
0
def MakeTopoCluster(image, noise_image):

    x1 = SumPixel(image[0], noise_image[0], size=LayerPix[0])
    #x1 = np.reshape( x1, tuple( [1] + list(x1.shape) ) )

    x2 = SumPixel(image[1], noise_image[1], size=LayerPix[1])
    #x2 = np.reshape( x2, tuple( [1] + list(x2.shape) ) )

    x3 = SumPixel(image[2], noise_image[2], size=LayerPix[2])
    #x3 = np.reshape( x3, tuple( [1] + list(x3.shape) ) )

    x4 = SumPixel(image[3], noise_image[3], size=LayerPix[3])
    #x4 = np.reshape( x4, tuple( [1] + list(x4.shape) ) )

    x5 = SumPixel(image[4], noise_image[4], size=LayerPix[4])
    #x5 = np.reshape( x5, tuple( [1] + list(x5.shape) ) )

    x6 = SumPixel(image[5], noise_image[5], size=LayerPix[5])
    #x6 = np.reshape( x6, tuple( [1] + list(x6.shape) ) )

    # ----- make the topocluster ------- #
    #topo_im = np.zeros([6, orig_pix, orig_pix])

    Proto = tools_generic.Clustering(
        x1[0:LayerPix[0], 0:LayerPix[0]],
        x2[0:LayerPix[1], 0:LayerPix[1]],
        x3[0:LayerPix[2], 0:LayerPix[2]],
        x4[0:LayerPix[3], 0:LayerPix[3]],
        x5[0:LayerPix[4], 0:LayerPix[4]],
        x6[0:LayerPix[5], 0:LayerPix[5]],
    )

    topo_clus = tools_generic.Assign_Topo(Proto)

    topo_clus = np.array(topo_clus)

    return topo_clus
Beispiel #3
0
                         str(lay)][ev][0] + f['RealRes_Noise_Layer' +
                                              str(lay)][ev][0]

        fnew_ch["layer_" + str(lay)] = Calo

out_image = []
i = -1
print("Looping")
for event in range(N_EV):

    i = i + 1
    if i % 100 == 0: print('in loop ev: ', i)
    if i > 20: break
    #print(Layer['n1'][i])
    Proto = tools_generic.Clustering(
        fnew_ch["layer_1"][i], fnew_ch["layer_2"][i], fnew_ch["layer_3"][i],
        fnew_ch["layer_4"][i], fnew_ch["layer_5"][i], fnew_ch["layer_6"][i])
    print('---------- Final Topocluster ' + str(i) + ' -----------')
    print(
        "Final proto",
        Proto,
        len(Proto),
    )
    #print('')
    out_image.append(tools_generic.Assign_Topo(Proto))

out_image = np.array(out_image)

print(out_image.shape)

print('opening File')
Beispiel #4
0
RealRes_TotalEnergy_Layer4 = f['RealRes_TotalEnergy_Layer4'][:]
RealRes_TotalEnergy_Layer5 = f['RealRes_TotalEnergy_Layer5'][:]
RealRes_TotalEnergy_Layer6 = f['RealRes_TotalEnergy_Layer6'][:]

#out_image = [out_image1,out_image2,out_image3,out_image4,out_image5,out_image6]
#out_image = np.stack(out_image,axis = 0)
out_image = []
i = 0
print("Looping")
for event in range(len(RealRes_TotalEnergy_Layer1)):

    i = i + 1
    if i > 2: break
    Proto = tools_generic.Clustering(RealRes_TotalEnergy_Layer1[i],
                                     RealRes_TotalEnergy_Layer2[i],
                                     RealRes_TotalEnergy_Layer3[i],
                                     RealRes_TotalEnergy_Layer4[i],
                                     RealRes_TotalEnergy_Layer5[i],
                                     RealRes_TotalEnergy_Layer6[i])
    #    print(Proto)
    out_image.append(tools_generic.Assign_Topo(Proto))

out_image = np.array(out_image)
print(out_image.shape)
print('opening File')
with h5py.File('Outfile_TopoCluster.h5', 'w') as f1:
    for layer_i in range(6):
        f1.create_dataset('TopoClusters' + str(layer_i + 1),
                          data=out_image[:, layer_i:layer_i + 1, :, :])

print("Exiting ... Bye!")
#