Skip to content

Commit

Permalink
fix doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlittle committed May 27, 2020
1 parent 9ba7171 commit 481528b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 41 deletions.
60 changes: 38 additions & 22 deletions docs/tephi/source/customise.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This section discusses how finer control of the tephigram isobars, saturated adi
.. testsetup::

import tephi
from pprint import pprint


Isobar control
Expand All @@ -18,7 +19,7 @@ Isobar lines

The default behaviour of the tephigram *isobar line* is controlled by the :data:`tephi.ISOBAR_LINE` dictionary:

>>> print tephi.ISOBAR_LINE
>>> print(tephi.ISOBAR_LINE)
{'color': 'blue', 'linewidth': 0.5, 'clip_on': True}

This is a dictionary of *key* and *value* pairs that are passed through as keyword arguments to :func:`matplotlib.pyplot.plot`.
Expand Down Expand Up @@ -53,8 +54,13 @@ Isobar text

Similarly, the default behaviour of the tephigram *isobar text* is controlled by the :data:`tephi.ISOBAR_TEXT` dictionary:

>>> print tephi.ISOBAR_TEXT
{'color': 'blue', 'va': 'bottom', 'ha': 'right', 'clip_on': True, 'size': 8}
>>> pprint(tephi.ISOBAR_TEXT)
{'clip_on': True,
'color': 'blue',
'ha': 'right',
'size': 8,
'transform': <...>,
'va': 'bottom'}

This is a dictionary of *key* and *value* pairs that are passed through as keyword arguments to :func:`matplotlib.pyplot.text`.

Expand Down Expand Up @@ -88,7 +94,7 @@ Isobar frequency

The *frequency* at which isobar lines are plotted on the tephigram is controlled by the :data:`tephi.ISOBAR_SPEC` list:

>>> print tephi.ISOBAR_SPEC
>>> print(tephi.ISOBAR_SPEC)
[(25, 0.03), (50, 0.1), (100, 0.25), (200, 1.5)]

This :term:`line specification` is a sequence of one or more tuple pairs that contain an isobar pressure :term:`line step` and a :term:`zoom level`.
Expand All @@ -99,9 +105,9 @@ below ``0.03``.
The *overall range* of isobar pressure levels that may be plotted is controlled by the :data:`tephi.MIN_PRESSURE` and
:data:`tephi.MAX_PRESSURE` variables:

>>> print tephi.MIN_PRESSURE
>>> print(tephi.MIN_PRESSURE)
50
>>> print tephi.MAX_PRESSURE
>>> print(tephi.MAX_PRESSURE)
1000

Note that, it is possible to set a *fixed* isobar pressure :term:`line step` for a tephigram plot by setting the associated :term:`zoom level` to ``None``.
Expand Down Expand Up @@ -133,7 +139,7 @@ For example, to **always** show isobar lines that are a multiple of 50 mb, irres

It is also possible to control which *individual* isobar lines should be *fixed* via the :data:`tephi.ISOBAR_FIXED` list:

>>> print tephi.ISOBAR_FIXED
>>> print(tephi.ISOBAR_FIXED)
[50, 1000]

By default, the isobar lines at 50 mb and 1000 mb will **always** be plotted.
Expand All @@ -145,9 +151,9 @@ Isobar line extent
The extent of each tephigram *isobar line* is controlled by the :data:`tephi.MIN_THETA` and
:data:`tephi.MAX_THETA` variables:

>>> print tephi.MIN_THETA
>>> print(tephi.MIN_THETA)
0
>>> print tephi.MAX_THETA
>>> print(tephi.MAX_THETA)
250

For example, to change the isobar line extent behaviour to be between 15 :sup:`o`\ C and 60 :sup:`o`\ C,
Expand Down Expand Up @@ -185,7 +191,7 @@ Saturated adiabat lines

The default behaviour of the tephigram *pseudo saturated wet adiabat line* is controlled by the :data:`tephi.WET_ADIABAT_LINE` dictionary:

>>> print .WET_ADIABAT_LINE
>>> print(tephi.WET_ADIABAT_LINE)
{'color': 'orange', 'linewidth': 0.5, 'clip_on': True}

This is a dictionary of *key* and *value* pairs that are passed through as keyword arguments to :func:`matplotlib.pyplot.plot`.
Expand Down Expand Up @@ -220,8 +226,13 @@ Saturated adiabat text

