Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completes the remainder of the code quality work #179

Merged
merged 13 commits into from
Mar 27, 2025
Merged
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ updates:
timezone: "Europe/London"
labels:
- "🤖 Bot"
groups:
actions:
patterns:
- "*"
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ci:
files: |
(?x)(
docs\/.+\.py|
docs\/.+\.rst|
pyproject\.toml|
setup\.py|
src\/.+\.py
Expand Down Expand Up @@ -105,3 +106,9 @@ repos:
hooks:
- id: validate-pyproject

- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
2 changes: 1 addition & 1 deletion docs/source/customise.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Updating the ``WET_ADIABAT_LINE`` dictionary will change the default behaviour o
Saturated adiabat text
^^^^^^^^^^^^^^^^^^^^^^

The default behavour of the tephigram *saturated adiabat text* is controlled by the :data:`tephi.WET_ADIABAT_TEXT` dictionary:
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'}
Expand Down
10 changes: 5 additions & 5 deletions docs/source/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Glossary

anchor
A sequence of two (pressure, temperature) pairs that specify the bottom left-hand corner and the
top right-hand corner of the plot. The pressure data points must be in units of mb or hPa, and the
temperature data points must be in units of :sup:`o`\ C.
top right-hand corner of the plot. The pressure data points must be in units of mb or hPa, and the
temperature data points must be in units of :sup:`o`\ C.

dry adiabat
A line of constant potential temperature, measured in units of :sup:`o`\ C. The zeroth dry adiabat line
Expand All @@ -25,18 +25,18 @@ Glossary
isotherm
A line of constant temperature, measured in :sup:`o`\ C. The zeroth isotherm line is an axis of the tephigram,
see :ref:`intro-isotherm`.

line specification
A sequence of one or more tuple pairs containing a :term:`line step` value and a :term:`zoom level` value.
Used to control the frequency at which the tephigram plots :term:`isobar` lines, :term:`humidity mixing ratio` lines,
and :term:`saturated adiabat` lines. Note that, specifying a :term:`zoom level` of ``None`` forces the associated
lines **always** to be visible.
lines **always** to be visible.

line step
The first value in the tuple pair of a :term:`line specification`. An integer that denotes N\ :sup:`th`\ step multiples.
i.e. a line step of ``25`` denotes all lines that are a multiple of 25, or every 25\ :sup:`th`\ item from an
enumerated list of values.

pseudo saturated wet adiabat
A line of constant equivalent potential temperature for saturated air parcels, measured in units of :sup:`o`\ C, see :ref:`intro-saturated-adiabat`.

Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. tephi documentation master file, created by
sphinx-quickstart on Thu Jun 26 15:24:09 2014.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
contain the root ``toctree`` directive.

The tephi user guide
====================
Expand Down Expand Up @@ -30,4 +30,4 @@ User guide table of contents
:caption: API
:maxdepth: 2

api/modules
api/modules
4 changes: 2 additions & 2 deletions docs/source/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Introduction

The tephigram is a thermodynamic or energy diagram, devised in 1915 by Sir William Napier Shaw, a former Director-General of the Met Office.

It is a graphical representation of the obervations of pressure, temperature and humidity, made in a vertical sounding of the atmosphere, typically from radiosondes.
It is a graphical representation of the observations of pressure, temperature and humidity, made in a vertical sounding of the atmosphere, typically from radiosondes.

The axis of the tephigram are temperature (T) and entropy (:math:`\phi`), hence the name "T-:math:`\phi`-gram".
The axes and lines of the tephigram are shown in :ref:`tephi_axes`.
Expand Down Expand Up @@ -121,7 +121,7 @@ Pseudo saturated wet adiabats

Saturated adiabats are lines of constant equivalent potential temperature for saturated air parcels, measured in units :sup:`o`\ C. They run as vertically curved lines across the plot from top to bottom.

The saturated adiabats represent the rate at which saturated air will cool when rising i.e. the saturated adiabatic lapse rate (SALR).
The saturated adiabats represent the rate at which saturated air will cool when rising i.e. the saturated adiabatic lapse rate (SALR).

.. _tephi_axis_wet_adiabat:

Expand Down
31 changes: 15 additions & 16 deletions docs/source/plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ This section describes how to visualise one or more data sets as a tephigram.

import os.path
import tephi
dew_point = os.path.join(tephi.DATA_DIR, 'dews.txt')
dry_bulb = os.path.join(tephi.DATA_DIR, 'temps.txt')
winds = os.path.join(tephi.DATA_DIR, 'barbs.txt')

dew_point = os.path.join(tephi.DATA_DIR, "dews.txt")
dry_bulb = os.path.join(tephi.DATA_DIR, "temps.txt")
winds = os.path.join(tephi.DATA_DIR, "barbs.txt")
dews, temps = tephi.loadtxt(dew_point, dry_bulb)


Expand All @@ -20,20 +21,20 @@ Tephigram data

Throughout this user guide we will make use of three data sets to plot temperature profiles on a tephigram.

Currently, the tephigram module can only plot data from ascii text files.
Currently, the tephigram module can only plot data from ascii text files.
These files may contain pressure, temperature, wind speed and wind direction data sets.
Here pressure is measured in units of *millibars* or *hectopascals*,
Here pressure is measured in units of *millibars* or *hectopascals*,
temperature is measured in units of *degrees celsius*,
wind speed is measured in *knots* and wind direction is measured in *degrees from north*.

Note that the data set must consist of one or more pressure and temperature paired values,
and optionally one wind speed and wind direction pair for each pressure value.
Thus any temperature value must be paired with a pressure value,
Note that the data set must consist of one or more pressure and temperature paired values,
and optionally one wind speed and wind direction pair for each pressure value.
Thus any temperature value must be paired with a pressure value,
and wind speed and wind direction pairs must be paired with a pressure value.

Data from the text files is loaded into one :func:`collections.namedtuple` instance per text file.
Each column of data representing a given phenomenon in a text file is loaded into a single named tuple.
The name of each tuple is set using a list of strings passed to the loader.
Data from the text files is loaded into one :func:`collections.namedtuple` instance per text file.
Each column of data representing a given phenomenon in a text file is loaded into a single named tuple.
The name of each tuple is set using a list of strings passed to the loader.
If not specified, the names default to *(pressure, temperature)*.

For our example tephigram data sets we have a 2-dimensional *dew-point* data set:
Expand All @@ -57,7 +58,7 @@ And a 2-dimensional *dry-bulb* data set, with each named tuple printed individua
-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`.
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*::

>>> import os.path
Expand All @@ -79,7 +80,7 @@ Here it is used to load the third example data set that contains four columns of
240., 270., 285., 300., 330., 359.], dtype=float32))

.. note::
WMO upper-level pressure, temperature, humidity, and wind reports *FM 35-IX Ext. TEMP*, *FM 36-IX Ext. TEMP SHIP*, *FM 37-IX Ext. TEMP DROP* and
WMO upper-level pressure, temperature, humidity, and wind reports *FM 35-IX Ext. TEMP*, *FM 36-IX Ext. TEMP SHIP*, *FM 37-IX Ext. TEMP DROP* and
*FM 38-IX Ext. MOBIL* are currently **not** supported.


Expand Down Expand Up @@ -146,7 +147,7 @@ Customising a temperature profile

All keyword arguments passed to :meth:`tephi.Tephigram.plot` are simply passed through to :func:`matplotlib.pyplot.plot`.

This transparency allows full control when plotting a temperature profile on the tephigram.
This transparency allows full control when plotting a temperature profile on the tephigram.

.. plot::
:include-source:
Expand Down Expand Up @@ -218,5 +219,3 @@ To fix the extent of a plot, simply specify an :term:`anchor` point to the tephi
tpg = tephi.Tephigram(anchor=[(1000, 0), (300, 0)])
tpg.plot(dews)
plt.show()


13 changes: 4 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,6 @@ ignore = [

# https://learn.scientific-python.org/development/guides/pytest#PP309
"PP309", # has filterwarnings set

# https://learn.scientific-python.org/development/guides/gha-basic/#GH212
"GH212", # Require GHA update grouping

# https://learn.scientific-python.org/development/guides/style/#PC170
"PC170", # Uses PyGrep hooks (only needed if rST present)

# https://learn.scientific-python.org/development/guides/style/#PC901
"PC901", # Custom pre-commit CI message
]

[tool.ruff]
Expand Down Expand Up @@ -188,6 +179,10 @@ known-first-party = ["tephi"]
]
"docs/source/conf.py" = [
"ERA001", # Has commented out code
"INP001" # File `docs/source/conf.py` is part of an implicit namespace package. Add an `__init__.py`.
]
"docs/source/plot/barbs.py" = [
"INP001" # File `docs/source/plot/barbs.py` is part of an implicit namespace package. Add an `__init__.py`.
]

[tool.ruff.lint.pydocstyle]
Expand Down
11 changes: 0 additions & 11 deletions setup.py

This file was deleted.

Loading