.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/seiss/seiss_example.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_seiss_seiss_example.py: Reading and plotting SEISS data =============================== Purpose: Python example of netcdf and plot commands for use with GOES-R SEISS files .. GENERATED FROM PYTHON SOURCE LINES 9-10 Import modules .. GENERATED FROM PYTHON SOURCE LINES 10-18 .. code-block:: Python import netCDF4 as nc import numpy as np import cftime import os, sys import requests import matplotlib.pyplot as plt .. GENERATED FROM PYTHON SOURCE LINES 19-22 - Relevant data files can be downloaded `here `__. To run this code, it may be necessary to update the filename version string (“v2-1-0”) to match available files. - Other data links and information about EXIS data can be found `here `__ .. GENERATED FROM PYTHON SOURCE LINES 22-34 .. code-block:: Python dir0 = "./" file0 = "sci_mpsh-l2-avg1m_g16_d20200601_v1-0-2.nc" # Download `file0` if it does not exist locally if not os.path.exists(dir0 + file0): with open(dir0 + file0, "wb") as f: url = f"https://data.ngdc.noaa.gov/platforms/solar-space-observing-satellites/goes/goes16/l2/data/mpsh-l2-avg1m/2020/06/{file0}" print('downloading: ', url) r = requests.get(url) f.write(r.content) .. GENERATED FROM PYTHON SOURCE LINES 35-36 Open netcdf file for reading data .. GENERATED FROM PYTHON SOURCE LINES 36-39 .. code-block:: Python ds = nc.Dataset(dir0 + file0) .. GENERATED FROM PYTHON SOURCE LINES 40-41 Time conversion .. GENERATED FROM PYTHON SOURCE LINES 41-46 .. code-block:: Python times = cftime.num2pydate(ds.variables["L2_SciData_TimeStamp"][:], ds["L2_SciData_TimeStamp"].units) print("Filename: ", file0) print("start and end times:", times[0], times[-1]) .. rst-class:: sphx-glr-script-out .. code-block:: none Filename: sci_mpsh-l2-avg1m_g16_d20200601_v1-0-2.nc start and end times: 2020-06-01 00:00:00 2020-06-01 23:59:00 .. GENERATED FROM PYTHON SOURCE LINES 47-48 Print all variable names .. GENERATED FROM PYTHON SOURCE LINES 48-52 .. code-block:: Python print("\nAll variable names: ") print(list(ds.variables.keys()), "\n") .. rst-class:: sphx-glr-script-out .. code-block:: none All variable names: ['L2_SciData_TimeStamp', 'L1bRecordsInAvg', 'YawFlipFlag', 'EclipseFlag', 'AvgDiffProtonFlux', 'AvgDiffProtonFluxUncert', 'DiffProtonValidL1bSamplesInAvg', 'DiffProtonDQFdtcSum', 'DiffProtonDQFoobSum', 'DiffProtonDQFerrSum', 'AvgDiffElectronFlux', 'AvgDiffElectronFluxUncert', 'DiffElectronEffectiveEnergy', 'DiffElectronValidL1bSamplesInAvg', 'DiffElectronDQFdtcSum', 'DiffElectronDQFoobSum', 'DiffElectronDQFerrSum', 'AvgIntElectronFlux', 'AvgIntElectronFluxUncert', 'IntElectronEffectiveEnergy', 'IntValidL1bSamplesInAvg', 'IntDQFdtcSum', 'IntDQFoobSum', 'IntDQFerrSum', 'DiffProtonLowerEnergy', 'DiffProtonUpperEnergy', 'DiffProtonEffectiveEnergy', 'ExpectedLUTNotFound'] .. GENERATED FROM PYTHON SOURCE LINES 53-54 Plot 1 day of MPSH 1-minute AvgDiffProtonFlux in Telescope 0, Band 0 .. GENERATED FROM PYTHON SOURCE LINES 54-74 .. code-block:: Python var = 'AvgDiffProtonFlux' tel = 0 band = 0 data = [] for i in range(0, len(times)): data.append(ds.variables[var][i][tel][band]) plt.figure(0, figsize=[10, 7]) plt.plot( times[:], data, linewidth=1, color="green", label=f"tel{tel}-band{band}", ) plt.yscale("log") plt.legend(loc="upper right", prop={"size": 12}) plt.xlabel("Time [UT]") plt.ylabel(f"{var} [{ds[var].units}]") plt.show() print("Done.\n") .. image-sg:: /examples/seiss/images/sphx_glr_seiss_example_001.png :alt: seiss example :srcset: /examples/seiss/images/sphx_glr_seiss_example_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/micromamba/envs/goesr-spwx-examples/lib/python3.12/site-packages/numpy/_core/shape_base.py:63: UserWarning: Warning: converting a masked element to nan. result = asanyarray(arys[0]) Done. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.544 seconds) .. _sphx_glr_download_examples_seiss_seiss_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: seiss_example.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: seiss_example.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: seiss_example.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_