Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation update for v0.10 #26

Merged
merged 36 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
541d871
Doc WIP
jeandet Nov 4, 2021
34ed161
[Documentation] Rewrite in progress
jeandet Jan 19, 2022
f3ba3ea
[Documentation] More switch to numpydoc
jeandet Jan 20, 2022
211ed9e
[Documentation] Switch to numpydoc complete, AMDA introduction OK
jeandet Jan 22, 2022
a777b08
[Fix] it seems we can't change tzinfo on a datetime
jeandet Jan 22, 2022
0f7389d
Dynamic plot with Bokeh WIP
jeandet Jan 22, 2022
52008a2
[Documentation] Basic SSCWeb module documentation
jeandet Jan 24, 2022
69aa198
Removes Python 3.6 support and adds Python 3.10
jeandet Jan 24, 2022
bcbe975
Try to pass AMDA credentials to doctest in GH Actions
jeandet Jan 24, 2022
e72bb70
[Documentation] Skip AMDA user products access from doctest
jeandet Jan 24, 2022
7660873
[Documentation] Removes standalone examples since they are in API doc…
jeandet Jan 25, 2022
141cb9b
[Documentation] Make AMDA list_ examples more robust for doctest
jeandet Jan 25, 2022
42fa31b
[Documentation] Adds two more complete examples about AMDA usage
jeandet Jan 25, 2022
d5cd3db
[Documentation] Removes auto generated doc files
jeandet Jan 25, 2022
904c824
[Documentation] Adds citation file for GitHub https://docs.github.com…
jeandet Jan 25, 2022
78453aa
[Documentation] Adds missing entries into history file
jeandet Jan 25, 2022
ee235c5
[Documentation] Fix minor typos
jeandet Jan 25, 2022
2211818
[Documentation] Split back readme and doc index :/ plus some overall doc
jeandet Jan 25, 2022
382b8ce
[Documentation] Typo + rephrase AMDA Magnetic Cloud example
jeandet Jan 25, 2022
3bf9ee1
[Documentation] Better index page for RTD doc and some minor stuff
jeandet Jan 26, 2022
a59831f
[Documentation] Adds a notebooks gallery
jeandet Jan 26, 2022
ba23385
[Documentation] Adds ipywidgets and ipympl reqs for RTD and nbsphinx
jeandet Jan 26, 2022
80e9afd
[Documentation] GH Actions needs documentation packages too for doctest
jeandet Jan 27, 2022
f2f4fb4
[SSCWeb] restore get_orbit with a deprecation message
jeandet Jan 27, 2022
07cf307
[Documentation] GH Actions needs documentation packages too for doctest
jeandet Jan 27, 2022
450e6ed
[Documentation] Make code examples clickable, and update intersphinx …
jeandet Jan 27, 2022
eb90a5a
[Documentation] Adds some notes stating that Speasy isn't a plotting …
jeandet Jan 27, 2022
1f0a9a5
[Documentation] preinstall astropy from doc requirements to avoid usi…
jeandet Jan 27, 2022
4f91e7a
[Documentation] same with pandas...
jeandet Jan 27, 2022
83a550a
[Documentation] Use sphinxcontrib-apidoc module to auto-run apidoc on…
jeandet Jan 27, 2022
10c9a7a
[Documentation] fixes missing header with binderhub link
jeandet Jan 27, 2022
e4bfc0b
[Documentation] links update
jeandet Jan 27, 2022
ce84a50
[Documentation] Adds caches analysis notebook in gallery
jeandet Jan 27, 2022
f9f68ad
[GH Actions] fix typo
jeandet Jan 28, 2022
b6fe705
[Documentation] Forgot to update binder badges URLs
jeandet Jan 28, 2022
1930377
Fixes #33, until we have something more elegant
jeandet Feb 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Documentation] Adds two more complete examples about AMDA usage
Also drops notebooks entry from TOC

Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
  • Loading branch information
jeandet committed Jan 25, 2022
commit 42fa31bb4ab38c645f0e42941c0a980304f96ea2
76 changes: 74 additions & 2 deletions docs/user/amda/amda.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ AMDA
.. toctree::
:maxdepth: 1

amda_notebooks

`AMDA <http://amda.irap.omp.eu/>`_ is one of the main data providers handled by speasy. Most products are either available using directly the AMDA module or using :meth:`speasy.get_data()`.
The following documentation will focus on AMDA module specific usage.

