def calculateFits(self): #{{{ """ Pulls the fit values saved along with the data set and draws the fit line. """ dataSet = list( self.collection.find({'expName': self.currentListSelection}))[0] # t1 t1Data = dtb.dictToNdData('t1PowerODNP', dataSet) t1Data.sort('power') t1fits = dataSet.get('data').get('t1PowerODNP').get('fitList') powerArray = pys.r_[t1Data.getaxis('power').min():t1Data. getaxis('power').max():100j] t1Fit = pys.nddata(t1fits[0] + t1fits[1] * powerArray).rename( 'value', 'power').labels('power', powerArray) # kSigma t1Fit.other_info = {'fitValues': t1fits} kSigmaData = dtb.dictToNdData('kSigmaODNP', dataSet, retValue=False) powerArray = pys.r_[kSigmaData.getaxis('power').min():kSigmaData. getaxis('power').max():100j] ksFits = dataSet.get('data').get('kSigmaODNP').get('fitList') kSigmaFit = pys.nddata(ksFits[0] / (ksFits[1] + powerArray) * powerArray).rename('value', 'power').labels( 'power', powerArray) try: eprData = dtb.dictToNdData('cwEPR', dataSet) except: eprData = False dataToPlot = { 'kSigma': kSigmaData, 'kSigmaFit': kSigmaFit, 't1Set': t1Data, 't1SetFit': t1Fit, 'cwEPR': eprData } self.dataDict.update({self.currentListSelection: dataToPlot})
def calculateFits(self):#{{{ """ Calculate the fits to both the T1 set and the kSigma set """ dataSet = list(self.collection.find({'expName':self.currentListSelection}))[0] t1Data = dtb.dictToNdData('t1Power',dataSet) t1Data.sort('power') # weighted fit as function of power out = minimize(residualLinear, params, args=(t1Data.getaxis('power'), t1Data.runcopy(pys.real).data, t1Data.get_error())) t1Fit = pys.nddata(analyticLinear(out.params,t1Data.getaxis('power'))).rename('value','power').labels('power',t1Data.getaxis('power')) kSigmaData = dtb.dictToNdData('kSigma',dataSet,retValue = False) kSigmaData = nmrfit.ksp(kSigmaData) kSigmaData.fit() self.dataDict.update({self.currentListSelection:{'kSigma':kSigmaData,'t1Set':t1Data,'t1SetFit':t1Fit}})
figure() colorlist = ['r', 'g', 'b', 'm', 'c'] for count, dictionary in enumerate(searchDict): listOfSets = list( collection.find(dictionary) ) # This will give me a list of dictionaries that satisfy the searchDict constraints. # An example of pulling the data from a dMTSL concentration series. dataList = [] # a list for the nddata sets concentration = [ ] # a list for the associated concentration, from metadata concentrationError = [ ] # a list for the associated concentration error, from metadata for dataSet in listOfSets: data = dtb.dictToNdData( dataTag, dataSet ) # return an nddata for the given entry in the list of database entries concEntry = data.other_info.get('concentrationMeasured').split(' +/- ') concentration.append(float(concEntry[0])) concentrationError.append(float(concEntry[1].split(' ')[0])) dataList.append(data.mean()) # Throw list of data into nddata set along dimension conc data = concat(dataList, 'conc') data.labels('conc', array(concentration)).set_error('conc', array(concentrationError)) # Sort and fit the data and make a new nddata set with the fit data.sort('conc') out = minimize(residualLinear, params, args=(data.getaxis('conc'), data.runcopy(real).data,
'setType': 'dnpExp' } #,{'spinLabel':'MTSL','osmolyte':'urea','osmolyteConcentration':'5M','macroMolecule':'CheY','repeat':'0'}] dataTag = 'kSigma' # This defines what data I pull from the database#}}} # Pull the kSigma data from the data base listOfSets = list( collection.find(searchDict) ) # this gives me a list of dictionaries from the collection that satisfy the constraints imposed by my search dictionary. kSigmaList = [] kSigmaListError = [] concentrationList = [ ] # will hold list of nddata, data = concentration, error = concentration errr siteList = [] # dim0 for both kSigmaList and concentrationList for dataSet in listOfSets: data = dtb.dictToNdData( dataTag, dataSet, retValue=True ) # setting retValue to True gives me the fit value instead of the power data. Note this only works for kSigma and nothing else for now. kSigmaList.append(data.data) kSigmaListError.append(data.get_error()) siteList.append(float(data.other_info.get('spinLabelSite')[1:-1])) # Make an nddata with dim0 defined by the site. kSigma = nddata(array(kSigmaList)).rename('value', 'site').labels( 'site', array(siteList)).set_error(array(kSigmaListError)) kSigma.sort('site') figure() plot(kSigma, 'ro') figure() t1zpL = [] siteList = []
# Lets pull in a collection from the database MONGODB_URI = 'mongodb://*****:*****@ds047040.mongolab.com:47040/magresdata' # This is the address to the database hosted at MongoLab.com # Make the connection to the server as client conn = pymongo.MongoClient(MONGODB_URI) # Connect to the database that I purchased db = conn.magresdata collection = db.hanLabODNPTest # This is my test collection searchDict = {'setType':'seriesData','macroMolecule':'CheY','bindingPartner':'None','osmolyte':'None'} dispersionList = [] listOfSets = list(collection.find(searchDict)) dataTag = 'tau' fig = figure(figsize=(15,8)) for count,dataSet in enumerate(listOfSets[0:1]): tauNS = dtb.dictToNdData(dataTag,dataSet) # setting retValue to True gives me the fit value instead of the power data. Note this only works for kSigma and nothing else for now. tauNS.sort('site') plot(tauNS*1e12,'--.',alpha = 0.6,markersize=20,label='native state') dispersionList.append(float(std(tauNS.data))/float(average(tauNS.data))) searchDict = {'setType':'seriesData','macroMolecule':'CheY','bindingPartner':'None','osmolyte':'urea','osmolyteConcentration':'5M'} fig = figure(figsize=(15,8)) listOfSets = list(collection.find(searchDict)) dataTag = 'tau' for count,dataSet in enumerate(listOfSets): tau5MUNS = dtb.dictToNdData(dataTag,dataSet) # setting retValue to True gives me the fit value instead of the power data. Note this only works for kSigma and nothing else for now. tau5MUNS.sort('site') plot(tau5MUNS*1e12,'--.',alpha = 0.6,markersize=20,label='native 5M Urea') dispersionList.append(float(std(tau5MUNS.data))/float(average(tau5MUNS.data)))
import matlablike as pys pys.close('all') MONGODB_URI = 'mongodb://*****:*****@ds047040.mongolab.com:47040/magresdata' #self.conn = pymongo.MongoClient(self.MONGODB_URI) # Connect to the database that I purchased #db = self.conn.magresdata # 'dynamicalTransition' is the name of my test database #self.collection = db.hanLabODNPTest # This is my test collection conn = pymongo.MongoClient('localhost', 27017) # Connect to the database that I purchased db = conn.homeDB # 'dynamicalTransition' is the name of my test database collection = db.localDataRevisedDataLayout # This is my test collection#}}} dataSet = list(collection.find({'expName': '150529_CheYPep_N62C_5MUrea_ODNP'}))[0] epr = dtb.dictToNdData('cwEPR', dataSet) t1Data = dtb.dictToNdData('t1PowerODNP', dataSet) t1Data.sort('power') t1fits = dataSet.get('data').get('t1PowerODNP').get('fitList') powerArray = pys.r_[t1Data.getaxis('power').min():t1Data.getaxis('power').max( ):100j] t1Fit = pys.nddata(t1fits[0] + t1fits[1] * powerArray).rename( 'value', 'power').labels('power', powerArray) pys.figure() pys.plot(t1Data) pys.plot(t1Fit) kSigmaData = dtb.dictToNdData('kSigmaODNP', dataSet, retValue=False) powerArray = pys.r_[kSigmaData.getaxis('power').min():kSigmaData.
import pymongo import matlablike as pys import nmrfit pys.close('all') MONGODB_URI = 'mongodb://*****:*****@ds047040.mongolab.com:47040/magresdata' # This is the address to the database hosted at MongoLab.com # Make the connection to the server as client conn = pymongo.MongoClient( MONGODB_URI) # Connect to the database that I purchased db = conn.magresdata collection = db.hanLabODNPTest # This is my test collection searchDict = { 'spinLabel': 'MTSL', 'osmolyte': 'None', 'osmolyteConcentration': 'None', 'macroMolecule': 'CheY', 'bindingPartner': 'P2' } #,'repeat':'0'}#,{'spinLabel':'MTSL','osmolyte':'urea','osmolyteConcentration':'5M','macroMolecule':'CheY','repeat':'0'}] listOfSets = list( collection.find(searchDict) ) # this gives me a list of dictionaries from the collection that satisfy the constraints imposed by my search dictionary. dataTag = 'kSigma' # This defines what data I pull from the database data = dtb.dictToNdData(dataTag, listOfSets[0], retValue=False) data = nmrfit.ksp(data) data.fit() pys.plot(data) pys.plot(data.eval(100)) pys.show()