Skip to content

Commit 8975a6c

Browse files
committed
rename xrsimlab to xsimlab
Also rename Dataset.simlab to Dataset.xsimlab Also rename xrtopo to xtopo (doc: example)
1 parent e488d1b commit 8975a6c

21 files changed

+89
-89
lines changed

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
xrsimlab/_version.py export-subst
1+
xsimlab/_version.py export-subst

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
include versioneer.py
2-
include xrsimlab/_version.py
2+
include xsimlab/_version.py

doc/api.rst

+15-15
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ This page provides an auto-generated summary of xarray-simlab's API. For more
88
details and examples, refer to the relevant sections in the main part of the
99
documentation.
1010

11-
Dataset.simlab (xarray accessor)
12-
================================
11+
Dataset.xsimlab (xarray accessor)
12+
=================================
1313

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

1717
.. code-block:: python
1818
1919
>>> import xarray as xr # first import xarray
20-
>>> import xrsimlab # import xrsimlab (the simlab xarray accessor is registered)
20+
>>> import xsimlab # import xsimlab (the simlab xarray accessor is registered)
2121
>>> ds = xr.Dataset()
22-
>>> ds.simlab.<meth_or_prop> # access to the methods and properties listed below
22+
>>> ds.xsimlab.<meth_or_prop> # access to the methods and properties listed below
2323
2424
.. currentmodule:: xarray
2525

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

32-
Dataset.simlab.model
33-
Dataset.simlab.dim_master_clock
34-
Dataset.simlab.snapshot_vars
32+
Dataset.xsimlab.model
33+
Dataset.xsimlab.dim_master_clock
34+
Dataset.xsimlab.snapshot_vars
3535

3636
**Methods**
3737

3838
.. autosummary::
3939
:toctree: _api_generated/
4040
:template: autosummary/accessor_method.rst
4141

42-
Dataset.simlab.use_model
43-
Dataset.simlab.set_master_clock
44-
Dataset.simlab.set_snapshot_clock
45-
Dataset.simlab.set_input_vars
46-
Dataset.simlab.set_snapshot_vars
47-
Dataset.simlab.run
42+
Dataset.xsimlab.use_model
43+
Dataset.xsimlab.set_master_clock
44+
Dataset.xsimlab.set_snapshot_clock
45+
Dataset.xsimlab.set_input_vars
46+
Dataset.xsimlab.set_snapshot_vars
47+
Dataset.xsimlab.run
4848

4949
Model
5050
=====
5151

5252
Creating a model
5353
----------------
5454

55-
.. currentmodule:: xrsimlab
55+
.. currentmodule:: xsimlab
5656
.. autosummary::
5757
:toctree: _api_generated/
5858

@@ -86,7 +86,7 @@ Running a model
8686
---------------
8787

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

9292
.. autosummary::

doc/conf.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
except ImportError:
3333
print("no xarray")
3434

35-
import xrsimlab
36-
print("xrsimlab: %s, %s" % (xrsimlab.__version__, xrsimlab.__file__))
35+
import xsimlab
36+
print("xsimlab: %s, %s" % (xsimlab.__version__, xsimlab.__file__))
3737

3838
# -- General configuration ------------------------------------------------
3939

@@ -90,9 +90,9 @@
9090
# built documents.
9191
#
9292
# The short X.Y version.
93-
version = xrsimlab.__version__
93+
version = xsimlab.__version__
9494
# The full version, including alpha/beta/rc tags.
95-
release = xrsimlab.__version__
95+
release = xsimlab.__version__
9696

9797
# The language for content autogenerated by Sphinx. Refer to documentation
9898
# for a list of supported languages.

doc/create_model.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Creating models
44
===============
55

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

1111
A ``Model`` is a collection of processes that each define an interface with the

doc/examples/landscape-evolution-model.ipynb