The default behavour of the tephigram *saturated adiabat text* is controlled by the :data:`tephi.WET_ADIABAT_TEXT` dictionary:

>>> print .WET_ADIABAT_TEXT
{'color': 'orange', 'va': 'bottom', 'ha': 'left', 'clip_on': True, 'size': 8}
>>> pprint(tephi.WET_ADIABAT_TEXT)
{'clip_on': True,
'color': 'orange',
'ha': 'left',
'size': 8,
'transform': <...>,
'va': 'bottom'}

This is a dictionary of *key* and *value* pairs that are passed through as keyword arguments to :func:`matplotlib.pyplot.text`.

Expand Down Expand Up @@ -255,7 +266,7 @@ Saturated adiabat line frequency

The *frequency* at which saturated adiabat lines are plotted on the tephigram is controlled by the :data:`tephi.WET_ADIABAT_SPEC` list:

>>> print .WET_ADIABAT_SPEC
>>> print(tephi.WET_ADIABAT_SPEC)
[(1, 0.05), (2, 0.15), (4, 1.5)]

This :term:`line specification` is a sequence of one or more tuple pairs that contain a saturated adiabat temperature :term:`line step` and a
Expand All @@ -267,9 +278,9 @@ when the :term:`zoom level` is at or below ``0.15``.
The *overall range* of saturated adiabat levels that may be plotted is controlled by the :data:`tephi.MIN_WET_ADIABAT` and
:data:`tephi.MAX_WET_ADIABAT` variables:

>>> print tephi.MIN_WET_ADIABAT
>>> print(tephi.MIN_WET_ADIABAT)
1
>>> print tephi.MAX_WET_ADIABAT
>>> print(tephi.MAX_WET_ADIABAT)
60

Note that, it is possible to set a *fixed* saturated adiabat temperature :term:`line step` for a tephigram plot by setting the
Expand Down Expand Up @@ -301,7 +312,7 @@ For example, to **always** show saturated adiabat lines that are a multiple of 5

It is also possible to control which *individual* saturated adiabat lines should be *fixed* via the :data:`tephi.WET_ADIABAT_FIXED` variable:

>>> print tephi.WET_ADIABAT_FIXED
>>> print(tephi.WET_ADIABAT_FIXED)
None

By default, no saturated adiabat lines are fixed. To force saturated adiabat lines with a temperature of ``15`` :sup:`o`\ C and ``17`` :sup:`o`\ C
Expand Down Expand Up @@ -338,7 +349,7 @@ Humidity mixing ratio lines

The default behaviour of the tephigram *humidity mixing ratio line* is controlled by the :data:`tephi.MIXING_RATIO_LINE` dictionary:

>>> print tephi.MIXING_RATIO_LINE
>>> print(tephi.MIXING_RATIO_LINE)
{'color': 'green', 'linewidth': 0.5, 'clip_on': True}

This is a dictionary of *key* and *value* pairs that are passed through as keyword arguments to :func:`matplotlib.pyplot.plot`.
Expand Down Expand Up @@ -373,8 +384,13 @@ Humidity mixing ratio text

The default behaviour of the tephigram *humidity mixing ratio text* is controlled by the :data:`tephi.MIXING_RATIO_TEXT` dictionary:

>>> print tephi.MIXING_RATIO_TEXT
{'color': 'green', 'va': 'bottom', 'ha': 'right', 'clip_on': True, 'size': 8}
>>> pprint(tephi.MIXING_RATIO_TEXT)
{'clip_on': True,
'color': 'green',
'ha': 'right',
'size': 8,
'transform': <...>,
'va': 'bottom'}

This is a dictionary of *key* and *value* pairs that are passed through as keyword arguments to :func:`matplotlib.pyplot.text`.

Expand Down Expand Up @@ -408,7 +424,7 @@ Humidity mixing ratio line frequency

The *frequency* at which humidity mixing ratio lines are plotted on the tephigram is controlled by the :data:`tephi.MIXING_RATIO_SPEC` list:

>>> print tephi.MIXING_RATIO_SPEC
>>> print(tephi.MIXING_RATIO_SPEC)
[(1, 0.05), (2, 0.18), (4, 0.3), (8, 1.5)]

This :term:`line specification` is a sequence of one or more tuple pairs that contain a humidity mixing ratio :term:`line step` and a
Expand All @@ -419,12 +435,12 @@ is at or below ``0.3``.

