Skip to content

Commit

Permalink
rename xrsimlab to xsimlab
Browse files Browse the repository at this point in the history
Also rename Dataset.simlab to Dataset.xsimlab
Also rename xrtopo to xtopo (doc: example)
  • Loading branch information
benbovy committed Jun 19, 2017
1 parent e488d1b commit 8975a6c
Show file tree
Hide file tree
Showing 21 changed files with 89 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
xrsimlab/_version.py export-subst
xsimlab/_version.py export-subst
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include versioneer.py
include xrsimlab/_version.py
include xsimlab/_version.py
30 changes: 15 additions & 15 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ This page provides an auto-generated summary of xarray-simlab's API. For more
details and examples, refer to the relevant sections in the main part of the
documentation.

Dataset.simlab (xarray accessor)
================================
Dataset.xsimlab (xarray accessor)
=================================

This accessor extends :py:class:`xarray.Dataset` with all the methods and
properties listed below. Proper use of this accessor should be like:

.. code-block:: python
>>> import xarray as xr # first import xarray
>>> import xrsimlab # import xrsimlab (the simlab xarray accessor is registered)
>>> import xsimlab # import xsimlab (the simlab xarray accessor is registered)
>>> ds = xr.Dataset()
>>> ds.simlab.<meth_or_prop> # access to the methods and properties listed below
>>> ds.xsimlab.<meth_or_prop> # access to the methods and properties listed below
.. currentmodule:: xarray

Expand All @@ -29,30 +29,30 @@ properties listed below. Proper use of this accessor should be like:
:toctree: _api_generated/
:template: autosummary/accessor_attribute.rst

Dataset.simlab.model
Dataset.simlab.dim_master_clock
Dataset.simlab.snapshot_vars
Dataset.xsimlab.model
Dataset.xsimlab.dim_master_clock
Dataset.xsimlab.snapshot_vars

**Methods**

.. autosummary::
:toctree: _api_generated/
:template: autosummary/accessor_method.rst

Dataset.simlab.use_model
Dataset.simlab.set_master_clock
Dataset.simlab.set_snapshot_clock
Dataset.simlab.set_input_vars
Dataset.simlab.set_snapshot_vars
Dataset.simlab.run
Dataset.xsimlab.use_model
Dataset.xsimlab.set_master_clock
Dataset.xsimlab.set_snapshot_clock
Dataset.xsimlab.set_input_vars
Dataset.xsimlab.set_snapshot_vars
Dataset.xsimlab.run

Model
=====

Creating a model
----------------

.. currentmodule:: xrsimlab
.. currentmodule:: xsimlab
.. autosummary::
:toctree: _api_generated/

Expand Down Expand Up @@ -86,7 +86,7 @@ Running a model
---------------

In most cases, the methods listed below should not be used directly.
For running simulations, it is preferable to use the ``Dataset.simlab`` accessor
For running simulations, it is preferable to use the ``Dataset.xsimlab`` accessor
instead. These methods might be useful for debugging, though.

.. autosummary::
Expand Down
8 changes: 4 additions & 4 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
except ImportError:
print("no xarray")

import xrsimlab
print("xrsimlab: %s, %s" % (xrsimlab.__version__, xrsimlab.__file__))
import xsimlab
print("xsimlab: %s, %s" % (xsimlab.__version__, xsimlab.__file__))

# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -90,9 +90,9 @@
# built documents.
#
# The short X.Y version.
version = xrsimlab.__version__
version = xsimlab.__version__
# The full version, including alpha/beta/rc tags.
release = xrsimlab.__version__
release = xsimlab.__version__

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions doc/create_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Creating models
===============

xarray-simlab's framework provides a few Python base classes, e.g.,
:class:`~xrsimlab.Variable`, :class:`~xrsimlab.Process` and
:class:`~xrsimlab.Model` that can used togheter to create fully operational
:class:`~xsimlab.Variable`, :class:`~xsimlab.Process` and
:class:`~xsimlab.Model` that can used togheter to create fully operational
models.

