Beispiel #1
0
def plotOpenfastError(testSolution, baselineSolution, attribute):
    testSolution, baselineSolution, attribute = _validateAndExpandInputs(
        [testSolution, baselineSolution, attribute])
    dict1, info1 = _parseSolution(testSolution)
    dict2, info2 = _parseSolution(baselineSolution)

    try:
        channel = info1['attribute_names'].index(attribute)
    except Exception as e:
        rtl.exitWithError("Error: Invalid channel name--{}".format(e))

    title1 = attribute + " (" + info1["attribute_units"][channel] + ")"
    title2 = "Max norm"
    xlabel = 'Time (s)'

    timevec = dict1[:, 0]
    y1series = np.array(dict1[:, channel], dtype=np.float)
    y2series = np.array(dict2[:, channel], dtype=np.float)
    plt = _plotError(timevec, y1series, y2series, xlabel, title1, title2)

    basePath = os.path.sep.join(testSolution.split(os.path.sep)[:-1])
    plotPath = os.path.join(basePath, "plots")
    rtl.validateDirOrMkdir(plotPath)
    _savePlot(plt, plotPath, attribute)

    plt.close()
print("-- Using gold standard files with machine-compiler type {}".format(
    outputType))

### Build the filesystem navigation variables for running openfast on the test case
regtests = os.path.join(sourceDirectory, "reg_tests")
lib = os.path.join(regtests, "lib")
rtest = os.path.join(regtests, "r-test")
moduleDirectory = os.path.join(rtest, "glue-codes", "openfast")
inputsDirectory = os.path.join(moduleDirectory, caseName)
targetOutputDirectory = os.path.join(inputsDirectory, outputType)
testBuildDirectory = os.path.join(buildDirectory, caseName)

# verify all the required directories exist
if not os.path.isdir(rtest):
    rtl.exitWithError(
        "The test data directory, {}, does not exist. If you haven't already, run `git submodule update --init --recursive`"
        .format(rtest))
if not os.path.isdir(targetOutputDirectory):
    rtl.exitWithError(
        "The test data outputs directory, {}, does not exist. Try running `git submodule update`"
        .format(targetOutputDirectory))
if not os.path.isdir(inputsDirectory):
    rtl.exitWithError(
        "The test data inputs directory, {}, does not exist. Verify your local repository is up to date."
        .format(inputsDirectory))

# create the local output directory if it does not already exist
# and initialize it with input files for all test cases
if not os.path.isdir(testBuildDirectory):
    shutil.copytree(inputsDirectory,
                    testBuildDirectory,
Beispiel #3
0
def readFASTOut(fastoutput):
    try:
        return load_output(fastoutput)
    except Exception as e:
        rtl.exitWithError("Error: {}".format(e))
Beispiel #4
0
def calculateNorms(testData, baselineData, tolerance):
    relativeNorm = calculateMaxNormOverRange(testData, baselineData, tolerance)
    maxNorm = calculateMaxNorm(testData, baselineData)
    return relativeNorm, maxNorm
    
if __name__=="__main__":

    rtl.validateInputOrExit(sys.argv, 4, "{} test_solution baseline_solution tolerance".format(sys.argv[0]))

    testSolution = sys.argv[1]
    baselineSolution = sys.argv[2]
    tolerance = sys.argv[3]

    try:
        tolerance = float(tolerance)
    except ValueError:
        rtl.exitWithError("Error: invalid tolerance given, {}".format(tolerance))

    rtl.validateFileOrExit(testSolution)
    rtl.validateFileOrExit(baselineSolution)

    testData, testInfo, testPack = readFASTOut(testSolution)
    baselineData, baselineInfo, basePack = readFASTOut(baselineSolution)
    
    normalizedNorm, maxNorm = pass_fail.calculateNorms(testData, baselineData, tolerance)
    if passRegressionTest(normalizedNorm, tolerance):
        sys.exit(0)
    else:
        dict1, info1, pack1 = readFASTOut(testSolution)
        sys.exit(1)
Beispiel #5
0
def _parseSolution(solution):
    try:
        data, info, _ = load_output(solution)
        return (data, info)
    except Exception as e:
        rtl.exitWithError("Error: {}".format(e))