The *overall range* of humidity mixing ratio levels that may be plotted is controlled by the :data:`tephi.MIXING_RATIOS` list:

>>> print tephi.MIXING_RATIOS
>>> print(tephi.MIXING_RATIOS)
[0.001, 0.002, 0.005, 0.01, 0.02, 0.03, 0.05, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0, 24.0, 28.0, 32.0, 36.0, 40.0, 44.0, 48.0, 52.0, 56.0, 60.0, 68.0, 80.0]

Note that, it is possible to control which *individual* humidity mixing ratio lines should be *fixed* i.e. **always** visible, via the :data:`tephi.MIXING_RATIO_FIXED` variable:

>>> print tephi.MIXING_RATIO_FIXED
>>> print(tephi.MIXING_RATIO_FIXED)
None

By default, no humidity mixing ratio lines are fixed. To force humidity mixing ratio lines ``4.0`` g kg\ :sup:`-1`\ and ``6.0`` g kg\ :sup:`-1`\
Expand Down
29 changes: 13 additions & 16 deletions docs/tephi/source/plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,24 @@ If not specified, the names default to *(pressure, temperature)*.

For our example tephigram data sets we have a 2-dimensional *dew-point* data set:

>>> print dews
>>> print(dews)
tephidata(
pressure=array([ 1006., 924., 900., 850., 800., 755., 710., 700.,
600., 500., 470., 459., 400., 300., 250.], dtype=float32)
temperature=array([ 26.39999962, 20.29999924, 19.79999924, 14.5 ,
12.89999962, 8.30000019, -5. , -5.0999999 ,
-11.19999981, -8.30000019, -12.10000038, -12.5 ,
-32.90000153, -46. , -53. ], dtype=float32))
pressure=array([1006., 924., 900., 850., 800., 755., 710., 700., 600.,
500., 470., 459., 400., 300., 250.], dtype=float32)
temperature=array([ 26.4, 20.3, 19.8, 14.5, 12.9, 8.3, -5. , -5.1, -11.2,
-8.3, -12.1, -12.5, -32.9, -46. , -53. ], dtype=float32))

And a 2-dimensional *dry-bulb* data set, with each named tuple printed individually:

>>> print temps.pressure
[ 1006. 924. 900. 850. 800. 755. 710. 700. 600. 500.
470. 459. 400. 300. 250. 210. 200. 186. 178. 159.
151. 150. 129. 117. 107. 100. 82. 80. 60. 54.
50.]
>>> print(temps.pressure)
[1006. 924. 900. 850. 800. 755. 710. 700. 600. 500. 470. 459.
400. 300. 250. 210. 200. 186. 178. 159. 151. 150. 129. 117.
107. 100. 82. 80. 60. 54. 50.]

>>> print temps.temperature
[ 30. 22. 21. 18. 16. 12. 12. 11. 4. -4. -7. -7. -13. -29. -38.
-47. -51. -56. -57. -63. -63. -64. -69. -77. -79. -77. -78. -78. -72. -71.
-69.]
>>> print(temps.temperature)
[ 30. 22. 21. 18. 16. 12. 12. 11. 4. -4. -7. -7. -13. -29.
-38. -47. -51. -56. -57. -63. -63. -64. -69. -77. -79. -77. -78. -78.
-72. -71. -69.]

A convenience function, as introduced above, has been provided to assist with loading one or more text files of pressure, temperature, wind speed and wind direction data; see :func:`tephi.loadtxt`.
Here it is used to load the third example data set that contains four columns of data, being *pressure*, *temperature*, *wind speed* and *wind direction*::
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ addopts =
--cov-config=.coveragerc
--cov=tephi
--cov-report=term-missing
# --doctest-modules
#doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS
--doctest-modules
doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS NUMBER

[metadata]
name = tephi
Expand Down
2 changes: 1 addition & 1 deletion tephi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def __init__(self, step):
>>> from tephi import Locator
>>> locator = Locator(10)
>>> locator(-45, 23)
(array([-50, -40, -30, -20, -10, 0, 10, 20]), 8, 1)
(array([-45., -35., -25., -15., -5., 5., 15., 25.]), 8, 1)
Args:
Expand Down

0 comments on commit 481528b

Please sign in to comment.