{ "cells": [ { "source": [ "Computing the true position of the Sun\n", "======================================" ], "cell_type": "markdown", "metadata": {} }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Imports\n", "\n", "import numpy as np\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, PrecisionMode\n", "import astropy.units as u" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "tags": [ "parameters" ] }, "outputs": [], "source": [ "# 3rd of July 1327\n", "\n", "year = 1327\n", "month = 7\n", "day = 3" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "02,14,35,04 ; " ] }, "metadata": {}, "execution_count": 3 } ], "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_float(date.days_from_epoch(), 0)\n", "\n", "days" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# Defining a function resolving a position from a mean motion table\n", "\n", "def position_from_table(ndays, tab, radix, zodiac_offset=4, width=9):\n", " # Starting with the radix\n", "\n", " result = radix\n", "\n", " # Adding days\n", " with set_precision(pmode=PrecisionMode.MAX):\n", " for i, v in enumerate(ndays[:]):\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" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "\n", " Days Entries \n", " d deg \n", "Sexagesimal Sexagesimal \n", "----------- --------------------------\n", " 01 ; 59,08,19,37,19,13,56 ; \n", " 02 ; 01,58,16,39,14,38,27,52 ; \n", " 03 ; 02,57,24,58,51,57,41,48 ; \n", " 04 ; 03,56,33,18,29,16,55,44 ; \n", " 05 ; 04,55,41,38,06,36,09,40 ; \n", " 06 ; 05,54,49,57,43,55,23,36 ; \n", " 07 ; 06,53,58,17,21,14,37,32 ; \n", " 08 ; 07,53,06,36,58,33,51,28 ; \n", " 09 ; 08,52,14,56,35,53,05,24 ; \n", " ... ...\n", " 51 ; 50,16,04,40,43,20,50,36 ; \n", " 52 ; 51,15,13,00,20,40,04,32 ; \n", " 53 ; 52,14,21,19,57,59,18,28 ; \n", " 54 ; 53,13,29,39,35,18,32,24 ; \n", " 55 ; 54,12,37,59,12,37,46,20 ; \n", " 56 ; 55,11,46,18,49,57,00,16 ; \n", " 57 ; 56,10,54,38,27,16,14,12 ; \n", " 58 ; 57,10,02,58,04,35,28,08 ; \n", " 59 ; 58,09,11,17,41,54,42,04 ; \n", " 01,00 ; 59,08,19,37,19,13,56,00 ; " ], "text/html": "HTable length=60\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
DaysEntries
ddeg
SexagesimalSexagesimal
01 ;59,08,19,37,19,13,56 ;
02 ;01,58,16,39,14,38,27,52 ;
03 ;02,57,24,58,51,57,41,48 ;
04 ;03,56,33,18,29,16,55,44 ;
05 ;04,55,41,38,06,36,09,40 ;
06 ;05,54,49,57,43,55,23,36 ;
07 ;06,53,58,17,21,14,37,32 ;
08 ;07,53,06,36,58,33,51,28 ;
09 ;08,52,14,56,35,53,05,24 ;
......
51 ;50,16,04,40,43,20,50,36 ;
52 ;51,15,13,00,20,40,04,32 ;
53 ;52,14,21,19,57,59,18,28 ;
54 ;53,13,29,39,35,18,32,24 ;
55 ;54,12,37,59,12,37,46,20 ;
56 ;55,11,46,18,49,57,00,16 ;
57 ;56,10,54,38,27,16,14,12 ;
58 ;57,10,02,58,04,35,28,08 ;
59 ;58,09,11,17,41,54,42,04 ;
01,00 ;59,08,19,37,19,13,56,00 ;
" }, "metadata": {}, "execution_count": 5 } ], "source": [ "# Sun mean position\n", "\n", "# Reading the table from DISHAS\n", "tab_mean_motion = HTable.read(193, format=\"dishas\")\n", "tab_mean_motion" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "" ], "text/latex": "$01,47 ; 58,21,32,17,28,35,44 \\; \\mathrm{{}^{\\circ}}$" }, "metadata": {}, "execution_count": 6 } ], "source": [ "# Mean position from days, table, and radix\n", "\n", "mean_sun_pos = position_from_table(days, tab_mean_motion, Sexagesimal(\"4,38;21,0,30,28\") * u.degree)\n", "mean_sun_pos" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "" ], "text/latex": "$09 ; 44,44,33,52,35,08,48 \\; \\mathrm{{}^{\\circ}}$" }, "metadata": {}, "execution_count": 7 } ], "source": [ "# Fixed stars\n", "\n", "tab_fixed_stars = HTable.read(236, format=\"dishas\")\n", "\n", "mean_fixed_star_pos = position_from_table(days, tab_fixed_stars, 0)\n", "mean_fixed_star_pos" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "" ], "text/latex": "$01,07 ; 25,45,56,14,16 \\; \\mathrm{{}^{\\circ}}$" }, "metadata": {}, "execution_count": 8 } ], "source": [ "# Access and recess position\n", "\n", "tab_access_recess = HTable.read(237, format=\"dishas\")\n", "\n", "access_recess_pos = position_from_table(days, tab_access_recess, Sexagesimal(\"5,59;12,34\")*u.degree, zodiac_offset=2, width=7)\n", "access_recess_pos" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "" ], "text/latex": "$08 ; 18,18,36,54,20 \\; \\mathrm{{}^{\\circ}}$" }, "metadata": {}, "execution_count": 9 } ], "source": [ "# Access and recess equation\n", "\n", "tab_eq_access_recess = HTable.read(238, format=\"dishas\")\n", "\n", "with set_precision(pmode=PrecisionMode.MAX, tmode=TruncatureMode.ROUND):\n", " eq_access_recess = tab_eq_access_recess.get(access_recess_pos.value)\n", "eq_access_recess" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "" ], "text/latex": "$01,29 ; 28,26,10,46,55,08,48 \\; \\mathrm{{}^{\\circ}}$" }, "metadata": {}, "execution_count": 10 } ], "source": [ "# Sun apogy\n", "\n", "with set_precision(pmode=PrecisionMode.MAX, tmode=TruncatureMode.ROUND):\n", " solar_apogee_pos = mean_fixed_star_pos + eq_access_recess + Sexagesimal(\"1,11;25,23\") * u.degree\n", "solar_apogee_pos" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "" ], "text/latex": "$18 ; 29,55,21,30,33,26,56 \\; \\mathrm{{}^{\\circ}}$" }, "metadata": {}, "execution_count": 11 } ], "source": [ "# Sun mean argument\n", "\n", "with set_precision(pmode=PrecisionMode.MAX, tmode=TruncatureMode.ROUND):\n", " mean_arg_sun = mean_sun_pos + (Sexagesimal(6,0) * u.degree if mean_sun_pos < solar_apogee_pos else 0) - solar_apogee_pos\n", "mean_arg_sun" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "" ], "text/latex": "$00 ; 39,33,20,10,31,40,48 \\; \\mathrm{{}^{\\circ}}$" }, "metadata": {}, "execution_count": 12 } ], "source": [ "# Sun equation\n", "\n", "tab_eq_sun = HTable.read(19, format=\"dishas\")\n", "with set_precision(pmode=PrecisionMode.MAX, tmode=TruncatureMode.ROUND):\n", " eq_sun = tab_eq_sun.get(mean_arg_sun.value)\n", "eq_sun" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "" ], "text/latex": "$01,47 ; 18,49 \\; \\mathrm{{}^{\\circ}}$" }, "metadata": {}, "execution_count": 13 } ], "source": [ "# Sun true position\n", "\n", "with set_precision(pmode=2, tmode=TruncatureMode.ROUND):\n", " true_pos_sun = mean_sun_pos + (Sexagesimal(6,0) * u.degree if mean_sun_pos < eq_sun else 0) - eq_sun\n", "true_pos_sun" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "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.9.0" } }, "nbformat": 4, "nbformat_minor": 4 }