A ``Model`` is a collection of processes that each define an interface with the
Expand Down
64 changes: 32 additions & 32 deletions doc/examples/landscape-evolution-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"source": [
"import numpy as np\n",
"import xarray as xr\n",
"import xrsimlab"
"import xsimlab"
]
},
{
Expand All @@ -28,7 +28,7 @@
"source": [
"## Import and inspect a model\n",
"\n",
"The model (i.e., the `xrsimlab.Model` object) that we use here is provided by the [xarray-topo](https://gitext.gfz-potsdam.de/sec55-public/xarray-topo) package."
"The model (i.e., the `xsimlab.Model` object) that we use here is provided by the [xarray-topo](https://gitext.gfz-potsdam.de/sec55-public/xarray-topo) package."
]
},
{
Expand All @@ -39,7 +39,7 @@
},
"outputs": [],
"source": [
"from xrtopo.models.fastscape_base import fastscape_base_model"
"from xtopo.models.fastscape_base import fastscape_base_model"
]
},
{
Expand Down Expand Up @@ -67,7 +67,7 @@
{
"data": {
"text/plain": [
"<xrsimlab.Model (9 processes, 13 inputs)>\n",
"<xsimlab.Model (9 processes, 13 inputs)>\n",
"grid\n",
" x_size (in) nb. of nodes in x\n",
" y_size (in) nb. of nodes in y\n",
Expand Down Expand Up @@ -144,7 +144,7 @@
{
"data": {
"text/plain": [
"<xrsimlab.Process 'xrtopo.models.fastscape_base.StackedGridXY'>\n",
"<xsimlab.Process 'xtopo.models.fastscape_base.StackedGridXY'>\n",
"Variables:\n",
" x_size IntegerVariable ()\n",
" y_size IntegerVariable ()\n",
Expand Down Expand Up @@ -175,7 +175,7 @@
"source": [
"## Create a model setup\n",
"\n",
"With a few lines of code, using the `Dataset.simlab` extension (accessor), we create the setup of a new simulation, starting from an empty `Dataset`."
"With a few lines of code, using the `Dataset.xsimlab` extension (accessor), we create the setup of a new simulation, starting from an empty `Dataset`."
]
},
{
Expand All @@ -190,16 +190,16 @@
"ds = xr.Dataset() \n",
"\n",
"# use the model above with this Dataset\n",
"ds.simlab.use_model(fastscape_base_model) \n",
"ds.xsimlab.use_model(fastscape_base_model) \n",
"\n",
"# populate Dataset with input variable values (per process in the model)\n",
"ds.simlab.set_input_vars('grid', x_size=101, y_size=101, x_length=1e5, y_length=1e5)\n",
"ds.simlab.set_input_vars('topography', elevation=('node', np.random.rand(101 * 101)))\n",
"ds.simlab.set_input_vars('spower', k_coef=7e-5, m_exp=0.4, n_exp=1)\n",
"ds.simlab.set_input_vars('uplift', u_coef=2e-3)\n",
"ds.xsimlab.set_input_vars('grid', x_size=101, y_size=101, x_length=1e5, y_length=1e5)\n",
"ds.xsimlab.set_input_vars('topography', elevation=('node', np.random.rand(101 * 101)))\n",
"ds.xsimlab.set_input_vars('spower', k_coef=7e-5, m_exp=0.4, n_exp=1)\n",
"ds.xsimlab.set_input_vars('uplift', u_coef=2e-3)\n",
"\n",
"# set the clock coordinate where labels are time steps (here in years)\n",
"ds.simlab.set_master_clock('time', end=1e6, step=1e3)"
"ds.xsimlab.set_master_clock('time', end=1e6, step=1e3)"
]
},
{
Expand All @@ -218,10 +218,10 @@
"outputs": [],
"source": [
"# set another time coordinate for snapshots with much larger steps than for 'time'\n",
"ds.simlab.set_snapshot_clock('out', end=1e6, step=1e5)\n",
"ds.xsimlab.set_snapshot_clock('out', end=1e6, step=1e5)\n",
"\n",
"# use the last created time coordinate to save topographic elevation values\n",
"ds.simlab.set_snapshot_vars('out', topography='elevation')"
"ds.xsimlab.set_snapshot_vars('out', topography='elevation')"
]
},
{
Expand All @@ -240,7 +240,7 @@
"outputs": [],
"source": [
"# use None for saving time-independent outputs\n",
"ds.simlab.set_snapshot_vars(None, grid=['x', 'y'])"
"ds.xsimlab.set_snapshot_vars(None, grid=['x', 'y'])"
]
},
{
Expand Down Expand Up @@ -279,7 +279,7 @@
" spower__n_exp int64 1\n",
" uplift__u_coef float64 0.002\n",
"Attributes:\n",
" _simlab_snapshot_vars: grid__x,grid__y"
" _xsimlab_snapshot_vars: grid__x,grid__y"
]
},
"execution_count": 9,
Expand Down Expand Up @@ -327,7 +327,7 @@
"source": [
"## Run the model\n",
"\n",
"We run the model simply by calling `Dataset.simlab.run()`, which returns a new Dataset with both the inputs and the outputs. Note the additional variables `grid__x` and `grid__y` and the `topography__elevation` variable which has now also the `out` dimension. "
"We run the model simply by calling `Dataset.xsimlab.run()`, which returns a new Dataset with both the inputs and the outputs. Note the additional variables `grid__x` and `grid__y` and the `topography__elevation` variable which has now also the `out` dimension. "
]
},
{
Expand Down Expand Up @@ -368,7 +368,7 @@
}
],
"source": [
"out_ds = ds.simlab.run()\n",
"out_ds = ds.xsimlab.run()\n",
"\n",
"out_ds"
]
Expand Down Expand Up @@ -1403,7 +1403,7 @@
" spower__n_exp int64 1\n",
" uplift__u_coef float64 0.002\n",
"Attributes:\n",
" _simlab_snapshot_vars: grid__x,grid__y"
" _xsimlab_snapshot_vars: grid__x,grid__y"
]
},
"execution_count": 20,
Expand All @@ -1415,9 +1415,9 @@
"ds_kt = ds.copy()\n",
"\n",
"# we copied the dataset so we need to explicitly re-assign the Model\n",
"ds_kt.simlab.use_model(fastscape_base_model)\n",
"ds_kt.xsimlab.use_model(fastscape_base_model)\n",
"\n",
"ds_kt.simlab.set_input_vars('spower', k_coef=da_k_time, m_exp=0.4, n_exp=1)\n",
"ds_kt.xsimlab.set_input_vars('spower', k_coef=da_k_time, m_exp=0.4, n_exp=1)\n",
"\n",
"ds_kt"
]
Expand Down Expand Up @@ -1446,7 +1446,7 @@
}
],
"source": [
"out_ds_kt = ds_kt.simlab.run()\n",
"out_ds_kt = ds_kt.xsimlab.run()\n",
"\n",
"out_ds_kt_unstack = out_ds_kt.set_index(node=['grid__x', 'grid__y']).unstack('node')\n",
"\n",
Expand Down Expand Up @@ -1484,13 +1484,13 @@
"datasets_k = []\n",
" \n",
"ds_in = ds.copy()\n",
"ds_in.simlab.use_model(fastscape_base_model)\n",
"ds_in.xsimlab.use_model(fastscape_base_model)\n",
"\n",
"for k in k_values:\n",
" print('run k=%f' % k)\n",
"\n",
" ds_in.simlab.set_input_vars('spower', k_coef=k, m_exp=0.4, n_exp=1)\n",
" out_ds = ds_in.simlab.run()\n",
" ds_in.xsimlab.set_input_vars('spower', k_coef=k, m_exp=0.4, n_exp=1)\n",
" out_ds = ds_in.xsimlab.run()\n",
"\n",
" datasets_k.append(out_ds)\n",
"\n",
Expand Down Expand Up @@ -1985,11 +1985,11 @@
"metadata": {},
"outputs": [],
"source": [
"from xrtopo.models.fastscape_base import StackedGridXY, BoundaryFacesXY\n",
"from xrsimlab import Process, FloatVariable, Variable, ForeignVariable\n",
"from xtopo.models.fastscape_base import StackedGridXY, BoundaryFacesXY\n",
"from xsimlab import Process, FloatVariable, Variable, ForeignVariable\n",
"\n",
"\n",
"class VariableUplift(xrsimlab.Process):\n",
"class VariableUplift(xsimlab.Process):\n",
" \"\"\"Compute spatially variable uplift as a linear function of x.\"\"\"\n",
" \n",
" x_coef = FloatVariable((), description='uplift function x coefficient')\n",
Expand Down Expand Up @@ -2023,7 +2023,7 @@
{
"data": {
"text/plain": [
"<xrsimlab.Model (9 processes, 13 inputs)>\n",
"<xsimlab.Model (9 processes, 13 inputs)>\n",
"grid\n",
" x_size (in) nb. of nodes in x\n",
" y_size (in) nb. of nodes in y\n",
Expand Down Expand Up @@ -2076,10 +2076,10 @@
"\n",
"alt_ds = ds.drop('uplift__u_coef')\n",
"\n",
"alt_ds.simlab.use_model(alt_model)\n",
"alt_ds.simlab.set_input_vars('uplift', x_coef=1e-7)\n",
"alt_ds.xsimlab.use_model(alt_model)\n",
"alt_ds.xsimlab.set_input_vars('uplift', x_coef=1e-7)\n",
"\n",
"out_alt_ds = alt_ds.simlab.run()"
"out_alt_ds = alt_ds.xsimlab.run()"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion doc/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ Import xarray-simlab
To make sure that ``xarray-simlab`` is correctly installed, try import it in a
Python console::

>>> import xrsimlab
>>> import xsimlab
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ max-line-length = 80
[versioneer]
VCS = git
style = pep440
versionfile_source = xrsimlab/_version.py
versionfile_build = xrsimlab/_version.py
versionfile_source = xsimlab/_version.py
versionfile_build = xsimlab/_version.py
tag_prefix =
parentdir_prefix = xarray-simlab-
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
maintainer_email='benbovy@gmail.com',
license='BSD-Clause3',
keywords='python xarray modelling simulation-framework',
packages=['xrsimlab', 'xrsimlab.variable'],
packages=['xsimlab', 'xsimlab.variable'],
long_description=(open('README.md').read() if exists('README.md')
else ''),
python_requires='>=3.4',
Expand Down
2 changes: 1 addition & 1 deletion xrsimlab/__init__.py → xsimlab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xarray-simlab.
"""
from .xr_accessor import SimLabAccessor
from .xr_accessor import SimlabAccessor
from .variable.base import (Variable, ForeignVariable, VariableList,
VariableGroup, diagnostic, ValidationError)
from .variable.custom import NumberVariable, FloatVariable, IntegerVariable
Expand Down
2 changes: 1 addition & 1 deletion xrsimlab/_version.py → xsimlab/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_config():
cfg.style = "pep440"
cfg.tag_prefix = ""
cfg.parentdir_prefix = "xarray-simlab-"
cfg.versionfile_source = "xrsimlab/_version.py"
cfg.versionfile_source = "xsimlab/_version.py"
cfg.verbose = False
return cfg

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion xrsimlab/formatting.py → xsimlab/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _summarize_var(name, var, col_width, marker=' '):
if isinstance(var, tuple):
var_repr = "VariableList"
else:
var_repr = str(var).strip('<>').replace('xrsimlab.', '')
var_repr = str(var).strip('<>').replace('xsimlab.', '')
var_repr = maybe_truncate(var_repr, max_line_length - col_width)

return first_col + var_repr
Expand Down
File renamed without changes.

0 comments on commit 8975a6c

Please sign in to comment.