Commit 008ef33b14e by Pierre Augier

First commit.

parents
syntax: glob
*.pyc
*~
*.egg-info*
*tmp
doc/_build/*
doc/generated
\ No newline at end of file
This diff is collapsed. Click to expand it.
clean_so:
find fluiddyn -name "*.so" -delete
tests:
python -m unittest discover
develop:
python setup.py develop
SpectrAtmo is a Python package for doing spectral analysing of GCM
results.
It uses the library for Spherical Harmonic `SHTns
<http://users.isterre.fr/nschaeff/SHTns/>`_.
License
-------
SpectrAtmo is distributed under the CeCILL-B_ License, enabling reuse
with few restrictions (GPL compatible french License).
.. _CeCILL-B: http://www.cecill.info/index.en.html
If you use SpectAtmos for research work, please `cite this paper
<http://dx.doi.org/10.1175/JAS-D-12-0281.1>`_::
@article {AugierLindborg2013,
author = {Pierre Augier and Erik Lindborg},
title = {A New Formulation of the Spectral Energy Budget of the Atmosphere,
with Application to Two High-Resolution General Circulation Models},
journal = {J. Atmos. Sci.},
doi = {10.1175/JAS-D-12-0281.1},
volume = {70}, number = {7}, pages = {2293--2308},
year = {2013},
}
Installation
------------
Install first `SHTns <http://users.isterre.fr/nschaeff/SHTns/>`_.
If you need `grads <http://iges.org/grads/>`_ to load the data,
install it manually.
To install the package spectatmos in the development mode, from the
root directory::
sudo python setup.py develop
Tests
-----
From the root directory or from any of the "test" directories::
python -m unittest discover
Please report bugs and feature request on the `issue tracker
<https://bitbucket.org/paugier/spectatmos/issues>`_.
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python $(shell which sphinx-build)
PAPER =
BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
IPYNB_DIR = $(abspath ipynb)
IPYTHON_NOTEBOOKS = $(wildcard ipynb/*.ipynb)
IPYTHON_NOTEBOOKS_RST = $(IPYTHON_NOTEBOOKS:.ipynb=.rst)
IPYTHON_NOTEBOOKS_DIR = $(IPYTHON_NOTEBOOKS:.ipynb=_files)
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
rm -rf $(BUILDDIR)/*
rm -rf $(IPYTHON_NOTEBOOKS_DIR)
rm -f $(IPYTHON_NOTEBOOKS_RST)
cleanall: clean
rm -rf generated html.zip
html: $(IPYTHON_NOTEBOOKS_RST)
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/fluidlab.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/fluidlab.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/fluidlab"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/fluidlab"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
zip: html
cd _build/html && zip -r html.zip * && mv html.zip ../../.
%.rst: %.ipynb
cd $(IPYNB_DIR) && ipython nbconvert --to rst $(notdir $<)
# -*- coding: utf-8 -*-
#
# fluidlab documentation build configuration file, created by
# sphinx-quickstart on Sun Mar 2 12:15:31 2014.
#
# This file is execfile() with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
# to be able to build the doc without h5py with Read the docs
on_rtd = os.environ.get('READTHEDOCS')
if on_rtd:
# this package comes from fluiddyn
from fluidrtd import mock_modules
mock_modules(['h5py', 'subprocess32'])
import fluiddyn as fld
# 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.
sys.path.insert(0, os.path.abspath('../scripts'))
sys.path.insert(0, os.path.abspath('./'))
# -- 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.doctest',
'sphinx.ext.todo',
# 'sphinx.ext.pngmath',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode', 'sphinx.ext.autosummary',
'numpydoc',
'mathmacro',
# 'IPython.sphinxext.ipython_directive'
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'SpectrAtmo'
copyright = u'2015, Pierre Augier'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = fld.__version__.split('.')
version = '{}.{}'.format(version[0], version[1])
# The full version, including alpha/beta/rc tags.
release = fld.__version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- 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 = 'default'
html_theme = 'sphinxdoc'
# 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 themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
html_short_title = 'SpectrAtmo '+release
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# 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 = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'doc'
# -- 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': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'spectratmo.tex', u'spectratmo Documentation',
u'Pierre Augier', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'SpectrAtmo', u'SpectrAtmo Documentation',
[u'Pierre Augier'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- 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 = [
('index', 'SpectrAtmo', u'SpectrAtmo Documentation',
u'Pierre Augier', 'FluidDyn', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# -- Other options ---------------------------------------------------------
numpydoc_show_class_members = False
autosummary_generate = True
autodoc_default_flags = ['show-inheritance']
autodoc_member_order = 'bysource'
todo_include_todos = True
.. SpectrAtmo documentation master file, created by
sphinx-quickstart on Sun Mar 2 12:15:31 2014.
Welcome to SpectrAtmo's documentation!
======================================
Blabla
User Guide
----------
..
.. toctree::
:maxdepth: 2
overview
install
tutorials
Modules Reference
-----------------
.. autosummary::
:toctree: generated/
spectratmo.spherical_harmonics
spectratmo.util
spectratmo.datasets
spectratmo.planets
More
----
.. toctree::
:maxdepth: 1
SpectrAtmo forge in Bitbucket <https://bitbucket.org/fluiddyn/spectratmo>
SpectrAtmo in PyPI <https://pypi.python.org/pypi/spectratmo/>
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
"""Sphinx extension provide a new directive *mathmacro*.
This extension has to be added after the other math extension since it
redefined the math directive and the math role. For example, like this
(in the conf.py file)::
extensions = [
'sphinx.ext.autodoc', 'sphinx.ext.doctest',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode', 'sphinx.ext.autosummary',
'numpydoc',
'mathmacro']
"""
from __future__ import print_function
import re
from docutils.parsers.rst.directives.misc import Replace
from sphinx.ext.mathbase import MathDirective
from sphinx.ext.mathbase import math_role
def multiple_replacer(replace_dict):
"""Return a function replacing doing multiple replacements.
The produced function replace `replace_dict.keys()` by
`replace_dict.values`, respectively.
"""
def replacement_function(match):
s = match.group(0)
end = s[-1]
if re.match(r'[\W_]', end):
return replace_dict[s[:-1]]+end
else:
return replace_dict[s]
pattern = "|".join([re.escape(k)+r'[\W_]'
for k in replace_dict.keys()])
pattern = re.compile(pattern, re.M)
return lambda string: pattern.sub(replacement_function, string)
def multiple_replace(string, replace_dict):
mreplace = multiple_replacer(replace_dict)
return mreplace(string)
class MathMacro(Replace):
"""Directive defining a math macro."""
def run(self):
if not hasattr(self.state.document, 'math_macros'):
self.state.document.math_macros = {}
latex_key = '\\'+self.state.parent.rawsource.split('|')[1]
self.state.document.math_macros[latex_key] = ''.join(self.content)
self.content[0] = ':math:`'+self.content[0]
self.content[-1] = self.content[-1]+'`'
return super(MathMacro, self).run()
class NewMathDirective(MathDirective):
"""New math block directive parsing the latex code."""
def run(self):
try:
math_macros = self.state.document.math_macros
except AttributeError:
pass
else:
if math_macros:
multiple_replace = multiple_replacer(math_macros)
for i, c in enumerate(self.content):
self.content[i] = multiple_replace(c)
for i, a in enumerate(self.arguments):
self.arguments[i] = multiple_replace(a)
return super(NewMathDirective, self).run()
def new_math_role(role, rawtext, text, lineno, inliner,
options={}, content=[]):
"""New math role parsing the latex code."""
try:
math_macros = inliner.document.math_macros
except AttributeError:
pass
else:
if math_macros:
rawtext = multiple_replace(rawtext, math_macros)
text = rawtext.split('`')[1]
return math_role(role, rawtext, text, lineno, inliner,
options=options, content=content)
def setup(app):
app.add_role('math', new_math_role)
app.add_directive('math', NewMathDirective)
app.add_directive('mathmacro', MathMacro)
from setuptools import setup, find_packages
from pkg_resources import parse_version
import os
here = os.path.abspath(os.path.dirname(__file__))
import sys
if sys.version_info[:2] < (2, 6) or (3, 0) <= sys.version_info[0:2] < (3, 2):
raise RuntimeError("Python version 2.6, 2.7 or >= 3.2 required.")
# Get the long description from the relevant file
with open(os.path.join(here, 'README.rst')) as f:
long_description = f.read()
# Get the version from the relevant file
d = {}
execfile('spectratmo/_version.py', d)
__version__ = d['__version__']
# Get the development status from the version string
parsed_version = parse_version(__version__)
if any(w in ['*a', '*alpha'] for w in parsed_version):
devstatus = 'Development Status :: 3 - Alpha'
elif any(w in ['*b', '*beta'] for w in parsed_version):
devstatus = 'Development Status :: 4 - Beta'
else:
devstatus = 'Development Status :: 5 - Production/Stable'
setup(name='spectratmo',
version=__version__,
description=('Toolkit for doing spectral analysing of GCM results.'),
long_description=long_description,
keywords='spectral analysis, GCM, Fluid dynamics, research',
author='Pierre Augier',
author_email='pierre.augier@legi.cnrs.fr',
url='https://bitbucket.org/paugier/spectatmos',
license='CeCILL B',
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 1 - Planning',
'Intended Audience :: Science/Research',
'Intended Audience :: Education',
'Topic :: Scientific/Engineering',
'License :: OSI Approved', # :: CeCILL License',
# Specify the Python versions you support here. In particular,
# ensure that you indicate whether you support Python 2,
# Python 3 or both.
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
# 'Programming Language :: Python :: 3',
# 'Programming Language :: Python :: 3.4',
],
packages=find_packages(exclude=['doc']),
install_requires=['numpy', 'matplotlib', 'h5py',
'pygrid', 'netCDF4'])
__version__ = '0.0.0.alpha'
"""Represent data sets
======================
.. autosummary::
:toctree:
base
"""
"""Base class of dataset
========================
.. autoclass:: DataSetGCM
:members:
:private-members: