.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_spectrum.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_gallery_plot_spectrum.py: Spatial Power Spectra ===================== This script creates a plot of the spatial power spectrum of the time-dependent internal field from the CHAOS geomagnetic field model. .. GENERATED FROM PYTHON SOURCE LINES 9-40 .. image-sg:: /gallery/images/sphx_glr_plot_spectrum_001.png :alt: Spatial power spectra at Earth's surface :srcset: /gallery/images/sphx_glr_plot_spectrum_001.png :class: sphx-glr-single-img .. code-block:: Python import chaosmagpy as cp import matplotlib.pyplot as plt import matplotlib.ticker as ticker import numpy as np model = cp.CHAOS.from_mat('CHAOS-7.mat') # load the mat-file of CHAOS-7 nmax = 20 time = cp.data_utils.mjd2000(2018, 1, 1) degrees = np.arange(1, nmax+1, dtype=int) fig, ax = plt.subplots(1, 1, figsize=(12, 7)) for deriv, label in enumerate(['nT', 'nT/yr', 'nT/yr$^2$']): # get spatial power spectrum from time-dependent internal field in CHAOS spec = model.model_tdep.power_spectrum(time, nmax=nmax, deriv=deriv) ax.semilogy(degrees, spec, label=label) ax.legend() ax.grid(which='both') ax.yaxis.set_major_locator(ticker.LogLocator(base=10.0, numticks=15)) ax.xaxis.set_major_locator(ticker.MultipleLocator(1)) ax.set_title("Spatial power spectra at Earth's surface", fontsize=14) ax.set_xlabel('Spherical harmonic degree') plt.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.444 seconds) .. _sphx_glr_download_gallery_plot_spectrum.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_spectrum.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_spectrum.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_