Пример #1
0
def main():
# This method requires the user to input the absolute file path of the data file.   

#    ***** Manual input of file location and data meanings. ***** 
#    headings = input('Enter the heading titles for the data: i.e. Entry,Time,Rows,etc')
#    location = input('Absolute path of the data file:\n')
#    f = open(os.path.abspath(location), 'r')

    energyBits = 10 #number of bits used to represent the detected energy 
    enDifBins=2**10
    rows = 15
    columns = 31
    minEnergy = 1
    maxEnergy = 2**energyBits
    minCnt = 25
    maxCnt = None
    headings = ['Entry','Time','Rows','Columns','Missed','Energy','B0', 'B1', 'B2', 'B3', 'B4', 'A0', 'A1', 'A2', 'A3', 'A4']
    
    #Read in data from .txt file
    sourcefile = 'AM241_pinhole_touch_Feb13_2014'
    f = open(os.path.abspath('/home/ben/Desktop/Untitled Folder/{}.txt'.format(sourcefile)), 'r')
    allData = f.read()
    f.close()
    
#    f = open('test', 'w')
        
    dataDict, dataList = str2dicList(allData,headings)
    

    # Comprehensive list [list[]] "Row", "Column", "Detected Engrgy" - one entry per detection  
    xyList = EC.smList3(dataList, headings.index('Rows'), headings.index('Columns'), headings.index('Energy'))

    xList  = [int(x[0]) for x in xyList if int(x[2]) >= minEnergy and int(x[2]) <= maxEnergy]
    yList  = [int(x[1]) for x in xyList if int(x[2]) >= minEnergy and int(x[2]) <= maxEnergy]

    Hg.hist2Dscatter(xList, yList)
    plt.savefig('2D Hit Count Scatter Graph of {}.pdf'.format(sourcefile))
    plt.show()
    
    Hg.hist2DheatMap(xList, yList, [rows,columns], 'Energy min/max:{}/{} | file:{}'.format(minEnergy,maxEnergy,sourcefile), headings[2], headings[3],minCnt,maxCnt)
    plt.savefig('2D Heatmap of {}.pdf'.format(sourcefile))
    plt.show()
    
#******************** Single Pix Historgrams for every pixel - Count and Energy Constrants.
    xyListNew = []
    for x in range(16):
        for y in range(31):
            if EC.elmCount2D(xyList, 0, str(x), 1, str(y)) >= minCnt:
                print(int(x),int(y),minCnt)
                xyListNew.append([int(x),int(y)])
    
    minEnergy = minEnergy
    for elm in xyListNew: 
        temp12 = [int(part) for part in EC.sPixEn(dataDict, headings[2], str(elm[0]), headings[3], str(elm[1]), headings[5])]
        temp123 = DM.CutEnergyRange(temp12, minEnergy, 1024)
        print(elm)
        print(temp123)
        Hg.hist(temp123, np.floor(enDifBins/10), "Pixel ({},{}) Energy Cut off:{} - Lowest:{} Highest:{}".format(elm[0],elm[1],minEnergy,min(temp123),max(temp123)), "Energy difference(+-2^10 bits - autoscaled)", "Count (int)")
        plt.savefig('pix_bucket_{}_{}_{}.pdf'.format(elm[0],elm[1],sourcefile))
        plt.show()
Пример #2
0
def EnListxy(DictIn,key1,xRange,key2,yRange, keyOut):
    tempList = []
    for x in xRange:
        for y in yRange:
            print(x,y)
            tempList.append(EC.sPixEn(DictIn, key1, str(x), key2, str(y), keyOut))
    return [int(num) for elem in tempList for num in elem]