meteostat-cli 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. meteostat_cli-0.2.0/.claude/skills/meteo/SKILL.md +38 -0
  2. meteostat_cli-0.2.0/.claude/skills/meteo/examples.md +72 -0
  3. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/PKG-INFO +10 -5
  4. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/README.md +9 -3
  5. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/meteo/__init__.py +1 -1
  6. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/meteo/cli.py +0 -1
  7. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/meteo/commands/nearby.py +18 -9
  8. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/meteo/config.py +1 -0
  9. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/meteo/plotting.py +1 -1
  10. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/meteo/utils.py +18 -3
  11. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/pyproject.toml +1 -2
  12. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/tests/test_cli.py +0 -6
  13. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/tests/test_commands.py +6 -7
  14. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/uv.lock +3 -3
  15. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/.github/workflows/lint.yml +0 -0
  16. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/.github/workflows/publish.yml +0 -0
  17. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/.github/workflows/test.yml +0 -0
  18. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/.gitignore +0 -0
  19. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/LICENSE +0 -0
  20. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/meteo/commands/__init__.py +0 -0
  21. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/meteo/commands/config.py +0 -0
  22. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/meteo/commands/daily.py +0 -0
  23. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/meteo/commands/hourly.py +0 -0
  24. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/meteo/commands/inventory.py +0 -0
  25. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/meteo/commands/monthly.py +0 -0
  26. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/meteo/commands/normals.py +0 -0
  27. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/meteo/commands/station.py +0 -0
  28. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/tests/__init__.py +0 -0
  29. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/tests/conftest.py +0 -0
  30. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/tests/test_config.py +0 -0
  31. {meteostat_cli-0.1.0 → meteostat_cli-0.2.0}/tests/test_utils.py +0 -0
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: meteo
3
+ description: Access weather and climate data for thousands of weather stations and any place worldwide.
4
+ ---
5
+
6
+ # Meteo
7
+
8
+ ## Usage
9
+
10
+ If the `meteo` command is not found, install the tool using:
11
+
12
+ ```bash
13
+ uv tool install meteostat-cli
14
+ ```
15
+
16
+ Alternatively, you can use `uvx`:
17
+
18
+ ```bash
19
+ uvx --from meteostat-cli meteo
20
+ ```
21
+
22
+ ## Commands
23
+
24
+ Run `meteo --help` to see a list of all available commands and options.
25
+
26
+ ## Gotchas
27
+
28
+ - `meteo nearby` requires numeric `LAT,LON` argument — city names are not accepted. Use coordinates directly.
29
+ - When looking for stations that match the elevation of a place, use `meteo nearby` without a radius and filter results by elevation.
30
+ - Pass multiple station IDs in one call instead of looping: `meteo daily D1424 EDEV0 10635 --start 2025 --end 2025`
31
+ - Fetch only the columns you need with `--parameters` to eliminate post-processing: `--parameters tmax` or `--parameters tmax,prcp`
32
+ - Aggregate all rows with `--agg` (Pandas `.agg()`): `--agg max`, `--agg mean`, `--agg sum`
33
+ - `--start` and `--end` accept YYYY-MM-DD, YYYY-MM, YYYY
34
+ - Machine-readable output for piping: `--format json` or `--format csv`
35
+
36
+ ## Additional resources
37
+
38
+ - For usage examples, see [examples.md](examples.md)
@@ -0,0 +1,72 @@
1
+ # Examples
2
+
3
+ ## Fetch weather data
4
+
5
+ ```bash
6
+ meteo daily 10637 # Station ID for Frankfurt/Main
7
+ meteo hourly 10637 --start 2024-01-01 --end 2024-01-31
8
+ meteo daily 50.1109,8.6821 --start 2024-01-01 --end 2024-12-31 # Geo coordinates (interpolated)
9
+ meteo monthly 10637 --start 2020 --end 2024 --parameters temp,tmin,tmax,prcp
10
+ meteo normals 10637
11
+ meteo hourly 10637 10635 --start 2024-06-01 --end 2024-06-30 --timezone Europe/Berlin
12
+ meteo daily 10637 10635 --start 2025-01-01 --end 2025-12-31 --agg max # Custom aggregation (Pandas `.agg()`) across multiple stations
13
+ ```
14
+
15
+ ## Export data
16
+
17
+ ```bash
18
+ meteo daily 10637 --start 2024-01-01 --end 2024-12-31 --output data.csv
19
+ meteo daily 10637 --start 2024-01-01 --end 2024-12-31 --output data.json
20
+ meteo daily 10637 --start 2024-01-01 --end 2024-12-31 --output data.xlsx
21
+ meteo daily 10637 --start 2024-01-01 --end 2024-12-31 --output data.parquet
22
+ meteo daily 10637 --start 2024-01-01 --end 2024-12-31 --output chart.png
23
+ meteo daily 10637 --start 2024-01-01 --end 2024-12-31 --format csv --no-header
24
+ ```
25
+
26
+ ## Station discovery
27
+
28
+ ```bash
29
+ meteo station 10637 # Metadata for a specific station
30
+ meteo station --country DE # All stations in Germany
31
+ meteo station --country DE --state HE
32
+ meteo station --name "Frankfurt" # Search by name (case-insensitive, partial match)
33
+ meteo station --bbox "8.0,50.0,10.0,51.0"
34
+ meteo station --sql "SELECT * FROM stations WHERE country = 'DE' AND elevation > 500"
35
+ meteo nearby 50.1109,8.6821 --limit 10 --radius 20000
36
+ ```
37
+
38
+ ## Data quality & filtering
39
+
40
+ ```bash
41
+ meteo daily 10637 --start 2024-01-01 --end 2024-12-31 --with-sources # Include source provider columns
42
+ meteo daily 10637 --start 2024-01-01 --end 2024-12-31 --no-models # Exclude model data
43
+ meteo daily 10637 10635 --start 2024-01-01 --end 2024-12-31 --agg mean
44
+ meteo daily 10637 --no-cache # Disable cache for the latest data
45
+ meteo daily 10637 --start 2024-01-01 --end 2024-12-31 --all # Show all rows without truncation
46
+ ```
47
+
48
+ ## Finding the hottest/coldest day
49
+
50
+ ```bash
51
+ # Peak tmax for a station over a full year — single command, no awk needed
52
+ meteo daily D1424 --start 2025-01-01 --end 2025-12-31 --parameters tmax --agg max -f csv
53
+ # To also get the date of the peak, filter with sort after fetching tmax only
54
+ meteo daily D1424 --start 2025-01-01 --end 2025-12-31 --parameters tmax -f csv \
55
+ | awk -F',' 'NR>1' | sort -t',' -k3 -rn | head -1
56
+ ```
57
+
58
+ ## Inventory
59
+
60
+ ```bash
61
+ meteo inventory 10637
62
+ meteo inventory 10637 --granularity daily
63
+ meteo inventory 10637 --parameters temp,tmin,tmax
64
+ ```
65
+
66
+ ## Configuration
67
+
68
+ ```bash
69
+ meteo config --list
70
+ meteo config cache_enable false
71
+ meteo config interpolation_radius 50000
72
+ ```
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meteostat-cli
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Access weather and climate data through the terminal.
5
5
  Project-URL: Homepage, https://github.com/meteostat/cli
