pydeepskylog User Guide
This guide provides practical examples for common use cases with the pydeepskylog package.
Table of Contents
- Description
- Installation
- Basic Usage
- Magnitude and Sky Brightness Conversions
- Contrast Reserve Calculation
- Optimal Detection Magnification
- DeepskyLog API Integration
- Validation Utilities
- Logging Configuration
- API
- Astronomical Background
- Contributing
- License
- Changelog
- Acknowledgements
Description
A Python package with utilities for deep-sky observations. This version of pydeepskylog provides the following functionality:
- Calculating of contrast reserve and optimal detection magnification for deep-sky objects.
- Conversion of magnitudes to SQM value and bortle scale and vice versa.
- Fetching instruments, eyepieces, lenses, and filters from a DeepskyLog user account.
Installation
Install via pip:
pip install pydeepskylog
Development dependencies can be installed with:
pip install -e .[dev]
Basic Usage
Import the main modules:
import pydeepskylog.magnitude as mag
import pydeepskylog.contrast_reserve as cr
Magnitude and Sky Brightness Conversions
Convert NELM to SQM:
sqm = mag.nelm_to_sqm(6.2)
print(f"SQM: {sqm:.2f}")
Convert SQM to Bortle scale:
bortle = mag.sqm_to_bortle(21.0)
print(f"Bortle class: {bortle}")
Contrast Reserve Calculation
Calculate the contrast reserve for an object:
reserve = cr.contrast_reserve(
sqm=21.0,
telescope_diameter=200, # mm
magnification=100,
surf_brightness=None,
magnitude=10.5,
object_diameter1=120, # arcsec
object_diameter2=60 # arcsec
)
print(f"Contrast reserve: {reserve:.2f}")
Optimal Detection Magnification
Find the best magnification for detection:
magnifications = [50, 75, 100, 150, 200]
optimal = cr.optimal_detection_magnification(
sqm=21.0,
telescope_diameter=200,
surf_brightness=None,
magnitude=10.5,
object_diameter1=120,
object_diameter2=60,
magnifications=magnifications
)
print(f"Optimal magnification: {optimal}")
DeepskyLog API Integration
Fetch user instruments:
from pydeepskylog.deepskylog_interface import dsl_instruments
instruments = dsl_instruments("your_username")
for inst_id, inst in instruments.items():
print(inst["name"], inst["diameter"])
The API endpoints are documented in the API Endpoints section.
Validation Utilities
Validate a positive number:
from pydeepskylog.validation import validate_positive
validate_positive(42, "Telescope diameter")
Logging Configuration
Set up logging for debugging:
from pydeepskylog.logging_config import configure_logging
import logging
configure_logging(logging.DEBUG)
API
Documentation for the API is available at Read the Docs.
Astronomical background
Contrast Reserve
The contrast reserve is a measure of the difference in brightness between the object and the sky background. It is calculated as the difference between the object's surface brightness and the sky background brightness. The contrast reserve is a useful metric for determining the visibility of deep sky objects through a telescope.
The higher the contrast reserve, the easier it is to see the object. The following table can be used to interpret the contrast reserve:
| Contrast Reserve | Visibility | Typical color |
|---|---|---|
| < -0.2 | Not visible | dark grey |
| -0.2 < CR < 0.1 | Questionable | light grey |
| 0.1 < CR < 0.35 | Difficult | dark red |
| 0.35 < CR < 0.5 | Quite difficult to see | light red |
| 0.5 < CR < 1.0 | Easy to see | dark green |
| 1.0 < CR | Very easy to see | light green |
The contrast reserved is calculated for the object as a whole. Smaller details in the object might be visible even if the contrast reserve of the object as a whole is below -0.2. This is certainly the case for galaxies, where the core might be much brighter than the outer regions.
It is important to note that the contrast reserve is a theoretical value and that the actual visibility of an object will depend on a number of other factors, including the observer's experience, the transparency of the sky, and the seeing conditions. The contrast reserve is just a guideline.
The calculation of the contrast reserve depends heavily on the quality of the object database. A small error in the object's magnitude or size can lead to a large error in the contrast reserve.
Only if the observer tries to observe the object, he/she will know if the object is visible or not.
Optimal Detection Magnification
The optimal detection magnification is the magnification at which the object is most easily visible. Take into account that the optimal detection magnification is not the same as the best magnification for observing details in an object, but for the object as a whole.
Magnitudes
Conversion methods are provided to convert magnitudes to SQM value and bortle scale and vice versa.
Different formulae are available to convert magnitudes to SQM value. The formula used here converts a sqm value of 22.0 to a naked eye limiting magnitude of 6.6. The faintest star offset can be given to the formula. If taking a value of -1.4 for the faintest star offset, the formula converts a sqm value of 22.0 to a naked eye limiting magnitude of 8.0.
| Measurement | Description | Conversion Functions |
|---|---|---|
| NELM | Naked Eye Limiting Magnitude, the faintest star visible to the naked eye under ideal conditions. | nelm_to_sqm(), nelm_to_bortle() |
| SQM | Sky Quality Meter, a measure of sky brightness in magnitudes per square arcsecond. | sqm_to_nelm(), sqm_to_bortle() |
| Bortle Scale | A qualitative scale that classifies the night sky based on light pollution and visibility. | bortle_to_nelm(), bortle_to_sqm() |
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. See CONTRIBUTING.md for details on how to contribute.
License
Changelog
See CHANGELOG.md for a detailed list of changes and updates to the package.
Acknowledgements
This package is inspired by the DeepskyLog website and the code is based on the formulas used in DeepskyLog. We would like to thank the DeepskyLog developers team.
Metadata
Release files for pydeepskylog 1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pydeepskylog-1.6.tar.gz | 37.9 kB | With provenance | Details for pydeepskylog-1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydeepskylog-1.6-py3-none-any.whl | Python 3 | none | any | Details for pydeepskylog-1.6-py3-none-any.whl |
Total release size: 77.7 kB
Release files / pydeepskylog-1.6.tar.gz
| Download URL | pydeepskylog-1.6.tar.gz |
|---|---|
| Size | 37.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ddeae6d004817cfb50d5c9e0cecaa4654ae72a82cd201bbc5350fa880e1e3e61
|
|
BLAKE2b-256 checksum How to use checksums |
45edea27d8e554cce16ba402aa349251c9d1bbc269efa93a9546a389b9ea1e4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2025.
Transparency logRelease files / pydeepskylog-1.6-py3-none-any.whl
| Download URL | pydeepskylog-1.6-py3-none-any.whl |
|---|---|
| Size | 39.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f4fa53b1f980a61846a3e79fa8d4134f809703d9ac346dc98bfc49091ee237f9
|
|
BLAKE2b-256 checksum How to use checksums |
9d00e7f11ab824ef760fe22c93012b90631d8772c7af3a58d22f15d0b383f51e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2025.
Transparency logSecurity for pydeepskylog 1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pydeepskylog-1.6.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 30, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.