Beispiel #1
0
    def openWDFile(self):
        fname = QtGui.QFileDialog.getOpenFileName(self, 'Open file',
                                                  var.path(),
                                                  "FILE (*.nc *.HIST *.out)")
        #Save the current path
        pathFile = str(fname)
        var.global_path = pathFile

        if fname != "":
            fname = fname.replace(' ', '\ ')
            if str(fname).find('_OUT.nc') != -1:
                TEMP = Read.MolecularDynamicFile(fname)
                if TEMP.isGoodFile():
                    self.files['WD'] = TEMP
                    self.teWD.setText(str(fname))
                    self.lblWD.hide()
                    self.sbWD.hide()

            else:
                TEMP = Read.outputFile(fname)
                if TEMP.isGoodFile():
                    self.files['WD'] = TEMP
                    self.teWD.setText(str(fname))
                    self.lblWD.show()
                    self.sbWD.show()
Beispiel #2
0
 def read(self, pathFile):
     TEMP = Read.MolecularDynamicFile(pathFile)
     if TEMP.isGoodFile():
         self.emit(QtCore.SIGNAL("Reading(PyQt_PyObject)"), TEMP)
     try:
         del self.progressbar
     except:
         pass
Beispiel #3
0
def openFile(choose = 'please choose file (help):'):
    while True :
        
        words = commands.getoutput('ls').split()
        completer = Completer.Completer(words)
        readline.set_completer(completer.complete)
        
        sub = raw_input('Command : ')
        
        if sub == 'ls':
            subprocess.call(sub, shell=True)
            
        elif sub == 'pwd':
            print commands.getoutput(sub)
            
        elif sub == 'cd ..':
            os.chdir('..')
            
        elif sub == 'cd':
            os.chdir(commands.getoutput('echo ~/'))
            
        elif sub.find('cd') == 0:
            dir_files = sub.replace('cd','').split()
            dir_file = str(dir_files[0])

            if len(dir_files) > 1 :
                for i in range(1,len(dir_files)):
                    dir_file += ' '+str(dir_files[i])		    	        
                
            try:
                os.chdir(dir_file)
            except:
                print 'No such file or directory : '+str(dir_file)
                
        elif (sub.find('.nc')!=-1 or sub.find('HIST')!=-1 or sub.find('out') != -1 ) :
            MD_file = Read.MolecularDynamicFile(str(os.getcwd())+'/'+str(sub))
            if MD_file.getNameFile() != '':
                print '\nloading successful!'
                print 'File :' + str(MD_file.getNameFile())+'\n\n'
                return MD_file   
                
                
        elif sub == 'clear':
            clear()
        
        
        elif sub == 'quit':
            break;
        elif (sub == 'help') or (sub == 'help'):
            print 'available commands:'
            print '    ls '
            print '    cd '
            print '    pwd '
            print '    clear '
            print '    quit'
        
        else:
            print 'Unknown command'
Beispiel #4
0
def clear():
    os.system('/usr/bin/clear')
    logo()    
    try:
        global MD_file
        global units
        print 'File :' + str(MD_file.getNameFile())+'\n'
        if MD_file.isGoodFile():
            showData(MD_file,units)
    except:
        print "Loading File please wait..."
        #Try to read the last output:
        MD_file = Read.MolecularDynamicFile("")
        if MD_file.isGoodFile():
            print 'loading successful!'
            print 'File :' + str(MD_file.getNameFile())+'\n\n'
        else:
         #the last output does'nt exist        
            print 'Unable to load file,',  
            MD_file = openFile()
            if MD_file == None:
                sys.exit(0)
