DataPipeline/Utilities.py
def createSimulatedSpectralData(fname, names, peaks=10, noise=0.08):
    """Create spectral type data with noise and peaks that you might find
       commonly in experimental data"""

    cw = csv.writer(open(fname,'w'))
    cw.writerow(['temp']+names)
    offset=100
    n=800
    pheight = offset*2
    percnoise = offset*noise
    baselinefunc = lambda x: offset + pheight*pow(.98/x,0.2)

    def gaussianpeaks(x, peaks):
        #add random gaussian-shaped peaks as signals
        res=0
        for i in peaks:
           height = random.normalvariate(pheight,pheight/5)
           res+= height*exp(-(i-x)**2/1.3)
        return res

    data={}
    freqs = [i+100 for i in range(0,n,1)]
    peakdata = {}
    for name in names:
        peakvals = [int(random.normalvariate(n/2,n/4)) for p in range(peaks)]
        print name, sorted(peakvals)
        vals=[]
        for i in freqs:
            val = gaussianpeaks(i, peakvals)
            val += baselinefunc(i)+random.normalvariate(0,percnoise)
            vals.append(val)
        data[name] = vals
        peakdata[name] = peakvals
    for x in range(len(freqs)):
        row=[]
        for name in names:
            row.append(data[name][x])
        row.insert(0,freqs[x])
        cw.writerow(row)
    return peakdata
Create spectral type data with noise and peaks that you might find
       commonly in experimental data
Create spectral type data with noise and peaks that you might find
commonly in experimental data
Create spectral type data with noise and peaks that you might find commonly in experimental data
def createSimulatedSpectralData(fname, names, peaks=10, noise=0.08):
    cw = csv.writer(open(fname,'w'))
    cw.writerow(['temp']+names)
    offset=100
    n=800
    pheight = offset*2
    percnoise = offset*noise
    baselinefunc = lambda x: offset + pheight*pow(.98/x,0.2)
    def gaussianpeaks(x, peaks):
        res=0
        for i in peaks:
           height = random.normalvariate(pheight,pheight/5)
           res+= height*exp(-(i-x)**2/1.3)
        return res
    data={}
    freqs = [i+100 for i in range(0,n,1)]
    peakdata = {}
    for name in names:
        peakvals = [int(random.normalvariate(n/2,n/4)) for p in range(peaks)]
        print name, sorted(peakvals)
        vals=[]
        for i in freqs:
            val = gaussianpeaks(i, peakvals)
            val += baselinefunc(i)+random.normalvariate(0,percnoise)
            vals.append(val)
        data[name] = vals
        peakdata[name] = peakvals
    for x in range(len(freqs)):
        row=[]
        for name in names:
            row.append(data[name][x])
        row.insert(0,freqs[x])
        cw.writerow(row)
    return peakdata
def createSimulatedSpectralData ( fname , names , peaks = 10 , noise = 0.08 ) : cw = csv . writer ( open ( fname , 'w' ) ) cw . writerow ( [ 'temp' ] + names ) offset = 100 n = 800 pheight = offset * 2 percnoise = offset * noise baselinefunc = lambda x : offset + pheight * pow ( .98 / x , 0.2 ) def gaussianpeaks ( x , peaks ) : res = 0 for i in peaks : height = random . normalvariate ( pheight , pheight / 5 ) res += height * exp ( - ( i - x ) ** 2 / 1.3 ) return res data = { } freqs = [ i + 100 for i in range ( 0 , n , 1 ) ] peakdata = { } for name in names : peakvals = [ int ( random . normalvariate ( n / 2 , n / 4 ) ) for p in range ( peaks ) ] print name , sorted ( peakvals ) vals = [ ] for i in freqs : val = gaussianpeaks ( i , peakvals ) val += baselinefunc ( i ) + random . normalvariate ( 0 , percnoise ) vals . append ( val ) data [ name ] = vals peakdata [ name ] = peakvals for x in range ( len ( freqs ) ) : row = [ ] for name in names : row . append ( data [ name ] [ x ] ) row . insert ( 0 , freqs [ x ] ) cw . writerow ( row ) return peakdata
Create spectral type data with noise and peaks that you might find
commonly in experimental data
Create spectral type data with noise and peaks that you might find commonly in experimental data
"""Create spectral type data with noise and peaks that you might find
       commonly in experimental data""" #add random gaussian-shaped peaks as signals
fname
names
peaks
noise