Skip to content

Instantly share code, notes, and snippets.

@jayendra13
Created March 28, 2022 16:20
Show Gist options
  • Save jayendra13/e8405373f698e0c2e30805a619533c59 to your computer and use it in GitHub Desktop.
Save jayendra13/e8405373f698e0c2e30805a619533c59 to your computer and use it in GitHub Desktop.
# https://www.tifr.res.in/~vahia/tithi-calculations.pdf
import datetime
from astropy.coordinates import get_body
from astropy.time import Time
from astropy.coordinates import EarthLocation
NUM_TITHIS = 15
def get_tithi(timestamp, location):
sun = get_body('sun', timestamp, location)
moon = get_body('moon', timestamp, location)
# TODO: Add the correction constant from the paper
diff = sun.position_angle(moon).degree
paksha = 'કૃષ્ણ' if diff > 180 else 'શુક્લ'
tithi = (int(diff)) % NUM_TITHIS
return (tithi, paksha)
if __name__ == "__main__":
now = Time(datetime.datetime.now())
location = EarthLocation.from_geodetic(lon=72, lat=23, height=0)
tithi = get_tithi(now, location)
print(tithi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment