Every galaxy in the distant universe carries a cosmic fingerprint—subtle distortions in their shapes caused by the gravitational pull of invisible dark matter between us and them. This phenomenon, called weak gravitational lensing, offers our most direct window into mapping the universe’s hidden mass distribution, but extracting these whisper-faint signals requires sophisticated mathematical reconstruction techniques.

SMPy brings the powerful Kaiser-Squires inversion method into the modern Python ecosystem, transforming raw galaxy shear measurements into detailed convergence maps that reveal where dark matter lurks. The toolkit implements both the classic 1993 algorithm and the enhanced KS+ method, which corrects for missing data using sparsity priors and reduces border effects through intelligent field extension. Beyond basic mass reconstruction, SMPy offers aperture mass mapping for localized measurements, E/B-mode decomposition for systematic error analysis, and peak statistics with customizable detection thresholds—all wrapped in an intuitive, ‘Pythonic’ interface.

Whether you’re a graduate student mapping galaxy clusters or a seasoned researcher analyzing wide-field surveys, SMPy handles both weighted catalogs and irregular galaxy distributions with built-in spherical geometry support. With comprehensive documentation and robust error quantification through spatial randomization techniques, this toolkit democratizes weak lensing analysis for astrophysicists at every level, making the invisible universe finally visible.


Stars: 9
💻 Language: Python
🔗 Repository: GeorgeVassilakis/SMPy