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

Fix docs #299

Merged
merged 7 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ jobs:
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
auto-update-conda: true
miniforge-variant: Mambaforge
miniforge-version: "latest"
channel-priority: flexible
python-version: ${{ matrix.python-version }}
environment-file: ${{ matrix.ymlfile }}
mamba-version: "*"
activate-environment: pytesmo # todo: must match with name in environment.yml
auto-activate-base: false
Comment on lines 30 to 38
Copy link
Member Author

@wpreimes wpreimes Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebhahn I just fixed an error in the pytesmo windows builds that looks a lot like the error in the ascat package (e.g. here). So these few lines in the CI file might be relevant for you (also that I use setup-miniconda@v2 while you pin a specific old version there).

- name: Print Infos
Expand All @@ -59,7 +58,7 @@ jobs:
- name: Install package and test
shell: bash -l {0}
run: |
pip install -e .
pip install -e .[testing]
pytest --cache-clear
- name: Upload Coverage
shell: bash -l {0}
Expand Down
7 changes: 6 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ build:
tools:
python: mambaforge-4.10

python:
install:
- method: pip
path: .

sphinx:
configuration: docs/conf.py

conda:
environment: docs/rtd_env.yml
environment: docs/env.yml
6 changes: 3 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ Changelog

Unreleased changes in master
============================
-
- Adapters for metric calculatores were introduced. The here implemented adapters compute metrics based on temporal subsets of the time series, which can be used for rolling window metrics, seasonal metrics or multiple arbitrary sub-periods. (PR `#266 <https://github.com/TUW-GEO/pytesmo/pull/266>`_),

Version 0.15.2, 2023-06-14
==========================
- Add kwarg to `time_series.anomaly.calc_climatology` to compute the standard deviation of the climatology (e.g. for anomaly z-scores)
- Add kwarg to `time_series.anomaly.calc_climatology` to compute the standard deviation of the climatology (e.g. for anomaly z-scores) (PR `#290 <https://github.com/TUW-GEO/pytesmo/pull/290>`_)

Version 0.15.1, 2023-03-29
==========================
- Adding scikit-learn as installation dependency.
- Adding scikit-learn as installation dependency. (PR `#298 <https://github.com/TUW-GEO/pytesmo/pull/298>`_)

Version 0.15.0, 2023-03-28
==========================
Expand Down
20 changes: 6 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ This package should be installable through `pip
<https://pip.pypa.io/en/latest/installing.html>`__ which downloads the package
from the `python package repository Pypi <https://pypi.python.org/>`__.
However, pytesmo also needs some packages that depend on C or Fortran libraries (like ``netCDF4``).
They should be installed first with conda. See http://conda.pydata.org/docs/ on how to use it.
We recommend using either `Anaconda <https://www.anaconda.com/>`__ or
`Miniconda <https://conda.io/en/latest/miniconda.html>`__.
They should be installed first with conda or mamba. We recommend installing `Mambaforge <https://github.com/conda-forge/miniforge#mambaforge>`__.
Then the following command should install all dependencies:

.. code-block:: bash

conda install -c conda-forge numpy scipy pandas netCDF4 cython pyresample
mamba install -c conda-forge numpy scipy pandas netCDF4 cython pyresample

Afterwards ``pytesmo`` can be installed via pip.

Expand All @@ -71,17 +70,11 @@ clone the Github repository and install from source:

git clone https://github.com/TUW-GEO/pytesmo.git --recursive
cd pytesmo
conda create -n pytesmo python=3.7 # or any supported python version
source activate pytesmo
conda env update -f environment.yml -n pytesmo
mamba create -n pytesmo python=3.10 # or any supported python version
conda activate pytesmo
mamba env update -f environment.yml -n pytesmo
pip install -e .

.. note::

If you are using windows and conda is missing a package then always check
http://www.lfd.uci.edu/~gohlke/pythonlibs/ to see if there is already a
precompiled .exe or .whl file for you to easily install.

Supported Products
==================

Expand Down Expand Up @@ -123,4 +116,3 @@ against our master branch for new features or bug fixes.

Please follow the `developers guide
<https://github.com/TUW-GEO/pytesmo/blob/master/DEVELOPERS_GUIDE.md>`_.

5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,13 @@
# a list of builtin themes.
html_theme = "sphinx_rtd_theme"


# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {"sidebar_width": "300px", "page_width": "1200px"}
html_theme_options = {"sidebar_width": "300px", "page_width": "1200px",
"show_navbar_depth": 2
}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
Expand Down
13 changes: 10 additions & 3 deletions docs/rtd_env.yml → docs/env.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# To keep the RTD build as small as possible, we define a separate .yml here
name: pytesmo_docs
name: docs
channels:
- conda-forge
- defaults
dependencies:
- python=3.9
- python=3.10
- ipykernel
- nbsphinx
# Note: RTD will add packages it needs automatically such as sphinx, sphinx_rtd_theme
- mock
- pillow
- sphinx<7
- sphinx_rtd_theme
- pip
- pip:
- recommonmark
- readthedocs-sphinx-ext
15 changes: 0 additions & 15 deletions docs/examples/index.rst

This file was deleted.

10 changes: 9 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
:hidden:
:glob:


README <readme>
Introduction <introduction>
Examples <examples/index>

