-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joseph Hamman
committed
Oct 10, 2019
1 parent
d1a4af4
commit 14ad3a1
Showing
9 changed files
with
419 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line. | ||
SPHINXOPTS = | ||
SPHINXBUILD = sphinx-build | ||
SOURCEDIR = . | ||
BUILDDIR = _build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.. currentmodule:: xsd.pointwise_models | ||
|
||
############# | ||
API reference | ||
############# | ||
|
||
This page provides an auto-generated summary of xsd's API. For more details | ||
and examples, refer to the relevant chapters in the main part of the | ||
documentation. | ||
|
||
Pointwise methods | ||
================= | ||
|
||
Xarray Wrappers | ||
~~~~~~~~~~~~~~~ | ||
|
||
.. autosummary:: | ||
:toctree: generated/ | ||
|
||
PointWiseDownscaler | ||
|
||
Linear Models | ||
~~~~~~~~~~~~~ | ||
|
||
.. autosummary:: | ||
:toctree: generated/ | ||
|
||
BcsdPrecipitation | ||
BcsdTemperature | ||
|
||
Transformers | ||
~~~~~~~~~~~~ | ||
|
||
.. autosummary:: | ||
:toctree: generated/ | ||
|
||
LinearTrendTransformer | ||
QuantileMapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# This file does only contain a selection of the most common options. For a | ||
# full list see the documentation: | ||
# http://www.sphinx-doc.org/en/master/config | ||
|
||
# -- Path setup -------------------------------------------------------------- | ||
|
||
# If extensions (or modules to document with autodoc) are in another directory, | ||
# add these directories to sys.path here. If the directory is relative to the | ||
# documentation root, use os.path.abspath to make it absolute, like shown here. | ||
# | ||
# import os | ||
# import sys | ||
# sys.path.insert(0, os.path.abspath('.')) | ||
|
||
|
||
# -- Project information ----------------------------------------------------- | ||
from pkg_resources import get_distribution | ||
import xsd | ||
|
||
project = 'xsd' | ||
copyright = '2019, Joe Hamman' | ||
author = 'Joe Hamman' | ||
|
||
release = get_distribution('xsd').version | ||
# for example take major/minor | ||
version = '.'.join(release.split('.')[:2]) | ||
|
||
# -- General configuration --------------------------------------------------- | ||
|
||
# If your documentation needs a minimal Sphinx version, state it here. | ||
# | ||
# needs_sphinx = '1.0' | ||
|
||
# Add any Sphinx extension module names here, as strings. They can be | ||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
# ones. | ||
extensions = [ | ||
'sphinx.ext.autodoc', | ||
'sphinx.ext.intersphinx', | ||
'sphinx.ext.mathjax', | ||
'sphinx.ext.viewcode', | ||
'sphinx.ext.autosummary' | ||
] | ||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ['_templates'] | ||
|
||
# The suffix(es) of source filenames. | ||
# You can specify multiple suffix as a list of string: | ||
# | ||
# source_suffix = ['.rst', '.md'] | ||
source_suffix = '.rst' | ||
|
||
# The master toctree document. | ||
master_doc = 'index' | ||
|
||
# The language for content autogenerated by Sphinx. Refer to documentation | ||
# for a list of supported languages. | ||
# | ||
# This is also used if you do content translation via gettext catalogs. | ||
# Usually you set "language" from the command line for these cases. | ||
# language = None | ||
|
||
# List of patterns, relative to source directory, that match files and | ||
# directories to ignore when looking for source files. | ||
# This pattern also affects html_static_path and html_extra_path. | ||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] | ||
|
||
# The name of the Pygments (syntax highlighting) style to use. | ||
pygments_style = "sphinx" | ||
|
||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
|
||
# The theme to use for HTML and HTML Help pages. See the documentation for | ||
# 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 = {} | ||
|
||
# Add any paths that contain custom static files (such as style sheets) here, | ||
# relative to this directory. They are copied after the builtin static files, | ||
# so a file named "default.css" will overwrite the builtin "default.css". | ||
html_static_path = ['_static'] | ||
|
||
# Custom sidebar templates, must be a dictionary that maps document names | ||
# to template names. | ||
# | ||
# The default sidebars (for documents that don't match any pattern) are | ||
# defined by theme itself. Builtin themes are using these templates by | ||
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', | ||
# 'searchbox.html']``. | ||
# | ||
# html_sidebars = {} | ||
|
||
|
||
# -- Options for HTMLHelp output --------------------------------------------- | ||
|
||
# Output file base name for HTML help builder. | ||
htmlhelp_basename = 'xsddoc' | ||
|
||
|
||
# -- Options for LaTeX output ------------------------------------------------ | ||
|
||
latex_elements = { | ||
# The paper size ('letterpaper' or 'a4paper'). | ||
# | ||
# 'papersize': 'letterpaper', | ||
|
||
# The font size ('10pt', '11pt' or '12pt'). | ||
# | ||
# 'pointsize': '10pt', | ||
|
||
# Additional stuff for the LaTeX preamble. | ||
# | ||
# 'preamble': '', | ||
|
||
# Latex figure (float) alignment | ||
# | ||
# 'figure_align': 'htbp', | ||
} | ||
|
||
# Grouping the document tree into LaTeX files. List of tuples | ||
# (source start file, target name, title, | ||
# author, documentclass [howto, manual, or own class]). | ||
latex_documents = [ | ||
(master_doc, 'xsd.tex', 'xsd Documentation', | ||
'Joe Hamman', 'manual'), | ||
] | ||
|
||
|
||
# -- Options for manual page output ------------------------------------------ | ||
|
||
# One entry per manual page. List of tuples | ||
# (source start file, name, description, authors, manual section). | ||
man_pages = [ | ||
(master_doc, 'xsd', 'xsd Documentation', | ||
[author], 1) | ||
] | ||
|
||
|
||
# -- Options for Texinfo output ---------------------------------------------- | ||
|
||
# Grouping the document tree into Texinfo files. List of tuples | ||
# (source start file, target name, title, author, | ||
# dir menu entry, description, category) | ||
texinfo_documents = [ | ||
(master_doc, 'xsd', 'xsd Documentation', | ||
author, 'xsd', 'Statistical Downscaling in Python', | ||
'Miscellaneous'), | ||
] | ||
|
||
|
||
# -- Options for Epub output ------------------------------------------------- | ||
|
||
# Bibliographic Dublin Core info. | ||
epub_title = project | ||
|
||
# The unique identifier of the text. This can be a ISBN number | ||
# or the project homepage. | ||
# | ||
# epub_identifier = '' | ||
|
||
# A unique identification for the text. | ||
# | ||
# epub_uid = '' | ||
|
||
# A list of files that should not be packed into the epub file. | ||
epub_exclude_files = ['search.html'] | ||
|
||
|
||
# -- Extension configuration ------------------------------------------------- | ||
|
||
# -- Options for intersphinx extension --------------------------------------- | ||
|
||
# Example configuration for intersphinx: refer to the Python standard library. | ||
intersphinx_mapping = { | ||
"python": ("https://docs.python.org/3/", None), | ||
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None), | ||
"numpy": ("https://docs.scipy.org/doc/numpy/", None), | ||
"xarray": ("http://xarray.pydata.org/en/stable/", None), | ||
"scikit-learn": ("https://scikit-learn.org/stable/", None), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.. xsd documentation master file, created by | ||
sphinx-quickstart on Wed Oct 9 13:59:33 2019. | ||
You can adapt this file completely to your liking, but it should at least | ||
contain the root `toctree` directive. | ||
Welcome to xsd's documentation! | ||
=============================== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
roadmap | ||
api | ||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
.. _roadmap: | ||
|
||
Development Roadmap | ||
=================== | ||
|
||
Author: Joe Hamman | ||
Date:September 15, 2019 | ||
|
||
Background and scope | ||
-------------------- | ||
|
||
`xsd` is a toolkit for statistical downscaling usising Xarray. It is meant to | ||
support the development of new and existing downscaling methods in a common | ||
framework. It implements a train/predict API that accepts Xarray objects, | ||
similiar to Python's Scikit-Learn, for building a range of downscaling models. | ||
For example, implementing a BCSD workflow may look something like this: | ||
|
||
.. code-block:: Python | ||
from xsd.pointwise_models import PointWiseDownscaler | ||
from xsd.models.bcsd import BCSDTemperature, bcsd_disaggregator | ||
# da_temp_train: xarray.DataArray (monthly) | ||
# da_temp_obs: xarray.DataArray (monthly) | ||
# da_temp_obs_daily: xarray.DataArray (daily) | ||
# da_temp_predict: xarray.DataArray (monthly) | ||
# create a model | ||
bcsd_model = PointWiseDownscaler(BCSDTemperature(), dim='time') | ||
# train the model | ||
bcsd_model.train(da_temp_train, da_temp_obs) | ||
# predict with the model (downscaled_temp: xr.DataArray) | ||
downscaled_temp = bcsd_model.predict(da_temp_predict) | ||
# disaggregate the downscaled data (final: xr.DataArray) | ||
final = bcsd_disaggregator(downscaled_temp, da_temp_obs_daily) | ||
We are currently envisioning the project having three componenets (described | ||
in the components section below). While we haven't started work on the deep | ||
learning models component, this is certainly a central motivation to this | ||
package and I am looking forward to starting on this work soon. | ||
|
||
Principles | ||
---------- | ||
|
||
- Open - aim to take the sausage making out downscaling; open-source methods, | ||
comparable, extensible | ||
- Scalable - plug into existing frameworks (e.g. dask/pangeo) to scale up, | ||
allow for use a single points to scale down | ||
- Portable - unopionated when it comes to compute platform | ||
- Tested - Rigourously tested, both on the computational and scientific | ||
implementation | ||
|
||
Components | ||
---------- | ||
|
||
1. `pointwise_models`: a collection of linear models that are intended to be | ||
applied point-by-point. These may be sklearn Pipelines or custom sklearn-like | ||
models (e.g. BCSDTemperature). | ||
2. `global_models`: (not implemented) concept space for deep learning-based | ||
models. | ||
3. `metrics`: (not implemented) concept space for a benchmarking suite | ||
|
||
Models | ||
------ | ||
|
||
XSD should provide a collection of a common set of downscaling models and the | ||
building blocks to construct new models. As a starter, I intend to implement | ||
the following models: | ||
|
||
Pointwise models | ||
~~~~~~~~~~~~~~~~ | ||
|
||
1. BCSD_[Temperature, Precipitation]: Wood et al 2002 | ||
2. ARRM: Stoner et al 2012 | ||
3. Delta Method | ||
4. Hybrid Delta Method | ||
5. GARD: https://github.com/NCAR/GARD | ||
6. ? | ||
|
||
Other methods, like LOCA, MACA, BCCA, etc, should also be possible. | ||
|
||
Global models | ||
~~~~~~~~~~~~~ | ||
|
||
This category of methods is really what is motivating the development of this | ||
package. We've seen some early work from TJ Vandal in this area but there is | ||
more work to be done. For now, I'll just jot down what a possible API might | ||
look like: | ||
|
||
.. code-block:: Python | ||
from xsd.global_models import GlobalDownscaler | ||
from xsd.global_models.deepsd import DeepSD | ||
# ... | ||
# create a model | ||
model = GlobalDownscaler(DeepSD()) | ||
# train the model | ||
model.train(da_temp_train, da_temp_obs) | ||
# predict with the model (downscaled_temp: xr.DataArray) | ||
downscaled_temp = model.predict(da_temp_predict) | ||
Dependencies | ||
------------ | ||
|
||
- Core: Xarray, Pandas, Dask, Scikit-learn, Numpy, Scipy | ||
- Optional: Statsmodels, Keras, PyTorch, Tensorflow, etc. | ||
|
||
Related projects | ||
---------------- | ||
|
||
- FUDGE: https://github.com/NOAA-GFDL/FUDGE | ||
- GARD: https://github.com/NCAR/GARD | ||
- DeepSD: https://github.com/tjvandal/deepsd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build-system] | ||
requires = ["setuptools>=30.3.0", "wheel", "setuptools_scm"] |
Oops, something went wrong.