This notebook provides a few simple worked examples showing you how to use the tephi
Python package to easily plot your metorological data on a tephigram.
For further details, please refer to the Tephi documentation.
In [1]:
%matplotlib notebook
In [2]:
import matplotlib.pyplot as plt
import os
import tephi
from tephi import Tephigram
Let's load some pre-define tephi
sample data to plot on our tephigrams.
First, let's load some tephi
sample dew point temperature and dry bulb temperature data...
In [3]:
fname_dewpoint = os.path.join(tephi.DATA_DIR, "dews.txt")
fname_drybulb = os.path.join(tephi.DATA_DIR, "temps.txt")
column_titles = [("pressure", "dewpoint"),
("pressure", "temperature")]
data_dewpoint, data_drybulb = tephi.loadtxt(fname_dewpoint, fname_drybulb, column_titles=column_titles)
dewpoint = list(zip(data_dewpoint.pressure, data_dewpoint.dewpoint))
drybulb = list(zip(data_drybulb.pressure, data_drybulb.temperature))
Also, let's load some tephi
sample wind barb data...
In [4]:
fname_barbs = os.path.join(tephi.DATA_DIR, "barbs.txt")
column_titles = [("pressure", "dewpoint", "wind_speed", "wind_direction")]
data_barbs = tephi.loadtxt(fname_barbs, column_titles=column_titles)
barbs = list(zip(data_barbs.wind_speed, data_barbs.wind_direction, data_barbs.pressure))
Now let's plot our dew point temperature and dry bulb temperature data...
In [5]:
figure = plt.figure(figsize=(8, 8))
tephigram = Tephigram(figure=figure)
tephigram.plot(dewpoint, label="Dew Point Temperature", color="blue")
tephigram.plot(drybulb, label="Dry Bulb Temperature", color="red")
Out[5]:
And finally, let's plot our wind barb data and associate it with the dew point temperature data...
In [6]:
figure = plt.figure(figsize=(8, 8))
tephigram = Tephigram(figure=figure)
profile = tephigram.plot(dewpoint, label="Dew Point Temperature", color="blue")
profile.barbs(barbs)
tephigram.plot(drybulb, label="Dry Bulb Temperature", color="red")
Out[6]:
Note that, you can easily associated the sample wind barb data with the dry bulb temperature data instead...
In [7]:
figure = plt.figure(figsize=(8, 8))
tephigram = Tephigram(figure=figure)
tephigram.plot(dewpoint, label="Dew Point Temperature", color="blue")
profile = tephigram.plot(drybulb, label="Dry Bulb Temperature", color="red")
profile.barbs(barbs)
By default, tephi
will automatically center the plot around all rendered temperature profiles. This behaviour may not be desirable, particularly when comparing several separate tephigram plots against one another e.g., for a time-series for a specific observation point-of-interest.
To fix the extent of a plot, simply specify an anchor
point to tephi
.
An anchor
point is 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 oC, e.g.,
In [8]:
anchor = [(1000, 0), (300, 0)]
figure = plt.figure(figsize=(8, 8))
tephigram = Tephigram(figure=figure, anchor=anchor)
tephigram.plot(dewpoint, label="Dew Point Temperature", color="blue")
profile = tephigram.plot(drybulb, label="Dry Bulb Temperature", color="red")
profile.barbs(barbs)
In [ ]: