<commit_before>__author__ = 'martin'

from monty import arrayFromFile
from monty import cleanData
from monty import plotevents
import csv
import numpy as np
import os



def norm(dataarray1, dataarray2):
    dataarray1 = np.array(dataarray1)
    dataarray2 = np.array(dataarray2)

    newlist = np.subtract(dataarray2, dataarray1)
    newlist = np.divide(newlist, dataarray2)
    newlist = np.subtract(1, newlist)
    finlist = np.multiply(newlist, dataarray2)
    return finlist

#write an array to a file.
def arrayTofile(dataArray, fileNum):
    fileName = fileNum+"_a.csv"
    print(fileName)
    with open(fileName, 'w+') as csvfile:
        linewriter = csv.writer(csvfile, delimiter= ",")
        for each in dataArray:
            linewriter.writerow([each])
    print("done")


def main():
    for file in os.listdir("/Users/"):
        if file == "martin":
            inputFileDer = "/Users/martin/Dropbox/School/Spring-2014/PHY-474/Labs/Positronium/data/Enclosed/Lower_amp/"
            outputfiledir = "/Users/martin/Dropbox/School/Spring-2014/PHY-474/Labs/Positronium/data/play_data/"
        elif file is 'admin':
            inputFileDer = "/Users/admin/Dropbox/School/Spring-2014/PHY-474/Labs/Positronium/data/Enclosed/Lower_amp/"
            outputfiledir = "/Users/admin/Dropbox/School/Spring-2014/PHY-474/Labs/Positronium/data/play_data/"


    file1 = arrayFromFile(inputFileDer + 'ACal_3.Spe') #raw_input("Type in file name: ")
    file2 = "BCal_2.Spe" #raw_input("Type in file name: ")
    file3 = arrayFromFile(inputFileDer + 'CCal_3.Spe')
    file1 = cleanData(file1)
    file3 = cleanData(file3)

    normdata = norm(file1, file3)
    print(len(normdata))
    arrayTofile(normdata, outputfiledir + 'CNorm_2')
    #plotevents(data)

    return "done"



main()

<commit_msg>Edit normalizing file used for normalizing individual files.<commit_after>__author__ = 'martin'

from monty import arrayFromFile
from monty import cleanData
from monty import plotevents
import csv
import numpy as np
import os



def normlize(data_small, data_large, binnum):
    """Normalizes the data of the larger count data_large
    :rtype : numpy array
    according to the count rate of data_small"""
    data_small = np.array(data_small)
    data_large = np.array(data_large)

    newlist = np.divide(data_small, data_large[binnum])
    finlist = np.multiply(newlist, data_large)
    return finlist

#write an array to a file.
def arrayTofile(dataArray, fileNum):
    fileName = fileNum+"_a.csv"
    print(fileName)
    with open(fileName, 'w+') as csvfile:
        linewriter = csv.writer(csvfile, delimiter= ",")
        for each in dataArray:
            linewriter.writerow([each])
    print("done")


def main():
    for file in os.listdir("/Users/"):
        if file == "martin":
            inputFileDer = "/Users/martin/Dropbox/School/Spring-2014/PHY-474/Labs/Positronium/data/Enclosed/HV_Failure/"
            outputfiledir = "/Users/martin/Dropbox/School/Spring-2014/PHY-474/Labs/Positronium/data/play_data/"
        elif file is 'admin':
            inputFileDer = "/Users/admin/Dropbox/School/Spring-2014/PHY-474/Labs/Positronium/data/Enclosed/HV_Failure/"
            outputfiledir = "/Users/admin/Dropbox/School/Spring-2014/PHY-474/Labs/Positronium/data/play_data/"


    file1 = arrayFromFile(inputFileDer + 'ACal_5.Spe') #raw_input("Type in file name: ")
    file2 = "BCal_5.Spe"  #raw_input("Type in file name: ")
    file3 = arrayFromFile(inputFileDer + 'CCal_3.Spe')
    file1 = cleanData(file1)
    file3 = cleanData(file3)

    normdata = norm(file1, file3)
    print(len(normdata))
    arrayTofile(normdata, outputfiledir + 'CNorm_2')
    #plotevents(data)

    return "done"



main()


{'fraction_non_alphanumeric': 0.11843876177658143, 'fraction_numerical': 0.02503364737550471, 'mean_word_length': 3.3717647058823528, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1279486', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1259, 'n_words': 262}