Beispiel #1
0
 def test_createNewDataDoc(self):
     xmlDoc, root = stgxml.createNewStgDataDoc()
     stgxml.writeParam(root, "testParam", 45)
     stgxml.writeStgDataDocToFile(xmlDoc, "output/testCreate.xml")
     xmlDocRead = etree.parse("output/testCreate.xml")
     rootRead = xmlDocRead.getroot()
     testParamNode = stgxml.getParamNode(rootRead, "testParam")
 def test_createNewDataDoc(self):
     xmlDoc, root = stgxml.createNewStgDataDoc()
     stgxml.writeParam(root, "testParam", 45)
     stgxml.writeStgDataDocToFile(xmlDoc, "output/testCreate.xml")
     xmlDocRead = etree.parse("output/testCreate.xml")
     rootRead = xmlDocRead.getroot()
     testParamNode = stgxml.getParamNode(rootRead, "testParam")
Beispiel #3
0
    def analysisXMLGen(self, filename=None):
        """Generates an XML file, in StGermainData XML format, to over-ride
        necessary parameters of the model as specified on this ModelRun
        instance. Returns the name of the just-written XML file.

        Overrides can have the following main sources:

        * Over-ridden simulation parameters that have been specified
          as members of the ModelRun itself, such as cpReadPath, and cpFields;
        * Over-ridden simulation parameters on this ModelRun's SimParams
          attribute (if it exists);  
        * Requested analysis operations that've been added to the ModelRun,
          as specified in the self.analysisOps member list.

        .. note::
           Remember that as well as those overrides written to this XML,
           the user can over-ride particular parameters in the ModelRun via the
           command line by setting the self.paramOverrides member dictionary.
        """
        xmlDoc, root = stgxml.createNewStgDataDoc()
        # Write key entries:
        stgxml.writeParam(root, 'outputPath', self.outputPath, mt='replace')
        if self.cpReadPath:
            stgxml.writeParam(root,
                              'checkpointReadPath',
                              self.cpReadPath,
                              mt='replace')
        if self.simParams:
            self.simParams.writeStgDataXML(root)
        for analysisName, analysisOp in self.analysisOps.iteritems():
            analysisOp.writeStgDataXML(root)

        # This is so we can checkpoint fields list: defined in FieldVariable.c
        if len(self.cpFields):
            # Have used the Merge mergeType, because the solvers for the
            # models in use may have a minimum set of fields to checkpoint.
            stgxml.writeParamList(root,
                                  'FieldVariablesToCheckpoint',
                                  self.cpFields,
                                  mt='merge')

        if filename is None:
            #By default, store this file in the output path.
            absOutputPath = os.path.join(self.basePath, self.outputPath)
            if not os.path.exists(absOutputPath):
                os.makedirs(absOutputPath)
            filename = os.path.join(absOutputPath,
                                    CREDO_ANALYSIS_RECORD_FILENAME)
        stgxml.writeStgDataDocToFile(xmlDoc, filename)
        self.analysisXML = filename
        return filename
Beispiel #4
0
    def analysisXMLGen(self, filename=None):
        """Generates an XML file, in StGermainData XML format, to over-ride
        necessary parameters of the model as specified on this ModelRun
        instance. Returns the name of the just-written XML file.

        Overrides can have the following main sources:

        * Over-ridden simulation parameters that have been specified
          as members of the ModelRun itself, such as cpReadPath, and cpFields;
        * Over-ridden simulation parameters on this ModelRun's SimParams
          attribute (if it exists);  
        * Requested analysis operations that've been added to the ModelRun,
          as specified in the self.analysisOps member list.

        .. note::
           Remember that as well as those overrides written to this XML,
           the user can over-ride particular parameters in the ModelRun via the
           command line by setting the self.paramOverrides member dictionary.
        """ 
        xmlDoc, root = stgxml.createNewStgDataDoc()
        # Write key entries:
        stgxml.writeParam(root, 'outputPath', self.outputPath, mt='replace')
        if self.cpReadPath:
            stgxml.writeParam(root, 'checkpointReadPath', self.cpReadPath,
                mt='replace')
        if self.simParams:
            self.simParams.writeStgDataXML(root)
        for analysisName, analysisOp in self.analysisOps.iteritems():
            analysisOp.writeStgDataXML(root)

        # This is so we can checkpoint fields list: defined in FieldVariable.c
        if len(self.cpFields):
            # Have used the Merge mergeType, because the solvers for the
            # models in use may have a minimum set of fields to checkpoint.
            stgxml.writeParamList(root, 'FieldVariablesToCheckpoint',
                self.cpFields, mt='merge')

        if filename is None:
            #By default, store this file in the output path.
            absOutputPath = os.path.join(self.basePath, self.outputPath)
            if not os.path.exists(absOutputPath):
                os.makedirs(absOutputPath)
            filename = os.path.join(absOutputPath,
                CREDO_ANALYSIS_RECORD_FILENAME)
        stgxml.writeStgDataDocToFile(xmlDoc, filename)
        self.analysisXML = filename
        return filename
Beispiel #5
0
 def test_getNodeFromStrSpec_CreateMode(self):
     xmlDoc, root = stgxml.createNewStgDataDoc()
     # resultNode, lastSpecStr = stgxml.navigateStrSpecHierarchy(root, "dim")
     # TODO: actually test some stuff
     stgxml.writeStgDataDocToFile(xmlDoc, "output/testInsert.xml")
 def test_getNodeFromStrSpec_CreateMode(self):
     xmlDoc, root = stgxml.createNewStgDataDoc()
     # resultNode, lastSpecStr = stgxml.navigateStrSpecHierarchy(root, "dim")
     # TODO: actually test some stuff
     stgxml.writeStgDataDocToFile(xmlDoc, "output/testInsert.xml")