Validation Framework <examples/validation_framework>
Temporal Collocation <examples/temporal_collocation>
Anomaly Computation <examples/anomalies>
Triple Collocation Analysis <examples/triple_collocation>
Soil Water Index Computation <examples/swi_calc>
Example: Validate ASCAT with ISMN <examples/compare_ASCAT_ISMN>

License <license>
Authors <authors>
Changelog <changelog>
Expand Down
28 changes: 5 additions & 23 deletions docs/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,8 @@ Features
as more complex ones like :ref:`triple-collocation-example` or MSE as a
decomposition of the RMSD see :mod:`pytesmo.metrics`

Prerequisites
=============

Necessary Python packages
-------------------------

In order to enjoy all pytesmo features, a recent Python 3 installtation with the
conda/pip packages listed in :download:`requirements.txt <../requirements.txt>`
should be installed:

Some packages are optional:

* pykdtree: https://github.com/storpipfugl/pykdtree

which makes Nearest Neighbor search faster

* pyresample: https://github.com/pytroll/pyresample

for resampling of irregular images onto a regular grid for e.g. plotting

* matplotlib with cartopy/basemap: http://matplotlib.org

for plotting maps of ISMN stations, maps in general
Notebooks
=========
The following documentation is created from ipython notebooks in ``pytesmo/docs/examples``.
The notebooks can be run interactively and the results can be reproduced locally using `jupyter <http://jupyter.org/>`__.
Some of the examples require the packages `ascat` and `ismn`, which can be installed with `pip`.
9 changes: 6 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ dependencies:
- numpy<=1.23.5 # v1.24 not yet supported by numba
- scipy>=0.12
- pandas>=0.11.0,!=0.15.2
- netcdf4>=1.0.1,!=1.6.2 # at v1.6.2 only defaults channel worked properly
- netcdf4>=1.0.1,!=1.6.2
- cython>=0.29.21
- scikit-learn
- pykdtree
- pyresample
- numba
- matplotlib>=1.2.0
- pip
# optional, for documentation and testing:
- nb_conda
- ipykernel
- pip
# ----------------------------------------
- pip:
- pynetcf>=0.4.0
- pygeogrids
Expand All @@ -30,6 +30,8 @@ dependencies:
- repurpose>=0.7.1
- cadati>=0.0.2
# optional, for documentation and testing:
- nbconvert
- ipykernel
- ascat>=2.0
- ismn>=1.2.0
- pytest
Expand All @@ -38,3 +40,4 @@ dependencies:
- pre-commit
- flake8
- yapf
# ----------------------------------------
8 changes: 8 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ exclude =
# `pip install pytesmo[PDF]` like:
# PDF = ReportLab; RXP
# Add here test requirements (semicolon/line-separated)
testing =
pytest
pytest-cov
pytest-mpl
nbconvert
ipykernel
ascat>=2.0
ismn>=1.2.0

[options.entry_points]
# Add here console scripts like:
Expand Down
23 changes: 15 additions & 8 deletions src/pytesmo/validation_framework/metric_calculators_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class MonthsMetricsAdapter(SubsetsMetricsAdapter):
Adapt MetricCalculators to calculate metrics for groups across months
"""

def __init__(self, calculator, sets=None):
def __init__(self, calculator, month_subsets=None, group_results='tuple'):
"""
Add functionality to a metric calculator to calculate validation
metrics for subsets of certain months in a time series (e.g. seasonal).
Expand All @@ -155,7 +155,7 @@ def __init__(self, calculator, sets=None):
calculator : PairwiseIntercomparisonMetrics or TripleCollocationMetrics
A metric calculator to adapt. Preferably an instance of a metric
calculator listed in `_supported_metric_calculators`
sets : dict, optional (default: None)
month_subsets : dict, optional (default: None)
Define groups of data. With group names as key and a list of
months (1-12) that belong to the group as values.

Expand All @@ -166,27 +166,34 @@ def __init__(self, calculator, sets=None):

The name will be used in the results to distinguish between the
same metrics for different groups:
e.g. ('Group1', 'BIAS'): ..., ('Group2', 'BIAS'): ..., etc.
e.g. ('Group1', 'BIAS'): ..., ('Group2', 'BIAS'): ..., etc. or
'Group1|BIAS': ..., 'Group2|BIAS': ..., etc.
denpending on the chosen `group_results` parameter.

The default groups are based on 4 seasons plus one group that uses
all data (as the unadapted metric calculator would do):
{'DJF': [12,1,2], 'MAM': [3,4,5], 'JJA': [6, 7, 8],
'SON': [9, 10, 11], 'ALL': list(range(1, 13))}
group_results: str, optional (default: 'tuple')
How to group the results.
- 'tuple' will group the results by (group, metric)
- 'join' will join group and metric name with a '|'
"""
if sets is None:
sets = {
if month_subsets is None:
month_subsets = {
'DJF': [12, 1, 2],
'MAM': [3, 4, 5],
'JJA': [6, 7, 8],
'SON': [9, 10, 11],
'ALL': list(range(1, 13)),
}

for name, months in sets.items():
for name, months in month_subsets.items():
distr = TsDistributor(yearless_date_ranges=[(
YearlessDatetime(m, 1, 0, 0, 0),
YearlessDatetime(m, days_in_month(m), 23, 59, 59))
for m in months])
sets[name] = distr
month_subsets[name] = distr

super().__init__(calculator, subsets=sets)
super().__init__(calculator, subsets=month_subsets,
group_results=group_results)
Loading