Skip to content
Snippets Groups Projects
Commit a4693a1e authored by Francois POLACK's avatar Francois POLACK
Browse files

feat: Added cumulated RMS height and associated plot

parent 9552734d
No related branches found
No related tags found
No related merge requests found
......@@ -125,6 +125,9 @@ class HeightMap(object):
#added 20/03/2024
self.hrms=None
self.hrms_sag=None
# added 03/04/2024 storage for 1D-PSD
self.PSD_tan=None
self.PSD_sag=None
def read_Zygofile(self, filename='', origin='zero' ):
"""! Reads a Zygo datafile in .datx, .dat or xyz format, and loads it into the HeightMap object.
......@@ -496,10 +499,10 @@ class HeightMap(object):
#€nd compute_CPSD_old
def compute_CPSD(self):
print("tagential RMS slope error")
(self.sf, self.srms, self.hrms)=self.CRMSslope(axis=-1)
print("tangential RMS slope error")
(self.sf, self.srms, self.hrms,self.PSD_tan)=self.CRMSslope(axis=-1)
print("sagittal RMS slope error")
(self.sf_sag, self.srms_sag, self.hrms_sag)=self.CRMSslope(axis=0)
(self.sf_sag, self.srms_sag, self.hrms_sag,PSD_sag)=self.CRMSslope(axis=0)
def CRMSslope(self, axis=-1):
......@@ -525,7 +528,7 @@ class HeightMap(object):
s1csd = np.cumsum(s1psd) * (sf[1] - sf[0])
srms = np.sqrt(s1csd)
print("Total cumulated rms=", srms[srms.shape[0]-1]*1e6, "µrad")
return (sf,srms, hrms)
return (sf,srms, hrms,h1psd)
def print_statistics(self, height = True, raw = False, percent=0):
"""! Print statistics excluding the specified percentage of outlier pixels.
......@@ -821,6 +824,29 @@ class HeightMap(object):
plt.semilogx()
# end plot_height_rms
def plot_PSD(self, tangential=True, scale='log', comment='') :
"""! Display a graph of the surface height PSD versus spatial frequency
@param comment an optional comment which will be appended to the graph title
"""
from crmsfig import create_crms_figure
csfig=create_crms_figure(figsize=fig.figaspect(0.5)) # new plot window
if tangential:
plt.plot(self.sf*1e-3, self.PSD_tan*1e9)
plt.title('Tangential PSD {}'.format(comment))
else:
plt.plot(self.sf_sag*1e-3, self.hrms_sag*1e9)
plt.title('Sagittal PSD {}'.format(comment))
plt.grid(visible=True, which='major', axis='both')
plt.xlabel(r'spatial frequency $(mm^{-1})$')
plt.ylabel('rms PSD $(mm^{3})$')
if scale=='log':
plt.loglog()
csfig.canvas.mpl_connect('close_event', self.on_close_fig)
else:
plt.semilogx()
# end plot_height_rms
def on_close_fig(self,event):
from crmsfig import Crms_fig
if isinstance(event.canvas.figure, Crms_fig):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment