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

Update and correct docs #180

Merged
merged 56 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
98025a3
feat: add rough version of `join_xr_time_series`
spool Sep 26, 2024
66aaa29
feat: rename and improve `join_xr_time_series` -> `join_xr_time_serie…
spool Sep 28, 2024
488139a
feat: finish `join_xr_time_series_var` to summarise `xarray` time series
spool Sep 30, 2024
34939d8
feat: add `annual_group_xr_time_series` plotting
spool Oct 1, 2024
0463ae8
doc: add `quarto` doc for `cpm` interporation
spool Oct 2, 2024
859484f
Fix extension
sgreenbury Oct 2, 2024
abf227e
Edits while running quarto notebook
sgreenbury Oct 2, 2024
3522ee4
doc: add `jupyter` caching and rename to `cpm_projection.qmd`
spool Oct 2, 2024
0c7ab94
doc: fix import error in `cpm_projection.qmd`
spool Oct 2, 2024
effe46f
fix: ensure `join_xr_time_series` results are sorted chronologically
spool Oct 3, 2024
9744466
feat: add `XarrayTimeSeriesCalcManager` to aggregate summary calculat…
spool Oct 3, 2024
df50b31
fix: `XarrayTimeSeriesCalcManager` `PathLike` attributes -> `Path`
spool Oct 4, 2024
e00b984
feat: add `range_len` for easing progress information
spool Oct 5, 2024
46923a9
fix: cases where `XarrayTimeSeriesCalcManager.sub_path` is `None`
griff-rees Oct 7, 2024
0b4a602
fix: `XarrayTimeSeriesCalcManager` `save_path` -> `sub_path` typo
griff-rees Oct 7, 2024
aedea44
doc: fix and add plots to `cpm_projection.qmd`
spool Oct 8, 2024
7e2c48b
Merge remote-tracking branch 'origin/plot-cpm-time-series' into plot-…
spool Oct 8, 2024
82ada4e
doc: add `.` marks for a plot in `cpm_projection.qmd`
spool Oct 8, 2024
10f4980
chore: `pre-commit run --all-files`
spool Oct 8, 2024
a6aa5fb
fix: add `jupyter-cache` for `quarto` builds
spool Oct 8, 2024
f28040c
doc: add group plots in `cpm_projection.qmd`
spool Oct 8, 2024
7b7fa98
doc: refactor `cpm_projection.qmd` for remote hosted data
spool Oct 15, 2024
3ea428e
ci: add `pip install` for `docs` rendering
spool Oct 15, 2024
61b9689
ci: fix local `pip install` for `docs` rendering
spool Oct 15, 2024
25f0f20
ci: add `gdal` for `docs` render
spool Oct 15, 2024
378b271
ci: target `gdal=3.8.4` for `doc` render
spool Oct 15, 2024
f897a84
doc: refactor `cpm_projection.qmd` for remote hosted data
spool Oct 18, 2024
a3c7101
Notebook with plots measuring variable diffs
sgreenbury Oct 8, 2024
56a3f4d
Fix plots
sgreenbury Oct 9, 2024
128a5e3
Additional debugging plot
sgreenbury Oct 10, 2024
ae335e6
Move to notebooks path
sgreenbury Oct 10, 2024
413be20
Add notebook comparing linear and nearest interpolation
sgreenbury Oct 14, 2024
00484fe
Add blob container filepath to first notebook
sgreenbury Oct 22, 2024
1530918
Add blob container filepath for second notebook
sgreenbury Oct 22, 2024
37fc8be
doc: add vertical lines to `cpm_projection.qmd` plots
spool Oct 23, 2024
87e9c60
Merge remote-tracking branch 'origin/plot-cpm-time-series-notebook' i…
spool Oct 23, 2024
7ef6e5d
doc: add links to `jupyter` `notebook` examples
spool Oct 23, 2024
7295535
doc: switch from `mean` to `median` `annual_group_xr_time_series`
spool Oct 28, 2024
64ca277
doc: add night and day themes
spool Oct 28, 2024
fdef0c3
merge: `main`
spool Oct 28, 2024
96a55ce
doc: add `cpm_projection_diff_plots` files to `quarto`
spool Oct 29, 2024
226ab3b
doc: remove and update sections in `README.md` and `python/README.md`
spool Oct 29, 2024
e347444
doc: fix `quarto` links in `cpm_projection.qmd`
spool Oct 29, 2024
216619f
Updated to docs section of root Readme.md dodc
andrewphilipsmith Oct 29, 2024
0e197da
Merge remote-tracking branch 'origin/fix-docs' into fix-docs
spool Oct 29, 2024
1147c06
doc: remove broken table of contents and update `README.md`
spool Oct 29, 2024
03accd3
add warning about install methods
andrewphilipsmith Oct 29, 2024
952fd4f
Update navigation
andrewphilipsmith Oct 29, 2024
782d724
Add subheadings for doc types
andrewphilipsmith Oct 29, 2024
2f8c2cc
doc: deprecate old pipeline guidance
andrewphilipsmith Oct 29, 2024
45d7a4d
doc: reorders sections within the navigation
andrewphilipsmith Oct 29, 2024
59be2c6
doc: fix links in root `README.md` and remove commented out sections
spool Oct 30, 2024
b058725
doc: fix more broken links
spool Oct 30, 2024
ae7ce46
doc: add `license`, `black` and `CI` badges and fix `pytest` `BADGE_P…
spool Oct 30, 2024
6445bc2
doc: fix `CI` badge and add `coverage`
spool Oct 30, 2024
c415d7e
ci: drop `cp coverage` step
spool Oct 30, 2024
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
20 changes: 13 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ jobs:
mamba run -n ${{ env.CONDA_ENV_NAME }} --cwd python pytest -m "not darwin and not mount"
shell: bash -el {0}

