Commit 346bfbe1 authored by eric pellegrini's avatar eric pellegrini

Added a generic ASCII trajectory converter

Many bug fixes related to ud
parent 83a72c1e
......@@ -36,9 +36,10 @@ import os
import wx
import wx.aui as wxaui
from MDANSE import LOGGER, REGISTRY, UD_STORE
from MDANSE import LOGGER, REGISTRY
from MDANSE.Core.Error import Error
from MDANSE.Externals.pubsub import pub
from MDANSE.Framework.UserDefinitionsStore import UD_STORE
from MDANSE.Framework.AtomSelectionParser import AtomSelectionParser, AtomSelectionParserError
from MDANSE.MolecularDynamics.Trajectory import sorted_atoms
......
......@@ -33,8 +33,9 @@ import os
import wx
from MDANSE import ELEMENTS, LOGGER, REGISTRY, UD_STORE
from MDANSE import ELEMENTS, LOGGER, REGISTRY
from MDANSE.Externals.pubsub import pub as Publisher
from MDANSE.Framework.UserDefinitionsStore import UD_STORE
from MDANSE.App.GUI.Framework.Plugins.AtomSelectionPlugin import AtomSelectionPlugin
......
......@@ -35,8 +35,10 @@ import os
import wx
import wx.aui as wxaui
from MDANSE import LOGGER, REGISTRY, UD_STORE
from MDANSE import LOGGER, REGISTRY
from MDANSE.Externals.pubsub import pub
from MDANSE.Framework.UserDefinitionsStore import UD_STORE
from MDANSE.App.GUI.Framework.Plugins.ComponentPlugin import ComponentPlugin
from MDANSE.App.GUI.ComboWidgets.UserDefinitionsPanel import UserDefinitionsPanel
from MDANSE.MolecularDynamics.Trajectory import find_atoms_in_molecule, get_chemical_objects_dict
......
......@@ -35,8 +35,10 @@ import os
import wx
import wx.aui as wxaui
from MDANSE import LOGGER, REGISTRY, UD_STORE
from MDANSE import LOGGER, REGISTRY
from MDANSE.Externals.pubsub import pub
from MDANSE.Framework.UserDefinitionsStore import UD_STORE
from MDANSE.App.GUI.Framework.Plugins.ComponentPlugin import ComponentPlugin
from MDANSE.App.GUI.ComboWidgets.UserDefinitionsPanel import UserDefinitionsPanel
from MDANSE.MolecularDynamics.Trajectory import find_atoms_in_molecule, get_chemical_objects_dict
......@@ -124,7 +126,7 @@ class BasisSelectionPlugin(ComponentPlugin):
self._moleculeNames.SetItems(sorted(self._molecularContents.keys()))
def on_close(self, event):
def on_close(self, event=None):
self.parent.clear_selection()
self.parent.mgr.ClosePane(self.parent.mgr.GetPane(self))
......@@ -138,7 +140,6 @@ class BasisSelectionPlugin(ComponentPlugin):
if (not origin) or (not xAxis) or (not yAxis):
LOGGER("One of the atom selection is empty. Please select some values.", "error", ["dialog"])
return
if (origin == xAxis) or (origin == yAxis) or (xAxis == yAxis):
LOGGER("A basis can not be set from identical atom selections.", "error", ["dialog"])
......
......@@ -33,7 +33,6 @@ Created on Apr 14, 2015
import os
import subprocess
import sys
import tempfile
import time
import wx
......
......@@ -37,9 +37,11 @@ import wx.aui as wxaui
import wx.grid as wxgrid
from wx.lib.delayedresult import startWorker
from MDANSE import LOGGER, REGISTRY, UD_STORE
from MDANSE import LOGGER, REGISTRY
from MDANSE.Externals.pubsub import pub
from MDANSE.Framework.UserDefinitionsStore import UD_STORE
from MDANSE.App.GUI.ComboWidgets.ConfigurationPanel import ConfigurationPanel
from MDANSE.App.GUI.ComboWidgets.ProgressBar import ProgressBar
from MDANSE.App.GUI.Framework.Plugins.ComponentPlugin import ComponentPlugin
......
......@@ -34,7 +34,7 @@ import os
import wx.combo
from MDANSE.Framework.UserDefinitions.IUserDefinition import UD_STORE
from MDANSE.Framework.UserDefinitionsStore import UD_STORE
from MDANSE.App.GUI.Framework.Widgets.IWidget import IWidget
from MDANSE.App.GUI.ComboWidgets.ComboCheckbox import ComboCheckbox
......
......@@ -13,7 +13,6 @@ class MainApplication(wx.App):
f.Show()
self.SetTopWindow(f)
return True
class PeriodicTableApplication(wx.App):
......@@ -24,7 +23,6 @@ class PeriodicTableApplication(wx.App):
self.SetTopWindow(f)
return True
class PlotterApplication(wx.App):
def OnInit(self):
......@@ -42,4 +40,9 @@ class UserDefinitionViewerApplication(wx.App):
f.Show()
self.SetTopWindow(f)
return True
if __name__ == "__main__":
app = MainApplication()
app.MainLoop()
\ No newline at end of file
......@@ -57,7 +57,7 @@ class MainFrame(wx.Frame):
# Add some handlers to the loggers
LOGGER.add_handler("console", REGISTRY['handler']['console'](self._panels["controller"].pages["logger"]), level="info")
LOGGER.add_handler("dialog", REGISTRY['handler']['dialog'], level="error")
LOGGER.add_handler("dialog", REGISTRY['handler']['dialog'](), level="error")
LOGGER.start()
def build_dialog(self):
......
......@@ -35,7 +35,7 @@ import operator
import numpy
from MDANSE.Framework.UserDefinitions.IUserDefinition import UD_STORE, UserDefinitionError
from MDANSE.Framework.UserDefinitionsStore import UD_STORE, UserDefinitionsStoreError
from MDANSE.Framework.Configurators.IConfigurator import IConfigurator, ConfiguratorError
from MDANSE.Framework.AtomSelectionParser import AtomSelectionParser
......@@ -91,7 +91,7 @@ class AtomSelectionConfigurator(IConfigurator):
try:
ud = UD_STORE[trajConfig["basename"],"atom_selection",value]
# The input value is an atom selection string: parse it and update the configuration
except UserDefinitionError:
except UserDefinitionsStoreError:
parser = AtomSelectionParser(trajConfig["instance"].universe)
self["indexes"] = parser.parse(value)
self["expression"] = value
......
......@@ -31,7 +31,7 @@ Created on Mar 30, 2015
'''
from MDANSE import ELEMENTS
from MDANSE.Framework.UserDefinitions.IUserDefinition import UD_STORE
from MDANSE.Framework.UserDefinitionsStore import UD_STORE
from MDANSE.Framework.Configurators.IConfigurator import IConfigurator, ConfiguratorError
from MDANSE.Framework.AtomSelectionParser import AtomSelectionParser
......
......@@ -30,7 +30,7 @@ Created on Mar 30, 2015
@author: Eric C. Pellegrini and Bachir Aoun
'''
from MDANSE.Framework.UserDefinitions.IUserDefinition import UD_STORE
from MDANSE.Framework.UserDefinitionsStore import UD_STORE, UserDefinitionsStoreError
from MDANSE.Framework.Configurators.IConfigurator import IConfigurator
from MDANSE.MolecularDynamics.Trajectory import find_atoms_in_molecule
......@@ -73,11 +73,12 @@ class AxisSelection(IConfigurator):
trajConfig = configuration[self._dependencies['trajectory']]
ud = UD_STORE[trajConfig["basename"],"axis_selection",value]
if ud is not None:
self.update(ud)
else:
try:
ud = UD_STORE[trajConfig["basename"],"axis_selection",value]
except UserDefinitionsStoreError:
self.update(value)
else:
self.update(ud)
e1 = find_atoms_in_molecule(trajConfig['instance'].universe,self['molecule'], self['endpoint1'], True)
e2 = find_atoms_in_molecule(trajConfig['instance'].universe,self['molecule'], self['endpoint2'], True)
......
......@@ -30,7 +30,7 @@ Created on Mar 30, 2015
@author: Eric C. Pellegrini and Bachir Aoun
'''
from MDANSE.Framework.UserDefinitions.IUserDefinition import UD_STORE
from MDANSE.Framework.UserDefinitionsStore import UD_STORE, UserDefinitionsStoreError
from MDANSE.Framework.Configurators.IConfigurator import IConfigurator
from MDANSE.MolecularDynamics.Trajectory import find_atoms_in_molecule
......@@ -74,12 +74,14 @@ class BasisSelection(IConfigurator):
'''
trajConfig = configuration[self._dependencies['trajectory']]
ud = UD_STORE[trajConfig["basename"],"basis_selection",value]
if ud is not None:
self.update(ud)
else:
try:
ud = UD_STORE[trajConfig["basename"],"basis_selection",value]
except UserDefinitionsStoreError:
self.update(value)
else:
self.update(ud)
e1 = find_atoms_in_molecule(trajConfig['instance'].universe,self['molecule'], self['origin'], True)
e2 = find_atoms_in_molecule(trajConfig['instance'].universe,self['molecule'], self['x_axis'], True)
......
......@@ -31,7 +31,7 @@ Created on May 22, 2015
'''
from MDANSE import REGISTRY
from MDANSE.Framework.UserDefinitions.IUserDefinition import UD_STORE
from MDANSE.Framework.UserDefinitionsStore import UD_STORE, UserDefinitionsStoreError
from MDANSE.Framework.Configurators.IConfigurator import IConfigurator, ConfiguratorError
class QVectorsConfigurator(IConfigurator):
......@@ -70,15 +70,11 @@ class QVectorsConfigurator(IConfigurator):
trajConfig = configuration[self._dependencies['trajectory']]
ud = UD_STORE[trajConfig["basename"],"q_vectors",value]
if ud is not None:
try:
ud = UD_STORE[trajConfig["basename"],"q_vectors",value]
self["parameters"] = ud['parameters']
self["type"] = ud['generator']
self["is_lattice"] = ud['is_lattice']
self["q_vectors"] = ud['q_vectors']
else:
except UserDefinitionsStoreError:
generator, parameters = value
generator = REGISTRY["q_vectors"][generator](trajConfig["instance"])
generator.setup(parameters)
......@@ -86,6 +82,12 @@ class QVectorsConfigurator(IConfigurator):
if not data:
raise ConfiguratorError("no Q vectors could be generated", self)
else:
self["parameters"] = ud['parameters']
self["type"] = ud['generator']
self["is_lattice"] = ud['is_lattice']
self["q_vectors"] = ud['q_vectors']
self["parameters"] = parameters
self["type"] = generator.type
......
This diff is collapsed.
......@@ -74,7 +74,7 @@ class JobError(Error):
trace.append("\n%s" % self._message)
trace = '\n'.join(trace)
LOGGER(trace,'error',[job._name])
if job._status is not None:
......@@ -128,7 +128,7 @@ class IJob(Configurable):
return name
def __init__(self, status=None):
def __init__(self, status=False):
"""
The base class constructor.
"""
......@@ -143,7 +143,7 @@ class IJob(Configurable):
self._info = ""
if status is not None:
if status:
self._status = JobStatus(self)
else:
self._status = None
......@@ -467,7 +467,10 @@ class IJob(Configurable):
if getattr(self,'numberOfSteps', 0) <= 0:
raise JobError(self,"Invalid number of steps for job %s" % self._name)
mode = self.configuration['running_mode']['mode']
if self.configuration.has_key('running_mode'):
mode = self.configuration['running_mode']['mode']
else:
mode = 'monoprocessor'
IJob._runner[mode](self)
......
......@@ -29,6 +29,8 @@ class Status(object):
def __init__(self):
self._updateStep = 1
self._currentStep = 0
self._nSteps = None
self._finished = False
......@@ -121,10 +123,8 @@ class Status(object):
return
self._nSteps = nSteps
if rate is None:
self._updateStep = 1
else:
if rate is not None:
self._updateStep = max(0,int(rate*nSteps))
Publisher.sendMessage("status_start",message=self)
......@@ -137,6 +137,9 @@ class Status(object):
def update(self,force=False):
if self._nSteps is None:
return
if self._updateStep == 0:
return
......
......@@ -4,7 +4,6 @@ import os
from MDANSE import PLATFORM
from MDANSE.Core.Error import Error
from MDANSE.Core.Singleton import Singleton
from MDANSE.Framework.UserDefinitions.AtomSelectionDefinition import AtomSelectionDefinition
class UserDefinitionsStoreError(Error):
pass
......@@ -82,23 +81,18 @@ class UserDefinitionsStore(UnicodeDict):
if not os.path.exists(UserDefinitionsStore.UD_PATH):
return
# # Try to open the UD file.
# try:
# f = open(UserDefinitionsStore.UD_PATH, "rb")
# UD = cPickle.load(f)
#
# # If for whatever reason the pickle file loading failed do not even try to restore it
# except:
# return
#
# else:
# UnicodeDict.update(self,UD)
# f.close()
f = open(UserDefinitionsStore.UD_PATH, "rb")
UD = cPickle.load(f)
UnicodeDict.update(self,UD)
f.close()
# Try to open the UD file.
try:
f = open(UserDefinitionsStore.UD_PATH, "rb")
UD = cPickle.load(f)
# If for whatever reason the pickle file loading failed do not even try to restore it
except:
return
else:
UnicodeDict.update(self,UD)
f.close()
def save(self):
'''
......
......@@ -41,7 +41,7 @@ from MDANSE.Logging.Logger import LOGGER
from MDANSE.Core.Preferences import PREFERENCES
from MDANSE.Framework.UserDefinitionsStore import UD_STORE
import Framework
import os
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment