rsplot 0.3.2.dev4__py3-none-any.whl → 0.3.2.dev37__py3-none-any.whl
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.
- rsplot/atomic.py +36 -0
- rsplot/cli.py +272 -497
- rsplot/commands/common.py +52 -3
- rsplot/commands/fnr.py +389 -104
- rsplot/commands/forecast.py +0 -2
- rsplot/commands/meteo.py +499 -186
- rsplot/commands/overlay.py +284 -326
- rsplot/commands/radius.py +526 -0
- rsplot/commands/raster.py +418 -293
- rsplot/commands/reconstruct.py +0 -1
- rsplot/commands/sidecar.py +106 -0
- rsplot/commands/station.py +154 -42
- rsplot/commands/station_trend.py +259 -174
- rsplot/config.py +43 -16
- rsplot/data_files.py +253 -0
- rsplot/errors.py +43 -0
- rsplot/fnr.py +38 -46
- rsplot/geo/boundaries.py +212 -9
- rsplot/geo/footprints.py +3 -0
- rsplot/geo/processing.py +2 -5
- rsplot/geo/radius.py +205 -0
- rsplot/plotting/colormap_22.txt +256 -0
- rsplot/plotting/colormaps.py +24 -29
- rsplot/plotting/map_frame.py +84 -6
- rsplot/plotting/meteo.py +10 -3
- rsplot/plotting/overlay.py +31 -40
- rsplot/plotting/raster.py +10 -3
- rsplot/plotting/station.py +86 -33
- rsplot/plotting/station_focus.py +84 -0
- rsplot/plotting/station_trend.py +60 -47
- rsplot/plotting/styles.py +3 -5
- rsplot/readers/__init__.py +52 -4
- rsplot/readers/_tropomi.py +121 -3
- rsplot/readers/era5.py +110 -10
- rsplot/readers/era5_wind.py +3 -2
- rsplot/readers/gems.py +11 -8
- rsplot/readers/guokong.py +125 -39
- rsplot/readers/netcdf.py +32 -0
- rsplot/readers/tropomi_hcho.py +1 -1
- rsplot/readers/tropomi_no2.py +1 -1
- rsplot/readers/tropomi_nrti.py +116 -0
- rsplot/readers/tropomi_o3.py +1 -1
- rsplot/readers/tropomi_o3pr.py +1 -1
- rsplot/result_builders/__init__.py +0 -14
- rsplot/result_builders/common.py +4 -1
- rsplot/result_builders/envelope.py +236 -0
- rsplot/result_builders/fnr.py +47 -131
- rsplot/result_builders/provenance.py +59 -0
- rsplot/result_builders/satellite.py +240 -0
- rsplot/result_builders/series_layer.py +289 -0
- rsplot/result_builders/station.py +23 -0
- rsplot/result_builders/station_layer.py +326 -0
- rsplot/results.py +0 -12
- rsplot/schemas/result.schema.json +566 -0
- rsplot/temporal.py +7 -0
- {rsplot-0.3.2.dev4.dist-info → rsplot-0.3.2.dev37.dist-info}/METADATA +426 -121
- rsplot-0.3.2.dev37.dist-info/RECORD +76 -0
- {rsplot-0.3.2.dev4.dist-info → rsplot-0.3.2.dev37.dist-info}/WHEEL +1 -1
- rsplot/commands/recent.py +0 -186
- rsplot/recent.py +0 -447
- rsplot/result_builders/meteo.py +0 -171
- rsplot/result_builders/overlay.py +0 -105
- rsplot/result_builders/raster.py +0 -104
- rsplot/result_builders/station_trend.py +0 -229
- rsplot-0.3.2.dev4.dist-info/RECORD +0 -66
- {rsplot-0.3.2.dev4.dist-info → rsplot-0.3.2.dev37.dist-info}/entry_points.txt +0 -0
- {rsplot-0.3.2.dev4.dist-info → rsplot-0.3.2.dev37.dist-info}/licenses/LICENSE +0 -0
rsplot/commands/common.py
CHANGED
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import math
|
|
6
|
+
import re
|
|
6
7
|
from collections.abc import Callable
|
|
7
8
|
from typing import TYPE_CHECKING, ParamSpec, TypeVar
|
|
8
9
|
|
|
9
10
|
import typer
|
|
10
11
|
|
|
12
|
+
from rsplot.errors import RsplotError
|
|
13
|
+
|
|
11
14
|
if TYPE_CHECKING:
|
|
12
15
|
import geopandas as gpd
|
|
13
16
|
from rich.console import Console
|
|
@@ -39,6 +42,50 @@ def parse_basemap(value: str | None) -> bool | None:
|
|
|
39
42
|
raise ValueError("--basemap 仅支持 satellite / none。")
|
|
40
43
|
|
|
41
44
|
|
|
45
|
+
def parse_explicit_window(date_arg: str, days: int | None) -> list[str]:
|
|
46
|
+
"""Return the dates of a window whose length is stated explicitly.
|
|
47
|
+
|
|
48
|
+
The window is either a ``YYYYMMDD-YYYYMMDD`` range or an end date
|
|
49
|
+
``YYYYMMDD`` with ``--days``; a single date alone is rejected.
|
|
50
|
+
"""
|
|
51
|
+
from rsplot.temporal import parse_date_window
|
|
52
|
+
|
|
53
|
+
if days is not None and days < 1:
|
|
54
|
+
raise RsplotError(
|
|
55
|
+
"invalid_argument", "--days 必须 >= 1。", option="--days"
|
|
56
|
+
)
|
|
57
|
+
if "-" in date_arg and days is not None:
|
|
58
|
+
raise RsplotError(
|
|
59
|
+
"invalid_argument",
|
|
60
|
+
"日期区间不能与 --days 同时使用;"
|
|
61
|
+
"请选择 YYYYMMDD-YYYYMMDD 或结束日期 YYYYMMDD 配合 --days N。",
|
|
62
|
+
option="--days",
|
|
63
|
+
)
|
|
64
|
+
if "-" not in date_arg and days is None:
|
|
65
|
+
raise RsplotError(
|
|
66
|
+
"invalid_argument",
|
|
67
|
+
"单日 DATE 需要 --days N 指定窗口长度,"
|
|
68
|
+
"或使用日期区间 YYYYMMDD-YYYYMMDD。",
|
|
69
|
+
option="--days",
|
|
70
|
+
)
|
|
71
|
+
try:
|
|
72
|
+
return parse_date_window(date_arg, default_days=days or 0)
|
|
73
|
+
except ValueError as error:
|
|
74
|
+
raise RsplotError("invalid_time", str(error)) from error
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def require_single_region(region: str) -> None:
|
|
78
|
+
"""Reject a comma list where a merged regional mean would be implicit."""
|
|
79
|
+
names = [name.strip() for name in re.split("[,,]", region)]
|
|
80
|
+
if len(names) > 1:
|
|
81
|
+
raise RsplotError(
|
|
82
|
+
"invalid_argument",
|
|
83
|
+
f"'{region}' 列出了多个区域。时间序列一次只汇总一个区域,"
|
|
84
|
+
"合并多个区域会隐式加权;请对每个区域分别运行。",
|
|
85
|
+
details={"regions": [name for name in names if name]},
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
42
89
|
def validate_positive(value: float, option: str) -> None:
|
|
43
90
|
"""Require a finite value greater than zero."""
|
|
44
91
|
if not math.isfinite(value) or value <= 0:
|
|
@@ -123,12 +170,13 @@ def resolve_satellite(
|
|
|
123
170
|
qa: float | None,
|
|
124
171
|
cfg: AppConfig,
|
|
125
172
|
console: Console,
|
|
173
|
+
processing: str | None = None,
|
|
126
174
|
) -> tuple[ProductInfo, float]:
|
|
127
175
|
"""Resolve source and QA policy before opening regional/data files."""
|
|
128
176
|
from rsplot.readers import get_product_info
|
|
129
177
|
|
|
130
178
|
try:
|
|
131
|
-
info = get_product_info(product, sensor=sensor)
|
|
179
|
+
info = get_product_info(product, sensor=sensor, processing=processing)
|
|
132
180
|
if info.sensor == "gems" and qa is not None:
|
|
133
181
|
raise ValueError(
|
|
134
182
|
"--qa 仅用于 TROPOMI;GEMS 使用最终质量标记 = 0 "
|
|
@@ -142,9 +190,10 @@ def resolve_satellite(
|
|
|
142
190
|
else cfg.qa_threshold
|
|
143
191
|
)
|
|
144
192
|
validate_unit_interval(threshold, "--qa")
|
|
193
|
+
except RsplotError:
|
|
194
|
+
raise
|
|
145
195
|
except ValueError as error:
|
|
146
|
-
|
|
147
|
-
raise typer.Exit(1) from error
|
|
196
|
+
raise RsplotError("invalid_argument", str(error)) from error
|
|
148
197
|
return info, threshold
|
|
149
198
|
|
|
150
199
|
|