{"id":19540609,"url":"https://github.com/armandomtz05/optikit","last_synced_at":"2026-02-02T12:34:07.907Z","repository":{"id":253613865,"uuid":"843547892","full_name":"ARMANDOMTZ05/OptiKit","owner":"ARMANDOMTZ05","description":"Solution of the paraxial wave equations using different coordinates systems","archived":false,"fork":false,"pushed_at":"2024-08-28T23:30:52.000Z","size":2907,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-21T01:49:22.643Z","etag":null,"topics":["fourier-transform","holography","numerical-methods","numpy","optics-code","optics-simulation","pillow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ARMANDOMTZ05.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-16T18:58:18.000Z","updated_at":"2024-08-28T23:52:13.000Z","dependencies_parsed_at":"2024-08-27T02:52:24.948Z","dependency_job_id":null,"html_url":"https://github.com/ARMANDOMTZ05/OptiKit","commit_stats":null,"previous_names":["armandomtz05/paraxial-wave-equation-solutions","armandomtz05/pyoptics"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMANDOMTZ05%2FOptiKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMANDOMTZ05%2FOptiKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMANDOMTZ05%2FOptiKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMANDOMTZ05%2FOptiKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ARMANDOMTZ05","download_url":"https://codeload.github.com/ARMANDOMTZ05/OptiKit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251017571,"owners_count":21523608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fourier-transform","holography","numerical-methods","numpy","optics-code","optics-simulation","pillow"],"created_at":"2024-11-11T03:05:08.565Z","updated_at":"2026-02-02T12:34:07.874Z","avatar_url":"https://github.com/ARMANDOMTZ05.png","language":"Python","readme":"# OptiKit\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"resources/OptiKit.png\"  width=\"50%\"/\u003e\n\u003c/p\u003e\n\n## Summary\nThis Python module provides a comprehensive suite of tools for studying and applying optics principles, particularly focusing on wave optics. The module is designed to generate families of solutions to the paraxial wave equation, which is fundamental in understanding the behavior of light in optical systems. Additionally, it includes functionalities for hologram generation, light propagation, and analysis of Stokes parameters, which describe the polarization state of light. These tools are essential for research and applications in optical engineering, laser physics, and related fields.\n\nSolutions to the paraxial wave equation in various coordinate systems.\n* Hermite-Gaussian Modes in cartesian coordinates\n* Laguerre-Gaussian Modes in cylindrical coordinates\n* Ince-Gaussian Modes in elyptical coordinates\n\n\n## Library installation\n\n### Requirements\n\n* numpy\n* pillow\n* scipy\n* matplotlib\n* python \u003e= 3.10\n\n```\npip install optikit\n```\n\n## Gaussian Modes\n$U(r, \\theta, z) = \\frac{\\omega_0}{\\omega(z)}\\exp{\\frac{-r^2}{\\omega(z)^2}} \\exp{\\left(-i\\left(kz + k\\frac{r^2}{2R(z)} - \\Psi(z) \\right)\\right)}$\n\nwhere r is the radius, $\\omega_0$ represents the beam width at $z = 0$, $\\omega(z) = \\omega_0\\sqrt{1 + z^2/z_R^2}$ describes the beam width, $R(z) = z + z^2_R/z$ is the radius of curvature of the phase front, $z_R = k\\omega_0^2/2$ is the Rayleigh range and $\\Psi = arctan(z/z_R)$ is the Gouy shift.\n\n### Code implementation\n```\nfrom optikit.Beam import Beam\n\nGauss = Beam(type = 'Gaussian',\n            size = 5e-3, # in meters\n            shape = 501, # Number of points\n            w0 = 1e-3, # Beam width\n            k = (2*np.pi/632.8e-9), # wavenumber\n            z = 0)\nGauss.plot_amplitude()\n```\n\n## Ince-Gaussian Modes\nThe Ince-Gaussian (IG) mode is a solution to the paraxial wave equation expressed in elliptic coordinates $(\\xi, \\eta)$. The general form of an Ince-Gaussian beam $(\\xi, \\eta, z)$ can be written as:\n\n$\\text{IG}_{p,m}^e(\\mathbf{r}, \\epsilon) = \\frac{C\\omega_0}{\\omega(z)}C_p^m(i\\xi, \\epsilon)C_p^m(\\eta, \\epsilon)\\exp\\left[\\frac{-r^2}{\\omega^2(z)}\\right] \\exp\\left(i\\left[kz + \\frac{kr^2}{2R(z)} - (p - 1) \\Psi(z)\\right]\\right)$,\n\n$\\text{IG}_{p,m}^o(\\mathbf{r}, \\epsilon) = \\frac{S\\omega_0}{\\omega(z)}S_p^m(i\\xi, \\epsilon)S_p^m(\\eta, \\epsilon)\\exp\\left[\\frac{-r^2}{\\omega^2(z)}\\right] \\exp\\left(i\\left[kz + \\frac{kr^2}{2R(z)} - (p - 1) \\Psi(z)\\right]\\right)$\n\nwhere r is the radius, $\\omega_0$ represents the beam width at $z = 0$, $\\omega(z) = \\omega_0\\sqrt{1 + z^2/z_R^2}$ describes the beam width, $R(z) = z + z^2_R/z$ is the radius of curvature of the phase front, $z_R = k\\omega_0^2/2$ is the Rayleigh range and $\\Psi = arctan(z/z_R)$ is the Gouy shift. C and S are normalization constants and the superindices $e$ and $o$ refer to even and odd modes, respectively.\n\n\n### Code implementation\n\n```\nfrom optikit.Beam import Beam\n\nInce = Beam(type = 'InceGaussian',\n            size = 5e-3, \n            shape = 501,\n            parity = 0,\n            p = 2,\n            m = 2,\n            e = 2,            \n            w0 = 1e-3, \n            k = (2*np.pi/632.8e-9),\n            z = 0)\nInce.plot_amplitude()\n```\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"resources/InceGauss.JPG\"  width=\"30%\"/\u003e\n\u003c/p\u003e\n\nCreated using a DMD\n\n## Laguerre-Gaussian modes\n\n$\\text{LG}_{p}^l(r, \\phi, z) = \\frac{1}{w(z)} \\sqrt{\\frac{2p!}{\\pi (p + |l|)!}} \\left(\\frac{\\sqrt{2} r}{\\omega(z)}\\right)^{|l|} L_p^{|l|}\\left(\\frac{2r^2}{\\omega(z)^2}\\right) \\exp\\left(-\\frac{r^2}{\\omega(z)^2}\\right) \\exp\\left(-i \\left(k z + k \\frac{r^2}{2 R(z)} - l \\phi - (2p + |l| + 1)\\Psi(z)\\right)\\right)$\n\nwhere r is the radius, $\\omega_0$ represents the beam width at $z = 0$, $\\omega(z) = \\omega_0\\sqrt{1 + z^2/z_R^2}$ describes the beam width, $R(z) = z + z^2_R/z$ is the radius of curvature of the phase front, $z_R = k\\omega_0^2/2$ is the Rayleigh range and $\\Psi = arctan(z/z_R)$ is the Gouy shift.\n\n### Code implementation\n```\nfrom optikit.Beam import Beam\n\nLag = Beam(type = 'LaguerreGauss',\n            size = 5e-3, \n            shape = 501,\n            p = 2,\n            l = 2,         \n            w0 = 1e-3, \n            k = (2*np.pi/632.8e-9),\n            z = 0)\nLag.plot_amplitude()\n```\n\n## Hermite-Gaussian modes\n\n$\\text{HG}_{m}^n(x, y, z) = \\frac{1}{w(z)} \\sqrt{\\frac{2}{\\pi \\, 2^{n+m} \\, n! \\, m!}} \\, H_n\\left(\\frac{\\sqrt{2} \\, x}{w(z)}\\right) H_m\\left(\\frac{\\sqrt{2} \\, y}{w(z)}\\right) \\exp\\left(-\\frac{x^2 + y^2}{w(z)^2}\\right) \\exp\\left(-i \\left(k z + (n + m + 1) \\Psi(z) - \\frac{k (x^2 + y^2)}{2 R(z)}\\right)\\right)$\n\nwhere r is the radius, $\\omega_0$ represents the beam width at $z = 0$, $\\omega(z) = \\omega_0\\sqrt{1 + z^2/z_R^2}$ describes the beam width, $R(z) = z + z^2_R/z$ is the radius of curvature of the phase front, $z_R = k\\omega_0^2/2$ is the Rayleigh range and $\\Psi = arctan(z/z_R)$ is the Gouy shift.\n\n### Code implementation\n\n```\nfrom optikit.Beam import Beam\n\nHerm = Beam(type = 'HermiteGaussian',\n            size = 5e-3, \n            shape = 501,\n            n = 2,\n            m = 2,          \n            w0 = 1e-3, \n            k = (2*np.pi/632.8e-9),\n            z = 0)\nHerm.plot_amplitude()\n```\n\n## Hologram generation\nThe [slmpy](https://github.com/wavefrontshaping/slmPy/tree/master) module can be used to project the holograms in a SLM, the code implementation should be as bellow:\n\n```\nfrom optikit.Beam import Beam\nimport slmpy\n\nInce = Beam(type = 'InceGaussian',\n            size = 5e-3, \n            shape = 501,\n            parity = 0,\n            p = 2,\n            m = 2,\n            e = 2,            \n            w0 = 1e-3, \n            k = (2*np.pi/632.8e-9),\n            z = 0)\n\nslm = slmpy.SLMdisplay()\nHologram = Ince.Beam.Hologam(gamma=np.pi/3000, theta = np.pi/4, save= True)\nslm.updateArray(Hologram)\n\n```\n## Propagator\nThe equation is solve numericaly by applying a transfer function.\n\n$U(z) = \\\\mathfrak{F}^{-1}\\\\left\\\\{H\\\\cdot \\\\mathfrak{F}\\\\{U_0\\\\}\\\\right\\\\}$\n\nwhere $H = \\exp\\left(-i kz\\sqrt{k_0^2 -\\left(k_x^2+k_y^2\\right)}\\right)$ and $U_0$ represents the initial field.\n\n### Code implementation\nThe `Propagator` class supports as an input a `np.ndarray` ans `OptiKit.Beam` class\n\n```\nfrom optikit.optics import propagator\nfrom optikit.Beam import Beam\n\nGauss = Beam(type = 'Gaussian',\n            size = 2e-3, \n            shape = 2**8, \n            w0 = 1e-3, \n            k = (2*np.pi/632.8e-9),\n            z = 0)\n\nGauss.plot_amplitude()\nGauss_z = Propagator(beam= Gauss)\nGauss_z.propagate(zi = 1/2 * (2*np.pi/632.8e-9) * (1e-3 ** 2) , zn = 2**8)\nGauss_z.plot()\n```\n\n## Stokes parameters\nA classical way to measure the stokes paramters is the following:\n\n| Polarizer axis angle| Wave plate fast axis angle| Power Measurement|\n|---------------------|---------------------------|------------------|\n| $0°$                | -                         | $P_1$            |\n| $90°$               | -                         | $P_2$            |\n| $45°$               | -                         | $P_3$            |\n| $45°$               | $0°$                      | $P_4$            |\n\n### Stokes equations\n* $S_0 = P_1 + P_2$\n* $S_1 = P_1 - P_2$\n* $S_2 = 2P_3 - S_0$\n* $S_3 = S_0 - 2P_4$\n\n### Ellipse Parameters\n* $\\psi = \\frac{1}{2}\\text{arctan}\\left(\\frac{S_2}{S_1}\\right)$\n* $E_{ox} = \\sqrt{0.5(S_0 + S_1)}$\n* $E_{oy} = \\sqrt{0.5(S_0 - S_1)}$\n\n### Example\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"resources/Polarization.png\"  width=\"30%\"/\u003e\n\u003c/p\u003e\n\n## References\n\n[1] R. W. Gerchberg and W. O. Saxton, “A practical algorithm for the determination of the phase from image and diﬀraction plane pictures”, Optik 35, 237 (1972).\n\n[2] K. Mitchell, S. Turtaev, M. Padgett, T. Cizmár, and D. Phillips, “High-speed spatial control of the intensity, phase and polarisation of vector beams using a digital micro-mirror device”, Opt. Express 24, 29269-29282 (2016).\n\n[3] Forbes A. 2014, Laser Beam Propagation: Generation and Propagation of Customized Light (London: Taylor and Francis).\n\n[4] Bandres MA, Gutiérrez-Vega JC. Ince-Gaussian modes of the paraxial wave equation and stable resonators. J Opt Soc Am A Opt Image Sci Vis. 2004 May;21(5):873-80. doi: 10.1364/josaa.21.000873. PMID: 15139441.\n\n[5] Beth Schaefer, Edward Collett, Robert Smyth, Daniel Barrett, and Beth Fraher \"Measuring the Stokes polarization parameters,\" Am. J. Phys. 75, 163-168 (2007).\n\n[6] Siegman, A. E. (1986). Lasers. Taiwan: University Science Books.\n\n[7] Vallone, Giuseppe. (2015). On the properties of circular beams: normalization, Laguerre–Gauss expansion, and free-space divergence. Optics Letters. 40. 10.1364/OL.40.001717. \n\n[8] Capps DM. Derivation and application of a Green function propagator suitable for nonparaxial propagation over a two-dimensional domain. J Opt Soc Am A Opt Image Sci Vis. 2019 Apr 1;36(4):563-577. doi: 10.1364/JOSAA.36.000563. PMID: 31044976.\n\n## To do\n\nThis project is still in development. New features will be added in upcoming versions.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmandomtz05%2Foptikit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farmandomtz05%2Foptikit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmandomtz05%2Foptikit/lists"}