{ "cells": [ { "cell_type": "markdown", "source": [ "Computing the true position of the Sun\n", "======================================" ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# Imports\n", "\n", "from kanon.calendars import Calendar, Date\n", "from kanon.tables import HTable\n", "from kanon.units import Sexagesimal\n", "from kanon.units.precision import set_precision, TruncatureMode\n", "import astropy.units as u" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# 3rd of July 1327\n", "\n", "year = 1327\n", "month = 7\n", "day = 3" ], "outputs": [], "metadata": { "tags": [ "parameters" ] } }, { "cell_type": "code", "execution_count": null, "source": [ "# Day computation\n", "\n", "# We're using the Julian A.D. calendar\n", "\n", "calendar = Calendar.registry[\"Julian A.D.\"]\n", "date = Date(calendar, (year, month, day))\n", "\n", "# We need to express the numbers of days from the start of the calendar\n", "# in Sexagesimal representation.\n", "\n", "days = Sexagesimal.from_int(int(date.days_from_epoch()))\n", "\n", "days" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# Defining a function resolving a position from a mean motion table\n", "\n", "def position_from_table(tab, radix, zodiac_offset=4):\n", " # Starting with the radix\n", "\n", " result = radix * u.degree\n", "\n", " # Adding days\n", " for i, v in enumerate(days[:]):\n", " result += tab.get(v) >> i + zodiac_offset\n", "\n", " # Conversion in degrees modulo 6 zodiacal signs\n", "\n", " result %= Sexagesimal(6, 0) * u.degree\n", " return result" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# Sun mean position\n", "\n", "# Reading the table from DISHAS\n", "tab_mean_motion = HTable.read(193)\n", "tab_mean_motion" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# Mean position from days, table, and radix\n", "\n", "mean_sun_pos = position_from_table(tab_mean_motion, Sexagesimal(\"4,38;21,0,30,28\"))\n", "mean_sun_pos" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# Fixed stars\n", "\n", "tab_fixed_stars = HTable.read(236)\n", "\n", "mean_fixed_star_pos = position_from_table(tab_fixed_stars, Sexagesimal(0))\n", "mean_fixed_star_pos" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# Access and recess position\n", "\n", "tab_access_recess = HTable.read(237)\n", "\n", "access_recess_pos = position_from_table(\n", " tab_access_recess, Sexagesimal(\"5,59;12,34\"), zodiac_offset=2\n", ")\n", "access_recess_pos" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# Access and recess equation\n", "\n", "tab_eq_access_recess = HTable.read(238)\n", "\n", "with set_precision(tmode=TruncatureMode.ROUND):\n", " eq_access_recess = tab_eq_access_recess.get(access_recess_pos)\n", "eq_access_recess" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# Sun apogee\n", "\n", "with set_precision(tmode=TruncatureMode.ROUND):\n", " solar_apogee_pos = (\n", " mean_fixed_star_pos + eq_access_recess + Sexagesimal(\"1,11;25,23\") * u.degree\n", " )\n", "solar_apogee_pos" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# Sun mean argument\n", "\n", "with set_precision(tmode=TruncatureMode.ROUND):\n", " mean_arg_sun = mean_sun_pos - solar_apogee_pos\n", " if mean_arg_sun < 0:\n", " mean_arg_sun += 360\n", "mean_arg_sun" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# Sun equation\n", "\n", "tab_eq_sun = HTable.read(19)\n", "with set_precision(tmode=TruncatureMode.ROUND):\n", " eq_sun = tab_eq_sun.get(mean_arg_sun)\n", "eq_sun" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# Sun true position\n", "\n", "with set_precision(pmode=2, tmode=TruncatureMode.ROUND):\n", " true_pos_sun = mean_sun_pos - eq_sun\n", " if true_pos_sun < 0:\n", " true_pos_sun += 360\n", "true_pos_sun" ], "outputs": [], "metadata": {} } ], "metadata": { "kernelspec": { "name": "python3", "display_name": "Python 3.8.6 64-bit" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.6" }, "interpreter": { "hash": "4cd7ab41f5fca4b9b44701077e38c5ffd31fe66a6cab21e0214b68d958d0e462" } }, "nbformat": 4, "nbformat_minor": 4 }