.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/plot_annual_variation.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_plot_annual_variation.py: Annual variation ---------------- This example demonstrates how to calculate the difference from the annual mean at a single location. .. GENERATED FROM PYTHON SOURCE LINES 9-52 .. image-sg:: /examples/images/sphx_glr_plot_annual_variation_001.png :alt: plot annual variation :srcset: /examples/images/sphx_glr_plot_annual_variation_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import pymsis lon = 0 lat = 0 alt = 200 f107 = 150 f107a = 150 ap = 7 # One years worth of data at the 12th hour every day dates = np.arange("2003-01", "2004-01", dtype="datetime64[D]") + np.timedelta64(12, "h") ndates = len(dates) # (F107, F107a, ap) all need to be specified at the same length as dates f107s = [f107] * ndates f107as = [f107a] * ndates aps = [[ap] * 7] * ndates output = pymsis.calculate(dates, lon, lat, alt, f107s, f107as, aps) # output is now of the shape (ndates, 1, 1, 1, 11) # Get rid of the single dimensions output = np.squeeze(output) # Lets get the percent variation from the annual mean for each variable variation = 100 * (output / output.mean(axis=0) - 1) _, ax = plt.subplots() for variable in pymsis.Variable: if variable.name == "NO": # There is currently no NO data continue ax.plot(dates, variation[:, variable], label=variable.name) ax.legend( loc="upper center", bbox_to_anchor=(0.5, 1.15), fancybox=True, shadow=True, ncol=5 ) ax.set_xlabel(f"Longitude: {lon}, Latitude: {lat}, Altitude: {alt} km") ax.set_ylabel("Difference from annual mean (%)") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.115 seconds) .. _sphx_glr_download_examples_plot_annual_variation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_annual_variation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_annual_variation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_annual_variation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_