Пример #1
0
def genSpecDistribute():
    allModelList = util.listDirFiles(sourceDir)

    dic = {}

    for modelPath in allModelList:
        specType = getSpecType(modelPath)
        util.addItemToDic(dic, specType[0], modelPath)

    avgCount = int(modelCount / 7)
    for key in dic.keys():
        modelMatchFileCopy(dic, key, avgCount, modelDir_avg)

    disCount = 0
    for key in dic_dis.keys():
        disCount += dic_dis[key]

    for key in dic.keys():
        typeCount = int(float(dic_dis[key]) / disCount * modelCount)
        if typeCount == 0:
            typeCount = 1
        modelMatchFileCopy(dic, key, typeCount, modelDir_dis)

    for key in dic.keys():
        modelMatchFileCopy(dic, key, 10, targetFitsDir)
Пример #2
0
    def fitsToDatabase(self, strategy):
        strategy.preHandle()

        filePaths = util.listDirFiles(strategy.dirPath, ".fits")
        for filePath in filePaths:
            try:
                fitsInfo = astroUtil.getFitsInfo(filePath)
                strategy.handle(fitsInfo)
            except Exception, ex:
                exUtil.printTagMessage(ex, "Fits handle error", filePath)
Пример #3
0
def calcMinChi22(flux_target, templateDir, waveRange):
    minChi2 = 0
    templatePath = ""

    templatePaths = util.listDirFiles(templateDir)
    for path in templatePaths:
        data = np.loadtxt(path)
        wave, flux = formatWaveAndFlux(data[:, 0], data[:, 1], waveRange)
        chi2_value = mathUtil.chi2(flux_target, flux)

        if minChi2 == 0 or chi2_value < minChi2:
            minChi2 = chi2_value
            templatePath = path

    return templatePath, minChi2
Пример #4
0
def calcMinChi2(flux_target, templateDir, waveRange):
    minChi2 = 0
    templatePath = ""
    minCoeff = None

    templatePaths = util.listDirFiles(templateDir)
    for path in templatePaths:
        data = np.loadtxt(path)
        wave, flux = formatWaveAndFlux(data[:, 0], data[:, 1], waveRange)
        try:
            coeff = mathUtil.calcChi2Coeff(flux_target, flux, wave)
        except Exception, ex:
            exUtil.printTagMessage(ex, "error", path)
            continue
        chi2_value = mathUtil.chi2_ploy(wave, flux_target, flux, coeff[0], coeff[1], coeff[2])

        if minChi2 == 0 or chi2_value < minChi2:
            minChi2 = chi2_value
            templatePath = path
            minCoeff = coeff
Пример #5
0
    for key in dic_dis.keys():
        disCount += dic_dis[key]

    for key in dic.keys():
        typeCount = int(float(dic_dis[key]) / disCount * modelCount)
        if typeCount == 0:
            typeCount = 1
        modelMatchFileCopy(dic, key, typeCount, modelDir_dis)

    for key in dic.keys():
        modelMatchFileCopy(dic, key, 10, targetFitsDir)


# genSpecDistribute()

targetFitsList = util.listDirFiles(targetFitsDir, ".sm")

c_1 = 0
c_2 = 0
c_m_1 = 0
c_m_2 = 0

for target in targetFitsList:
    st = getSpecType(target)
    print "%s , %s" % (target, st)
    templatePath, minChi2 = specUtil.modelMatch2(target, modelDir_avg)
    st1 = getSpecType(templatePath)
    print "AVG : %s , %s, %s" % (templatePath, minChi2, st1)

    templatePath_dis, minChi2_dis = specUtil.modelMatch2(target, modelDir_dis)
    st2 = getSpecType(templatePath_dis)