def getFeaturesFromBestFit(bestFit): merits=[] i=0 origSpec=bestFit.origSpec aSpec,subSpec,llist,w,t=bestFit['aspec'],bestFit['subspec'],bestFit['llist'],bestFit['w'],bestFit['t'] addSpec=aSpec+origSpec intTotal=fit.getInt(subSpec)/fit.getInt(addSpec) intUV=fit.getUVInt(subSpec)/fit.getUVInt(addSpec) slope=fit.getSlope(subSpec) chiSquared=fit.getChiSquared(subSpec) modChiSquared=fit.getModChiSquared(subSpec) elementMerits=[] for element in ['C','O','Na','Mg','Si','S','Ca','Ti','Cr','Ni','Fe']: try: lmerits,weights=fitelem.getElementMerit(element,llist,subSpec) elementMerits.append(np.average(lmerits,weights=weights)) #pdb.set_trace() except: elementMerits.append(-1) allMerit=[intTotal,intUV,chiSquared,modChiSquared,slope,w,t]+elementMerits print "modincl" tmpParam=bestFit.param #tmpParam.update(modelGrid.grid[j].param.comp.data) merits.append((np.array(allMerit),tmpParam)) return merits
def getInputFromModel(modelGrid): merits=[] i=0 origSpec=modelGrid.origSpec for aSpec,subSpec,llist,w,t in zip(modelGrid['aspec'],modelGrid['subspec'],modelGrid['llist'],modelGrid['w'],modelGrid['t']): print i i+=1 #subSpec=model['subspec'] addSpec=aSpec+origSpec intTotal=fit.getInt(subSpec)/fit.getInt(addSpec) intUV=fit.getUVInt(subSpec)/fit.getUVInt(addSpec) slope=fit.getSlope(subSpec) chiSquared=fit.getChiSquared(subSpec) modChiSquared=fit.getModChiSquared(subSpec) MAD=fit.getMAD(aSpec,origSpec) elementMerits=[] for element in ['C','O','Na','Mg','Si','S','Ca','Ti','Cr','Ni','Fe']: try: lmerits,weights=fitelem.getElementMerit(element,llist,subSpec) elementMerits.append(np.average(lmerits,weights=weights)) #pdb.set_trace() except: elementMerits.append(-1) allMerit=[intTotal,intUV,chiSquared,modChiSquared,MAD,slope,w,t]+elementMerits print 'MAD' merits.append(allMerit) return np.array(merits)