Ejemplo n.º 1
0
    def __readBlocksData(self):
        '''
        read block data from file
        '''
        import Base , os
        filename = os.path.join(Base.__currentProjectPath__ , 'data.df')
        if not os.path.exists(filename):
            Base.showErrorMessageBox('FileNotFound', '\'data.df\' file was not found in project path.')
            return
        
        from loadDataTools import ParseDFInputGraphData
        self.dataParser = ParseDFInputGraphData()
        
        if not self.dataParser.parse(str(filename)):
            showErrorMessageBox('Data Error' , 'the schema of file is incorrected')
            self.__mainWidget.ui.loadDataLabel.setText('faild')
            return

        self.__mainWidget.ui.loadDataLabel.setText('sucessed')

        print 'DF data parse successfully'    
        self.__mainWidget.enableConfigPanel(True)
        
        from DDADatabase import df_inputDatabase
        data = df_inputDatabase
        self.__mainWidget.ui.blockNumLineE.setText(str(len(df_inputDatabase.blockMatCollections)))
        print df_inputDatabase.blockMatCollections
        self.__mainWidget.ui.jointNumLineE.setText(str(len(df_inputDatabase.jointMatCollections)))
        print df_inputDatabase.jointMatCollections
        self.dataParser = None
        
        self.__setDefaultParameters()
Ejemplo n.º 2
0
 def __configMats(self):
     
     if self.__matsWidget.setEarthquakeMaxSteps(self.__mainWidget.ui.stepsNumSpinB.value()):
         self.__matsWidget.show()
     else:
         import Base
         Base.showErrorMessageBox("DataError", "The sum of Earthquake steps and earthquake start step numer is bigger than total steps for DDA analysis.\nPlease modify total step number.")
Ejemplo n.º 3
0
    def storeEarthquakeData(self):
        import Base
        import os
        if not self.ifEarthquakeDataOK():
            Base.showErrorMessageBox('Data Error', 'There are some errors for earthquake configuration.\nPlease check earthquake data.')
        lines = open(self.ui.earthquakeFilenameLabel.text(), 'rb').readlines()

        resultFile = open(os.path.join(Base.__currentProjectPath__, 'earthquake.df'),'wb')
        resultFile.write('%d %f %f\n'%(self.ui.startStepsSpinB.value()+len(lines)-1 \
                         , self.ui.gravitySpinB.value(), self.ui.timeSpinB.value()))
        resultFile.write('0 0 0\n'*self.ui.startStepsSpinB.value())
        resultFile.write(''.join(lines[1:]))
        resultFile.close()
        return True
Ejemplo n.º 4
0
    def __readParameters(self):
        '''
        read parameters from file
        '''
        import Base
        filename = os.path.join(Base.__currentProjectPath__ , 'parameters.df')
        if not os.path.exists(filename):
            Base.showErrorMessageBox('FileNotFound', '\'parameters.df\' file was not found in project path.')
            return

        from loadDataTools import ParseDFInputParameters
        parasParser = ParseDFInputParameters()
        
        if not parasParser.parse(str(filename)):
            showErrorMessageBox('Data Error' , 'the schema of file is incorrected')
            self.__mainWidget.ui.loadParasLabel.setText('faild')
            return        
        self.__mainWidget.ui.loadParasLabel.setText('sucessed')

        self.__storePara2Panel()
Ejemplo n.º 5
0
 def selectEarthquakeFile(self):
     import PySide, Base
     fileDialog = PySide.QtGui.QFileDialog(None,'Select earthquake data file'\
                     , Base.__currentProjectPath__)
     fileDialog.setFileMode(PySide.QtGui.QFileDialog.ExistingFile)
     filename = None
     if fileDialog.exec_():
         filename = fileDialog.selectedFiles()[0]
     else:
         return
     
     lines = open(filename, 'rb').readlines()
     if len(lines)>self.__totalSteps+1: # first line is schema
         import Base
         Base.showErrorMessageBox('DataError'\
            , 'The number of earthquake data steps is bigger than total steps.')
         return False 
     print 'selected earthquake file: ', filename
     nums = lines[0].split()
     try:
         steps, gravity, timeInterval = \
                      int(nums[0]) \
                     ,float(nums[1]) \
                     ,float(nums[2])
         self.checkEarthquakeDataValid(lines[1:])
     except:
         import Base
         Base.showErrorMessageBox('DataError'\
            , 'Earthquake data is unvalid')
         return False
         
     if steps==None or gravity==None or timeInterval==None:
         import Base
         Base.showErrorMessageBox('DataError'\
            , 'Earthquake data is unvalid')
         return False
     
     if steps>self.__totalSteps:
         import Base
         Base.showErrorMessageBox('DataError'\
            , 'The number of earthquake steps is bigger than the number of total steps for DDA analysis.')
         return False
         
     
     self.ui.totalStepsSpinB.setValue(steps-1)
     self.ui.startStepsSpinB.setMaximum(self.__totalSteps-steps+1)
     self.ui.earthquakeFilenameLabel.setText(filename)
     self.setEarthquakeParas(0, gravity, timeInterval)