+32-32
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"source": [
2020
"import numpy as np\n",
2121
"import xarray as xr\n",
22-
"import xrsimlab"
22+
"import xsimlab"
2323
]
2424
},
2525
{
@@ -28,7 +28,7 @@
2828
"source": [
2929
"## Import and inspect a model\n",
3030
"\n",
31-
"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."
31+
"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."
3232
]
3333
},
3434
{
@@ -39,7 +39,7 @@
3939
},
4040
"outputs": [],
4141
"source": [
42-
"from xrtopo.models.fastscape_base import fastscape_base_model"
42+
"from xtopo.models.fastscape_base import fastscape_base_model"
4343
]
4444
},
4545
{
@@ -67,7 +67,7 @@
6767
{
6868
"data": {
6969
"text/plain": [
70-
"<xrsimlab.Model (9 processes, 13 inputs)>\n",
70+
"<xsimlab.Model (9 processes, 13 inputs)>\n",
7171
"grid\n",
7272
" x_size (in) nb. of nodes in x\n",
7373
" y_size (in) nb. of nodes in y\n",
@@ -144,7 +144,7 @@
144144
{
145145
"data": {
146146
"text/plain": [
147-
"<xrsimlab.Process 'xrtopo.models.fastscape_base.StackedGridXY'>\n",
147+
"<xsimlab.Process 'xtopo.models.fastscape_base.StackedGridXY'>\n",
148148
"Variables:\n",
149149
" x_size IntegerVariable ()\n",
150150
" y_size IntegerVariable ()\n",
@@ -175,7 +175,7 @@
175175
"source": [
176176
"## Create a model setup\n",
177177
"\n",
178-
"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`."
178+
"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`."
179179
]
180180
},
181181
{
@@ -190,16 +190,16 @@
190190
"ds = xr.Dataset() \n",
191191
"\n",
192192
"# use the model above with this Dataset\n",
193-
"ds.simlab.use_model(fastscape_base_model) \n",
193+
"ds.xsimlab.use_model(fastscape_base_model) \n",
194194
"\n",
195195
"# populate Dataset with input variable values (per process in the model)\n",
196-
"ds.simlab.set_input_vars('grid', x_size=101, y_size=101, x_length=1e5, y_length=1e5)\n",
197-
"ds.simlab.set_input_vars('topography', elevation=('node', np.random.rand(101 * 101)))\n",
198-
"ds.simlab.set_input_vars('spower', k_coef=7e-5, m_exp=0.4, n_exp=1)\n",
199-
"ds.simlab.set_input_vars('uplift', u_coef=2e-3)\n",
196+
"ds.xsimlab.set_input_vars('grid', x_size=101, y_size=101, x_length=1e5, y_length=1e5)\n",
197+
"ds.xsimlab.set_input_vars('topography', elevation=('node', np.random.rand(101 * 101)))\n",
198+
"ds.xsimlab.set_input_vars('spower', k_coef=7e-5, m_exp=0.4, n_exp=1)\n",
199+
"ds.xsimlab.set_input_vars('uplift', u_coef=2e-3)\n",
200200
"\n",
201201
"# set the clock coordinate where labels are time steps (here in years)\n",
202-
"ds.simlab.set_master_clock('time', end=1e6, step=1e3)"
202+
"ds.xsimlab.set_master_clock('time', end=1e6, step=1e3)"
203203
]
204204
},
205205
{
@@ -218,10 +218,10 @@
218218
"outputs": [],
219219
"source": [
220220
"# set another time coordinate for snapshots with much larger steps than for 'time'\n",
221-
"ds.simlab.set_snapshot_clock('out', end=1e6, step=1e5)\n",
221+
"ds.xsimlab.set_snapshot_clock('out', end=1e6, step=1e5)\n",
222222
"\n",
223223
"# use the last created time coordinate to save topographic elevation values\n",
224-
"ds.simlab.set_snapshot_vars('out', topography='elevation')"
224+
"ds.xsimlab.set_snapshot_vars('out', topography='elevation')"
225225
]
226226
},
227227
{
@@ -240,7 +240,7 @@
240240
"outputs": [],
241241
"source": [
242242
"# use None for saving time-independent outputs\n",
243-
"ds.simlab.set_snapshot_vars(None, grid=['x', 'y'])"
243+
"ds.xsimlab.set_snapshot_vars(None, grid=['x', 'y'])"
244244
]
245245
},
246246
{
@@ -279,7 +279,7 @@
279279
" spower__n_exp int64 1\n",
280280
" uplift__u_coef float64 0.002\n",
281281
"Attributes:\n",
282-
" _simlab_snapshot_vars: grid__x,grid__y"
282+
" _xsimlab_snapshot_vars: grid__x,grid__y"
283283
]
284284
},
285285
"execution_count": 9,
@@ -327,7 +327,7 @@
327327
"source": [
328328
"## Run the model\n",
329329
"\n",
330-
"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. "
330+
"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. "
331331
]
332332
},
333333
{
@@ -368,7 +368,7 @@
368368
}
369369
],
370370
"source": [
371-
"out_ds = ds.simlab.run()\n",
371+
"out_ds = ds.xsimlab.run()\n",
372372
"\n",
373373
"out_ds"
374374
]
@@ -1403,7 +1403,7 @@
14031403
" spower__n_exp int64 1\n",
14041404
" uplift__u_coef float64 0.002\n",
14051405
"Attributes:\n",
1406-
" _simlab_snapshot_vars: grid__x,grid__y"
1406+
" _xsimlab_snapshot_vars: grid__x,grid__y"
14071407
]
14081408
},
14091409
"execution_count": 20,
@@ -1415,9 +1415,9 @@
14151415
"ds_kt = ds.copy()\n",
14161416
"\n",
14171417
"# we copied the dataset so we need to explicitly re-assign the Model\n",
1418-
"ds_kt.simlab.use_model(fastscape_base_model)\n",
1418+
"ds_kt.xsimlab.use_model(fastscape_base_model)\n",
14191419
"\n",
1420-
"ds_kt.simlab.set_input_vars('spower', k_coef=da_k_time, m_exp=0.4, n_exp=1)\n",
1420+
"ds_kt.xsimlab.set_input_vars('spower', k_coef=da_k_time, m_exp=0.4, n_exp=1)\n",
14211421
"\n",
14221422
"ds_kt"
14231423
]
@@ -1446,7 +1446,7 @@
14461446
}
14471447
],
14481448
"source": [
1449-
"out_ds_kt = ds_kt.simlab.run()\n",
1449+
"out_ds_kt = ds_kt.xsimlab.run()\n",
14501450
"\n",
14511451
"out_ds_kt_unstack = out_ds_kt.set_index(node=['grid__x', 'grid__y']).unstack('node')\n",
14521452
"\n",
@@ -1484,13 +1484,13 @@
14841484
"datasets_k = []\n",
14851485
" \n",
14861486
"ds_in = ds.copy()\n",
1487-
"ds_in.simlab.use_model(fastscape_base_model)\n",
1487+
"ds_in.xsimlab.use_model(fastscape_base_model)\n",
14881488
"\n",
14891489
"for k in k_values:\n",
14901490
" print('run k=%f' % k)\n",
14911491
"\n",
1492-
" ds_in.simlab.set_input_vars('spower', k_coef=k, m_exp=0.4, n_exp=1)\n",
1493-
" out_ds = ds_in.simlab.run()\n",
1492+
" ds_in.xsimlab.set_input_vars('spower', k_coef=k, m_exp=0.4, n_exp=1)\n",
1493+
" out_ds = ds_in.xsimlab.run()\n",
14941494
"\n",
14951495
" datasets_k.append(out_ds)\n",
14961496
"\n",
@@ -1985,11 +1985,11 @@
19851985
"metadata": {},
19861986
"outputs": [],
19871987
"source": [
1988-
"from xrtopo.models.fastscape_base import StackedGridXY, BoundaryFacesXY\n",
1989-
"from xrsimlab import Process, FloatVariable, Variable, ForeignVariable\n",
1988+
"from xtopo.models.fastscape_base import StackedGridXY, BoundaryFacesXY\n",
1989+
"from xsimlab import Process, FloatVariable, Variable, ForeignVariable\n",
19901990
"\n",
19911991
"\n",
1992-
"class VariableUplift(xrsimlab.Process):\n",
1992+
"class VariableUplift(xsimlab.Process):\n",
19931993
" \"\"\"Compute spatially variable uplift as a linear function of x.\"\"\"\n",
19941994
" \n",
19951995
" x_coef = FloatVariable((), description='uplift function x coefficient')\n",
@@ -2023,7 +2023,7 @@
20232023
{
20242024
"data": {
20252025
"text/plain": [
2026-
"<xrsimlab.Model (9 processes, 13 inputs)>\n",
2026+
"<xsimlab.Model (9 processes, 13 inputs)>\n",
20272027
"grid\n",
20282028
" x_size (in) nb. of nodes in x\n",
20292029
" y_size (in) nb. of nodes in y\n",
@@ -2076,10 +2076,10 @@
20762076
"\n",
20772077
"alt_ds = ds.drop('uplift__u_coef')\n",
20782078
"\n",
2079-
"alt_ds.simlab.use_model(alt_model)\n",
2080-
"alt_ds.simlab.set_input_vars('uplift', x_coef=1e-7)\n",
2079+
"alt_ds.xsimlab.use_model(alt_model)\n",
2080+
"alt_ds.xsimlab.set_input_vars('uplift', x_coef=1e-7)\n",
20812081
"\n",
2082-
"out_alt_ds = alt_ds.simlab.run()"
2082+
"out_alt_ds = alt_ds.xsimlab.run()"
20832083
]
20842084
},
20852085
{

doc/installing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ Import xarray-simlab
5656
To make sure that ``xarray-simlab`` is correctly installed, try import it in a
5757
Python console::
5858

59-
>>> import xrsimlab
59+
>>> import xsimlab

setup.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ max-line-length = 80
1313
[versioneer]
1414
VCS = git
1515
style = pep440
16-
versionfile_source = xrsimlab/_version.py
17-
versionfile_build = xrsimlab/_version.py
16+
versionfile_source = xsimlab/_version.py
17+
versionfile_build = xsimlab/_version.py
1818
tag_prefix =
1919
parentdir_prefix = xarray-simlab-

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
maintainer_email='[email protected]',
1616
license='BSD-Clause3',
1717
keywords='python xarray modelling simulation-framework',
18-
packages=['xrsimlab', 'xrsimlab.variable'],
18+
packages=['xsimlab', 'xsimlab.variable'],
1919
long_description=(open('README.md').read() if exists('README.md')
2020
else ''),
2121
python_requires='>=3.4',

xrsimlab/__init__.py renamed to xsimlab/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
xarray-simlab.
33
44
"""
5-
from .xr_accessor import SimLabAccessor
5+
from .xr_accessor import SimlabAccessor
66
from .variable.base import (Variable, ForeignVariable, VariableList,
77
VariableGroup, diagnostic, ValidationError)
88
from .variable.custom import NumberVariable, FloatVariable, IntegerVariable

xrsimlab/_version.py renamed to xsimlab/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def get_config():
4242
cfg.style = "pep440"
4343
cfg.tag_prefix = ""
4444
cfg.parentdir_prefix = "xarray-simlab-"
45-
cfg.versionfile_source = "xrsimlab/_version.py"
45+
cfg.versionfile_source = "xsimlab/_version.py"
4646
cfg.verbose = False
4747
return cfg
4848

File renamed without changes.

xrsimlab/formatting.py renamed to xsimlab/formatting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _summarize_var(name, var, col_width, marker=' '):
3838
if isinstance(var, tuple):
3939
var_repr = "VariableList"
4040
else:
41-
var_repr = str(var).strip('<>').replace('xrsimlab.', '')
41+
var_repr = str(var).strip('<>').replace('xsimlab.', '')
4242
var_repr = maybe_truncate(var_repr, max_line_length - col_width)
4343

4444
return first_col + var_repr
File renamed without changes.

0 commit comments

Comments
 (0)