From eadd7ffdb56d8b914aef1a7b7d6aae8926881d48 Mon Sep 17 00:00:00 2001 From: Elias Sadek Date: Mon, 29 Sep 2025 14:37:36 +0100 Subject: [PATCH 1/6] corrected customise.rst formatting --- docs/source/customise.rst | 91 +++++++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 22 deletions(-) diff --git a/docs/source/customise.rst b/docs/source/customise.rst index 8430050..983b310 100644 --- a/docs/source/customise.rst +++ b/docs/source/customise.rst @@ -14,37 +14,69 @@ There are two main methods to customise tephigram lines: default values, and ind ALL axes by default, whereas individual values affect only the axes you change them on. The default values of barbs, isobars, mixing ratios, isopleths and wet adiabats are stored in the -``constants.defaults`` dictionary. Changing these values will change the default behaviour of the tephigram. +``constants.default`` dictionary. Changing these values will change the default behaviour of the tephigram. Individual values can only be changed for the three adjustable isopleths (isobars, humidity mixing ratios, and wet adiabats. Barbs ----- -Barb defaults can be altered via the ``constants.defaults`` dictionary. +Barb defaults can be altered via the ``constants.default`` dictionary. -from tephi.constants import defaults -defaults["barbs_gutter"] -defaults["barbs_length"] -defaults["barbs_linewidth"] -defaults["barbs_zorder"] +.. code:: python + + from tephi.constants import default + + default["barbs_gutter"] + default["barbs_length"] + default["barbs_linewidth"] + default["barbs_zorder"] Isopleths --------- Defaults ^^^^^^^^ -.. note:: - "" can be replaced by any of "isobar", "mixing_ratio" and "wet_adiabat", to change the - respective isopleth defaults. -from tephi.constants import defaults -defaults["_line"] -defaults["_nbins"] -defaults["_text"] -defaults["_ticks"] -defaults["_min_"] -defaults["_max_"] +.. code:: python + + from tephi.constants import default + + # isobars + default["isobar_line"] + default["isobar_nbins"] + default["isobar_text"] + default["isobar_ticks"] + + # mixing ratios + default["mixing_ratio_line"] + default["mixing_ratio_nbins"] + default["mixing_ratio_text"] + default["mixing_ratio_ticks"] + + # wet adiabats + default["wet_adiabat_line"] + default["wet_adiabat_nbins"] + default["wet_adiabat_text"] + default["wet_adiabat_ticks"] + +You can also change the default min and max axis measurement for each isopleth. These change +depending on the isopleth. + +.. code:: python + + # isobars + default["isobar_min_theta"] + default["isobar_max_theta"] + + # mixing ratios + default["mixing_ratio_min_pressure"] + default["mixing_ratio_max_pressure"] + + # wet adiabats + default["wet_adiabat_min_temperature"] + default["wet_adiabat_max_pressure"] + Individual ^^^^^^^^^^ @@ -52,11 +84,26 @@ Individual If you wish to change the behaviour of the three additional gridlines (isobars, wet adiabats, humidity mixing ratios) for a specific axes, you can edit the gridline artist properties. -tephigram = TephiAxes() -tephigram.add_() -tephigram. +.. code:: python + + from tephi import TephiAxes + + tephigram = TephiAxes() + + # isobars + tephigram.add_isobars() + tephigram.isobar + + # wet adiabats + tephigram.add_wet_adiabats() + tephigram.wet_adiabat + + # mixing ratios + tephigram.add_mixing_ratios() + tephigram.mixing_ratio .. note:: - Currently, the only directly editable values are nbins, ticks, and the max\_ and min\_ values for the respective. - isopleth. Other values can be changed through the ``_kwarg`` dictionary, although this should be improved + Currently, the only directly editable values are nbins, ticks, and the max\_ and min\_ values for the respective + isopleth. Other values can be changed through the ``_kwargs`` dictionary, although this should be improved in the future. + >>> tephigram.isobar._kwargs["line"]["color"] = "green" From 0bafd593e4c607702383c1a8eb08846f7e04f628 Mon Sep 17 00:00:00 2001 From: Elias Sadek Date: Mon, 29 Sep 2025 14:38:15 +0100 Subject: [PATCH 2/6] maybe fixed code block in note --- docs/source/customise.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/source/customise.rst b/docs/source/customise.rst index 983b310..bf0478e 100644 --- a/docs/source/customise.rst +++ b/docs/source/customise.rst @@ -106,4 +106,7 @@ for a specific axes, you can edit the gridline artist properties. Currently, the only directly editable values are nbins, ticks, and the max\_ and min\_ values for the respective isopleth. Other values can be changed through the ``_kwargs`` dictionary, although this should be improved in the future. - >>> tephigram.isobar._kwargs["line"]["color"] = "green" + + .. code:: python + + tephigram.isobar._kwargs["line"]["color"] = "green" From 3ab31f7b07c9b465c4267fe26f58862036746849 Mon Sep 17 00:00:00 2001 From: Elias Sadek Date: Mon, 29 Sep 2025 15:38:10 +0100 Subject: [PATCH 3/6] fixed zoom decimals bug --- tephi/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tephi/__init__.py b/tephi/__init__.py index 076dbcf..c6f602f 100644 --- a/tephi/__init__.py +++ b/tephi/__init__.py @@ -169,7 +169,7 @@ class _FormatterTheta(object): """ def __call__(self, direction, factor, values): - return [r"$\theta={}$".format(value) for value in values] + return [r"$\theta={:.1f}$".format(value) for value in values] class _FormatterIsotherm(object): @@ -179,7 +179,7 @@ class _FormatterIsotherm(object): """ def __call__(self, direction, factor, values): - return [r"$T={}$".format(value) for value in values] + return [r"$T={:.1f}$".format(value) for value in values] class Locator(object): From 0b95e885c56e4c12abc3879acee00c1baab06b28 Mon Sep 17 00:00:00 2001 From: Elias Sadek Date: Tue, 7 Oct 2025 11:37:24 +0100 Subject: [PATCH 4/6] added local tracking of Text --- tephi/isopleths.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/tephi/isopleths.py b/tephi/isopleths.py index b5807b0..5543f50 100644 --- a/tephi/isopleths.py +++ b/tephi/isopleths.py @@ -14,6 +14,7 @@ from collections import namedtuple import math import matplotlib.artist +from matplotlib.text import Text from matplotlib.collections import PathCollection from matplotlib.path import Path import matplotlib.pyplot as plt @@ -275,13 +276,12 @@ def text(self, temperature, theta, text, **kwargs): kwargs["zorder"] = default.get("isopleth_zorder", 10) + 1 text_kwargs = dict(self._kwargs["text"]) text_kwargs.update(kwargs) - if self.label is not None and self.label in self.axes.texts: - self.axes.lines.remove(self.label) - self.label = self.axes.text( + self.label = Text( temperature, theta, str(text), transform=self._transform, + figure=self.axes.figure, **text_kwargs, ) self.label.set_bbox( @@ -297,17 +297,7 @@ def text(self, temperature, theta, text, **kwargs): return self.label def refresh(self, temperature, theta, renderer=None, **kwargs): - if self.label is None: - self.text(temperature, theta, self.data, **kwargs) - if renderer is not None: - try: - self.axes.tests = tuple( - list(self.axes.texts).remove(self.label) - ) - except TypeError: - self.axes.tests = None - else: - self.label.set_position((temperature, theta)) + self.text(temperature, theta, self.data, **kwargs) if renderer is not None: self.label.draw(renderer) From 7a6076bbeb972d4cc9dccc5726abcbb028580e4f Mon Sep 17 00:00:00 2001 From: Elias Sadek Date: Wed, 8 Oct 2025 14:51:29 +0100 Subject: [PATCH 5/6] Updated to allow for None type nbins --- tephi/artists.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tephi/artists.py b/tephi/artists.py index 2759cf2..20d9e1f 100644 --- a/tephi/artists.py +++ b/tephi/artists.py @@ -146,7 +146,7 @@ def __init__( self.max_pressure = max_pressure if nbins is None: nbins = default.get("wet_adiabat_nbins") - if nbins < 2 or isinstance(nbins, str): + if nbins is None or (nbins < 2 or isinstance(nbins, str)): nbins = None self.nbins = nbins @@ -241,7 +241,7 @@ def __init__( self.max_pressure = max_pressure if nbins is None: nbins = default.get("mixing_ratio_nbins") - if nbins < 2 or isinstance(nbins, str): + if nbins is None or (nbins < 2 or isinstance(nbins, str)): nbins = None self.nbins = nbins From 05e1a916d37262db80f3d94105321e09a971f6c3 Mon Sep 17 00:00:00 2001 From: Elias Sadek Date: Wed, 8 Oct 2025 14:56:47 +0100 Subject: [PATCH 6/6] Customise docs: Isobars --- docs/source/customise.rst | 481 ++++++++++++++++++++++++++++++++------ 1 file changed, 411 insertions(+), 70 deletions(-) diff --git a/docs/source/customise.rst b/docs/source/customise.rst index bf0478e..cb84798 100644 --- a/docs/source/customise.rst +++ b/docs/source/customise.rst @@ -10,103 +10,444 @@ This section discusses how finer control of the tephigram isobars, saturated adi import tephi from pprint import pprint -There are two main methods to customise tephigram lines: default values, and individual values. Default values apply to -ALL axes by default, whereas individual values affect only the axes you change them on. -The default values of barbs, isobars, mixing ratios, isopleths and wet adiabats are stored in the -``constants.default`` dictionary. Changing these values will change the default behaviour of the tephigram. +Isobar control +-------------- -Individual values can only be changed for the three adjustable isopleths (isobars, humidity mixing ratios, and wet -adiabats. +Isobar lines +^^^^^^^^^^^^ -Barbs ------ -Barb defaults can be altered via the ``constants.default`` dictionary. +The default behaviour of the tephigram *isobar line* is controlled by the :data:`tephi.constants.default["isobar_line"]` +dictionary: -.. code:: python + >>> print(tephi.constants.default["isobar_line"]) + {'color': 'blue', 'linewidth': 0.5, 'clip_on': True} - from tephi.constants import default +This is a dictionary of *key* and *value* pairs that are passed through as keyword arguments to :func:`matplotlib.pyplot.plot`. - default["barbs_gutter"] - default["barbs_length"] - default["barbs_linewidth"] - default["barbs_zorder"] +Updating the ``tephi.constants.default["isobar_line"]`` dictionary will subsequently change the default behaviour of +how the tephigram isobar lines are plotted. -Isopleths ---------- +.. plot:: + :include-source: + :align: center -Defaults -^^^^^^^^ + import matplotlib.pyplot as plt + import os.path -.. code:: python + import tephi + from tephi.constants import default + + dew_point = os.path.join(tephi.DATA_DIR, 'dews.txt') + dew_data = tephi.loadtxt(dew_point, column_titles=('pressure', 'dewpoint')) + dews = zip(dew_data.pressure, dew_data.dewpoint) + default["isobar_line"].update({'color': 'purple', 'linewidth': 3, 'linestyle': '--'}) + tpg = tephi.TephiAxes() + tpg.plot(dews) + plt.show() + +.. plot:: + + import tephi + from tephi.constants import default + default["isobar_line"] = {'color': 'blue', 'linewidth': 0.5, 'clip_on': True} + + +Isobar text +^^^^^^^^^^^ + +Similarly, the default behaviour of the tephigram *isobar text* is controlled by the +:data:`tephi.constants.default["isobar_text"]` dictionary: + + >>> pprint(tephi.constants.default["isobar_text"]) + {'clip_on': True, 'color': 'blue', 'ha': 'right', 'size': 8, 'va': 'bottom'} + +This is a dictionary of *key* and *value* pairs that are passed through as keyword arguments to :func:`matplotlib.pyplot.text`. + +Updating the ``tephi.constants.default["isobar_text"]`` dictionary will change the default behaviour of how the +tephigram isobar text is plotted. + +.. plot:: + :include-source: + :align: center + + import matplotlib.pyplot as plt + import os.path + + import tephi + from tephi.constants import default + + dew_point = os.path.join(tephi.DATA_DIR, 'dews.txt') + dew_data = tephi.loadtxt(dew_point, column_titles=('pressure', 'dewpoint')) + dews = zip(dew_data.pressure, dew_data.dewpoint) + default["isobar_text"].update({'color': 'purple', 'size': 12}) + tpg = tephi.TephiAxes() + tpg.plot(dews) + plt.show() + +.. plot:: + + import tephi + from tephi.constants import default + default["isobar_text"] = {'color': 'blue', 'va': 'bottom', 'ha': 'right', 'clip_on': True, 'size': 8} + + +Isobar frequency +^^^^^^^^^^^^^^^^ + +The values at which isobars lines can be created is controlled by the +:data:`tephi.common.default["isobar_ticks"]` value: + + >>> print(tephi.common.default["isobar_ticks"]) + [1050, 1000, 950, 900, 850, 800, 700, 600, 500, 400, 300, 250, 200, 150, 100, 70, 50, 40, 30, 20, 10] + +The *frequency* at which isobar lines are plotted on the tephigram is controlled by the +:data:`tephi.common.default["isobar_nbins"]` value: + + >>> print(tephi.common.default["isobar_nbins"]) + None + +``nbins`` controls the maximum number of lines plotted at one time. It can either be an integer value, or a ``None`` +value, which means that a line will be shown for every tick in :data:`tephi.common.default["isobar_ticks"]`. + +.. plot:: + :include-source: + :align: center + + import matplotlib.pyplot as plt + import os.path + + import tephi + from tephi.common import default + + dew_point = os.path.join(tephi.DATA_DIR, 'dews.txt') + dew_data = tephi.loadtxt(dew_point, column_titles=('pressure', 'dewpoint')) + dews = zip(dew_data.pressure, dew_data.dewpoint) + default["isobar_ticks"] = [900, 875, 850] + default["isobar_nbins"] = 2 + tpg = tephi.TephiAxes() + tpg.plot(dews) + plt.show() + +.. plot:: + + import tephi + from tephi.constants import default + default["isobar_ticks"] = [1050, 1000, 950, 900, 850, 800, 700, 600, 500, 400, 300, 250, 200, 150, 100, 70, 50, 40, 30, 20, 10] + default["isobar_nbins"] = None + + +Isobar line extent +^^^^^^^^^^^^^^^^^^ + +The extent of each tephigram *isobar line* is controlled by the :data:`tephi.constants.default["isobar_min_theta"]` and +:data:`tephi.constants.default["isobar_max_theta"]` variables: + + >>> print(tephi.constants.default["isobar_min_theta"]) + 0 + >>> print(tephi.constants.default["isobar_max_theta"]) + 250 + +For example, to change the isobar line extent behaviour to be between 15 :sup:`o`\ C and 60 :sup:`o`\ C, + +.. plot:: + :include-source: + :align: center + + import matplotlib.pyplot as plt + import os.path + + import tephi + from tephi.constants import default + + dew_point = os.path.join(tephi.DATA_DIR, 'dews.txt') + dew_data = tephi.loadtxt(dew_point, column_titles=('pressure', 'dewpoint')) + dews = zip(dew_data.pressure, dew_data.dewpoint) + default["isobar_max_theta"] = 15 + default["isobar_max_theta"] = 60 + tpg = tephi.TephiAxes() + tpg.plot(dews) + plt.show() + +.. plot:: + + import tephi + from tephi.constants import default + default["isobar_max_theta"] = 0 + default["isobar_max_theta"] = 250 + + +Saturated adiabat control +------------------------- + +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(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`. + +Updating the ``WET_ADIABAT_LINE`` dictionary will change the default behaviour of **all** saturated adiabat line plotting. + +.. plot:: + :include-source: + :align: center + + import matplotlib.pyplot as plt + import os.path + + import tephi + + dew_point = os.path.join(tephi.DATA_DIR, 'dews.txt') + dew_data = tephi.loadtxt(dew_point, column_titles=('pressure', 'dewpoint')) + dews = zip(dew_data.pressure, dew_data.dewpoint) + tephi.WET_ADIABAT_LINE.update({'color': 'purple', 'linewidth': 3, 'linestyle': '--'}) + tpg = tephi.TephiAxes() + tpg.plot(dews) + plt.show() + +.. plot:: + + import tephi + tephi.WET_ADIABAT_LINE = {'color': 'orange', 'linewidth': 0.5, 'clip_on': True} + + +Saturated adiabat text +^^^^^^^^^^^^^^^^^^^^^^ + +The default behaviour of the tephigram *saturated adiabat text* is controlled by the :data:`tephi.WET_ADIABAT_TEXT` dictionary: + + >>> pprint(tephi.WET_ADIABAT_TEXT) + {'clip_on': True, 'color': 'orange', 'ha': 'left', 'size': 8, 'va': 'bottom'} - from tephi.constants import default +This is a dictionary of *key* and *value* pairs that are passed through as keyword arguments to :func:`matplotlib.pyplot.text`. - # isobars - default["isobar_line"] - default["isobar_nbins"] - default["isobar_text"] - default["isobar_ticks"] +Updating the ``WET_ADIABAT_TEXT`` dictionary will change the default behaviour of how the text of associated saturated adiabat lines are plotted. - # mixing ratios - default["mixing_ratio_line"] - default["mixing_ratio_nbins"] - default["mixing_ratio_text"] - default["mixing_ratio_ticks"] +.. plot:: + :include-source: + :align: center - # wet adiabats - default["wet_adiabat_line"] - default["wet_adiabat_nbins"] - default["wet_adiabat_text"] - default["wet_adiabat_ticks"] + import matplotlib.pyplot as plt + import os.path -You can also change the default min and max axis measurement for each isopleth. These change -depending on the isopleth. + import tephi + + dew_point = os.path.join(tephi.DATA_DIR, 'dews.txt') + dew_data = tephi.loadtxt(dew_point, column_titles=('pressure', 'dewpoint')) + dews = zip(dew_data.pressure, dew_data.dewpoint) + tephi.WET_ADIABAT_TEXT.update({'color': 'purple', 'size': 12}) + tpg = tephi.TephiAxes() + tpg.plot(dews) + plt.show() + +.. plot:: + + import tephi + tephi.WET_ADIABAT_TEXT = {'color': 'orange', 'va': 'bottom', 'ha': 'left', 'clip_on': True, 'size': 8} + + +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(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 +:term:`zoom level`. + +For example, ``(2, 0.15)`` states that all saturated adiabat lines that are a multiple of ``2`` :sup:`o`\ C will be plotted i.e. visible, +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) + 1 + >>> 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 +associated :term:`zoom level` to ``None``. + +For example, to **always** show saturated adiabat lines that are a multiple of 5 :sup:`o`\ C, irrespective of the :term:`zoom level`, + +.. plot:: + :include-source: + :align: center + + import matplotlib.pyplot as plt + import os.path + + import tephi + + dew_point = os.path.join(tephi.DATA_DIR, 'dews.txt') + dew_data = tephi.loadtxt(dew_point, column_titles=('pressure', 'dewpoint')) + dews = zip(dew_data.pressure, dew_data.dewpoint) + tephi.WET_ADIABAT_SPEC = [(5, None)] + tpg = tephi.TephiAxes() + tpg.plot(dews) + plt.show() + +.. plot:: + + import tephi + tephi.WET_ADIABAT_SPEC = [(1, 0.05), (2, 0.15), (4, 1.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) + 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 +always to be plotted, + +.. plot:: + :include-source: + :align: center + + import matplotlib.pyplot as plt + import os.path + + import tephi + + dew_point = os.path.join(tephi.DATA_DIR, 'dews.txt') + dew_data = tephi.loadtxt(dew_point, column_titles=('pressure', 'dewpoint')) + dews = zip(dew_data.pressure, dew_data.dewpoint) + tephi.WET_ADIABAT_FIXED = [15, 17] + tpg = tephi.TephiAxes() + tpg.plot(dews) + plt.show() + +.. plot:: + + import tephi + tephi.WET_ADIABAT_FIXED = None + + +Humidity mixing ratio control +----------------------------- -.. code:: python +Humidity mixing ratio lines +^^^^^^^^^^^^^^^^^^^^^^^^^^^ - # isobars - default["isobar_min_theta"] - default["isobar_max_theta"] +The default behaviour of the tephigram *humidity mixing ratio line* is controlled by the :data:`tephi.MIXING_RATIO_LINE` dictionary: - # mixing ratios - default["mixing_ratio_min_pressure"] - default["mixing_ratio_max_pressure"] + >>> print(tephi.MIXING_RATIO_LINE) + {'color': 'green', 'linewidth': 0.5, 'clip_on': True} - # wet adiabats - default["wet_adiabat_min_temperature"] - default["wet_adiabat_max_pressure"] +This is a dictionary of *key* and *value* pairs that are passed through as keyword arguments to :func:`matplotlib.pyplot.plot`. +Updating the ``MIXING_RATIO_LINE`` dictionary will change the default behaviour of **all** humidity mixing ratio line plotting. -Individual -^^^^^^^^^^ +.. plot:: + :include-source: + :align: center -If you wish to change the behaviour of the three additional gridlines (isobars, wet adiabats, humidity mixing ratios) -for a specific axes, you can edit the gridline artist properties. + import matplotlib.pyplot as plt + import os.path + + import tephi + + dew_point = os.path.join(tephi.DATA_DIR, 'dews.txt') + dew_data = tephi.loadtxt(dew_point, column_titles=('pressure', 'dewpoint')) + dews = zip(dew_data.pressure, dew_data.dewpoint) + tephi.MIXING_RATIO_LINE.update({'color': 'purple', 'linewidth': 3, 'linestyle': '--'}) + tpg = tephi.TephiAxes() + tpg.plot(dews) + plt.show() + +.. plot:: + + import tephi + tephi.MIXING_RATIO_LINE = {'color': 'green', 'linewidth': 0.5, 'clip_on': True} -.. code:: python - from tephi import TephiAxes +Humidity mixing ratio text +^^^^^^^^^^^^^^^^^^^^^^^^^^ - tephigram = TephiAxes() +The default behaviour of the tephigram *humidity mixing ratio text* is controlled by the :data:`tephi.MIXING_RATIO_TEXT` dictionary: - # isobars - tephigram.add_isobars() - tephigram.isobar + >>> pprint(tephi.MIXING_RATIO_TEXT) + {'clip_on': True, 'color': 'green', 'ha': 'right', 'size': 8, 'va': 'bottom'} - # wet adiabats - tephigram.add_wet_adiabats() - tephigram.wet_adiabat +This is a dictionary of *key* and *value* pairs that are passed through as keyword arguments to :func:`matplotlib.pyplot.text`. - # mixing ratios - tephigram.add_mixing_ratios() - tephigram.mixing_ratio +Updating the ``MIXING_RATIO_TEXT`` dictionary will change the default behaviour of how the text of associated humidity mixing ratio lines are plotted. + +.. plot:: + :include-source: + :align: center + + import matplotlib.pyplot as plt + import os.path + + import tephi + + dew_point = os.path.join(tephi.DATA_DIR, 'dews.txt') + dew_data = tephi.loadtxt(dew_point, column_titles=('pressure', 'dewpoint')) + dews = zip(dew_data.pressure, dew_data.dewpoint) + tephi.MIXING_RATIO_TEXT.update({'color': 'purple', 'size': 12}) + tpg = tephi.TephiAxes() + tpg.plot(dews) + plt.show() + +.. plot:: + + import tephi + tephi.MIXING_RATIO_TEXT = {'color': 'green', 'va': 'bottom', 'ha': 'right', 'clip_on': True, 'size': 8} -.. note:: - Currently, the only directly editable values are nbins, ticks, and the max\_ and min\_ values for the respective - isopleth. Other values can be changed through the ``_kwargs`` dictionary, although this should be improved - in the future. - .. code:: python +Humidity mixing ratio line frequency +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - tephigram.isobar._kwargs["line"]["color"] = "green" +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) + [(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 +:term:`zoom level`. + +For example, ``(4, 0.3)`` states that every *fourth* humidity mixing ratio line will be plotted i.e. visible, when the :term:`zoom level` +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) + [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) + 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`\ +always to be plotted independent of the :term:`zoom level`, + +.. plot:: + :include-source: + :align: center + + import matplotlib.pyplot as plt + import os.path + + import tephi + + dew_point = os.path.join(tephi.DATA_DIR, 'dews.txt') + dew_data = tephi.loadtxt(dew_point, column_titles=('pressure', 'dewpoint')) + dews = zip(dew_data.pressure, dew_data.dewpoint) + tephi.MIXING_RATIO_FIXED = [4.0, 6.0] + tpg = tephi.TephiAxes() + tpg.plot(dews) + plt.show() + +.. plot:: + + import tephi + tephi.MIXING_RATIO_FIXED = None