Skip to content
Tutorials Center
My learning

Topics

Lesson 36 of 37 · Projects and Practice

Project: A Weather Station Calculator

Build a small program that turns temperature, humidity and pressure readings into dew point, cloud base, heat index-style comfort notes and a simple pressure trend.

Real weather stations measure a few numbers: temperature, humidity, pressure and wind. Everything else a forecaster says, such as "dew point 18" or "pressure falling", is calculated from those readings. In this project you build the calculating part. You will reuse formulas from Clouds and Precipitation and The Atmosphere: Layers and Composition.

The goal is a function that takes raw readings and returns a short report. You build it in four steps, then extend it with your own ideas.

Step 1: Dew point and cloud base

The Magnus approximation gives the dew point from temperature and relative humidity. The cloud base follows from 125 × (T − Td) meters.

Python Step 1: dew point and cloud base

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 2: Station pressure to sea-level pressure

Weather maps compare pressure at the same height, so stations correct their pressure to sea level. A simple approximation using the same exponential model as before is:

p_sea = p_station × e^(h / H) with H about 8 km for the lower atmosphere (this project assumes 8.4 km; the exact value depends on temperature).

Real services use a more careful formula that includes temperature, so treat this as an estimate.

Python Step 2: sea-level pressure estimate

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 3: Pressure trend

A forecaster looks at whether pressure is rising or falling. Falling pressure usually signals an approaching low-pressure system and worsening weather; rising pressure often signals clearing. Here is a simple rule using the change over three hours:

Change in 3 hours Description
less than −3 hPa Falling quickly
−3 to −1 hPa Falling
−1 to +1 hPa Steady
+1 to +3 hPa Rising
more than +3 hPa Rising quickly
Python Step 3: pressure trend

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 4: The full station report

Put the pieces together. The function below returns a plain-language report, including a comfort note based only on the dew point (a common approximation: below 10 °C feels dry, 10 to 16 comfortable, 16 to 21 humid, above 21 oppressive).

Python Step 4: the weather station report

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Extensions

  1. Add wind: read speed in m/s and print the Beaufort force (see Air Pressure and Wind).
  2. Add a lightning-distance input: seconds between flash and thunder.
  3. Compare your estimates with a real local report; why might they differ (instrument error, local conditions, the rough rule of thumb)?
  4. Record readings for a week with a cheap thermometer and a hygrometer, and run your program on each. Keep notes on how well the "pressure trend" worked as a forecast for your location. Never treat the program as a safety tool for severe weather; follow the official warnings of your national weather service.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. A station at 1,000 m reads 900 hPa. Why must pressure be corrected to sea level for maps?

    Pressure falls with height, so you need a common level to see weather-related differences.
  2. 2. Temperature 20 °C, dew point 20 °C. What is true?

    When temperature equals the dew point, relative humidity is 100%.
  3. 3. Pressure falls by 4 hPa in three hours. Under the simple rule, the trend is

    A drop of more than 3 hPa in three hours counts as falling quickly.
  4. 4. Why is a program like this not a replacement for official warnings?

    Professional forecasts use large-scale models and many observations.

Summary

  • A weather report is built from temperature, humidity and pressure using short formulas.
  • Dew point and cloud base come from the Magnus formula and the 125 m per °C rule.
  • Pressure is corrected to sea level so maps can compare stations; its trend hints at change.
  • Rules of thumb are good for learning, not for safety-critical forecasting.

Next: Project: Earth History in One Year