rsplot 0.3.2.dev37__py3-none-any.whl → 0.4.1.dev8__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/cli.py +98 -10
- rsplot/commands/common.py +24 -0
- rsplot/commands/exceedance.py +541 -0
- rsplot/commands/fnr.py +122 -50
- rsplot/commands/meteo.py +4 -10
- rsplot/commands/overlay.py +3 -8
- rsplot/commands/radius.py +2 -7
- rsplot/commands/raster.py +1 -0
- rsplot/commands/station.py +4 -13
- rsplot/commands/station_trend.py +2 -6
- rsplot/config.py +3 -7
- rsplot/data_files.py +20 -2
- rsplot/exceedance.py +140 -0
- rsplot/fnr.py +85 -51
- rsplot/plotting/__init__.py +6 -0
- rsplot/plotting/exceedance.py +559 -0
- rsplot/readers/era5_days.py +263 -0
- rsplot/readers/guokong.py +155 -88
- rsplot/result_builders/common.py +102 -0
- rsplot/result_builders/exceedance.py +524 -0
- rsplot/result_builders/satellite.py +10 -0
- rsplot/result_builders/weather_days.py +231 -0
- rsplot/schemas/result.schema.json +209 -10
- rsplot/weather_days.py +121 -0
- {rsplot-0.3.2.dev37.dist-info → rsplot-0.4.1.dev8.dist-info}/METADATA +70 -5
- {rsplot-0.3.2.dev37.dist-info → rsplot-0.4.1.dev8.dist-info}/RECORD +29 -22
- {rsplot-0.3.2.dev37.dist-info → rsplot-0.4.1.dev8.dist-info}/WHEEL +1 -1
- {rsplot-0.3.2.dev37.dist-info → rsplot-0.4.1.dev8.dist-info}/entry_points.txt +0 -0
- {rsplot-0.3.2.dev37.dist-info → rsplot-0.4.1.dev8.dist-info}/licenses/LICENSE +0 -0
rsplot/cli.py
CHANGED
|
@@ -387,7 +387,7 @@ def station(
|
|
|
387
387
|
var: str = typer.Option(
|
|
388
388
|
...,
|
|
389
389
|
"--var",
|
|
390
|
-
help="变量名: AQI, PM2.5, PM2.5_24h, PM10, PM10_24h, SO2, SO2_24h, NO2, NO2_24h, O3,
|
|
390
|
+
help="变量名: AQI, PM2.5, PM2.5_24h, PM10, PM10_24h, SO2, SO2_24h, NO2, NO2_24h, O3, CO, CO_24h",
|
|
391
391
|
),
|
|
392
392
|
output: str = typer.Option(
|
|
393
393
|
...,
|
|
@@ -441,7 +441,7 @@ def trend(
|
|
|
441
441
|
var: str = typer.Option(
|
|
442
442
|
...,
|
|
443
443
|
"--var",
|
|
444
|
-
help="变量名: AQI, PM2.5, PM10, NO2, O3, SO2, CO
|
|
444
|
+
help="变量名: AQI, PM2.5, PM10, NO2, O3, SO2, CO",
|
|
445
445
|
),
|
|
446
446
|
output: str = typer.Option(
|
|
447
447
|
...,
|
|
@@ -507,6 +507,84 @@ def trend(
|
|
|
507
507
|
)
|
|
508
508
|
|
|
509
509
|
|
|
510
|
+
@app.command()
|
|
511
|
+
def exceedance(
|
|
512
|
+
target: str = typer.Argument(
|
|
513
|
+
...,
|
|
514
|
+
help="区域名称(可用逗号分隔);使用 --station 时为站点 ID",
|
|
515
|
+
),
|
|
516
|
+
date_arg: str = typer.Argument(
|
|
517
|
+
...,
|
|
518
|
+
metavar="DATE",
|
|
519
|
+
help="单日 YYYYMMDD(逐小时图)或日期区间 YYYYMMDD-YYYYMMDD(站点×日热图)",
|
|
520
|
+
),
|
|
521
|
+
# --- Required options ---
|
|
522
|
+
var: str = typer.Option(
|
|
523
|
+
...,
|
|
524
|
+
"--var",
|
|
525
|
+
help=(
|
|
526
|
+
"污染物:O3(由逐小时值计算 MDA8,限值 160);PM2.5、PM10、"
|
|
527
|
+
"NO2、SO2、CO(由逐小时值计算日均值,限值 60、120、80、150 "
|
|
528
|
+
"μg/m³ 和 4 mg/m³);all 同时筛查六项污染物"
|
|
529
|
+
),
|
|
530
|
+
),
|
|
531
|
+
output: str = typer.Option(
|
|
532
|
+
...,
|
|
533
|
+
"--output",
|
|
534
|
+
help="输出 .png 文件路径(不能是目录),同时写同名 JSON",
|
|
535
|
+
),
|
|
536
|
+
station: bool = typer.Option(
|
|
537
|
+
False, "--station", help="按单个国控站点 ID 判断",
|
|
538
|
+
),
|
|
539
|
+
# --- Weather ---
|
|
540
|
+
meteo_hours: str | None = typer.Option(
|
|
541
|
+
None,
|
|
542
|
+
"--meteo-hours",
|
|
543
|
+
help=(
|
|
544
|
+
"加入 ERA5 逐日区域气象:每天 A-B 时(1–24,24 为次日 00 时)"
|
|
545
|
+
"的最高气温、平均相对湿度、短波辐射、最大边界层高度、降水和"
|
|
546
|
+
"10 m 风,并比较超标日与未超标日;仅用于区域、单一污染物和日期区间,如 12-20"
|
|
547
|
+
),
|
|
548
|
+
),
|
|
549
|
+
# --- Plotting ---
|
|
550
|
+
dpi: int | None = typer.Option(300, "--dpi", help="输出 DPI"),
|
|
551
|
+
title: str | None = typer.Option(None, "--title", help="自定义标题"),
|
|
552
|
+
) -> None:
|
|
553
|
+
"""逐站判断 O3 的 MDA8 或其他污染物的日均值是否超过 GB 3095 限值。
|
|
554
|
+
|
|
555
|
+
每个站点单独判断,不计算区域均值。D 日使用 D 日 01 时至次日 00 时。
|
|
556
|
+
O3:8 小时均值至少 6 个有效小时,MDA8 取 08–24 时结束的 17 个均值的
|
|
557
|
+
最大值,至少 14 个有效均值(不足但超过限值时仍判超标),限值 160。
|
|
558
|
+
PM2.5、PM10、NO2、SO2、CO:日均值至少 20 个有效小时(GB 3095—2026
|
|
559
|
+
表 4),限值为过渡阶段二级日均值;不读文件中的 *_24h 滑动均值列。
|
|
560
|
+
NO2、SO2、CO 的 1 小时限值只在单日图中作为参考线。
|
|
561
|
+
--var all 绘制六种污染物的逐日超标站数,灰色表示当天无可判断站点。
|
|
562
|
+
--station 直接按站点 ID 查询;区域模式按行政区汇总超标站日。
|
|
563
|
+
--meteo-hours 为日期区间加入 ERA5 逐日区域气象(中心落在区域内的格点
|
|
564
|
+
等权平均),按"任一站点超标"分组比较超标日与未超标日。
|
|
565
|
+
|
|
566
|
+
示例:
|
|
567
|
+
rsplot exceedance 西安市 20260614 --var O3 --output xian_o3_0614.png
|
|
568
|
+
rsplot exceedance 西安,咸阳 20260601-20260630 --var all --output all.png
|
|
569
|
+
rsplot exceedance 1279A 20260614 --station --var PM2.5 --output pm.png
|
|
570
|
+
rsplot exceedance 西安 20260601-20260630 --var O3 \
|
|
571
|
+
--meteo-hours 12-20 --output w.png
|
|
572
|
+
"""
|
|
573
|
+
from rsplot.commands.exceedance import run_exceedance
|
|
574
|
+
|
|
575
|
+
run_exceedance(
|
|
576
|
+
target=target,
|
|
577
|
+
station=station,
|
|
578
|
+
date_arg=date_arg,
|
|
579
|
+
var=var,
|
|
580
|
+
meteo_hours=meteo_hours,
|
|
581
|
+
output=output,
|
|
582
|
+
dpi=dpi,
|
|
583
|
+
title=title,
|
|
584
|
+
console=console,
|
|
585
|
+
)
|
|
586
|
+
|
|
587
|
+
|
|
510
588
|
@app.command()
|
|
511
589
|
def overlay(
|
|
512
590
|
region: str = typer.Argument(
|
|
@@ -532,7 +610,7 @@ def overlay(
|
|
|
532
610
|
station_var: str = typer.Option(
|
|
533
611
|
...,
|
|
534
612
|
"--station-var",
|
|
535
|
-
help="站点变量名,如 NO2 / O3
|
|
613
|
+
help="站点变量名,如 NO2 / O3;与卫星产品无默认配对",
|
|
536
614
|
),
|
|
537
615
|
output: str = typer.Option(
|
|
538
616
|
...,
|
|
@@ -645,8 +723,11 @@ def fnr(
|
|
|
645
723
|
),
|
|
646
724
|
date_arg: str = typer.Argument(
|
|
647
725
|
...,
|
|
648
|
-
help=
|
|
649
|
-
|
|
726
|
+
help=(
|
|
727
|
+
"TROPOMI: 单日 (YYYYMMDD,配合 --days N) 或范围 "
|
|
728
|
+
"(YYYYMMDD-YYYYMMDD,闭区间);"
|
|
729
|
+
"GEMS 还支持 12 位单次扫描 (YYYYMMDDHHMM)"
|
|
730
|
+
),
|
|
650
731
|
),
|
|
651
732
|
# --- Required options ---
|
|
652
733
|
output: str = typer.Option(
|
|
@@ -655,20 +736,26 @@ def fnr(
|
|
|
655
736
|
help="输出 .png 文件路径(不能是目录),同时写同名 JSON",
|
|
656
737
|
),
|
|
657
738
|
# --- Data selection and processing ---
|
|
739
|
+
sensor: str = typer.Option(
|
|
740
|
+
"tropomi", "--sensor", help="卫星来源: tropomi / gems"
|
|
741
|
+
),
|
|
658
742
|
processing: str | None = typer.Option(
|
|
659
743
|
None,
|
|
660
744
|
"--processing",
|
|
661
|
-
help="TROPOMI 处理流: nrti,同时用于 NO2 与 HCHO",
|
|
745
|
+
help="TROPOMI 处理流: nrti,同时用于 NO2 与 HCHO;GEMS 不适用",
|
|
662
746
|
),
|
|
663
747
|
days: int | None = typer.Option(
|
|
664
748
|
None,
|
|
665
749
|
"--days",
|
|
666
|
-
help=
|
|
750
|
+
help=(
|
|
751
|
+
"以单日 DATE 为结束日的窗口天数;"
|
|
752
|
+
"单日 DATE 必填,日期区间或 GEMS 单次扫描时不可用"
|
|
753
|
+
),
|
|
667
754
|
),
|
|
668
755
|
n_min: int | None = typer.Option(
|
|
669
756
|
None,
|
|
670
757
|
"--n-min",
|
|
671
|
-
help="每像元最少有效天数,默认 max(3, 窗口天数 // 2)",
|
|
758
|
+
help="每像元最少有效天数,默认 max(3, 窗口天数 // 2);单次扫描固定为 1",
|
|
672
759
|
),
|
|
673
760
|
no2_min: float = typer.Option(
|
|
674
761
|
0.5,
|
|
@@ -688,9 +775,9 @@ def fnr(
|
|
|
688
775
|
),
|
|
689
776
|
res: float | None = typer.Option(None, "--res", help="网格分辨率 (度)"),
|
|
690
777
|
qa: float | None = typer.Option(
|
|
691
|
-
|
|
778
|
+
None,
|
|
692
779
|
"--qa",
|
|
693
|
-
help="QA 阈值 (0-1)
|
|
780
|
+
help="TROPOMI QA 阈值 (0-1),默认取配置;GEMS 不适用",
|
|
694
781
|
),
|
|
695
782
|
cf: float = typer.Option(
|
|
696
783
|
0.5,
|
|
@@ -729,6 +816,7 @@ def fnr(
|
|
|
729
816
|
from rsplot.commands.fnr import run_fnr
|
|
730
817
|
|
|
731
818
|
run_fnr(
|
|
819
|
+
sensor=sensor,
|
|
732
820
|
processing=processing,
|
|
733
821
|
region=region,
|
|
734
822
|
date_arg=date_arg,
|
rsplot/commands/common.py
CHANGED
|
@@ -222,3 +222,27 @@ def satellite_errors(function: Callable[_P, _R]) -> Callable[_P, _R]:
|
|
|
222
222
|
raise typer.Exit(1) from error
|
|
223
223
|
|
|
224
224
|
return wrapped
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
# Station-file columns whose contents do not match their names.
|
|
228
|
+
REMOVED_STATION_VARS = ("O3_8h", "O3_8h_24h", "O3_24h")
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def require_station_var(var: str, option: str) -> None:
|
|
232
|
+
"""Reject unknown station variables and the removed ozone summaries."""
|
|
233
|
+
from rsplot.config import STATION_VAR_META
|
|
234
|
+
|
|
235
|
+
if var in REMOVED_STATION_VARS:
|
|
236
|
+
raise RsplotError(
|
|
237
|
+
"invalid_argument",
|
|
238
|
+
f"不再支持 '{var}':站点文件中的该字段与其名称不符。"
|
|
239
|
+
"判断 O3 是否超标请用 exceedance 命令,它由逐小时 O3 计算 MDA8。",
|
|
240
|
+
option=option,
|
|
241
|
+
)
|
|
242
|
+
if var not in STATION_VAR_META:
|
|
243
|
+
noun = "变量" if option == "--var" else "站点变量"
|
|
244
|
+
raise RsplotError(
|
|
245
|
+
"invalid_argument",
|
|
246
|
+
f"未知{noun} '{var}'。可用: {', '.join(STATION_VAR_META)}",
|
|
247
|
+
option=option,
|
|
248
|
+
)
|