Beispiel #5
0
    def initUI(self):
        #----------MainFrame parameters----------#
        self.setWindowTitle("APPA " + var.version)
        self.setFixedSize(700, 550)
        self.center()
        #-------------------------------------#

        #---------------Creation of menubar----------------------------------#
        self.open = QtGui.QAction('&Open', self)
        self.open.setShortcut('Ctrl+O')
        self.open.setStatusTip('Open File')
        self.connect(self.open, QtCore.SIGNAL('triggered()'), self.showDialog)

        self.close = QtGui.QAction('&Exit', self)
        self.close.setShortcut('Ctrl+Q')
        self.close.setStatusTip('Exit application')
        self.connect(self.close, QtCore.SIGNAL('triggered()'),
                     QtCore.SLOT('close()'))

        self.save = QtGui.QAction('&Save', self)
        self.save.setShortcut('Ctrl+S')
        self.save.setStatusTip('Save simulation data')
        self.connect(self.save, QtCore.SIGNAL('triggered()'), self.showSave)

        self.export = QtGui.QAction('E&xport (.xyz)', self)
        self.export.setShortcut('Ctrl+X')
        self.export.setStatusTip('Export data to XYZ file')
        self.connect(self.export, QtCore.SIGNAL('triggered()'),
                     self.showExport)

        self.menubar = self.menuBar()
        self.fileMenu1 = self.menubar.addMenu('&File')
        self.fileMenu1.addAction(self.open)
        self.fileMenu1.addAction(self.save)
        self.fileMenu1.addAction(self.export)
        self.fileMenu1.addAction(self.close)

        self.ec = QtGui.QAction('&Elastics constants', self)
        self.ec.setShortcut('Ctrl+E')
        self.ec.setStatusTip('Calculation of Elastics constants')
        self.connect(self.ec, QtCore.SIGNAL('triggered()'), self.showElastics)

        self.fileMenu2 = self.menubar.addMenu('&Calculation')
        self.fileMenu2.addAction(self.ec)

        self.unit = QtGui.QAction('&Units', self)
        self.unit.setShortcut('Ctrl+U')
        self.unit.setStatusTip('change physical units')
        self.connect(self.unit, QtCore.SIGNAL('triggered()'), self.showConv)

        self.fileMenu3 = self.menubar.addMenu('&Option')
        self.fileMenu3.addAction(self.unit)

        self.about = QtGui.QAction('&About', self)
        self.about.setShortcut('Ctrl+A')
        self.about.setStatusTip('About software')
        self.connect(self.about, QtCore.SIGNAL('triggered()'), self.showAbout)

        self.fileMenu3 = self.menubar.addMenu('&APPA')
        self.fileMenu3.addAction(self.about)
        #---------------------------------------------------------------------#

        #----------------Creation of statusBar--------------------#
        self.setStatusBar(QtGui.QStatusBar())
        #---------------------------------------------------------#

        #-------Creation of CentralWidget-----------------------------------------#
        self.widget = QtGui.QWidget()
        self.widget_layout = QtGui.QGridLayout()
        self.widget.setLayout(self.widget_layout)

        self.box1 = QtGui.QGroupBox()
        self.box1layout = QtGui.QGridLayout()
        self.box1.setLayout(self.box1layout)

        self.lbltitle = QtGui.QLabel("Abinit Post-Process Application")
        self.lbltitle.setFont(QtGui.QFont("calibri", 25))
        self.lbltitle.setFixedWidth(520)
        self.box1layout.addWidget(self.lbltitle, 1, 0)

        self.tab = QtGui.QTabWidget()
        self.tab.setTabsClosable(True)
        self.connect(self.tab, QtCore.SIGNAL('tabCloseRequested (int)'),
                     self.closeTab)
        self.tab.setTabPosition(1)

        #----------Try to open the last .nc and .HIST files------------#
        MD_file = Read.MolecularDynamicFile("")
        if MD_file.isGoodFile():
            self.page1 = MD.Netcdf_MD(MD_file, self.units)
            self.tab.addTab(self.page1, MD_file.getNameFile())

        #----------Try to open the last Ground State file(BETA)--------#
        #GS_file = Read.outputFile("")
        #if GS_file.isGoodFile():
        #    self.page2 = GS.Ouput_GS(GS_file,self.units)
        #    self.tab.addTab(self.page2,str(GS_file.getNameFile()))

        #Connection of Signal (for the threading):
        self.connect(self, QtCore.SIGNAL("Reading(PyQt_PyObject)"), self.add)

        self.widget_layout.addWidget(self.box1, 1, 0, 1, 2)
        self.widget_layout.addWidget(self.tab, 2, 0, 5, 2)

        self.setCentralWidget(self.widget)
        #------------------------------------------------------------------------#
        self.show()

        if self.tab.count() == 0:
            self.showDialog()
Beispiel #6
0
    
#Main loop:
while i<size_input :

    choice = 0
    
    if input_file == True: 
        input_name=input_data.keys()[i]
        if os.path.isfile(input_name):
            pass
        else:
            print "\n!!!WARNING "+input_name+" doesnt exist"
            i+=1
            continue
       
        MD_file = Read.MolecularDynamicFile(str(input_name))
        if (MD_file.getNameFile() != '' and MD_file.isGoodFile()):
            print '\nFile :' + str(input_name)
            print 'loading successful!\n'
            #Set the inial step
            if("stepmin" in input_data[input_name]):
                try:
                    ni = int(input_data[input_name]["stepmin"])
                except:
                    ni = 1
                if ni >=1 and ni < MD_file.getNbTime():
                    MD_file.setNi(ni)
                else:
                    ni = 1
                    MD_file.setNi(ni)
                print "Set initial step to "+str(ni)