__init__.py 2.55 KB
Newer Older
1 2 3 4
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
Daniel Brown's avatar
Daniel Brown committed
5

Daniel Brown's avatar
Daniel Brown committed
6
try:
7 8 9 10 11
    try:
        from ._version import __version__
    except ModuleNotFoundError as ex:
        __version__ = "develop"
except (NameError, ImportError) as ex:
Daniel Brown's avatar
Daniel Brown committed
12 13
    __version__ = "develop"

14
__min_req_finesse__ = 2.2
15 16 17

# This flag is used to switch on the gui features in pkat at import time
USE_GUI = False
18
HAS_OPTIVIS = False
19

20 21 22 23 24 25 26
import six

########################
# Global helper functions
isContainer = lambda c: (not isinstance(c, six.string_types)) and hasattr(c, "__iter__")
########################

27
import imp
28

29 30 31 32 33
try:
	imp.find_module('optivis')
	HAS_OPTIVIS = True
except ImportError:
	HAS_OPTIVIS = False
34 35 36 37

import pykat.exceptions as pkex

NoGUIException = pkex.BasePyKatException("No PyQt4 module was found so cannot open a GUI")
38
    
39 40 41 42
import pykat.finesse as finesse
import pykat.components as components
import pykat.detectors as detectors
import pykat.commands as commands
43
import pykat.style as style
44

45
from pykat.optics.gaussian_beams import BeamParam
46

47
from pykat.plotting import init_pykat_plotting
Phil Jones's avatar
Phil Jones committed
48
from pykat.style import use as set_plot_style
49

50 51
from .SIfloat import SIfloat

52 53 54 55 56 57 58
kat = finesse.kat()
v = kat.finesse_version()

if float(v.split('-')[0]) < __min_req_finesse__:
    raise pkex.BasePyKatException("Pykat %s requires Finesse version %s or higher. You have have %s" % (__version__ ,
                                                                                              str(__min_req_finesse__),
                                                                                              v))
59

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
SI = {'yocto': 1E-24,  # yocto
    'zepto': 1E-21,  # zepto
    'atto': 1E-18,  # atto
    'femto': 1E-15,  # femto
    'pico': 1E-12,  # pico
    'nano': 1E-9,   # nano
    'micro': 1E-6,   # micro
    'milli': 1E-3,   # mili
    'centi': 1E-2,   # centi
    'deci': 1E-1,   # deci
    None: 1E-0,  
    'kilo': 1E3,    # kilo
    'mega': 1E6,    # mega
    'giga': 1E9,    # giga
    'tera': 1E12,   # tera
    'peta': 1E15   # peta
    }

SIlabel = {'yocto': 'y',# yocto
           'zepto': 'z',# zepto
            'atto': 'a',# atto
           'femto': 'f',# femto
            'pico': 'p',# pico
            'nano': 'n',# nano
            'micro':'u',# micro
            'milli':'m',# mili
            'centi':'c',# centi
            'deci': 'd',# deci
            None:   'k',
            'kilo': 'M',# kilo
            'mega': 'G',# mega
            'giga': 'T',# giga
            'tera': 'P',# tera
            'peta': 'y',# peta
94
    }