Skip to content
Snippets Groups Projects
Commit 269e5751 authored by Daniel Toyra's avatar Daniel Toyra
Browse files

Changed name and added a feature to the surfacemap method crop. Fixed a minor...

Changed name and added a feature to the surfacemap method crop. Fixed a minor thing in the read_map function.
parent 8e45aecc
No related branches found
No related tags found
No related merge requests found
......@@ -425,6 +425,7 @@ class surfacemap(object):
cbar = pylab.colorbar()
#cbar.set_clim(zmin, zmax)
cbar.set_clim(-1.86, 1.04)
if clabel is not None:
cbar.set_label(clabel)
......@@ -994,16 +995,23 @@ class surfacemap(object):
return self.center
# -------------------------------------------------
def removePeriphery(self):
def crop(self, radius=None):
'''
Finds the NaN elements closest to the map center, and sets all
elements further out to NaN. Then cropping and recentering.
If no radius is given it finds the NaN elements closest to the map
center, and sets all elements further out to NaN. Then cropping
and recentering. If radius is given, it sets all elements outside
the radius value to NaN, cropping, and recentering.
Based on FT_remove_elements_outside_map.m by Charlotte Bond.
Inputs: radius
radius - crops removes elements outside this value [m].
Based on Charlotte Bond's simtools function
'FT_remove_elements_outside_map.m'.
'''
# Saves the xyOffset to restore it afterwards
xyOffset = self.xyOffset
self.recenter()
if radius is None:
# Arrays of row and column indices where data is NaN.
r,c = np.where(self.notNan == False)
# Sets the map center to index [0,0]
......@@ -1011,6 +1019,10 @@ class surfacemap(object):
y = r-self.center[1]
# Minimum radius squared measured in data points.
r2 = (x**2+y**2).min()
else:
# Requires the same stepsize in x and y.
r2 = (radius/self.step_size[0])**2
# Grid with the same dimensions as the map.
X,Y = np.meshgrid(self.x, self.y)
# Grid containing radial distances squared measured from the center.
......@@ -1096,7 +1108,7 @@ class surfacemap(object):
def preparePhaseMap(self, w=None, xyOffset=None, verbose=False):
'''
Prepares the phase mirror map for being used in Finesse. The map is cropped, and
the curvature, offset and tilt are removed, in that order.
the curvature, offset, and tilts are removed, in that order.
Input: w, xyOffset, verbose
w - radius of Gaussian weights [m]. If specified, surfaces are fitted
......@@ -1139,7 +1151,7 @@ class surfacemap(object):
if verbose:
print(' Cropping map...')
before = self.size
self.removePeriphery()
self.crop()
if verbose:
print(' Size (rows, cols): ({:d}, {:d}) ---> ({:d}, {:d})'.
format(before[1], before[0], self.size[1], self.size[0]))
......@@ -1778,8 +1790,8 @@ def read_map(filename, mapFormat='finesse', scaling=1.0e-9, mapType='phase', fie
if mapFormat == 'metroPro':
# Remove '.dat' for output name
name = filename.split('.')[0]
# Remove directory part and '.dat' for name of map
name = filename.split('/')[-1].split('.')[0]
# Reading file
data, hData = readMetroProData(filename)
# xy-stepsize in meters
......@@ -1801,8 +1813,6 @@ def read_map(filename, mapFormat='finesse', scaling=1.0e-9, mapType='phase', fie
return smap
def readZygoLigoMaps(filename, isLigo=False, isAscii=True):
'''
Converts raw zygo and ligo mirror maps to the finesse
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment