How to use the nexusformat.nexus.nxclasses function in nexusformat

To help you get started, we’ve selected a few nexusformat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nexpy / nexpy / src / nexpy / gui / consoleapp.py View on Github external
def init_shell(self, filename):
        """Initialize imports in the shell."""
        global _shell
        _shell = self.window.user_ns
        s = ("import nexusformat.nexus as nx\n"
             "from nexusformat.nexus import NXgroup, NXfield, NXattr, NXlink\n"
             "from nexusformat.nexus import *\n"
             "import nexpy\n"
             "from nexpy.gui.plotview import NXPlotView")
        six.exec_(s, self.window.user_ns)

        s = ""
        for _class in nxclasses:
            s = "%s=nx.%s\n" % (_class,_class) + s
        six.exec_(s, self.window.user_ns)

        config_file = os.path.join(self.nexpy_dir, 'config.py')
        if not os.path.exists(config_file):
            s = ["import sys\n",
                 "import os\n",
                 "import h5py as h5\n",
                 "import numpy as np\n",
                 "import numpy.ma as ma\n",
                 "import scipy as sp\n",
                 "import matplotlib as mpl\n",
                 "from matplotlib import pylab, mlab, pyplot\n",
                 "plt = pyplot\n",
                 "os.chdir(os.path.expanduser('~'))\n"]
            with open(config_file, 'w') as f: