Skip to content

Commit

Permalink
DOC: Add station_info and StationLookup to docs.
Browse files Browse the repository at this point in the history
Includes a basic doctestable example.
  • Loading branch information
dopplershift committed Apr 5, 2022
1 parent 628c355 commit acd0e61
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/metpy/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Copyright (c) 2015,2016,2018,2021 MetPy Developers.
# Distributed under the terms of the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause
"""Classes for reading various file formats.
"""Tools for reading various file formats.
These classes are written to take both file names (for local files) or file-like objects;
this allows reading files that are already in memory (using :class:`python:io.StringIO`)
or remote files (using :func:`~python:urllib.request.urlopen`).
Classes supporting formats are written to take both file names (for local files) or file-like
objects; this allows reading files that are already in memory
(using :class:`python:io.StringIO`) or remote files
(using :func:`~python:urllib.request.urlopen`).
`station_info` is an instance of `StationLookup` to find information about station locations
(e.g. latitude, longitude, altitude) from various sources.
"""

from .gempak import * # noqa: F403
Expand Down
12 changes: 11 additions & 1 deletion src/metpy/io/station_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,18 @@ def _read_airports_file(input_file=None):
}).to_dict()


@exporter.export
class StationLookup(Mapping):
"""Look up station information from multiple sources."""
"""Look up station information from multiple sources.
This class follows the `Mapping` protocol with station ID as the key. This makes it
possible to e.g. iterate over all locations and get all of a certain criteria:
>>> import metpy.io
>>> conus_stations = [s for s in metpy.io.station_info if s.startswith('K')]
>>> conus_stations[:3]
['KEET', 'K8A0', 'KALX']
"""

@cached_property
def tables(self):
Expand Down

0 comments on commit acd0e61

Please sign in to comment.