Last active
December 14, 2020 13:56
-
-
Save epn-ml/53d65c045a16957146a6db21cd091ff1 to your computer and use it in GitHub Desktop.
This is a short script to plot MESSENGER magnetic field data as well as bow shock and magnetopause crossings along an orbit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# Copyright 2020 Alexander Lavrukhin <lavrukhin@physics.msu.ru>, David Parunakian <rumith@srd.sinp.msu.ru>\n", | |
"#\n", | |
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n", | |
"# you may not use this file except in compliance with the License.\n", | |
"# You may obtain a copy of the License at\n", | |
"#\n", | |
"# http://www.apache.org/licenses/LICENSE-2.0\n", | |
"#\n", | |
"# Unless required by applicable law or agreed to in writing, software\n", | |
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n", | |
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n", | |
"# See the License for the specific language governing permissions and\n", | |
"# limitations under the License." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"#############################################################\n", | |
"# Short script to plot MESSENGER magnetic field and bow shock \n", | |
"# and magnetopause crossings along an orbit\n", | |
"\n", | |
"import pandas as pd\n", | |
"import numpy as np\n", | |
"import plotly.graph_objs as go\n", | |
"import plotly.express as px\n", | |
"from plotly.subplots import make_subplots\n", | |
"\n", | |
"\n", | |
"# ENTER NUMBER OF ORBIT # (EXCLUDING 0025, 0026) #\n", | |
"orbit = '0027'\n", | |
"#_______________________#________________________#\n", | |
"\n", | |
"# Reading orbit file from FTP\n", | |
"df = pd.read_csv('ftp://epn2024.sinp.msu.ru/messenger/messenger-' + orbit + '.csv', sep = ',')\n", | |
"df[\"B_tot\"] = (df[\"BX_MSO\"]**2 + df[\"BY_MSO\"]**2 + df[\"BZ_MSO\"]**2)**0.5\n", | |
"\n", | |
"# Reading crossings file from FTP\n", | |
"# BS - bow shock; MP - magnetopause\n", | |
"df_cross = pd.read_csv('ftp://epn2024.sinp.msu.ru/messenger/Mercury_BS_and_MP_crossings.csv', sep = ',')\n", | |
"print(df_cross.head())\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# plotting total magnetic field magnitude B along the orbit\n", | |
"fig = go.Figure()\n", | |
"fig.add_trace(go.Scatter(x = df['DATE'], y = df['B_tot'], name = 'B_total'))\n", | |
"\n", | |
"# BS MP crossings times\n", | |
"orb_num = int(orbit) - 1\n", | |
"for i in range(1,9):\n", | |
" fig.add_trace(go.Scatter(x = [df_cross.iloc[orb_num][i], df_cross.iloc[orb_num][i]], y = [0, 450], mode='lines', name = df_cross.columns[i], line_color = 'black'))\n", | |
"\n", | |
"fig.show()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# Plotting components of the magnetic field B_x, B_y, B_z in MSO coordinates\n", | |
"\n", | |
"fig = go.Figure()\n", | |
"fig.add_trace(go.Scatter(x = df['DATE'], y = df['BX_MSO'], name = 'B_x'))\n", | |
"fig.add_trace(go.Scatter(x = df['DATE'], y = df['BY_MSO'], name = 'B_y'))\n", | |
"fig.add_trace(go.Scatter(x = df['DATE'], y = df['BZ_MSO'], name = 'B_z'))\n", | |
"\n", | |
"# BS MP crossings times\n", | |
"orb_num = int(orbit) - 1\n", | |
"for i in range(1,9):\n", | |
" fig.add_trace(go.Scatter(x = [df_cross.iloc[orb_num][i], df_cross.iloc[orb_num][i]], y = [-450, 450], mode='lines', name = df_cross.columns[i], line_color = 'black'))\n", | |
"\n", | |
"fig.show()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"celltoolbar": "Raw Cell Format", | |
"colab": { | |
"collapsed_sections": [], | |
"name": "Mercury_crossings_demonstration.ipynb", | |
"provenance": [], | |
"toc_visible": true | |
}, | |
"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.7.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pandas | |
numpy | |
plotly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python-3.8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment