Example #1
0
 def test_genConvergenceFileIndex(self):
     #TODO: should write the actual test convergence files,
     # perhaps in set-up
     cvgInfoEmpty = stgcvg.genConvergenceFileIndex(".")
     self.assertEqual(cvgInfoEmpty, {})
     cvgInfo = stgcvg.genConvergenceFileIndex("./sampleData")
     self.assertEqual(len(cvgInfo), 2)
     self.assertEqual(cvgInfo['TemperatureField'].filename, \
         './sampleData/CosineHillRotate-analysis.cvg')
     self.assertEqual(cvgInfo['TemperatureField'].dofColMap, {0:1,1:2})
     self.assertEqual(cvgInfo['VelocityField'].filename, \
         './sampleData/Analytic2-analysis.cvg')
     self.assertEqual(cvgInfo['VelocityField'].dofColMap, {0:1})
Example #2
0
 def getResult(self, modelResult):
     '''Gets the result of the operator on the given fields (as a
     :class:`.FieldComparisonResult`), given a
     modelResult (:class:`~credo.modelresult.ModelResult`) which
     refers to a directory containing field comparisons
     (i.e. cvg files, see :mod:`credo.io.stgcvg`).
     '''
     cvgIndex = stgcvg.genConvergenceFileIndex(modelResult.outputPath)
     try:
         cvgFileInfo = cvgIndex[self.name]
     except KeyError:
         # TODO: create a new exception type here?
         raise KeyError("Field '%s' not found in the known list of"\
             " convergence results (%s) for model run '%s'"\
             % (self.name, list(cvgIndex.keys()),modelResult.modelName))
     dofErrors = stgcvg.getDofErrors_ByDof(cvgFileInfo, steps="last")
     fieldResult = FieldComparisonResult(self.name, dofErrors)
     fieldResult.cvgFileInfo = cvgFileInfo
     return fieldResult
Example #3
0
    def _getLenScales(self, resultsSet):
        lenScales = []
        for runI, mResult in enumerate(resultsSet):
            cvgIndex = stgcvg.genConvergenceFileIndex(mResult.outputPath)
            # a bit hacky, need to redesign cvg stuff, esp len scales??
            try:
                cvgInfo = cvgIndex[self.fComps.fields.keys()[0]]
            except KeyError:
                if len(cvgIndex) == 0:
                    raise IOError("No field comparison check results"\
                        " were found in output path '%s'." % mResult.outputPath)
                else:
                    raise IOError("Comparison info for field '%s' not found."\
                        " Fields that had comparison info found for them"\
                        " in results were %s."\
                        % (self.fComps.fields.keys()[0], str(cvgIndex.keys())))
 
            lenScales.append(stgcvg.getRes(cvgInfo.filename))        
        return lenScales    
 def getResult(self, modelResult):
     '''Gets the result of the operator on the given fields (as a
     :class:`.FieldComparisonResult`), given a 
     modelResult (:class:`~credo.modelresult.ModelResult`) which
     refers to a directory containing field comparisons
     (i.e. cvg files, see :mod:`credo.io.stgcvg`).
     '''
     cvgIndex = stgcvg.genConvergenceFileIndex(modelResult.outputPath)
     try:
         cvgFileInfo = cvgIndex[self.name]
     except KeyError:     
         # TODO: create a new exception type here?
         raise KeyError("Field '%s' not found in the known list of"\
             " convergence results (%s) for model run '%s'"\
             % (self.name, cvgIndex.keys(),modelResult.modelName))
     dofErrors = stgcvg.getDofErrors_ByDof(cvgFileInfo, steps="last")
     fieldResult = FieldComparisonResult(self.name, dofErrors)
     fieldResult.cvgFileInfo = cvgFileInfo
     return fieldResult
Example #5
0
def getFieldScaleCvgData_SingleCvgFile(cvgFilePath):
    '''Given a path that CVG files reside in, returns the length scales of
    each run (as a list), and a list of field error data for each field/cvg
    info in the given path.
    Thus is a utility function for generating necessary fieldErrorData for a
    multi-res convergence analysis.

    .. Note::

       This assumes all cvg info is stored in the same
       convergence file (the default approach of the legacy SYS tests)
    '''
    cvgIndex = stgcvg.genConvergenceFileIndex(cvgFilePath)
    fieldErrorData = {}
    for fieldName, cvgFileInfo in list(cvgIndex.items()):
        #NB: assumes all cvg files and all fields have same len scales.
        lenScales = stgcvg.getRes(cvgFileInfo.filename)
        dofErrors = stgcvg.getDofErrors_ByDof(cvgFileInfo)
        fieldErrorData[fieldName] = dofErrors
    return lenScales, fieldErrorData
def getFieldScaleCvgData_SingleCvgFile(cvgFilePath):
    '''Given a path that CVG files reside in, returns the length scales of
    each run (as a list), and a list of field error data for each field/cvg
    info in the given path.
    Thus is a utility function for generating necessary fieldErrorData for a
    multi-res convergence analysis.
    
    .. Note::

       This assumes all cvg info is stored in the same 
       convergence file (the default approach of the legacy SYS tests)
    '''
    cvgIndex = stgcvg.genConvergenceFileIndex(cvgFilePath)
    fieldErrorData = {}
    for fieldName, cvgFileInfo in cvgIndex.iteritems():
        #NB: assumes all cvg files and all fields have same len scales.
        lenScales = stgcvg.getRes(cvgFileInfo.filename)
        dofErrors = stgcvg.getDofErrors_ByDof(cvgFileInfo)
        fieldErrorData[fieldName] = dofErrors
    return lenScales, fieldErrorData