From ed941460498b68c40a3c33bf51bd624be4ceee0e Mon Sep 17 00:00:00 2001
From: Daniel Brown <ddb@star.sr.bham.ac.uk>
Date: Tue, 17 Feb 2015 11:16:38 +0000
Subject: [PATCH] moving math to maths so doesn't conflict with builtin module,
 tidy up of utilities folder

---
 examples/optivis_aligo_ex.py                  |  1 -
 pykat/finesse.py                              | 21 ++++++++++++-------
 pykat/{math => maths}/__init__.py             |  0
 pykat/{math => maths}/hermite.py              |  0
 pykat/{math => maths}/zernike.py              |  0
 pykat/optics/maps.py                          |  2 +-
 pykat/optics/romhom.py                        |  2 +-
 .../{utilities => tools/plotting}/__init__.py |  0
 .../plotting/beamtrace.py                     |  0
 .../{utilities => tools}/plotting/colormap.py |  0
 pykat/{utilities => tools}/plotting/tools.py  |  0
 pykat/utilities/plotting/__init__.py          |  0
 12 files changed, 15 insertions(+), 11 deletions(-)
 rename pykat/{math => maths}/__init__.py (100%)
 rename pykat/{math => maths}/hermite.py (100%)
 rename pykat/{math => maths}/zernike.py (100%)
 rename pykat/{utilities => tools/plotting}/__init__.py (100%)
 rename pykat/{utilities => tools}/plotting/beamtrace.py (100%)
 rename pykat/{utilities => tools}/plotting/colormap.py (100%)
 rename pykat/{utilities => tools}/plotting/tools.py (100%)
 delete mode 100644 pykat/utilities/plotting/__init__.py

diff --git a/examples/optivis_aligo_ex.py b/examples/optivis_aligo_ex.py
index 0e49704..95764e2 100644
--- a/examples/optivis_aligo_ex.py
+++ b/examples/optivis_aligo_ex.py
@@ -2,6 +2,5 @@ import pykat
 
 kat = pykat.finesse.kat(kat_file="LLO_matched.kat")
 
-
 kat.optivis().show()
 
diff --git a/pykat/finesse.py b/pykat/finesse.py
index 1ee87ec..3ac2858 100644
--- a/pykat/finesse.py
+++ b/pykat/finesse.py
@@ -34,8 +34,7 @@ import time
 import pickle
 import pykat
 import warnings
-import re
-import math       
+import re   
 import itertools
 import ctypes
 import ctypes.util
@@ -43,8 +42,9 @@ import collections
 import re
 import copy
 
-from collections import namedtuple, OrderedDict
+from math import erfc, pi
 
+from collections import namedtuple, OrderedDict
 from pykat.node_network import NodeNetwork
 from pykat.detectors import BaseDetector as Detector
 from pykat.components import Component
@@ -151,7 +151,13 @@ def f__lkat_trace_callback(lkat, trace_info, getCavities, getNodes, getSpaces):
             trace_info[space.name] = space_trace(gouyx = space.gouy_x,
                                                  gouyy = space.gouy_y)
                      
-                                             
+
+def GUILength(L):
+    """
+    Should scale the lengths in some way to handle km and mm
+    """                                  
+    return 10 * erfc(L/1e3) + 0.01
+    
 class katRun(object):
     def __init__(self):
         self.runtime = None
@@ -196,7 +202,7 @@ class katRun(object):
                     out = self.y[:, idx[0]]
             else: 
                 if self.yaxis == "abs:deg":
-                    out = self.y[:, idx[0]] * np.exp(1j*math.pi*self.y[:, idx[1]]/180.0)
+                    out = self.y[:, idx[0]] * np.exp(1j*pi*self.y[:, idx[1]]/180.0)
                 elif self.yaxis == "re:im":
                     out = self.y[:, idx[0]] + 1j*self.y[:, idx[1]]
             
@@ -1467,7 +1473,7 @@ class kat(object):
         # Run through once to add components, ignoring spaces
         for c in self.getComponents():
             if isinstance(c, pykat.components.space): continue
-            print("Adding %s" % c.name)
+            
             optivis_op = getattr(c, "getOptivisComponent", None)
             
         # Run through again to add links
@@ -1491,8 +1497,7 @@ class kat(object):
             if no is None or ni is None:
                 raise pkex.BasePyKatException("Optivis node is None")
             
-            print("Link %s (%s) -> %s (%s)" %(a[0].name, no.name, a[1].name, ni.name))
-            scene.addLink(links.Link(no, ni, c.L.value))
+            scene.addLink(links.Link(no, ni, GUILength(c.L.value) ))
                 
         gui = canvas.Simple(scene=scene)
         
diff --git a/pykat/math/__init__.py b/pykat/maths/__init__.py
similarity index 100%
rename from pykat/math/__init__.py
rename to pykat/maths/__init__.py
diff --git a/pykat/math/hermite.py b/pykat/maths/hermite.py
similarity index 100%
rename from pykat/math/hermite.py
rename to pykat/maths/hermite.py
diff --git a/pykat/math/zernike.py b/pykat/maths/zernike.py
similarity index 100%
rename from pykat/math/zernike.py
rename to pykat/maths/zernike.py
diff --git a/pykat/optics/maps.py b/pykat/optics/maps.py
index 4ca3b17..bee94b8 100644
--- a/pykat/optics/maps.py
+++ b/pykat/optics/maps.py
@@ -17,7 +17,7 @@ from pykat.optics.romhom import makeReducedBasis, makeEmpiricalInterpolant, make
 from scipy.interpolate import interp2d
 import numpy as np
 import math
-from pykat.math.zernike import *        
+from pykat.maths.zernike import *        
 		   
 class surfacemap(object):
     def __init__(self, name, maptype, size, center, step_size, scaling, data=None):
diff --git a/pykat/optics/romhom.py b/pykat/optics/romhom.py
index 958e3e7..b0b75f1 100644
--- a/pykat/optics/romhom.py
+++ b/pykat/optics/romhom.py
@@ -8,7 +8,7 @@ from itertools import combinations_with_replacement as combinations
 from pykat.optics.gaussian_beams import beam_param, HG_beam
 from scipy.linalg import inv
 from math import factorial
-from pykat.math.hermite import *
+from pykat.maths.hermite import *
 
 import numpy as np
 
diff --git a/pykat/utilities/__init__.py b/pykat/tools/plotting/__init__.py
similarity index 100%
rename from pykat/utilities/__init__.py
rename to pykat/tools/plotting/__init__.py
diff --git a/pykat/utilities/plotting/beamtrace.py b/pykat/tools/plotting/beamtrace.py
similarity index 100%
rename from pykat/utilities/plotting/beamtrace.py
rename to pykat/tools/plotting/beamtrace.py
diff --git a/pykat/utilities/plotting/colormap.py b/pykat/tools/plotting/colormap.py
similarity index 100%
rename from pykat/utilities/plotting/colormap.py
rename to pykat/tools/plotting/colormap.py
diff --git a/pykat/utilities/plotting/tools.py b/pykat/tools/plotting/tools.py
similarity index 100%
rename from pykat/utilities/plotting/tools.py
rename to pykat/tools/plotting/tools.py
diff --git a/pykat/utilities/plotting/__init__.py b/pykat/utilities/plotting/__init__.py
deleted file mode 100644
index e69de29..0000000
-- 
GitLab