Ejemplo n.º 1
0
def execWithValues(conn, sql, values):
    try:
        cur = conn.cursor()
        cur.execute(sql, values)
        conn.commit()
    except Exception, ex:
        exUtil.printTagMessage(ex, exceptionTag, sql)
Ejemplo n.º 2
0
def execSQL(sql):
    try:
        conn = getMySQLConn()
        cur = conn.cursor()
        cur.execute(sql)
        conn.commit()
    except Exception, ex:
        exUtil.printTagMessage(ex, exceptionTag, sql)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
def getList(sql):
    res = []
    try:
        conn = getMySQLConn()
        cur = conn.cursor()
        data = cur.fetchmany(cur.execute(sql))

        for item in data:
            res.append(item[0])
    except Exception, ex:
        exUtil.printTagMessage(ex, exceptionTag, sql)
Ejemplo n.º 5
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