Skip to content

Commit

Permalink
Small changes to Iris section 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
pp-mo committed Apr 25, 2019
1 parent f9fc72c commit 9f32da2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
29 changes: 17 additions & 12 deletions course_content/iris_course/3.Subcube_Extraction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"\n",
"## 3.1 Indexing<a id='indexing'></a>\n",
"\n",
"Cubes can be indexed in a familiar manner to that of NumPy arrays:"
"Cubes can be indexed in a similar manner to that of NumPy arrays:"
]
},
{
Expand Down Expand Up @@ -179,7 +179,8 @@
"outputs": [],
"source": [
"cubes = iris.load(fname)\n",
"print(cubes.extract('air_potential_temperature'))"
"potential_temperature_cubes = cubes.extract('air_potential_temperature')\n",
"print(potential_temperature_cubes)"
]
},
{
Expand All @@ -198,7 +199,10 @@
"outputs": [],
"source": [
"pot_temperature_constraint = iris.Constraint('air_potential_temperature')\n",
"print(cubes.extract(pot_temperature_constraint))"
"\n",
"pt2_cubes = cubes.extract(pot_temperature_constraint)\n",
"print(pt2_cubes)\n",
"print(pt2_cubes == potential_temperature_cubes)"
]
},
{
Expand Down Expand Up @@ -270,7 +274,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"As you may have seen in the iris.Constraint documentation, we can define arbitrary functions that operate on each cell of a coordinate. This is a common thing to do for floating point coordinates, where exact equality is non-trivial."
"As you may have seen in the iris.Constraint documentation, we can also make a Constraint from an arbitrary function that operates on each cell of a coordinate. This is a common thing to do for floating point coordinates, where exact equality testing is unreliable."
]
},
{
Expand All @@ -279,12 +283,13 @@
"metadata": {},
"outputs": [],
"source": [
"def less_than_10(cell):\n",
" \"\"\"Return True for values that are less than 10.\"\"\"\n",
" return cell < 10\n",
"def near_357p5(cell):\n",
" \"\"\"Return True for values close to 358.75. This will match one selected longitude point.\"\"\"\n",
" return 358.74 < cell < 358.76\n",
"\n",
"print(cubes.extract(iris.Constraint('air_potential_temperature',\n",
" model_level_number=less_than_10)))"
"model_level_10_cubes = cubes.extract(iris.Constraint('air_potential_temperature',\n",
" grid_longitude=near_357p5))\n",
"print(model_level_10_cubes)"
]
},
{
Expand Down Expand Up @@ -344,7 +349,7 @@
"source": [
"To combine different Constraints we use an `&`.\n",
"\n",
"For example, below we extract a cube named `air_potential_temperature` with model level numbers 4 and 10."
"For example, below we extract the data named `air_potential_temperature`, *and* with model level numbers 4 and 10."
]
},
{
Expand Down Expand Up @@ -522,7 +527,7 @@
"source": [
"----\n",
"\n",
"## 3.4 Exercise 3 <a id='exercise'></a>"
"## 3.4 Section Review Exercise <a id='exercise'></a>"
]
},
{
Expand Down Expand Up @@ -636,7 +641,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
"version": "3.6.8"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion course_content/iris_course/solutions/iris_exercise_3.1a
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Iris course sample answer 3.1a
# Index of first two elements from the first dimensions.
# Index of first two elements from the first dimension.

subcube[:2]

0 comments on commit 9f32da2

Please sign in to comment.