How inlnano/pymoe works
Project type and purpose
• This is a pure-Python, open-source scientific library (“pyMOE”) for designing and producing masks for micro-optical elements. It exposes functions and classes (under the pyMOE/ package) that implement mask generation, mask operations, CAD conversion, hologram computation, and field propagation. Users interact with it via Python scripts or Jupyter notebooks, and it provides documentation via Sphinx.
File structure
• Top-level directories and files:
• pyMOE/ – the core Python package containing all functional modules
• notebooks/ and docs/notebooks/ – example Jupyter notebooks demonstrating use
• docs/ and docs/source/ – Sphinx configuration and documentation source
• tests/ – pytest unit tests exercising each module
• config files (requirements.txt, .readthedocs.yaml, Sphinx makefiles)
• Key modules in pyMOE/:
– generate.py, dither.py, metas.py, holograms.py, propagate.py – core algorithms
– importing.py, export.py, gdsconverter.py, gds_klops.py – file I/O and CAD integration
– plotting.py, utils.py – visualization and utilities
• Build/deploy: standard Python packaging, ReadTheDocs integration for docs.
Read README for additional insights
• Features: mask design (analytical/numerical), dithering, metasurfaces, propagation, CAD I/O
• Usage: notebooks under notebooks/; tests via pytest
• Dependencies: scientific stack (likely numpy, scipy, matplotlib, gdstk or similar)
a. Main components
• Library core modules (grouped by functionality):
• Mask generation layer (generate.py, dither.py)
• Metasurfaces design (metas.py)
• Hologram routines (holograms.py)
• Field propagation (propagate.py)
• I/O layer: CAD conversion and file import/export (importing.py, export.py, gdsconverter.py, gds_klops.py)
• Utility layer: plotting, common helpers (plotting.py, utils.py, sag_functions.py)
• External dependencies: NumPy/SciPy, Matplotlib, GDS libraries
• Users & integration:
• Jupyter notebooks and Python scripts call the API
• Sphinx docs generation
• Test harness: pytest suite
b. Relationships and interactions
• Data flow: analytical input → generate → dither → final mask → export → CAD file
• Propagation functions consume mask data arrays, pass through numerical solvers, return field objects
• Plotting functions take outputs from any processing stage to render figures
• Tests invoke modules in isolation to verify behavior
c. Important architectural patterns
• Modular, layered design: separate algorithmic, I/O, and utility concerns
• Functional API: stateless functions returning data structures
• Notebook-driven examples: documentation and usage examples co-located with code
• Test-first quality: one test per major module
d. Key technologies/frameworks
• Python 3.7+ runtime
• NumPy/SciPy for array and numerical operations
• Matplotlib (or similar) for plotting
• GDSII handling library (e.g., gdsconverter, possibly gdspy/gdstk)
• Sphinx for docs (docs/, ReadTheDocs integration)
• pytest for testing