{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Un nouveau document, base sur mes calculs en *line tracing*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Introduction\n", "Je commence déjà par charger les bibliothèques nécessaires. Je définis également un certain nombre de fonction qui seront utiles pour la suite des calculs et des rendus." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import sys\n", "import os\n", "\n", "pi = np.pi" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "def centrifugal_lat(r,t,p):\n", " # ----------------------------------------------\n", " # Centrifugal latitude in Jovian magnetosphere\n", " # coefficient from Phipps & Bagenal (2021)\n", " #\n", " # Input : \n", " # R [Rj]\n", " # theta (colatitude) [°]\n", " # phi (longitude in S3RH) [°]\n", " # ----------------------------------------------\n", " a = 1.66 # [°]\n", " b = 0.131 # \n", " c = 1.62\n", " d = 7.76 # [°]\n", " e = 249 # [°]\n", " cent_eq = (a*np.tanh(b*r-c)+d) * (np.sin(np.radians(p-e)))\n", " \n", " jov_lat = 90 - t\n", " cent_lat = jov_lat - cent_eq\n", " \n", " return cent_lat\n", "\n", "def extractfilelines(filename: str, titlemarker=\"#\"):\n", " # -----------------------------------------------\n", " # This function converts a text file (at location specified by filename)\n", " # into a list of its lines in text format\n", " # -----------------------------------------------\n", " with open(filename, \"r\") as f:\n", " # read title\n", " line = f.readline()\n", " while line.startswith(titlemarker):\n", " line = f.readline()\n", "\n", " lines = [line] + f.readlines()\n", "\n", " return lines" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Etude de la dépendance entre le Mshell et la position de l'équateur centrifuge\n", "**Note :** Une partie importante de l'étude a déjà été fait en amont : le calcul, pour un certain échantillonage de l'équateur centrifuge en rayon sphérique $r_{cent}$ et en longitude $\\phi_{cent}$, de la latitude $\\lambda_{cent}$ et du $Mshell$ correspondant. Ces données sont chargées sur ce document computationnel à partir d'un document texte. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Tentative de détection de tendances\n", "Dans la suite, je travaille les données directement pour tenter de faire ressortir des tendances $Mshell = f(\\phi_{cent})$ et $Mshell = f(r_{cent})$ à $r_{cent}$ et $\\phi_{cent}$ fixés respectivement. " ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "# parametres utilisateur\n", "model = 'JRM33+CON2020' # magnetic field model used\n", "npoints = 100, 60\n", "radlims = (\"5\", \"30\")\n", "savefiletitle = \"centrifugalequator_radius{}min{}max{}pts_latitude_longitude{}pts_\"\\\n", " \"mshell{}\".format(radlims[0], radlims[1], npoints[1], npoints[0], model)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "ename": "FileNotFoundError", "evalue": "[Errno 2] No such file or directory: 'centrifugalequator_radius5min30max60pts_latitude_longitude100pts_mshellJRM33+CON2020.txt'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# definition et completion des tableaux de donnees a partir du fichier texte\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mmshells\u001b[0m \u001b[0;34m,\u001b[0m\u001b[0mradiis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlongitudes\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mlatitudes\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mzeros\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnpoints\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mzeros\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnpoints\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mzeros\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnpoints\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mzeros\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnpoints\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mlines\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mextractfilelines\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msavefiletitle\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;34m\".txt\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0mk\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnpoints\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m\u001b[0m in \u001b[0;36mextractfilelines\u001b[0;34m(filename, titlemarker)\u001b[0m\n\u001b[1;32m 26\u001b[0m \u001b[0;31m# into a list of its lines in text format\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 27\u001b[0m \u001b[0;31m# -----------------------------------------------\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 28\u001b[0;31m \u001b[0;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilename\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"r\"\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 29\u001b[0m \u001b[0;31m# read title\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 30\u001b[0m \u001b[0mline\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreadline\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'centrifugalequator_radius5min30max60pts_latitude_longitude100pts_mshellJRM33+CON2020.txt'" ] } ], "source": [ "# definition et completion des tableaux de donnees a partir du fichier texte\n", "mshells ,radiis, longitudes,latitudes = np.zeros(npoints), np.zeros(npoints), np.zeros(npoints), np.zeros(npoints)\n", "lines = extractfilelines(savefiletitle+\".txt\")\n", "k = 0\n", "for i in range(npoints[0]):\n", " for j in range(npoints[1]):\n", " line = lines[k]\n", " strvals = line.strip().split()\n", "\n", " radiis[i, j] = float(strvals[0].strip())\n", " latitudes[i, j] = float(strvals[1].strip())\n", " longitudes[i, j] = float(strvals[2].strip())\n", " mshells[i, j] = float(strvals[3].strip())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# test du format des tableaux de donnees\n", "for k in range(0, npoints[0], npoints[0]//5):\n", " print(\"Values on line \"+str(k))\n", " print(\"r in [{:.2f}, {:.2f}] RJ ; phi in [{:.2f}, {:.2f}] deg ; lambda in [{:.2f}, {:.2f}] deg ; \"\\\n", " \"mshell in [{:.2f}, {:.2f}] RJ\".format(np.min(radiis[k]), np.max(radiis[k]), np.min(longitudes[k]), \n", " np.max(longitudes[k]), np.min(latitudes[k]), np.max(latitudes[k]), \n", " np.min(mshells[k]), np.max(mshells[k])))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.6.4" } }, "nbformat": 4, "nbformat_minor": 2 }