Skip to content

Commit 58c2f09

Browse files
authored
docs: more instructive quickstart (#75)
2 parents 650a8c8 + 3b88d5e commit 58c2f09

File tree

7 files changed

+131
-132
lines changed

7 files changed

+131
-132
lines changed

README.rst

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,16 @@
5858
Overview
5959
---------------------
6060

61-
``xeofs`` is a Python package designed for Empirical Orthogonal Function (EOF) analysis, also known as Principal Component Analysis (PCA),
62-
and related variants. The package stands out due to its capacity
63-
to handle multi-dimensional Earth observation data, thereby optimizing the speed and efficiency of EOF analysis.
64-
Here are the key strengths of ``xeofs``:
61+
``xeofs`` is a Python toolbox designed for methods like **Empirical Orthogonal Function (EOF) analysis**, also known as Principal Component Analysis (PCA),
62+
and **related variants**. The package stands out due to its capacity
63+
to handle multi-dimensional Earth observation data.
6564

66-
The benefits of using ``xeofs`` include:
65+
Here are the key strengths of ``xeofs``:
6766

6867
- **Multi-dimensional Analysis**: Execute labeled EOF analysis with the extensive features of ``xarray``.
6968
- **Scalability**: Handle large datasets effectively with ``dask``.
7069
- **Speed**: Enjoy quick EOF analysis using ``scipy``'s randomized SVD.
71-
- **Variety of Methods**: Perform diverse variants of EOF analysis, including complex and rotated version, along with related techniques such as Maximum Covariance Analysis (MCA).
70+
- **Variety of Methods**: Perform diverse variants of EOF analysis, including **complex and rotated EOF analysis**, along with related techniques such as **Maximum Covariance Analysis (MCA)**.
7271
- **Model Validation**: Validate models through bootstrapping.
7372
- **Modular Code Structure**: Incorporate new EOF variants with ease due to the package's modular structure.
7473
- **Flexible Data Formats**: Accepts a variety of ``xarray`` input types (``DataArray``, ``Dataset``, list of ``DataArray``).
@@ -87,43 +86,66 @@ To install the package, use either of the following commands:
8786

8887
.. code-block:: bash
8988
90-
pip install xeofs
89+
conda install -c conda-forge xeofs
9190
9291
or
9392

9493
.. code-block:: bash
9594
96-
conda install -c conda-forge xeofs
97-
95+
pip install xeofs
9896
9997
Quickstart
10098
----------
10199

102100
In order to get started with ``xeofs``, follow these simple steps:
103101

104-
1. **Import the package**
102+
**Import the package**
103+
104+
.. code-block:: python
105+
106+
import xeofs as xe
107+
108+
**EOF analysis**
109+
110+
.. code-block:: python
111+
112+
model = xe.models.EOF(n_modes=10)
113+
model.fit(data, dim="time")
114+
comps = model.components() # EOFs (spatial patterns)
115+
scores = model.scores() # PCs (temporal patterns)
116+
117+
**Varimax-rotated EOF analysis**
105118

106-
.. code-block:: python
119+
.. code-block:: python
107120
108-
import xeofs as xe
121+
rotator = xe.models.EOFRotator(n_modes=10)
122+
rotator.fit(model)
123+
rot_comps = rotator.components() # Rotated EOFs (spatial patterns)
124+
rot_scores = rotator.scores() # Rotated PCs (temporal patterns)
109125
110-
2. **Instantiate the model**
126+
**MCA**
111127

112-
Select the type of analysis you want to perform (in this case, EOF analysis) and set the parameters. For example, if you want to analyze the first 10 modes, you would use the following code:
128+
.. code-block:: python
113129
114-
.. code-block:: python
130+
model = xe.models.MCA(n_modes=10)
131+
model.fit(data1, data2, dim="time")
132+
comps1, comps2 = model.components() # Singular vectors (spatial patterns)
133+
scores1, scores2 = model.scores() # Expansion coefficients (temporal patterns)
115134
116-
model = xe.models.EOF(n_modes=10)
135+
**Varimax-rotated MCA**
117136

118-
3. **Fit the model to your data**
137+
.. code-block:: python
119138
120-
Fit the model to your data by specifying the dimensions along which the analysis should be performed. Replace 'your_data' and 'your_dimension' with your specific data and dimension:
139+
rotator = xe.models.MCARotator(n_modes=10)
140+
rotator.fit(model)
141+
rot_comps = rotator.components() # Rotated singular vectors (spatial patterns)
142+
rot_scores = rotator.scores() # Rotated expansion coefficients (temporal patterns)
121143
122-
.. code-block:: python
123144
124-
model.fit(your_data, dim=your_dimension)
145+
To further explore the capabilities of ``xeofs``, check the available documentation_ and examples_.
146+
For a full list of currently available methods, see the methods_ section.
125147

126-
Congratulations! You have performed your first analysis with ``xeofs``. To further explore the capabilities of ``xeofs``, check the documentation_ and examples_.
148+
.. _methods: https://xeofs.readthedocs.io/en/latest/models.html
127149

128150

129151

docs/auto_examples/1eof/index.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,35 +82,35 @@
8282

8383
.. raw:: html
8484

85-
<div class="sphx-glr-thumbcontainer" tooltip="Weighted EOF analysis (in S-mode) maximises the temporal variance considering each gridpoint wi...">
85+
<div class="sphx-glr-thumbcontainer" tooltip="EOF (Empirical Orthogonal Function) analysis is commonly used in climate science, interpreting ...">
8686

8787
.. only:: html
8888

89-
.. image:: /auto_examples/1eof/images/thumb/sphx_glr_plot_weighted-eof_thumb.png
89+
.. image:: /auto_examples/1eof/images/thumb/sphx_glr_plot_rotated_eof_thumb.png
9090
:alt:
9191

92-
:ref:`sphx_glr_auto_examples_1eof_plot_weighted-eof.py`
92+
:ref:`sphx_glr_auto_examples_1eof_plot_rotated_eof.py`
9393

9494
.. raw:: html
9595

96-
<div class="sphx-glr-thumbnail-title">Weighted EOF analysis</div>
96+
<div class="sphx-glr-thumbnail-title">Rotated EOF analysis</div>
9797
</div>
9898

9999

100100
.. raw:: html
101101

102-
<div class="sphx-glr-thumbcontainer" tooltip="EOF (Empirical Orthogonal Function) analysis is commonly used in climate science, interpreting ...">
102+
<div class="sphx-glr-thumbcontainer" tooltip="Weighted EOF analysis (in S-mode) maximises the temporal variance considering each gridpoint wi...">
103103

104104
.. only:: html
105105

106-
.. image:: /auto_examples/1eof/images/thumb/sphx_glr_plot_rotated_eof_thumb.png
106+
.. image:: /auto_examples/1eof/images/thumb/sphx_glr_plot_weighted-eof_thumb.png
107107
:alt:
108108

109-
:ref:`sphx_glr_auto_examples_1eof_plot_rotated_eof.py`
109+
:ref:`sphx_glr_auto_examples_1eof_plot_weighted-eof.py`
110110

111111
.. raw:: html
112112

113-
<div class="sphx-glr-thumbnail-title">Rotated EOF analysis</div>
113+
<div class="sphx-glr-thumbnail-title">Weighted EOF analysis</div>
114114
</div>
115115

116116

@@ -126,6 +126,6 @@
126126
/auto_examples/1eof/plot_eof-smode
127127
/auto_examples/1eof/plot_multivariate-eof
128128
/auto_examples/1eof/plot_mreof
129-
/auto_examples/1eof/plot_weighted-eof
130129
/auto_examples/1eof/plot_rotated_eof
130+
/auto_examples/1eof/plot_weighted-eof
131131

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)