Expand Down Expand Up @@ -143,6 +141,80 @@ And also alternatively you can use the dynamic inventory:
>>> print(catalog_mms_2019[1])
<Event: 2019-01-01T00:24:04+00:00 -> 2019-01-01T00:24:04+00:00 | {'classes': '1'}>

Some examples using AMDA products
---------------------------------

My first plot from AMDA
^^^^^^^^^^^^^^^^^^^^^^^

In this example we will use AMDA module to retrieve and plot MMS2 FGM data, feel free to change the code and experiment!

>>> import matplotlib.pyplot as plt # doctest: +SKIP
>>> import speasy as spz
>>> from speasy.inventory.data_tree import amda as amda_tree
>>> mms2_b_gse = spz.amda.get_parameter(amda_tree.Parameters.MMS.MMS2.FGM.mms2_fgm_srvy.mms2_b_gse, "2020-02-01", "2020-02-02")
>>> # Check that mms2_b_gse isn't empty
>>> len(mms2_b_gse)
1382895
>>> # Then you can use the SpeasyVariable plot method for quick plots
>>> mms2_b_gse.plot() # doctest: +SKIP
>>> plt.show() # doctest: +SKIP

Then you should get something like this:

.. image:: images/AMDA_mms2_b_gse_plot.png
:height: 400px
:alt: mms2_b_gse plot

Note: Depending on your matplotlib backend and if you are using Jupyter Notebooks or a simple python terminal you may
need to adapt this example.

Using timetables to download data
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

In this example we will use AMDA to first retrieve a public timetable containing time intervals where Magnetic Clouds
were detected with `Wind <https://wind.nasa.gov/>`_. Then download the magnetic field magnitude measured with
`MFI <https://wind.nasa.gov/mfi/instrumentation.html>`_ for each interval. Once we have magnetic field measurements
inside each cloud, we will as an example plot the average distribution.

>>> import matplotlib.pyplot as plt # doctest: +SKIP
>>> import numpy as np
>>> import speasy as spz
>>> from speasy.inventory.data_tree import amda as amda_tree
>>> Magnetic_Clouds = spz.amda.get_timetable(amda_tree.TimeTables.SharedTimeTables.SOLAR_WIND.Magnetic_Clouds)
>>> print(Magnetic_Clouds.meta['description']) # doctest: +NORMALIZE_WHITESPACE
Magnetic Clouds from WIND/MFI 1995-2007 -- Estimated start and end times from a magnetic field model [Lepping et al., 1990] which assumes that the field within the magnetic cloud is force free, i.e., so that the electrical current and the magnetic field are parallel and proportional in strength everywhere within its volume -- see http://lepmfi.gsfc.nasa.gov/mfi/mag_cloud_pub1.html ;
Historic: From old AMDA;
Creation Date : 2013-11-22T13:52:50;

>>> # Check that the timetable has at least some events (as expected)
>>> len(Magnetic_Clouds)
106
>>> # Then we can plot their duration distribution
>>> def duration(event):
... return (event.stop_time.timestamp() - event.start_time.timestamp())/3600
...
>>> clouds_duration = [duration(cloud) for cloud in Magnetic_Clouds]
>>> plt.hist(clouds_duration, label="Clouds duration (Hours)") # doctest: +SKIP
>>> plt.legend() # doctest: +SKIP
>>> plt.show() # doctest: +SKIP
>>> # Now let's get MFI data for each cloud
>>> b_mfi_coulds = [ spz.amda.get_parameter(amda_tree.Parameters.Wind.MFI.wnd_mfi_kp.wnd_bmag, cloud.start_time, cloud.stop_time) for cloud in Magnetic_Clouds ]
>>> # compute mean of B for each cloud and ignore NaNs
>>> b_mean_mfi_clouds = [ np.nanmean(cloud.data) for cloud in b_mfi_coulds ]
>>> plt.hist(b_mean_mfi_clouds, label="B mean in Magnetic Clouds (nT)") # doctest: +SKIP
>>> plt.legend() # doctest: +SKIP
>>> plt.show() # doctest: +SKIP

Then you should get something these plots:

.. image:: images/AMDA_clouds_duration_hist.png
:width: 49%
:alt: Cloud duration histogram
.. image:: images/AMDA_b_mean_mfi_clouds.png
:width: 49%
:alt: Cloud's B mean histogram


Advanced: AMDA module configuration options
-------------------------------------------
Expand Down
5 changes: 0 additions & 5 deletions docs/user/amda/amda_notebooks.rst

This file was deleted.

Binary file added docs/user/amda/images/AMDA_b_mean_mfi_clouds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user/amda/images/AMDA_mms2_b_gse_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.