Skip to main content

Various calculations for Islamic purposes

Project description

islamic_times: An Astronomical Library for Islamic Astronomical Calculations

The IslamicTimes is a Python library dedicated to providing comprehensive solutions for various Islamic astronomical calculations. This includes but is not limited to, the calculation of prayer times, the positions of the sun and the moon, the moon phases, as well as related astronomical phenomena such as solar and lunar eclipses.

Features

  • Prayer Times: The library calculates the five daily Islamic prayer times based on geographical location and date. It includes Fajr, Zuhr, Asr, Maghrib, and Isha.

  • Different Prayer Time Methods Included: Seven methods to calculate prayer times, along with methods that allow for complete customization of what solar hour angle determines the time of a prayer.

  • Date Conversion: Conversion between Gregorian and Hijri (Islamic) dates.

  • Sun & Moon Positions: Provides the position (declination, right ascension, altitude, azimuth) of the sun and the moon at a given time.

  • Moon Illumination: Calculates the moon's illumination percentage.

  • Moon Phases: Provides the dates and times of the upcoming moon phases: New Moon, First Quarter, Full Moon, and Last Quarter.

  • New Moon Visibility: Calculates the visibility of an upcoming new moon according to Yallop, 1997 (a.k.a HMNAO TN No. 69) or Odeh, 2006.

  • Global Lunar Crescent Visibility Maps: Included is a mapper.py script that shows the visibility of a new moon for the day of conjunction, and one and two days after it.

  • Direction to Mecca (Qibla): Provides the direction and distance to Mecca from any location worldwide.

Usage

Below is a simple usage example:

from islamic_times import islamic_times as it
from datetime import datetime

##### Calculation #####
local = it.ITLocation(43.74506, -79.30947, 170.5, datetime.now())

##### Outputs #####
# Date & Time
temp = local.dates_times()
print("Time & Date")
print(f"\tGregorian Date:\t\t{temp['gregorian']}")
print(f"\tIslamic Date:\t\t{temp['hijri']}")
print(f"\t24h-Time:\t\t{temp['time']}\n\tTime Zone:\t\t{temp['timezone']} {temp['utc_offset']}")
print(f"\tLocal JD:\t\t{temp['jd']}")
print(f"\tEquation of time:\t{temp['eq_of_time']} minutes")
print(f"\tEstimated ΔT:\t\t{temp['deltaT']}s")

# Prayer Times
temp = local.calculate_prayer_times()
temp = local.prayer_times()
print("Local Prayer Times")
print(f"\tFajr:\t\t\t{temp['fajr']}")
print(f"\tSunrise:\t\t{temp['sunrise']}")

# More Outputs as required...

In the above script, the ITLocation class is initialized with the latitude, longitude, and elevation of the location, as well as the date for which calculations are to be performed. The dates_times(), calculate_prayer_times() and prayer_times() methods are then called to retrieve the observer date & time, then calculate the local prayer times (i.e. local according to the observer specified timezone), then retrieve them.

A more comprehensive example of usage can be seen in test.py.

Installation

You can install this package using pip:

pip install islamic_times

Requirements

Python 3.6 and above is required.

Contributing

We welcome contributions to this project. Please feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

islamic_times-1.4.1.tar.gz (28.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

islamic_times-1.4.1-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file islamic_times-1.4.1.tar.gz.

File metadata

  • Download URL: islamic_times-1.4.1.tar.gz
  • Upload date:
  • Size: 28.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for islamic_times-1.4.1.tar.gz
Algorithm Hash digest
SHA256 732ac48181d1a9deb42c452d25e6f67790b98c5228ce7227d78dff45a21fb517
MD5 091646d1ecbaad854866e3f03d691c4a
BLAKE2b-256 ef979377f2e017bc3bba4f9d690d9b09ec4f6ad8fbb24094161a6f6df94d911f

See more details on using hashes here.

File details

Details for the file islamic_times-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: islamic_times-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 30.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for islamic_times-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8bd4d2b3f1698ec557b69a7a107bd2a2a0e2bcf7bd9601b609c318cc1d05c846
MD5 02b2a8a302cc7ec4e94701a8395bd64c
BLAKE2b-256 3734e60cc03f0391fd0b12d2149f0bc88f9f5606dc60b5778b8ceb0fd1c9aea7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page