PEATDB/Ekin/Titration.py
def combineCurves(cls, d1, d2, factor=5):
        """Combine 2 sets of chem shifts to get one pH titr"""
        ph1,ch1 = d1.getxy()
        ph2,ch2 = d2.getxy()

        def getnearest(x, v):
            #get index of nearest val
            n=100
            c=0
            for val in x:
                i = abs(val-v)
                if v < n:
                    n = v
                    i = c
                c=c+1
                return i

        print ph1
        print ph2
        #get ref vals for both , ie. min val
        ref1 = min(ch1)
        ref2 = min(ch2)
        comb = []
        if ph1==ph2:
            for v in range(len(ph1)):
                comb.append(sqrt(pow(ch1[v]-ref1,2)+pow((ch2[v]-ref2)/factor,2)))
        else:
            print 'not equal'
            #combine nearest ph vals instead
            for v in range(len(ph1)):
                #get nearest in ph2 to v1
                v2 = getnearest(ph2, v)
                comb.append(sqrt(pow(ch1[v]-ref1,2)+pow((ch2[v2]-ref2)/factor,2)))

        dc = EkinDataset(xy=[ph1, comb])
        return dc
Combine 2 sets of chem shifts to get one pH titr
Combine 2 sets of chem shifts to get one pH titr
Combine 2 sets of chem shifts to get one pH titr
def combineCurves(cls, d1, d2, factor=5):
        ph1,ch1 = d1.getxy()
        ph2,ch2 = d2.getxy()
        def getnearest(x, v):
            n=100
            c=0
            for val in x:
                i = abs(val-v)
                if v < n:
                    n = v
                    i = c
                c=c+1
                return i
        print ph1
        print ph2
        ref1 = min(ch1)
        ref2 = min(ch2)
        comb = []
        if ph1==ph2:
            for v in range(len(ph1)):
                comb.append(sqrt(pow(ch1[v]-ref1,2)+pow((ch2[v]-ref2)/factor,2)))
        else:
            print 'not equal'
            for v in range(len(ph1)):
                v2 = getnearest(ph2, v)
                comb.append(sqrt(pow(ch1[v]-ref1,2)+pow((ch2[v2]-ref2)/factor,2)))
        dc = EkinDataset(xy=[ph1, comb])
        return dc
def combineCurves ( cls , d1 , d2 , factor = 5 ) : ph1 , ch1 = d1 . getxy ( ) ph2 , ch2 = d2 . getxy ( ) def getnearest ( x , v ) : n = 100 c = 0 for val in x : i = abs ( val - v ) if v < n : n = v i = c c = c + 1 return i print ph1 print ph2 ref1 = min ( ch1 ) ref2 = min ( ch2 ) comb = [ ] if ph1 == ph2 : for v in range ( len ( ph1 ) ) : comb . append ( sqrt ( pow ( ch1 [ v ] - ref1 , 2 ) + pow ( ( ch2 [ v ] - ref2 ) / factor , 2 ) ) ) else : print 'not equal' for v in range ( len ( ph1 ) ) : v2 = getnearest ( ph2 , v ) comb . append ( sqrt ( pow ( ch1 [ v ] - ref1 , 2 ) + pow ( ( ch2 [ v2 ] - ref2 ) / factor , 2 ) ) ) dc = EkinDataset ( xy = [ ph1 , comb ] ) return dc
Combine 2 sets of chem shifts to get one pH titr
Combine 2 sets of chem shifts to get one pH titr
"""Combine 2 sets of chem shifts to get one pH titr""" #get index of nearest val #get ref vals for both , ie. min val #combine nearest ph vals instead #get nearest in ph2 to v1
cls
d1
d2
factor