From 7c4ded00e69ea95d7efb76ac7b390bbd00c1a8c2 Mon Sep 17 00:00:00 2001 From: 40b4b9646ff373fd7a7b82d082e9f49d <40b4b9646ff373fd7a7b82d082e9f49d@app-learninglab.inria.fr> Date: Tue, 14 Nov 2023 15:12:43 +0000 Subject: [PATCH] getting into the hard coding part --- module2/exo1/Untitled.ipynb | 6 +++ module2/exo1/toy_notebook_fr.ipynb | 83 +++++++++++++++++++++++++++++- 2 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 module2/exo1/Untitled.ipynb diff --git a/module2/exo1/Untitled.ipynb b/module2/exo1/Untitled.ipynb new file mode 100644 index 0000000..7fec515 --- /dev/null +++ b/module2/exo1/Untitled.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/module2/exo1/toy_notebook_fr.ipynb b/module2/exo1/toy_notebook_fr.ipynb index e9dd4bf..7d037c8 100644 --- a/module2/exo1/toy_notebook_fr.ipynb +++ b/module2/exo1/toy_notebook_fr.ipynb @@ -17,7 +17,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -31,7 +31,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -73,6 +73,85 @@ " 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, -- 2.18.1