Ejemplo n.º 1
0
def printCurMerits():
    id=getLastID()
    aSpec=getHistSpec(id)
    aSpecOld=getHistSpec(id-1)
    divSpec=origspec/aSpec
    divSpecOld=origspec/aSpecOld
    subSpec=fit.getSubSpec(aSpec,origspec)
    subSpecOld=fit.getSubSpec(aSpecOld,origspec)
    checkElements=['Ni','Co','Fe','Ca','Ti','Cr','Si','S','O','C','Mg']
    #checkIons=[[]]
    print "General integral: %s last: %s"%(fit.getDiffIntBin(subSpec,1)[1],fit.getDiffIntBin(subSpecOld,1)[1])
    print "Integral slope: %s last: %s"%(fit.getIntSlope(subSpec),fit.getIntSlope(subSpecOld))
    print "UV excess: %s last: %s"%(fit.getUVInt(subSpec),fit.getUVInt(subSpecOld))
    print "UV comparison (UV to optical): %s last: %s"%(fit.getUVIntComp(subSpec),fit.getUVIntComp(subSpecOld))
    print "---------------- Element Ratios --------"
    for element in checkElements:
        try:
            print "Element %s: %.5f  last: %.5f "%(element,getElementMerit(element,divSpec,threshold=0),getElementMerit(element,divSpecOld,threshold=0,id=id-1))
        except Exception as inst:
            print "Problem getting %s merit: %s"%(element,inst)
    print "________________ Ion Ratios ------------"
Ejemplo n.º 2
0
        self.specFlag = vecFunc(self.grid)

    def _getDivSpec(self):
        self.divSpec = np.array([item.divSpec for item in self.grid])

    def _getFitness(self):
        self.fitness = np.array([item.fitness for item in self.grid])
        # def divSpecGetter(item):
        #    tmpAspec=item['aspec']
        #    tmpAspec=tmpAspec.interpolate(xref=self.origSpec.x)
        #    return tmpAspec/self.origSpec
        # vecFunc=np.vectorize(divSpecGetter)
        # self.divSpec=vecFunc(self.grid)

    def toDB(self, conn, dicaID=None, storeLList=None, storeWParam=None):
        modelGridIDs = []
        # saving all models to db
        for model in self.grid:
            modelGridIDs.append(model.toDB(conn, dicaID=dicaID, storeLList=storeLList, storeWParam=storeWParam))
        return np.array(modelGridIDs)


# simple Functions to extract merits
# getGridInt=np.vectorize(lambda item: fit.getDiffIntBin(item,1)[1][0])
getGridInt = np.vectorize(lambda item: fit.getInt(item))
getGridUV = np.vectorize(lambda item: fit.getUVInt(item, norm=False))
getGridOptical = np.vectorize(lambda item: fit.getInt(item, lower=3950.0, norm=False))
getGridUVComp = np.vectorize(lambda item: fit.getUVIntComp(item))
getGridSlope = np.vectorize(lambda item: fit.getIntSlope(item))
getGridSlope = np.vectorize(lambda item: fit.getSlope(item))