6
6
  Project-URL: Repository, https://github.com/meteostat/cli
@@ -9,7 +9,6 @@ Author-email: Meteostat <info@meteostat.net>
9
9
  License: MIT
10
10
  License-File: LICENSE
11
11
  Keywords: cli,climate,meteostat,weather
12
- Classifier: Development Status :: 4 - Beta
13
12
  Classifier: Environment :: Console
14
13
  Classifier: Intended Audience :: Developers
15
14
  Classifier: Intended Audience :: Science/Research
@@ -62,13 +61,19 @@ Description-Content-Type: text/markdown
62
61
  ## 📚 Installation
63
62
 
64
63
  ```bash
65
- pip install --user meteostat-cli
64
+ uv tool install meteostat-cli
66
65
  ```
67
66
 
68
- For plotting capabilities (`png`/`svg` output), install the `plot` extra:
67
+ For plotting capabilities (`png` and `svg` output), install the `plot` extra:
69
68
 
70
69
  ```bash
71
- pip install --user meteostat-cli[plot]
70
+ uv tool install "meteostat-cli[plot]"
71
+ ```
72
+
73
+ Alternatively, you can use `uvx`:
74
+
75
+ ```bash
76
+ uvx --from meteostat-cli meteo
72
77
  ```
73
78
 
74
79
  ## 🚀 Usage
@@ -34,13 +34,19 @@
34
34
  ## 📚 Installation
35
35
 
36
36
  ```bash
37
- pip install --user meteostat-cli
37
+ uv tool install meteostat-cli
38
38
  ```
39
39
 
40
- For plotting capabilities (`png`/`svg` output), install the `plot` extra:
40
+ For plotting capabilities (`png` and `svg` output), install the `plot` extra:
41
41
 
42
42
  ```bash
43
- pip install --user meteostat-cli[plot]
43
+ uv tool install "meteostat-cli[plot]"
44
+ ```
45
+
46
+ Alternatively, you can use `uvx`:
47
+
48
+ ```bash
49
+ uvx --from meteostat-cli meteo
44
50
  ```
45
51
 
46
52
  ## 🚀 Usage
@@ -1,3 +1,3 @@
1
1
  """Meteostat CLI — Access weather and climate data through the terminal."""
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "0.2.0"
@@ -48,7 +48,6 @@ def _register_commands() -> None:
48
48
 
49
49
  app.command("config")(config_cmd)
50
50
  app.command("station")(station_cmd)
51
- app.command("stations")(station_cmd)
52
51
  app.command("s", hidden=True)(station_cmd)
53
52
  app.command("nearby")(nearby_cmd)
54
53
  app.command("inventory")(inventory_cmd)
@@ -6,10 +6,11 @@ from meteo.utils import detect_format, output_df
6
6
 
7
7
 