- name: Copy test coverage results
run: |
cp ${{ env.PYTHON_MODULE_FOLDER }}${{ env.COVERAGE_SVG_PATH }} ${{ env.COVERAGE_SVG_FOLDER }}
# - name: Copy test coverage results
# run: |
# cp ${{ env.PYTHON_MODULE_FOLDER }}${{ env.COVERAGE_SVG_PATH }} ${{ env.COVERAGE_SVG_FOLDER }}

- name: Archive coverage svg
uses: actions/upload-artifact@v3
Expand All @@ -101,6 +101,9 @@ jobs:
name: coverage-badge
path: ${{ env.GH_PAGE_PATH }}${{ env.COVERAGE_SVG_PATH }}

- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2

- name: Build Conda Environment
uses: conda-incubator/setup-miniconda@v3
with:
Expand All @@ -114,15 +117,18 @@ jobs:
run: |
mamba run -n ${{ env.CONDA_ENV_NAME }} quartodoc build

- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2

- name: Install Python and Dependencies
uses: actions/setup-python@v4
with:
python-version: '3.12'
cache: 'pip'
- run: pip install jupyter

- name: Install gdal and local libraries
run: |
sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install gdal-bin libgdal-dev
pip install ./python

- name: Render and Publish
uses: quarto-dev/quarto-actions/publish@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ _extensions
_reference/
_site/
_sidebar.yml
*.quarto_ipynb
# See https://github.com/machow/quartodoc/issues/83
objects.json

Expand Down
130 changes: 35 additions & 95 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Welcome to the `clim-recal` repository!
![mit-license](https://img.shields.io/github/license/alan-turing-institute/clim-recal)
![coverage](https://alan-turing-institute.github.io/clim-recal/assets/coverage.svg)
![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)
![CI](https://github.com/alan-turing-institute/clim-recal/actions/workflows/ci.yaml/badge.svg)

Welcome to `clim-recal`, a specialized resource designed to tackle systematic errors or biases in **Regional Climate Models (RCMs)**. As researchers, policy-makers, and various stakeholders explore publicly available RCMs, they need to consider the challenge of biases that can affect the accurate representation of climate change signals.

Expand All @@ -11,21 +15,7 @@ Welcome to `clim-recal`, a specialized resource designed to tackle systematic er
- Was developed in partnership with the MetOffice to ensure the propriety, quality, and usability of our work
- Provides a framework for open additions of new software libraries/bias correction methods (in planning)

## Data results and documentation updates

*WARNING*: The documentation below is out of date in some cases, and we are in the process of updating this. In the meantime, see our [Exported Datasets](/docs/datasets.qmd) page for updates on datasets released for three UK cities.

## Table of Contents

1. [Overview: Bias Correction Pipeline](#overview-bias-correction-pipeline)
1. [Documentation](#documentation)
1. [The Datasets](#the-datasets)
1. [Why Bias Correction?](#why-bias-correction)
1. [Contributing](#contributing)
1. [Future Plans](#future-plans)
1. [License](/LICENSE)

## Overview: Bias Correction Pipeline
# Overview: Bias Correction Pipeline

`clim-recal` is a debiasing pipeline, with the following steps:

Expand All @@ -38,111 +28,61 @@ Welcome to `clim-recal`, a specialized resource designed to tackle systematic er
4. **Assess the debiased data**
*We have developed a way to assess the quality of the debiasing step across multiple alternative methods*

For a quick start on bias correction, refer to our [comprehensive analysis pipeline guide](https://github.com/alan-turing-institute/clim-recal/blob/documentation/docs/pipeline_guidance.md).
For a quick start on bias correction, refer to our [pipeline guide](python/README.md).

## Documentation
# Documentation

We are in the process of developing comprehensive documentation for our code base to supplement the guidance provided in this and other `README.md` files. In the interim, there is documentation available in the following forms:

- Comments within `R` scripts
- Command line `--help` documentation for some of our `python` scripts
- `python` `function` and `class` [`docstrings`](https://docs.python.org/3/library/doctest.html)
- Local render of documentation via [`quarto`](https://quarto.org/)

### `R`

For `R` scripts, please refer to contextual information and usage guidelines, and feel free to reach out with any specific queries.

### `python`

For many of our `python` command line scripts, you can use the `--help` flag to access a summary of the available options and usage information:

```sh
$ python resampling_hads.py --help

usage: resampling_hads.py [-h] --input INPUT [--output OUTPUT] [--grid_data GRID_DATA]
## User documentation

options:
-h, --help show this help message and exit
--input INPUT Path where the .nc files to resample is located
--output OUTPUT Path to save the resampled data data
--grid_data GRID_DATA Path where the .nc file with the grid to resample is located
```
- See [setup instructions](setup-instructions.md)
- See `python` [`README`](python/README.md) for an overview of the pipeline
- Once installed, using the `clim-recal --help` option for details
- See the [reproducibility page](docs/reproducibility.qmd) for information on how we used `clim-recal`

This will display all available options for the script, including their purposes.
## To use `clim-recal` programmatically

### Quarto

We also hope to provide comprehensive documentation via [`quarto`](https://quarto.org/). This is a work in progress, but if you would like to render documentation locally you can do so via `quarto` and [`conda`](https://docs.conda.io):

1. Ensure you have a [local installation](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) of `conda` or [`anaconda`](https://www.anaconda.com/download) .
1. Checkout a copy of our `git` repository
1. Create a local `conda` `environment` via our `environment.yml` file. This should install `quarto`.
1. Activate that environment
1. Run `quarto preview`.

Below are example `bash` shell commands to render locally after installing `conda`:
- There are extensive [`API Reference`](docs/reference) within the python code.
- Comments within `R` scripts

```sh
$ git clone https://github.com/alan-turing-institute/clim-recal
$ cd clim-recal
$ conda create -n clim-recal -f environment.yml
$ conda activate clim-recal
$ quarto preview
```
## To contribute to `clim-recal`

We appreciate your patience and encourage you to check back for updates on our ongoing documentation efforts.
- See the [Contributing](docs/contributing.md) section below

## The Datasets
# The Datasets

### UKCP18
The UK Climate Projections 2018 (UKCP18) dataset offers insights into the potential climate changes in the UK. UKCP18 is an advancement of the UKCP09 projections and delivers the latest evaluations of the UK's possible climate alterations in land and marine regions throughout the 21st century. This crucial information aids in future Climate Change Risk Assessments and supports the UK’s adaptation to climate change challenges and opportunities as per the National Adaptation Programme.
## UKCP18
The [UK Climate Projections 2018 (UKCP18)](https://www.metoffice.gov.uk/research/approach/collaboration/ukcp) dataset offers insights into the potential climate changes in the UK. UKCP18 is an advancement of the UKCP09 projections and delivers the latest evaluations of the UK's possible climate alterations in land and marine regions throughout the 21st century. This crucial information aids in future Climate Change Risk Assessments and supports the UK’s adaptation to climate change challenges and opportunities as per the National Adaptation Programme.

### HADS
## HADS
[HadUK-Grid](https://www.metoffice.gov.uk/research/climate/maps-and-data/data/haduk-grid/haduk-grid) is a comprehensive collection of climate data for the UK, compiled from various land surface observations across the country. This data is organized into a uniform grid to ensure consistent coverage throughout the UK at up to 1km x 1km resolution. The dataset, spanning from 1836 to the present, includes a variety of climate variables such as air temperature, precipitation, sunshine, and wind speed, available on daily, monthly, seasonal, and annual timescales.

### Geographical Dataset
The geographical dataset can be used for visualising climate data. It mainly includes administrative boundaries published by the Office for National Statistics (ONS). The dataset is sharable under the [Open Government Licence v.3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/) and is available for download via this [link](https://services1.arcgis.com/ESMARspQHYMw9BZ9/arcgis/rest/services/NUTS_Level_1_January_2018_FCB_in_the_United_Kingdom_2022/FeatureServer/replicafilescache/NUTS_Level_1_January_2018_FCB_in_the_United_Kingdom_2022_7279368953270783580.zip). We include a copy in the `data/Geofiles` folder for convenience. In addition, the clips for three cities' boundaries from the same dataset are copied to `three.cities` subfolder.

## Why Bias Correction?
# Why Bias Correction?

Regional climate models contain systematic errors, or biases in their output [1]. Biases arise in RCMs for a number of reasons, such as the assumptions in the general circulation models (GCMs), and in the downscaling process from GCM to RCM [1,2].
Regional climate models contain systematic errors, or biases in their output [^1]. Biases arise in RCMs for a number of reasons, such as the assumptions in the general circulation models (GCMs), and in the downscaling process from GCM to RCM.

Researchers, policy-makers and other stakeholders wishing to use publicly available RCMs need to consider a range of "bias correction” methods (sometimes referred to as "bias adjustment" or "recalibration"). Bias correction methods offer a means of adjusting the outputs of RCM in a manner that might better reflect future climate change signals whilst preserving the natural and internal variability of climate [2].
Researchers, policy-makers and other stakeholders wishing to use publicly available RCMs need to consider a range of "bias correction” methods (sometimes referred to as "bias adjustment" or "recalibration"). Bias correction methods offer a means of adjusting the outputs of RCM in a manner that might better reflect future climate change signals whilst preserving the natural and internal variability of climate [^2].

Part of the `clim-recal` project is to review several bias correction methods. This work is ongoing and you can find our initial [taxonomy here](https://docs.google.com/spreadsheets/d/18LIc8omSMTzOWM60aFNv1EZUl1qQN_DG8HFy1_0NdWk/edit?usp=sharing). When we've completed our literature review, it will be submitted for publication in an open peer-reviewed journal.

Our work is however, just like climate data, intended to be dynamic, and we are in the process of setting up a pipeline for researchers creating new methods of bias correction to be able to submit their methods for inclusion on in the `clim-recal` repository.

1. Senatore et al., 2022, https://doi.org/10.1016/j.ejrh.2022.101120
2. Ayar et al., 2021, https://doi.org/10.1038/s41598-021-82715-1


## Contributing

We hope to bring together the extensive work already undertaken by the climate science community and showcase a range of libraries and techniques. If you have suggestions on the repository, or would like to include a new method (see below) or library, please raise an issue or [get in touch](mailto:[email protected])!

### Adding to the conda environment file

To use `R` in `anaconda` you may need to specify the `conda-forge` channel:

```sh
$ conda config --env --add channels conda-forge
```
[^1]: Senatore et al., 2022, <https://doi.org/10.1016/j.ejrh.2022.101120>
[^2]: Ayar et al., 2021, <https://doi.org/10.1038/s41598-021-82715-1>

Some libraries may be only available through `pip`, for example, these may
require the generation / update of a `requirements.txt`:

```sh
$ pip freeze > requirements.txt
```
# Contributing

and installing with:
If you have suggestions on the repository, or would like to include a new method (see below) or library, please
- raise an [issue](https://github.com/alan-turing-institute/clim-recal/issues)
- [get in touch](mailto:[email protected])
- see our [contributing](docs/contributing.md) section, which includes details on contriubting to the documentation.

```sh
$ pip install -r requirements.txt
```
All are welcome and appreciated.

## Future plans
# Future plans
- **Finish refactor for BC**: The infrastructure for testing bias correction methods needs some reworking and documentation.
- **Release BC results**: Provide results from example BC runs.
- **More BC Methods**: Further bias correction of UKCP18 products. *This is planned for a future release and is not available yet.*
- **Pipeline for adding new methods**: *This is planned for a future release and is not available yet.*
97 changes: 54 additions & 43 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,25 @@ project:
- "R/README.md"
- "R/misc/Identifying_Runs.md"
- "R/comparing-r-and-python/HADs-reprojection/WIP-Comparing-HADs-grids.md"
- "docs/cpm_projection.qmd"
- "docs/reference"
# - "docs/pipeline.qmd"
- "docs/contributing.md"
- "docs/download.qmd"
- "docs/datasets.qmd"
- "docs/pipeline_guidance.qmd"
- "docs/docker-configurations.qmd"
- "docs/deprecated_pipeline.qmd"
- "python/README.md"
- "notebooks/cpm_projection_diff_plots.ipynb"
- "notebooks/cpm_projection_diff_plots_linear_nearest.ipynb"
# - "notebooks/Assessing_bc_data/MethodsAssessment_DecWorkshop.Rmd"
# Requires dataset mounted to run notebook

toc: True
number-sections: True

theme:
light: flatly
dark: darkly

# tell quarto to read the generated sidebar
metadata-files:
Expand All @@ -41,17 +47,12 @@ website:
href: "README.md"
- text: "Install"
href: "setup-instructions.md"
- text: "Pipeline"
href: "docs/pipeline_guidance.qmd"
- text: "Generated Datasets"
href: "docs/datasets.qmd"
# - section: "Pipeline"
# contents:
# - text: "Guidance"
# href: "docs/pipeline_guidance.qmd"
# - text: "Diagram"
# href: "docs/pipeline.qmd"
- section: "R"
- text: "Pipeline Description"
href: "python/README.md"
- text: "Download Datasets"
href: "docs/download.qmd"
# TODO: change name to deprecated?
- section: "Analysis in R"
href: "R/README.md"
contents:
- href: "R/misc/Identifying_Runs.md"
Expand All @@ -61,41 +62,51 @@ website:
- href: "R/comparing-r-and-python/HADs-reprojection/WIP-Comparing-HADs-grids.md"
text: "WIP Comparing HADs grids"

- section: "python"
href: "python/README.md"
- section: "API Reference"
href: "docs/reference/index.qmd"
contents:
- section: "Reference"
href: "docs/reference/index.qmd"
- href: "docs/reference/clim_recal.pipeline.qmd"
text: "Pipeline"
- href: "docs/reference/clim_recal.config.qmd"
text: "Configure"
- href: "docs/reference/clim_recal.ceda_ftp_download.qmd"
text: "CEDA Data Access"
- href: "docs/reference/clim_recal.data_loader.qmd"
text: "Data Loading"
- href: "docs/reference/clim_recal.resample.qmd"
text: "Data Resampling"
- section: "Debiasing"
contents:
- href: "docs/reference/clim_recal.pipeline.qmd"
text: "Pipeline"
- href: "docs/reference/clim_recal.config.qmd"
text: "Configure"
- href: "docs/reference/clim_recal.ceda_ftp_download.qmd"
text: "CEDA Data Access"
- href: "docs/reference/clim_recal.data_loader.qmd"
text: "Data Loading"
- href: "docs/reference/clim_recal.resample.qmd"
text: "Data Resampling"
- section: "Debiasing"
contents:
- href: "docs/reference/clim_recal.debiasing.debias_wrapper.qmd"
text: "Wrapper"
- section: "Utilities"
contents:
- href: "docs/reference/clim_recal.utils.core.qmd"
text: "core"
- href: "docs/reference/clim_recal.utils.server.qmd"
text: "server"
- href: "docs/reference/clim_recal.utils.xarray.qmd"
text: "xarray"
- href: "docs/reference/clim_recal.utils.data.qmd"
text: "data"
- text: "Docker"
href: "docs/docker-configurations.qmd"
- href: "docs/reference/clim_recal.debiasing.debias_wrapper.qmd"
text: "Wrapper"
- section: "Utilities"
contents:
- href: "docs/reference/clim_recal.utils.core.qmd"
text: "core"
- href: "docs/reference/clim_recal.utils.server.qmd"
text: "server"
- href: "docs/reference/clim_recal.utils.xarray.qmd"
text: "xarray"
- href: "docs/reference/clim_recal.utils.data.qmd"
text: "data"
- text: "Contributing"
href: "docs/contributing.md"

- section: "Appendix"
contents:
- section: "CPM Projection Analysis"
href: "docs/cpm_projection.qmd"
contents:
- text: "Temporal Interpolation Artefacts"
href: "notebooks/cpm_projection_diff_plots.ipynb"
- text: "Nearest vs Linear Temporal Interpolation"
href: "notebooks/cpm_projection_diff_plots_linear_nearest.ipynb"
- text: "Docker"
href: "docs/docker-configurations.qmd"
- text: "Deprecated"
href: "docs/deprecated_pipeline.qmd"



quartodoc:
# the name used to import the package you want to create reference docs for
Expand Down
2 changes: 1 addition & 1 deletion compose/docs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ USER root

# Install the local python environment set via
# `pre-commit` in .conda-linux-64
RUN micromamba create -n clim-recal gdal=3.8.5 pdm rsync quartodoc jupyter -c conda-forge
RUN micromamba create -n clim-recal gdal=3.8.5 pdm rsync quartodoc jupyter jupyter-cache -c conda-forge


CMD micromamba run -n clim-recal quartodoc build && \
Expand Down
Loading
Loading