from scipy import *
from numpy import *

sumModesN = 55

def stringarraytoarray(lineread, sizeSquare):
    dummy2 = lineread.replace(',','')
    dummy3 = dummy2.replace(']','')
    dummy4 = dummy3.replace('[','')
    dummyFinal = dummy4.split()

    target = [None]*sumModesN
    m = 0
    for i in range(sumModesN):
        target[i] = [0]*sumModesN
        for j in range(sumModesN):
            if abs(float(dummyFinal[m]))>10**-9:
                target[i][j] = float(dummyFinal[m])
            else:
                target[i][j] = 0.0
            m += 1
    return array(target)


assess = open("dumpnuclear", mode='r')
data = assess.readline()
array = stringarraytoarray(data, sumModesN)
assess.close()


count = 0

for i in range(sumModesN):
    for j in range(sumModesN):
        element = array[i][j]
        if element != 0.0:
            count += 1

print "Total unique nonzero elements", count/2
print "Out of total elements", float(count)/(2*sumModesN**2)



