.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\example_01_fit_concave_ellipsoid_with_tol.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_example_01_fit_concave_ellipsoid_with_tol.py: Example 01: Fit concave ellipsoid ================================= This example shows how to fit a concave ellipsoid to simulated data using the XMF library. .. GENERATED FROM PYTHON SOURCE LINES 8-76 .. image-sg:: /auto_examples/images/sphx_glr_example_01_fit_concave_ellipsoid_with_tol_001.png :alt: Concave Ellipsoid, Fitting, Residual :srcset: /auto_examples/images/sphx_glr_example_01_fit_concave_ellipsoid_with_tol_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np import xmf # 1. Define lateral coordinates x_range = 200e-3 y_range = 20e-3 x_num = 201 y_num = 21 x1d = np.linspace(-x_range/2, x_range/2, x_num) y1d = np.linspace(-y_range/2, y_range/2, y_num) x2d, y2d = np.meshgrid(x1d, y1d) # 2. Set mirror parameters # 2.1. Shape parameters abs_p = 30 abs_q = 0.3 theta = 30e-3 # 2.2. Pose parameters x_i = -1e-3 y_i = -2e-4 z_i = 3e-7 alpha = 2e-6 beta = 1e-5 gamma = 0.5e-3 # 2.3. True parameters as dictionary true_params_dict = { 'p': abs_p, 'q': abs_q, 'theta': theta, 'x_i': x_i, 'y_i': y_i, 'z_i': z_i, 'alpha': alpha, 'beta': beta, 'gamma': gamma } # 3. Set measurement noise height_measurement_noise_std = 0.5e-9 slope_measurement_noise_std = 100e-9 # 4. Demonstarte the fitting # 4.1. Set input parameters as dictionary input_params_dict = { 'p': abs_p, 'q': abs_q, 'theta': theta } # 4.2. Set the tolerance dictionary tol_dict = { 'p': 0, 'q': 0, 'theta': 0 } # 4.3. Generate the surface z2d = xmf.generate_2d_curved_surface_height(xmf.standard_concave_ellipsoid_height, x2d, y2d, abs_p, abs_q, theta, x_i, y_i, z_i, alpha, beta, gamma) # 4.4. Adding noise to mimic the measured data z2d_measured = z2d + np.random.randn(z2d.shape[0], z2d.shape[1])*height_measurement_noise_std # 4.5. Fit the surface shape z2d_res, z2d_fit, opt_params_dict, opt_params_ci_dict, _ = xmf.fit_concave_ellipsoid_height(x2d, y2d, z2d_measured, input_params_dict, tol_dict) # 4.6. Show fitting results xmf.fig_show_2d_fitting_map(x2d, y2d, z2d_measured, z2d_fit, z2d_res, true_params_dict, opt_params_dict, opt_params_ci_dict,'Concave Ellipsoid') .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.527 seconds) .. _sphx_glr_download_auto_examples_example_01_fit_concave_ellipsoid_with_tol.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_01_fit_concave_ellipsoid_with_tol.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_01_fit_concave_ellipsoid_with_tol.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_01_fit_concave_ellipsoid_with_tol.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_