def _initialise_math(self): """ Detect math routines """ if NumpySupport(): # Use numpy if we can, as the math calls are performance critical self._cos = numpy.cos self._sin = numpy.sin self._atan = numpy.arctan self._atan2 = numpy.arctan2 else: # Otherwise, fall back to math debug.deprint("Warning: Unable to use numpy module in Lomb-Scargle periodogram") self._cos = math.cos self._sin = math.sin self._atan = math.atan self._atan2 = math.atan2 return
def _initialise_math(self): """ Detect math routines """ if NumpySupport(): # Use numpy if we can, as the math calls are performance critical self._cos = numpy.cos self._sin = numpy.sin self._atan = numpy.arctan self._atan2 = numpy.arctan2 else: # Otherwise, fall back to math debug.deprint( "Warning: Unable to use numpy module in Lomb-Scargle periodogram" ) self._cos = math.cos self._sin = math.sin self._atan = math.atan self._atan2 = math.atan2 return
def ParseRawS(s, delimiter): newS = {} for key1 in s.keys(): assert(not key1 in ["val", "value"]) if isinstance(s[key1], dict): if len(s[key1].keys()) == 1 and s[key1].keys()[0] in ["val", "value"]: newS[str(key1)] = s[key1][s[key1].keys()[0]] else: subS = ParseRawS(s[key1], delimiter) newS[str(key1)] = {} for key2 in subS.keys(): newS[str(key1)][str(key2)] = subS[key2] else: rank = len(s[key1].shape) if rank > 1: assert(rank == 2) if includeMc: # Add in this vector # parser gives this in an inconvenient matrix order. Take the # transpose here to make life easier. newS[str(key1)] = s[key1].transpose() # Add in the vector field components for i in range(len(s[key1])): newS[str(key1) + delimiter + str(i + 1)] = s[key1][i] else: try: # Add in this scalar newS[str(key1)] = s[key1] except TypeError: debug.deprint("Type error for data " + str(s[key1]), 0) raise Exception("ParseRawS failure") except ValueError: debug.deprint("Value error for data " + str(s[key1]), 0) raise Exception("ParseRawS failure") return newS
import os import unittest import buckettools.diagnostics.debug as debug import buckettools.diagnostics.optimise as optimise import buckettools.diagnostics.utils as utils def GuiDisabledByEnvironment(): return "DIAGNOSTICS_GUI_DISABLED" in os.environ and os.environ["DIAGNOSTICS_GUI_DISABLED"] if not GuiDisabledByEnvironment(): try: import gobject except: debug.deprint("Warning: Failed to import gobject module") try: import gtk except: debug.deprint("Warning: Failed to import gtk module") def DisplayWindow(window): """ Launch the GTK main loop to display the supplied window """ window.connect("destroy", gtk.main_quit) window.show() gtk.main() return
# You should have received a copy of the GNU Lesser General Public License # along with TerraFERMA. If not, see <http://www.gnu.org/licenses/>. """ Some mathematical routines """ import copy import math import unittest import buckettools.diagnostics.debug as debug try: import numpy except ImportError: debug.deprint("Warning: Failed to import numpy module") try: import scipy.linalg except ImportError: debug.deprint("Warning: Failed to import scipy.linalg module") try: import scipy.stats except ImportError: debug.deprint("Warning: Failed to import scipy.stats module") try: import vtk except ImportError: debug.deprint("Warning: Failed to import vtk module") import buckettools.diagnostics.optimise as optimise import buckettools.diagnostics.utils as utils
Graph plotting utilities """ import os import tempfile import unittest import buckettools.diagnostics.debug as debug import buckettools.diagnostics.gui as gui import buckettools.diagnostics.utils as utils if not gui.GuiDisabledByEnvironment(): try: import matplotlib except ImportError: debug.deprint("Warning: Failed to import matplotlib module") def MatplotlibSupport(): return "matplotlib" in globals() if MatplotlibSupport(): matplotlib.use("Cairo") try: import matplotlib.backends.backend_gtk except: debug.deprint( "Warning: Failed to import matplotlib.backends.backend_gtk module") if not gui.GuiDisabledByEnvironment():
""" Some mathematical routines """ import copy import math import unittest import buckettools.diagnostics.debug as debug try: import numpy except ImportError: debug.deprint("Warning: Failed to import numpy module") try: import scipy.linalg except ImportError: debug.deprint("Warning: Failed to import scipy.linalg module") try: import scipy.stats except ImportError: debug.deprint("Warning: Failed to import scipy.stats module") try: import vtk except ImportError: debug.deprint("Warning: Failed to import vtk module") import buckettools.diagnostics.optimise as optimise import buckettools.diagnostics.utils as utils
Graph plotting utilities """ import os import tempfile import unittest import buckettools.diagnostics.debug as debug import buckettools.diagnostics.gui as gui import buckettools.diagnostics.utils as utils if not gui.GuiDisabledByEnvironment(): try: import matplotlib except ImportError: debug.deprint("Warning: Failed to import matplotlib module") def MatplotlibSupport(): return "matplotlib" in globals() if MatplotlibSupport(): matplotlib.use("Cairo") try: import matplotlib.backends.backend_gtk except: debug.deprint("Warning: Failed to import matplotlib.backends.backend_gtk module") if not gui.GuiDisabledByEnvironment(): try: import gtk except: