Commit 9546c4b7 by Daniel Toyra

### Added proper error handling in maps.py

parent eb6ecbe4
Pipeline #1551 failed with stage
in 22 seconds
 ... @@ -19,6 +19,8 @@ from scipy.optimize import minimize ... @@ -19,6 +19,8 @@ from scipy.optimize import minimize from pykat.math.zernike import * from pykat.math.zernike import * from pykat.exceptions import BasePyKatException from pykat.exceptions import BasePyKatException from copy import deepcopy from copy import deepcopy import matplotlib import matplotlib.pyplot as plt import numpy as np import numpy as np import math import math ... @@ -119,15 +121,15 @@ class surfacemap(object): ... @@ -119,15 +121,15 @@ class surfacemap(object): # Checking so new suggested "center" is within the the mirror surface # Checking so new suggested "center" is within the the mirror surface if (x0new>0 and x0new0 and y0new0 and x0new0 and y0new pos = ({:.2f}, {:.2f}) '+ raise BasePyKatException( ('Error in xyOffset: ({:.2e}, {:.2e}) m --> pos = ({:.2f}, {:.2f}) '+ 'is outside mirror surface.').format(offset[0],offset[1],x0new,y0new)) 'is outside mirror surface.').format(offset[0],offset[1],x0new,y0new)) @property @property def betaRemoved(self): def betaRemoved(self): return self._betaRemoved return self._betaRemoved ... @@ -409,7 +411,6 @@ class surfacemap(object): ... @@ -409,7 +411,6 @@ class surfacemap(object): # xlim and ylim given in centimeters # xlim and ylim given in centimeters def plot(self, show=True, clabel=None, xlim=None, ylim=None, isBlock=False): def plot(self, show=True, clabel=None, xlim=None, ylim=None, isBlock=False): import pylab if xlim is not None: if xlim is not None: # Sorts out the x-values within xlim # Sorts out the x-values within xlim ... @@ -448,22 +449,22 @@ class surfacemap(object): ... @@ -448,22 +449,22 @@ class surfacemap(object): yRange = 100*self.y yRange = 100*self.y # xRange, yRange = np.meshgrid(xRange,yRange) # xRange, yRange = np.meshgrid(xRange,yRange) fig = pylab.figure() fig = plt.figure() # Important to remember here is that xRange corresponds to column and # Important to remember here is that xRange corresponds to column and # yRange to row indices of the matrix self.data. # yRange to row indices of the matrix self.data. pcm = pylab.pcolormesh(xRange, yRange, self.data) pcm = plt.pcolormesh(xRange, yRange, self.data) pcm.set_rasterized(True) pcm.set_rasterized(True) pylab.xlabel('x [cm]') plt.xlabel('x [cm]') pylab.ylabel('y [cm]') plt.ylabel('y [cm]') if xlim is not None: pylab.xlim(xlim) if xlim is not None: plt.xlim(xlim) if ylim is not None: pylab.ylim(ylim) if ylim is not None: plt.ylim(ylim) pylab.title('Surface map {0}, type {1}'.format(self.name, self.type)) plt.title('Surface map {0}, type {1}'.format(self.name, self.type)) cbar = pylab.colorbar() cbar = plt.colorbar() cbar.set_clim(zmin, zmax) cbar.set_clim(zmin, zmax) # cbar.set_clim(-1.86, 1.04) # cbar.set_clim(-1.86, 1.04) ... @@ -471,7 +472,7 @@ class surfacemap(object): ... @@ -471,7 +472,7 @@ class surfacemap(object): cbar.set_label(clabel) cbar.set_label(clabel) if show: if show: pylab.show(block=isBlock) plt.show(block=isBlock) return fig return fig ... @@ -580,7 +581,7 @@ class surfacemap(object): ... @@ -580,7 +581,7 @@ class surfacemap(object): # x and y step sizes are different. # x and y step sizes are different. elif method=='area' or method=='Area' or method=='AREA': elif method=='area' or method=='Area' or method=='AREA': if unit == 'meters' or unit == 'metres' or unit=='Meters' or unit=='Metres': if unit == 'meters' or unit == 'metres' or unit=='Meters' or unit=='Metres': r = step_size[0]*math.sqrt(len(cIndx)/math.pi) r = self.step_size[0]*math.sqrt(len(cIndx)/math.pi) else: else: r = math.sqrt(len(cIndx)/math.pi) r = math.sqrt(len(cIndx)/math.pi) elif method=='min': elif method=='min': ... ...
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