Skip to content

Commit

Permalink
fix docs (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion authored Feb 11, 2024
1 parent bf3b012 commit 1e19b74
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 70 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.py[cod]
__pycache__
.vscode

# PyCharm stuffs
.idea/
Expand Down
1 change: 0 additions & 1 deletion ci/requirements-py310-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ channels:
- conda-forge
dependencies:
- python=3.10
- six
- numpy
- scipy
- pyproj
Expand Down
1 change: 0 additions & 1 deletion ci/requirements-py311-min.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ channels:
- conda-forge
dependencies:
- python=3.11
- six
- numpy
- scipy
- pyproj
Expand Down
1 change: 0 additions & 1 deletion ci/requirements-py311-xr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ channels:
- conda-forge
dependencies:
- python=3.11
- six
- numpy
- scipy
- pyproj
Expand Down
1 change: 0 additions & 1 deletion ci/requirements-py312-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ channels:
- conda-forge
dependencies:
- python=3.12
- six
- numpy
- scipy
- pyproj
Expand Down
47 changes: 23 additions & 24 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# 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
Expand All @@ -119,8 +119,8 @@
'sphinx_gallery.gen_gallery',
]

extlinks = {'issue': ('https://github.com/fmaussion/salem/issues/%s', 'GH'),
'pull': ('https://github.com/fmaussion/salem/pull/%s', 'PR'),
extlinks = {'issue': ('https://github.com/fmaussion/salem/issues/%s', 'GH%s'),
'pull': ('https://github.com/fmaussion/salem/pull/%s', 'PR%s'),
}

sphinx_gallery_conf = {
Expand All @@ -147,7 +147,7 @@
source_suffix = '.rst'

# The encoding of source files.
#source_encoding = 'utf-8-sig'
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'
Expand All @@ -162,7 +162,7 @@
# built documents.
#
# The short X.Y version.
version = salem.version.short_version
version = salem.__version__.split('+')[0]
# The full version, including alpha/beta/rc tags.
release = salem.__version__

Expand All @@ -175,24 +175,24 @@

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# 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
# default_role = None

# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# 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
# add_module_names = True

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
Expand All @@ -205,7 +205,7 @@
#modindex_common_prefix = []

# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# keep_warnings = False

# If true, `todo` and `todoList` produce output, else they produce nothing.
# todo_include_todos = True
Expand Down Expand Up @@ -337,29 +337,28 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'salem.tex', 'salem Documentation',
'salem Developers', 'manual'),
(master_doc, 'salem.tex', 'salem Documentation', 'salem Developers', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# latex_logo = None

# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# latex_use_parts = False

# If true, show page references after internal links.
#latex_show_pagerefs = False
# latex_show_pagerefs = False

# If true, show URL addresses after external links.
#latex_show_urls = False
# latex_show_urls = False

# Documents to append as an appendix to all manuals.
#latex_appendices = []
# latex_appendices = []

# If false, no module index is generated.
#latex_domain_indices = True
# latex_domain_indices = True


# -- Options for manual page output ---------------------------------------
Expand All @@ -379,24 +378,24 @@

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'salem', 'salem Documentation',
author, 'salem', 'Geoscientific data analysis and map projections.',
'Miscellaneous'),
]

# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# texinfo_appendices = []

# If false, no module index is generated.
#texinfo_domain_indices = True
# texinfo_domain_indices = True

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# texinfo_show_urls = 'footnote'

# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
# texinfo_no_detailmenu = False

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
Expand Down
16 changes: 8 additions & 8 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Let's take a time slice of the variable ``T2`` for a start:
t2 = ds.T2.isel(Time=2)
@savefig plot_wrf_t2.png width=80%
t2.salem.quick_map()
t2.salem.quick_map();
Although we are on a Lambert Conformal projection, it's possible to subset
the file using longitudes and latitudes:
Expand All @@ -33,7 +33,7 @@ the file using longitudes and latitudes:
t2_sub = t2.salem.subset(corners=((77., 20.), (97., 35.)), crs=salem.wgs84)
@savefig plot_wrf_t2_corner_sub.png width=80%
t2_sub.salem.quick_map()
t2_sub.salem.quick_map();
It's also possible to use geometries or shapefiles to subset your data:

Expand All @@ -45,7 +45,7 @@ It's also possible to use geometries or shapefiles to subset your data:
t2_sub = t2_sub.salem.subset(shape=shdf, margin=2) # add 2 grid points
@savefig plot_wrf_t2_country_sub.png width=80%
t2_sub.salem.quick_map()
t2_sub.salem.quick_map();
Based on the same principle, one can mask out the useless grid points:

Expand All @@ -54,7 +54,7 @@ Based on the same principle, one can mask out the useless grid points:
t2_roi = t2_sub.salem.roi(shape=shdf)
@savefig plot_wrf_t2_roi.png width=80%
t2_roi.salem.quick_map()
t2_roi.salem.quick_map();
Plotting
Expand All @@ -72,7 +72,7 @@ and more:
smap.set_text(91.2, 29.7, 'Lhasa', fontsize=17)
@savefig plot_wrf_t2_topo.png width=80%
smap.visualize()
smap.visualize();
Maps are persistent, which is useful when you have many plots to do. Plotting
further data on them is possible, as long
Expand All @@ -86,7 +86,7 @@ Celsius so we have to set it explicitly):
smap.set_data(ds.T2.isel(Time=1)-273.15, crs=ds.salem.grid)
@savefig plot_wrf_t2_transform.png width=80%
smap.visualize(title='2m temp - large domain', cbar_title='C')
smap.visualize(title='2m temp - large domain', cbar_title='C');
Reprojecting data
Expand All @@ -100,12 +100,12 @@ Salem can also transform data from one grid to another:
t2_era_reproj = ds.salem.transform(dse.t2m)
assert t2_era_reproj.salem.grid == ds.salem.grid
@savefig plot_era_repr_nn.png width=80%
t2_era_reproj.isel(time=0).salem.quick_map()
t2_era_reproj.isel(time=0).salem.quick_map();
.. ipython:: python
t2_era_reproj = ds.salem.transform(dse.t2m, interp='spline')
@savefig plot_era_repr_spline.png width=80%
t2_era_reproj.isel(time=0).salem.quick_map()
t2_era_reproj.isel(time=0).salem.quick_map();
4 changes: 2 additions & 2 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Frequently Asked Questions
What is the development status of the salem library?
----------------------------------------------------

As of today (August 2021), salem is used by several people (number unknown)
and is used by at least one downstream larger project
As of today (February 2024), salem is used by several people (number unknown)
and is used by at least one larger project important to me
(`OGGM <https://oggm.org>`_). I plan to continue to maintain salem in the
future, but cannot spend much time and energy in new, larger features that
the community might need. These larger features (mostly: improved support
Expand Down
2 changes: 1 addition & 1 deletion docs/gis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The default is to define the grids according to the pixels center point:
smap.set_points(lon.flatten(), lat.flatten())
@savefig plot_example_grid.png width=80%
smap.visualize(addcbar=False)
smap.visualize(addcbar=False);
But with the ``pixel_ref`` keyword you can use another convention. For Salem,
the two conventions are identical:
Expand Down
5 changes: 2 additions & 3 deletions docs/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ Salem is a pure python package, but it has several non-trivial dependencies.
Required dependencies
---------------------

- Python 2.7 or 3+ (Py3 `recommended <https://python3statement.github.io/>`__)
- Python 3+
- `numpy <http://www.numpy.org/>`__ (of course)
- `scipy <http://scipy.org/>`__: for its interpolation tools, among other things
- `pyproj <https://jswhit.github.io/pyproj/>`__: for map projections transformations
- `netCDF4 <https://github.com/Unidata/netcdf4-python>`__: to read most geoscientific files
- `pandas <http://pandas.pydata.org/>`__: working with labeled data
- `xarray <https://jswhit.github.io/pyproj/>`__ (0.8 or later): pandas in N-dimensions
- `xarray <https://jswhit.github.io/pyproj/>`__ : pandas in N-dimensions
- `joblib <https://pythonhosted.org/joblib/>`__: for it's `Memory`_ class
- `six <https://pythonhosted.org/six//>`__: for Py2 compatibility

.. _Memory: https://pythonhosted.org/joblib/memory.html

Expand Down
6 changes: 3 additions & 3 deletions docs/plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ nice looking regional maps:
.. ipython:: python
@savefig salem_quickmap.png width=80%
ds.T2C.isel(time=1).salem.quick_map()
ds.T2C.isel(time=1).salem.quick_map();
Salem maps are different from cartopy's in that they don't change the
matplotlib axes' projection. The map background is always going to be a
Expand All @@ -79,7 +79,7 @@ call to `imshow()`_, with an image size decided at instanciation:
smap.grid.nx, smap.grid.ny # size of the "image", and thus of the axes
@savefig map_central_europe.png width=100%
smap.visualize(addcbar=False)
smap.visualize(addcbar=False);
The map has it's own grid, wich is used internally in order to transform
the data that has to be plotted on it:
Expand All @@ -89,7 +89,7 @@ the data that has to be plotted on it:
ds = open_xr_dataset(get_demo_file('histalp_avg_1961-1990.nc'))
smap.set_data(ds.prcp) # histalp is a lon/lat dataset
@savefig map_histalp.png width=100%
smap.visualize()
smap.visualize();
Refer to :ref:`recipes` for more examples on how to use salem's maps.

Expand Down
4 changes: 2 additions & 2 deletions docs/wrf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ accumulated fields). For a list of diagnostic variables (and TODOs!), refer to
.. ipython:: python
@savefig plot_wrf_diag.png width=80%
ds.PRCP.isel(time=-1).salem.quick_map(cmap='Purples', vmax=5)
ds.PRCP.isel(time=-1).salem.quick_map(cmap='Purples', vmax=5);
Vertical interpolation
Expand Down Expand Up @@ -147,4 +147,4 @@ file and parse it:
maps[0].set_rgb(natural_earth='lr') # add a background image
@savefig plot_geo_simu.png width=100%
maps[0].visualize(title='Domains 1 to 4')
maps[0].visualize(title='Domains 1 to 4');
9 changes: 2 additions & 7 deletions salem/gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
# Python 2 stuff
from __future__ import division
from six import string_types

# Builtins
import copy
Expand Down Expand Up @@ -55,18 +54,14 @@ def check_crs(crs, raise_on_error=False):
except:
pass

if isinstance(crs, string_types):
# necessary for python 2
crs = str(crs)

err1, err2 = None, None

if isinstance(crs, pyproj.Proj) or isinstance(crs, Grid):
out = crs
elif isinstance(crs, crs_type):
out = pyproj.Proj(crs.to_wkt(), preserve_units=True)
elif isinstance(crs, dict) or isinstance(crs, string_types):
if isinstance(crs, string_types):
elif isinstance(crs, dict) or isinstance(crs, str):
if isinstance(crs, str):
# quick fix for https://github.com/pyproj4/pyproj/issues/345
crs = crs.replace(' ', '').replace('+', ' +')

Expand Down
Loading

0 comments on commit 1e19b74

Please sign in to comment.