Intro¶
Let’s make station data easier!
Install and structure¶
This is a walkthrough of the installation, importing, and general structure of metloom
But first, why?¶
What datasources have you used for accessing station data before?
What is difficult about accessing data from multiple sources?
The goal¶
The goal of metloom is consistent, simple sampling of meteorology and snow related point measurments from a variety of datasources
Install¶
metloom is available on pypi and can be installed by running
[1]:
!pip install metloom
try:
import matplotlib
except Exception as e:
!pip install matplotlib
Requirement already satisfied: metloom in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (0.9.2)
Requirement already satisfied: geopandas<2.0.0,>=1.0.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from metloom) (1.1.3)
Requirement already satisfied: pandas<3.0.0,>=1.0.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from metloom) (2.3.3)
Requirement already satisfied: lxml<6.0.0,>=5.4.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from metloom) (5.4.0)
Requirement already satisfied: requests<3.0.0,>2.0.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from metloom) (2.33.1)
Requirement already satisfied: beautifulsoup4<5,>4 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from metloom) (4.14.3)
Requirement already satisfied: zeep>4.0.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from metloom) (4.3.2)
Requirement already satisfied: pydash<9.0.0,>=8.0.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from metloom) (8.0.6)
Requirement already satisfied: soupsieve>=1.6.1 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from beautifulsoup4<5,>4->metloom) (2.8.3)
Requirement already satisfied: typing-extensions>=4.0.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from beautifulsoup4<5,>4->metloom) (4.15.0)
Requirement already satisfied: numpy>=1.24 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from geopandas<2.0.0,>=1.0.0->metloom) (2.2.6)
Requirement already satisfied: pyogrio>=0.7.2 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from geopandas<2.0.0,>=1.0.0->metloom) (0.12.1)
Requirement already satisfied: packaging in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from geopandas<2.0.0,>=1.0.0->metloom) (26.1)
Requirement already satisfied: pyproj>=3.5.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from geopandas<2.0.0,>=1.0.0->metloom) (3.7.1)
Requirement already satisfied: shapely>=2.0.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from geopandas<2.0.0,>=1.0.0->metloom) (2.1.2)
Requirement already satisfied: python-dateutil>=2.8.2 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from pandas<3.0.0,>=1.0.0->metloom) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from pandas<3.0.0,>=1.0.0->metloom) (2026.1.post1)
Requirement already satisfied: tzdata>=2022.7 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from pandas<3.0.0,>=1.0.0->metloom) (2026.1)
Requirement already satisfied: charset_normalizer<4,>=2 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from requests<3.0.0,>2.0.0->metloom) (3.4.7)
Requirement already satisfied: idna<4,>=2.5 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from requests<3.0.0,>2.0.0->metloom) (3.11)
Requirement already satisfied: urllib3<3,>=1.26 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from requests<3.0.0,>2.0.0->metloom) (2.6.3)
Requirement already satisfied: certifi>=2023.5.7 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from requests<3.0.0,>2.0.0->metloom) (2026.2.25)
Requirement already satisfied: six>=1.5 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from python-dateutil>=2.8.2->pandas<3.0.0,>=1.0.0->metloom) (1.17.0)
Requirement already satisfied: attrs>=17.2.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from zeep>4.0.0->metloom) (26.1.0)
Requirement already satisfied: isodate>=0.5.4 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from zeep>4.0.0->metloom) (0.7.2)
Requirement already satisfied: platformdirs>=1.4.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from zeep>4.0.0->metloom) (4.9.6)
Requirement already satisfied: requests-toolbelt>=0.7.1 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from zeep>4.0.0->metloom) (1.0.0)
Requirement already satisfied: requests-file>=1.5.1 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from zeep>4.0.0->metloom) (3.0.1)
Importing¶
The core components of metloom are the pointdata and the variables.
Each point data class is tailored to a specific datasource and extends the base class found here. Each variable class is made up of the variables known for a specific datasource and extends the base variable class found here.
Note: the variables are not an exhaustive list for each source. The class is extensible so we can add new variables as needed. We will cover how to do that later in the tutorial.
[2]:
# import the pointdata classes
from metloom.pointdata import (
PointData, CDECPointData, SnotelPointData, MesowestPointData, USGSPointData
)
# import the variable classes
from metloom.variables import (
SensorDescription, CdecStationVariables, SnotelVariables, MesowestVariables, USGSVariables
)
Let’s explore the base classes and see what methods are available to us.
Variables¶
Each variable class is made up of SensorDescriptions. The sensor descriptions specify the variable code used by the datasource, the name of the variable, and a description of the variable.
[3]:
sensor = CdecStationVariables.SWE
print(
f"THe SWE sensor has code {sensor.code}, "
f"name {sensor.name}, and description {sensor.description}"
)
THe SWE sensor has code 3, name SWE, and description SNOW, WATER CONTENT
The goal with sensor descriptions is that sensors representing the same property should have the same name. This allows us to access the same variable seamlessly across multiple networks.
[4]:
# The sensors represent SWE in inches, so the name is the same
print(CdecStationVariables.SWE.name)
print(SnotelVariables.SWE.name)
# The sensors represent accumulated precip in inches, so the name is the same
print(CdecStationVariables.PRECIPITATIONACCUM.name)
print(SnotelVariables.PRECIPITATIONACCUM.name)
SWE
SWE
ACCUMULATED PRECIPITATION
ACCUMULATED PRECIPITATION
Point data¶
The pointdata class has a number of attributes and methods available to us
Attributes¶
ALLOWED_VARIABLES
tzinfo
metdata
Methods¶
get_daily_data
get_hourly_data
get_snow_course_data
Class method¶
points_from_geometry
[5]:
# Let's explore the attributes for Red Mountain Pass SNOTEL 713:CO:SNTL
# a station requires a code and a name (the name can be anything)
point = SnotelPointData("713:CO:SNTL", "Red Mountain Pass")
print(f"Name: {point.name}")
print(f"ID: {point.id}")
print(f"Allowed Variables: {point.ALLOWED_VARIABLES}")
print(f"location: {point.metadata}")
print(f"tzinfo: {point.tzinfo}")
Name: Red Mountain Pass
ID: 713:CO:SNTL
Allowed Variables: <class 'types.SnotelVariables'>
location: POINT Z (-107.71389 37.89168 11060)
tzinfo: UTC-08:00
Knowledge check¶
How would you find the latitude and longitude for the Banner Summit SNOTEL with code 312:ID:SNTL?
[6]:
# Your work here
Note¶
This is an opensource, free project, so we love your participation!
Suggest new datasources, report bugs, and even contribute code
https://github.com/M3Works/metloom/issues
In the next section we will work on actually pulling data!
[ ]: