.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/plot_version_diff_surface.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_version_diff_surface.py: Version Differences (Surface) ----------------------------- This example demonstrates how to calculate the percent change of all variables on a surface between MSIS version 00 and 2. .. GENERATED FROM PYTHON SOURCE LINES 10-53 .. image-sg:: /examples/images/sphx_glr_plot_version_diff_surface_001.png :alt: MASS_DENSITY, N2, O2, O, HE, H, AR, N, ANOMALOUS_O :srcset: /examples/images/sphx_glr_plot_version_diff_surface_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np import pymsis lons = range(-180, 185, 5) lats = range(-90, 95, 5) alt = 200 f107 = 150 f107a = 150 ap = 7 # One years worth of data at the 12th hour every day date = np.datetime64("2003-01-01T12:00") aps = [[ap] * 7] output2 = pymsis.calculate(date, lons, lats, alt, f107, f107a, aps) output0 = pymsis.calculate(date, lons, lats, alt, f107, f107a, aps, version=0) diff = (output2 - output0) / output0 * 100 # diff is now of the shape (1, nlons, nlats, 1, 11) # Get rid of the single dimensions diff = np.squeeze(diff) fig, axarr = plt.subplots(nrows=3, ncols=3, constrained_layout=True, figsize=(8, 6)) xx, yy = np.meshgrid(lons, lats) norm = mpl.colors.Normalize(-50, 50) cmap = mpl.colormaps["RdBu_r"] for i, variable in enumerate(pymsis.Variable): if i > 8: break ax = axarr.flatten()[i] mesh = ax.pcolormesh( xx, yy, diff[:, :, variable].T, shading="auto", norm=norm, cmap=cmap ) ax.set_title(f"{variable.name}") plt.colorbar( mesh, ax=axarr, label="Change from MSIS-00 to MSIS2 (%)", orientation="horizontal" ) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.912 seconds) .. _sphx_glr_download_examples_plot_version_diff_surface.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_version_diff_surface.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_version_diff_surface.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_version_diff_surface.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_