Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 84 additions & 41 deletions making_components/making_components.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
"\n",
"## Class definition and header\n",
"\n",
"A Landlab component is a class that inherits from `Component`. The name of the class should be in CamelCase, and should make sense when used in the sentence: \"A *(component-name)* is a...\". The class definition should be followed by a docstring. The docstring should include a list of parameters for the `__init__` method."
"A Landlab component is a class that inherits from `Component`. The name of the class should be in CamelCase, and should make sense when used in the sentence: \"A *(component-name)* is a...\". The class definition should be followed by a docstring. The docstring should include a list of parameters for the `__init__` method and succintly describe them."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
"collapsed": true
},
"outputs": [],
"source": [
Expand All @@ -68,17 +68,69 @@
" \n",
" Construction:\n",
" \n",
" KinwaveOverlandFlowModel(grid, [stuff to be added later])\n",
" KinwaveOverlandFlowModel(grid, precip_rate=1.0,\n",
" precip_duration=1.0,\n",
" infilt_rate=0.0,\n",
" roughness=0.01, **kwds)\n",
" \n",
" Parameters\n",
" ----------\n",
" grid : ModelGrid\n",
" A Landlab grid object.\n",
" [others to be added later]\n",
" precip_rate : float, optional (defaults to 1 mm/hr)\n",
" Precipitation rate, mm/hr\n",
" precip_duration : float, optional (defaults to 1 hour)\n",
" Duration of precipitation, hours\n",
" infilt_rate : float, optional (defaults to 0)\n",
" Maximum rate of infiltration, mm/hr\n",
" roughnes : float, defaults to 0.01\n",
" Manning roughness coefficient, s/m^1/3\n",
"\n",
" \"\"\"\n",
" \n",
" pass # just for now, until we add stuff..."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Doc tests"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The following section 'Examples' should help the user understand what is the component's purpose and how it works. It is an example (or examples) of its use in a (more or less) simple case within the Landlab framework: a grid is created, the component is instantiated on this grid and run. Unlike in the example below, we strongly recommend commenting your example(s) to explain what is happening.\n",
"This is also the section that will be run during the integration tests of your component (once you submitted a pull request to have your component merged into the Landlab master branch). All lines starting with >>> are run and should produce the results you provided: here, the test fail if `kw.vel_coeff` does not return `100.0.`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
" \"\"\"\n",
" Examples\n",
" --------\n",
" >>> from landlab import RasterModelGrid\n",
" >>> rg = RasterModelGrid((4, 5), 10.0)\n",
" >>> kw = KinwaveOverlandFlowModel(rg)\n",
" >>> kw.vel_coef\n",
" 100.0\n",
" >>> rg.at_node['surface_water__depth']\n",
" array([ 0., 0., 0., 0., 0.,\n",
" 0., 0., 0., 0., 0.,\n",
" 0., 0., 0., 0., 0.,\n",
" 0., 0., 0., 0., 0.])\n",
" \"\"\"\n",
" pass # just for now, until we add stuff..."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -112,7 +164,7 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
"collapsed": true
},
"outputs": [],
"source": [
Expand All @@ -128,7 +180,7 @@
"### Header information: `_output_var_names`\n",
"*Output variables* are those arrays (fields) that the component solves for as part of its normal operation. In our kinematic wave example, the component will create fields for topographic gradient, water depth, velocity, and discharge per unit width (a.k.a., specific discharge).\n",
"\n",
"Like `_input_var_names`, `_output_var_names` should be either a tuple of strings with names based on standard Landlab semantics."
"Like `_input_var_names`, `_output_var_names` should be either a tuple of strings with names based on <a href=\"https://github.com/landlab/landlab/wiki/Components#landlab-standard-naming-conventions\">standard Landlab semantics</a> ."
]
},
{
Expand Down Expand Up @@ -180,14 +232,6 @@
"This is a dictionary that describes the grid element to which each field is mapped. In our example, elevation and water depth (both scalars) are mapped to nodes, whereas velocity and discharge (both vectors) are mapped to links."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Header information: `_var_units`\n",
"This is a dictionary that defines the units of each variable (both input and output)."
]
},
{
"cell_type": "code",
"execution_count": 6,
Expand Down Expand Up @@ -471,7 +515,7 @@
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
"collapsed": true
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -515,7 +559,7 @@
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
"collapsed": true
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -548,6 +592,17 @@
" Maximum rate of infiltration, mm/hr\n",
" roughnes : float, defaults to 0.01\n",
" Manning roughness coefficient, s/m^1/3\n",
" \n",
" Examples\n",
" --------\n",
" >>> from landlab import RasterModelGrid\n",
" >>> rg = RasterModelGrid((4, 5), 10.0)\n",
" >>> kw = KinwaveOverlandFlowModel(rg)\n",
" >>> kw.vel_coef\n",
" 100.0\n",
" >>> rg.at_node['surface_water__depth']\n",
" array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n",
" 0., 0., 0., 0., 0., 0., 0.]) \n",
" \"\"\"\n",
"\n",
" _name = 'KinwaveOverlandFlowModel'\n",
Expand Down Expand Up @@ -700,9 +755,7 @@
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -742,7 +795,7 @@
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
"collapsed": true
},
"outputs": [],
"source": [
Expand All @@ -766,9 +819,7 @@
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -801,9 +852,7 @@
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -839,9 +888,7 @@
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand All @@ -865,9 +912,7 @@
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand All @@ -894,9 +939,7 @@
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -940,23 +983,23 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python [conda root]",
"language": "python",
"name": "python2"
"name": "conda-root-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
"pygments_lexer": "ipython3",
"version": "3.5.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}