{
 "cells": [
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2"
   ],
   "id": "a78faf7f4883772f",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "%reload_ext autoreload\n",
    "%autoreload 2\n",
    "import numpy as np\n",
    "\n",
    "import winkelumrechnungen as wu\n",
    "from GHA_triaxial.utils import alpha_ell2para, alpha_para2ell\n",
    "from ellipsoid_triaxial import EllipsoidTriaxial"
   ],
   "id": "46aa84a937fea491",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "ell = EllipsoidTriaxial.init_name(\"KarneyTest2024\")\n",
    "diffs = []\n",
    "for beta_deg in range(-90, 91, 15):\n",
    "    for lamb_deg in range(-180, 180, 15):\n",
    "        for alpha_deg in range(0, 360, 15):\n",
    "            beta = wu.deg2rad(beta_deg)\n",
    "            lamb = wu.deg2rad(lamb_deg)\n",
    "            u, v = ell.ell2para(beta, lamb)\n",
    "            alpha = wu.deg2rad(alpha_deg)\n",
    "\n",
    "            alpha_para_1, *_ = alpha_ell2para(ell, beta, lamb, alpha)\n",
    "            alpha_ell_1, *_ = alpha_para2ell(ell, u, v, alpha_para_1)\n",
    "            diff_1 = wu.deg2rad(abs(alpha_ell_1 - alpha))/3600\n",
    "\n",
    "            alpha_ell_2, *_ = alpha_para2ell(ell, u, v, alpha)\n",
    "            alpha_para_2, *_ = alpha_ell2para(ell, beta, lamb, alpha_ell_2)\n",
    "            diff_2 = wu.deg2rad(abs(alpha_para_2 - alpha))/3600\n",
    "\n",
    "            diffs.append((beta_deg, lamb_deg, alpha_deg, diff_1, diff_2))\n",
    "diffs = np.array(diffs)"
   ],
   "id": "82fc6cbbe7d5abcb",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "i_max_ell = np.argmax(diffs[:, 3])\n",
    "max_ell = diffs[i_max_ell, 3]\n",
    "point_max_ell = diffs[i_max_ell, :3]\n",
    "\n",
    "i_max_para = np.argmax(diffs[:, 4])\n",
    "max_para = diffs[i_max_para, 4]\n",
    "point_max_para = diffs[i_max_para, :4]\n",
    "\n",
    "print(f'Für elliptisches Alpha = {point_max_ell[2]}° und beta = {point_max_ell[0]}°, lamb = {point_max_ell[1]}°: diff = {max_ell}\"')\n",
    "print(f'Für parametrisches Alpha = {point_max_para[2]}° und beta = {point_max_para[0]}°, lamb = {point_max_para[1]}°: diff = {max_ell}\"')\n",
    "pass"
   ],
   "id": "97b5b8c9ca5377ab",
   "outputs": [],
   "execution_count": null
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