8
8
  def nearby_cmd(
9
- lat: float = typer.Argument(..., help="Latitude."),
10
- lon: float = typer.Argument(..., help="Longitude."),
9
+ coords: str = typer.Argument(..., help="Coordinates as lat,lon (e.g. 48.1,11.6)."),
11
10
  limit: int = typer.Option(5, "--limit", "-l", help="Maximum number of stations."),
12
- radius: int = typer.Option(5000, "--radius", "-r", help="Search radius in meters."),
11
+ radius: int | None = typer.Option(
12
+ None, "--radius", "-r", help="Search radius in meters."
13
+ ),
13
14
  fmt: str | None = typer.Option(
14
15
  None, "--format", "-f", help="Output format (csv, json, xlsx, parquet)."
15
16
  ),
@@ -24,17 +25,25 @@ def nearby_cmd(
24
25
  """Find weather stations near a location."""
25
26
  import meteostat as ms
26
27
 
27
- if not (-90 <= lat <= 90):
28
- typer.echo(f"Error: Latitude must be between -90 and 90, got {lat}.", err=True)
29
- raise typer.Exit(2)
30
- if not (-180 <= lon <= 180):
28
+ parts = coords.split(",", 1)
29
+ if len(parts) != 2:
31
30
  typer.echo(
32
- f"Error: Longitude must be between -180 and 180, got {lon}.", err=True
31
+ "Error: Coordinates must be in lat,lon format (e.g. 48.1,11.6).", err=True
33
32
  )
34
33
  raise typer.Exit(2)
34
+ try:
35
+ lat = float(parts[0])
36
+ lon = float(parts[1])
37
+ except ValueError:
38
+ typer.echo(f"Error: Invalid coordinates: {coords}", err=True)
39
+ raise typer.Exit(2) from None
40
+ if not (-90 <= lat <= 90):
41
+ raise typer.BadParameter(f"Latitude must be between -90 and 90, got {lat}")
42
+ if not (-180 <= lon <= 180):
43
+ raise typer.BadParameter(f"Longitude must be between -180 and 180, got {lon}")
35
44
 
36
45
  point = ms.Point(lat, lon)
37
- df = ms.stations.nearby(point, radius=radius, limit=limit)
46
+ df = ms.stations.nearby(point, radius=radius or 40_075_000, limit=limit)
38
47
 
39
48
  actual_fmt = detect_format(fmt, output)
40
49
  output_df(df, actual_fmt, output, no_header, show_all=show_all)
@@ -14,6 +14,7 @@ import yaml
14
14
  # CLI-specific config keys (not part of Meteostat library config)
15
15
  CLI_CONFIG_KEYS = {
16
16
  "interpolation_radius": 25000,
17
+ "interpolation_station_count": 10,
17
18
  "humanize": True,
18
19
  }
19
20
 
@@ -100,7 +100,7 @@ def plot_dataframe(
100
100
 
101
101
  typer.echo(
102
102
  "Error: Matplotlib is required for plot output. "
103
- "Install with: pip install meteostat-cli[plot]",
103
+ 'Install with: uv tool install "meteostat-cli[plot]"',
104
104
  err=True,
105
105
  )
106
106
  raise typer.Exit(1) from None
@@ -121,6 +121,15 @@ def get_interpolation_radius() -> int:
121
121
  return CLI_CONFIG_KEYS["interpolation_radius"]
122
122
 
123
123
 
124
+ def get_interpolation_station_count() -> int:
125
+ """Get the configured station count limit for coordinate-based queries."""
126
+ data = load_config()
127
+ key = "interpolation_station_count"
128
+ if key in data:
129
+ return int(data[key])
130
+ return CLI_CONFIG_KEYS["interpolation_station_count"]
131
+
132
+
124
133
  def detect_format(fmt: str | None, output: str | None) -> str:
125
134
  """Detect the output format from explicit flag or file extension."""
126
135
  if fmt is not None:
@@ -362,7 +371,9 @@ def fetch_timeseries(
362
371
  else:
363
372
  point = ms.Point(resolved[1], resolved[2])
364
373
  radius = get_interpolation_radius()
365
- nearby = ms.stations.nearby(point, radius=radius)
374
+ nearby = ms.stations.nearby(
375
+ point, radius=radius, limit=get_interpolation_station_count()
376
+ )
366
377
  if nearby.empty:
367
378
  typer.echo(
368
379
  "No weather stations found within the specified radius.",
@@ -397,7 +408,9 @@ def fetch_timeseries(
397
408
  else:
398
409
  point = ms.Point(resolved[1], resolved[2])
399
410
  radius = get_interpolation_radius()
400
- nearby = ms.stations.nearby(point, radius=radius)
411
+ nearby = ms.stations.nearby(
412
+ point, radius=radius, limit=get_interpolation_station_count()
413
+ )
401
414
  if nearby.empty:
402
415
  typer.echo(
403
416
  "No weather stations found within the specified radius.",
@@ -434,7 +447,9 @@ def fetch_timeseries(
434
447
  else:
435
448
  point = ms.Point(resolved[1], resolved[2])
436
449
  radius = get_interpolation_radius()
437
- nearby = ms.stations.nearby(point, radius=radius)
450
+ nearby = ms.stations.nearby(
451
+ point, radius=radius, limit=get_interpolation_station_count()
452
+ )
438
453
  if nearby.empty:
439
454
  typer.echo(
440
455
  "No weather stations found within the specified radius.",
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "meteostat-cli"
7
- version = "0.1.0"
7
+ version = "0.2.0"
8
8
  description = "Access weather and climate data through the terminal."
9
9
  authors = [{ name = "Meteostat", email = "info@meteostat.net" }]
10
10
  readme = "README.md"
@@ -12,7 +12,6 @@ license = { text = "MIT" }
12
12
  requires-python = ">=3.11"
13
13
  keywords = ["weather", "climate", "meteostat", "cli"]
14
14
  classifiers = [
15
- "Development Status :: 4 - Beta",
16
15
  "Environment :: Console",
17
16
  "Intended Audience :: Developers",
18
17
  "Intended Audience :: Science/Research",
@@ -67,12 +67,6 @@ def test_command_help_config(invoke):
67
67
  assert result.exit_code == 0
68
68
 
69
69
 
70
- def test_command_help_stations(invoke):
71
- """Test that 'stations --help' works."""
72
- result = invoke("stations", "--help")
73
- assert result.exit_code == 0
74
-
75
-
76
70
  def test_command_help_nearby(invoke):
77
71
  """Test that 'nearby --help' works."""
78
72
  result = invoke("nearby", "--help")
@@ -86,7 +86,7 @@ class TestNearbyCommand:
86
86
  with patch("meteostat.stations") as mock_stations:
87
87
  mock_stations.nearby.return_value = df
88
88
  with patch("meteostat.Point"):
89
- result = invoke("nearby", "50.1109", "8.6821")
89
+ result = invoke("nearby", "50.1109,8.6821")
90
90
  assert result.exit_code == 0
91
91
  assert "Frankfurt" in result.output
92
92
 
@@ -259,7 +259,7 @@ class TestAllFlag:
259
259
  with patch("meteostat.stations") as mock_stations:
260
260
  mock_stations.nearby.return_value = df
261
261
  with patch("meteostat.Point"):
262
- result = invoke("nearby", "50.1109", "8.6821", "--all")
262
+ result = invoke("nearby", "50.1109,8.6821", "--all")
263
263
  assert result.exit_code == 0
264
264
 
265
265
  def test_hourly_all_flag(self, invoke):
@@ -311,7 +311,6 @@ class TestAllFlag:
311
311
  """--all flag appears in help for all data commands."""
312
312
  for cmd in [
313
313
  "station",
314
- "stations",
315
314
  "nearby",
316
315
  "inventory",
317
316
  "hourly",
@@ -544,7 +543,7 @@ class TestNearbyEdgeCases:
544
543
  """Nearby command exits 1 when no stations found."""
545
544
  with patch("meteostat.stations") as ms, patch("meteostat.Point"):
546
545
  ms.nearby.return_value = pd.DataFrame()
547
- result = invoke("nearby", "50.1109", "8.6821")
546
+ result = invoke("nearby", "50.1109,8.6821")
548
547
  assert result.exit_code == 1
549
548
  assert "No data" in result.output
550
549
 
@@ -556,19 +555,19 @@ class TestNearbyEdgeCases:
556
555
  )
557
556
  with patch("meteostat.stations") as ms, patch("meteostat.Point"):
558
557
  ms.nearby.return_value = df
559
- result = invoke("nearby", "50.1109", "8.6821", "--format", "csv")
558
+ result = invoke("nearby", "50.1109,8.6821", "--format", "csv")
560
559
  assert result.exit_code == 0
561
560
  assert "name" in result.output
562
561
 
563
562
  def test_nearby_invalid_latitude(self, invoke):
564
563
  """Nearby command exits 2 when latitude is out of range."""
565
- result = invoke("nearby", "200", "8.6821")
564
+ result = invoke("nearby", "200,8.6821")
566
565
  assert result.exit_code == 2
567
566
  assert "Latitude" in result.output
568
567
 
569
568
  def test_nearby_invalid_longitude(self, invoke):
570
569
  """Nearby command exits 2 when longitude is out of range."""
571
- result = invoke("nearby", "50.1109", "200")
570
+ result = invoke("nearby", "50.1109,200")
572
571
  assert result.exit_code == 2
573
572
  assert "Longitude" in result.output
574
573
 
@@ -891,11 +891,11 @@ wheels = [
891
891
 
892
892
  [[package]]
893
893
  name = "pygments"
894
- version = "2.19.2"
894
+ version = "2.20.0"
895
895
  source = { registry = "https://pypi.org/simple" }
896
- sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631, upload-time = "2025-06-21T13:39:12.283Z" }
896
+ sdist = { url = "https://files.pythonhosted.org/packages/c3/b2/bc9c9196916376152d655522fdcebac55e66de6603a76a02bca1b6414f6c/pygments-2.20.0.tar.gz", hash = "sha256:6757cd03768053ff99f3039c1a36d6c0aa0b263438fcab17520b30a303a82b5f", size = 4955991, upload-time = "2026-03-29T13:29:33.898Z" }
897
897
  wheels = [
898
- { url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" },
898
+ { url = "https://files.pythonhosted.org/packages/f4/7e/a72dd26f3b0f4f2bf1dd8923c85f7ceb43172af56d63c7383eb62b332364/pygments-2.20.0-py3-none-any.whl", hash = "sha256:81a9e26dd42fd28a23a2d169d86d7ac03b46e2f8b59ed4698fb4785f946d0176", size = 1231151, upload-time = "2026-03-29T13:29:30.038Z" },
899
899
  ]
900
900
 
901
901
  [[package]]
File without changes
File without changes