A Python script to identify sunspots in JPG images of the Sun…

I’m sharing a Python script (“sunspot_area13_1.py”), created with Chat GPT, which analyses white-light images of the solar disc captured in JPG format, tags areas it believes contains sunspots with a red border, and estimates the proportion of the apparent solar disc covered by sunspots in the image.

The original image is not altered. A separate analysis image is created, along with some other diagnostic images and text output in the Terminal.

Best results are achieved from images with even illumination and clear contrast. Colour saturation or image resolution are largely unimportant. The script omits a small “safe area” near the edge of the solar disc, to avoid generating high numbers of false-positive detections. The script occasionally misses a sunspot in or near to the region of limb-darkening, but this seems to be infrequent and does not disturb trends inferred from long-term data sets.

The files are stored in my area on ‘Pcloud’ (Europe’s secure & private cloud store, avoiding United Statesian tools). The script can be found here. Two brief documentation files can be found here.

Notes:
1) I use Linux Mint and have not tested this script in a Windows environment.
2) The script needs to be run as a .py file from the OS terminal/command line, not from the interactive Python terminal.
3) You may need to install the OpenCV and NumPy libraries into your Python environment, as they are not defaulted.

Disclaimer:
1 – No warranty is implied or given for this script. You are responsible for checking the appropriateness of using it on your machine.
3 – By running/using this script, you accept and agree that Lee J. Russell will not be held responsible for any damage or loss of data that might occur when using/running it.

Published by Lee J. Russell

Often having a Cold War influence, my stories explore desperate situations that take people to their physical and emotional limits. Find me on Twitter as @LeeJ_Russell or at leejrussell.com

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.