rsplot 0.3.2.dev4__py3-none-any.whl → 0.4.0__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.
Files changed (67) hide show
  1. rsplot/atomic.py +36 -0
  2. rsplot/cli.py +272 -497
  3. rsplot/commands/common.py +52 -3
  4. rsplot/commands/fnr.py +389 -104
  5. rsplot/commands/forecast.py +0 -2
  6. rsplot/commands/meteo.py +499 -186
  7. rsplot/commands/overlay.py +284 -326
  8. rsplot/commands/radius.py +526 -0
  9. rsplot/commands/raster.py +418 -293
  10. rsplot/commands/reconstruct.py +0 -1
  11. rsplot/commands/sidecar.py +106 -0
  12. rsplot/commands/station.py +154 -42
  13. rsplot/commands/station_trend.py +259 -174
  14. rsplot/config.py +43 -16
  15. rsplot/data_files.py +253 -0
  16. rsplot/errors.py +43 -0
  17. rsplot/fnr.py +38 -46
  18. rsplot/geo/boundaries.py +212 -9
  19. rsplot/geo/footprints.py +3 -0
  20. rsplot/geo/processing.py +2 -5
  21. rsplot/geo/radius.py +205 -0
  22. rsplot/plotting/colormap_22.txt +256 -0
  23. rsplot/plotting/colormaps.py +24 -29
  24. rsplot/plotting/map_frame.py +84 -6
  25. rsplot/plotting/meteo.py +10 -3
  26. rsplot/plotting/overlay.py +31 -40
  27. rsplot/plotting/raster.py +10 -3
  28. rsplot/plotting/station.py +86 -33
  29. rsplot/plotting/station_focus.py +84 -0
  30. rsplot/plotting/station_trend.py +60 -47
  31. rsplot/plotting/styles.py +3 -5
  32. rsplot/readers/__init__.py +52 -4
  33. rsplot/readers/_tropomi.py +121 -3
  34. rsplot/readers/era5.py +110 -10
  35. rsplot/readers/era5_wind.py +3 -2
  36. rsplot/readers/gems.py +11 -8
  37. rsplot/readers/guokong.py +125 -39
  38. rsplot/readers/netcdf.py +32 -0
  39. rsplot/readers/tropomi_hcho.py +1 -1
  40. rsplot/readers/tropomi_no2.py +1 -1
  41. rsplot/readers/tropomi_nrti.py +116 -0
  42. rsplot/readers/tropomi_o3.py +1 -1
  43. rsplot/readers/tropomi_o3pr.py +1 -1
  44. rsplot/result_builders/__init__.py +0 -14
  45. rsplot/result_builders/common.py +4 -1
  46. rsplot/result_builders/envelope.py +236 -0
  47. rsplot/result_builders/fnr.py +47 -131
  48. rsplot/result_builders/provenance.py +59 -0
  49. rsplot/result_builders/satellite.py +240 -0
  50. rsplot/result_builders/series_layer.py +289 -0
  51. rsplot/result_builders/station.py +23 -0
  52. rsplot/result_builders/station_layer.py +326 -0
  53. rsplot/results.py +0 -12
  54. rsplot/schemas/result.schema.json +566 -0
  55. rsplot/temporal.py +7 -0
  56. {rsplot-0.3.2.dev4.dist-info → rsplot-0.4.0.dist-info}/METADATA +426 -121
  57. rsplot-0.4.0.dist-info/RECORD +76 -0
  58. {rsplot-0.3.2.dev4.dist-info → rsplot-0.4.0.dist-info}/WHEEL +1 -1
  59. rsplot/commands/recent.py +0 -186
  60. rsplot/recent.py +0 -447
  61. rsplot/result_builders/meteo.py +0 -171
  62. rsplot/result_builders/overlay.py +0 -105
  63. rsplot/result_builders/raster.py +0 -104
  64. rsplot/result_builders/station_trend.py +0 -229
  65. rsplot-0.3.2.dev4.dist-info/RECORD +0 -66
  66. {rsplot-0.3.2.dev4.dist-info → rsplot-0.4.0.dist-info}/entry_points.txt +0 -0
  67. {rsplot-0.3.2.dev4.dist-info → rsplot-0.4.0.dist-info}/licenses/LICENSE +0 -0
rsplot/cli.py CHANGED
@@ -13,6 +13,7 @@ app = typer.Typer(
13
13
  name="rsplot",
14
14
  help="CLI tool for Remote sensing raster plotting.",
15
15
  no_args_is_help=True,
16
+ add_completion=False,
16
17
  )
17
18
 
18
19
 
@@ -50,70 +51,47 @@ def raster(
50
51
  ),
51
52
  date_arg: str = typer.Argument(
52
53
  ...,
53
- help="GEMS: 北京时间 YYYYMMDDHHMM 精确扫描,YYYYMMDD 日均;单日 YYYYMMDD 走单日路径;带 --days 或写成 YYYYMMDD-YYYYMMDD "
54
- "时切换为窗口均值(HCHO 单日覆盖率低,月均更可读)",
55
- ),
56
- # --- optional overrides ---
57
- sensor: str = typer.Option(
58
- "tropomi", "--sensor", help="卫星来源: tropomi / gems"
54
+ metavar="DATE",
55
+ help=(
56
+ "TROPOMI: YYYYMMDD 按文件名日期合并当天轨道;"
57
+ "GEMS: YYYYMMDD 日均或 YYYYMMDDHHMM 精确扫描。"
58
+ "两者均支持 YYYYMMDD-YYYYMMDD 闭区间,"
59
+ "或结束日期 YYYYMMDD 配合 --days N,逐日等权平均。"
60
+ ),
59
61
  ),
62
+ # --- Required options ---
60
63
  product: str = typer.Option(
61
- "o3",
64
+ ...,
62
65
  "--product",
63
- "-p",
64
66
  help="产品类型: no2 / o3 / o3pr / hcho",
65
67
  ),
66
- days: int | None = typer.Option(
67
- None,
68
- "--days",
69
- help="时间窗口天数;不指定且 DATE 为单日时走单日路径。"
70
- "推荐值: 30 (月均,HCHO 首选) / 7 (周均) / 显式区间用 YYYYMMDD-YYYYMMDD",
71
- ),
72
- n_min: int | None = typer.Option(
73
- None,
74
- "--n-min",
75
- help=(
76
- "窗口模式下每像元最少有效天数。默认: NO2/O3/O3PR="
77
- "max(3, 天数//2), HCHO=max(3, ceil(天数*0.25))"
78
- ),
68
+ output: str = typer.Option(
69
+ ...,
70
+ "--output",
71
+ help="输出 .png 文件路径(不能是目录),同时写同名 JSON",
79
72
  ),
80
- level: str | None = typer.Option(
81
- None,
82
- "--level",
83
- "-l",
84
- help="强制指定级别: country / key_region / province / city / county",
73
+ # --- Data selection and processing ---
74
+ sensor: str = typer.Option(
75
+ "tropomi", "--sensor", help="卫星来源: tropomi / gems"
85
76
  ),
86
- data_dir: str | None = typer.Option(
77
+ processing: str | None = typer.Option(
87
78
  None,
88
- "--data-dir",
89
- "-d",
90
- help="数据目录 (覆盖配置默认值)",
79
+ "--processing",
80
+ help="TROPOMI 处理流: nrti(筛选并去重);省略则读取目录内匹配文件",
91
81
  ),
92
- output: str | None = typer.Option(
82
+ days: int | None = typer.Option(
93
83
  None,
94
- "--output",
95
- "-o",
96
- help="输出文件路径,不指定则弹窗显示。",
84
+ "--days",
85
+ help=(
86
+ "以 DATE 为结束日期、向前共 N 天(含当天),按日等权平均;"
87
+ "不能与日期区间同时使用。省略时 YYYYMMDD 仅处理当天。"
88
+ ),
97
89
  ),
98
- dpi: int | None = typer.Option(300, "--dpi", help="输出 DPI"),
99
90
  res: float | None = typer.Option(
100
91
  None,
101
92
  "--res",
102
- help="网格分辨率 (度);GEMS 绘图仅控制显示,分析网格固定 0.05°",
103
- ),
104
- basemap: str | None = typer.Option(
105
- None,
106
- "--basemap",
107
- "-b",
108
- help="底图控制: satellite / none (覆盖级别默认)",
109
- ),
110
- vmin: float | None = typer.Option(None, "--vmin", help="Colorbar 最小值"),
111
- vmax: float | None = typer.Option(None, "--vmax", help="Colorbar 最大值"),
112
- cmap: str | None = typer.Option(None, "--cmap", help="Colormap 名称"),
113
- smooth: float | None = typer.Option(
114
- None, "--smooth", help="高斯平滑 sigma"
93
+ help="目标网格间距 (度);GEMS 默认 0.05°,直接重映射原始像元",
115
94
  ),
116
- title: str | None = typer.Option(None, "--title", help="自定义标题"),
117
95
  qa: float | None = typer.Option(
118
96
  None, "--qa", help="TROPOMI QA 阈值 (0-1),默认取配置;GEMS 不适用"
119
97
  ),
@@ -124,111 +102,41 @@ def raster(
124
102
  max=1.0,
125
103
  help="最大云量比例 (0-1),保留 CF <= 该值的卫星像元",
126
104
  ),
127
- ) -> None:
128
- """绘制卫星遥感栅格图。
129
-
130
- 示例:
131
- rsplot raster 北京 20260108 --dpi 300 --output yrd.png # 单日
132
- rsplot raster 安徽 20260131 -p hcho --days 30 # 月均(推荐 HCHO)
133
- rsplot raster 长三角 20260101-20260131 -p no2 # 显式区间
134
- """
135
- from rsplot.commands.raster import run_raster
136
-
137
- run_raster(
138
- region=region,
139
- date_arg=date_arg,
140
- product=product,
141
- sensor=sensor,
142
- days=days,
143
- n_min=n_min,
144
- level=level,
145
- data_dir=data_dir,
146
- output=output,
147
- dpi=dpi,
148
- res=res,
149
- basemap=basemap,
150
- vmin=vmin,
151
- vmax=vmax,
152
- cmap=cmap,
153
- smooth=smooth,
154
- title=title,
155
- qa=qa,
156
- cf=cf,
157
- console=console,
158
- )
159
-
160
-
161
- @app.command()
162
- def reconstruct(
163
- region: str = typer.Argument(
164
- ..., help="区域名称,如 中国、安徽、合肥、YRD、合肥/蜀山"
165
- ),
166
- datetime_str: str = typer.Argument(
167
- ...,
168
- help="中国时间 YYYYMMDDHH,或 YYYYMMDD 自动取当天最新完整小时",
169
- ),
170
- var: str = typer.Option(
171
- "o3",
172
- "--var",
173
- "-v",
174
- help="重构变量: PM2.5 / PM10 / SO2 / NO2 / CO / O3",
175
- ),
176
- level: str | None = typer.Option(
177
- None,
178
- "--level",
179
- "-l",
180
- help="强制指定级别: country / key_region / province / city / county",
181
- ),
182
- data_dir: str | None = typer.Option(
183
- None,
184
- "--data-dir",
185
- "-d",
186
- help="重构数据目录 (覆盖配置中的 reconstruct 路径)",
187
- ),
188
- output: str | None = typer.Option(
189
- None,
190
- "--output",
191
- "-o",
192
- help="输出文件路径",
105
+ smooth: float | None = typer.Option(
106
+ None, "--smooth", help="高斯平滑 sigma"
193
107
  ),
108
+ # --- Plotting ---
194
109
  dpi: int | None = typer.Option(300, "--dpi", help="输出 DPI"),
195
- res: float | None = typer.Option(
196
- None,
197
- "--res",
198
- help="输出网格分辨率 (度,须为原生 0.01° 的整数倍)",
199
- ),
200
110
  basemap: str | None = typer.Option(
201
111
  None,
202
112
  "--basemap",
203
- "-b",
204
113
  help="底图控制: satellite / none (覆盖级别默认)",
205
114
  ),
206
115
  vmin: float | None = typer.Option(None, "--vmin", help="Colorbar 最小值"),
207
116
  vmax: float | None = typer.Option(None, "--vmax", help="Colorbar 最大值"),
208
117
  cmap: str | None = typer.Option(None, "--cmap", help="Colormap 名称"),
209
- smooth: float | None = typer.Option(
210
- None,
211
- "--smooth",
212
- help="可选高斯平滑 sigma;默认不平滑",
213
- ),
214
118
  title: str | None = typer.Option(None, "--title", help="自定义标题"),
215
119
  ) -> None:
216
- """绘制逐小时空气质量重构栅格图。
120
+ """绘制卫星遥感栅格图。
217
121
 
218
- CLI 时次按中国标准时间解释,内部转换到 UTC 归档文件名。
122
+ TROPOMI 单日合并轨道后网格化;窗口模式先逐日网格化,再对每个网格的
123
+ 有效天等权平均(缺测不计为 0,至少一天有效即保留,全无有效天则留空)。
124
+ 统计只用有观测的网格;TROPOMI 单日图上的小空洞填补和平滑仅用于显示。
219
125
 
220
126
  示例:
221
- rsplot reconstruct 安徽 2026051108 --var PM2.5
222
- rsplot reconstruct 合肥 20260511 --var O3 --res 0.01
127
+ rsplot raster 北京市 20260108 --product no2 --output beijing_no2.png # 单日
128
+ rsplot raster 安徽 20260131 --product hcho --days 30 --output anhui_hcho.png # 30 日窗口
129
+ rsplot raster 长三角 20260101-20260131 --product no2 --output yrd_no2.png # 显式区间
223
130
  """
224
- from rsplot.commands.reconstruct import run_reconstruct
131
+ from rsplot.commands.raster import run_raster
225
132
 
226
- run_reconstruct(
133
+ run_raster(
227
134
  region=region,
228
- datetime_str=datetime_str,
229
- var=var,
230
- level=level,
231
- data_dir=data_dir,
135
+ date_arg=date_arg,
136
+ product=product,
137
+ sensor=sensor,
138
+ processing=processing,
139
+ days=days,
232
140
  output=output,
233
141
  dpi=dpi,
234
142
  res=res,
@@ -238,111 +146,125 @@ def reconstruct(
238
146
  cmap=cmap,
239
147
  smooth=smooth,
240
148
  title=title,
149
+ qa=qa,
150
+ cf=cf,
241
151
  console=console,
242
152
  )
243
153
 
244
154
 
245
155
  @app.command()
246
- def forecast(
247
- region: str = typer.Argument(
248
- ..., help="区域名称,如 中国、安徽、合肥、YRD、合肥/蜀山"
156
+ def radius(
157
+ station_id: str = typer.Argument(
158
+ ...,
159
+ help="中心国控站点 ID,如 1379A",
249
160
  ),
250
- datetime_str: str = typer.Argument(
161
+ date_arg: str = typer.Argument(
251
162
  ...,
252
- help=("中国时间起报时次 YYYYMMDDHH,或 YYYYMMDD 自动取当天最新小时"),
163
+ help="GEMS: YYYYMMDDHHMM 精确扫描,YYYYMMDD 日均;单日 YYYYMMDD 走单日路径;带 --days 或写成 YYYYMMDD-YYYYMMDD "
164
+ "时切换为窗口均值(HCHO 单日覆盖率低,月均更可读)",
253
165
  ),
254
- var: str = typer.Option(
255
- "o3",
256
- "--var",
257
- "-v",
258
- help="预报变量: PM2.5 / PM10 / SO2 / NO2 / CO / O3",
166
+ # --- Required options ---
167
+ product: str = typer.Option(
168
+ ...,
169
+ "--product",
170
+ help="产品类型: no2 / o3 / o3pr / hcho",
259
171
  ),
260
- lead: int = typer.Option(
261
- 24,
262
- "--lead",
263
- help="预报时效: 6 / 12 / 24 / 48 / 72 小时",
172
+ km: float = typer.Option(
173
+ ...,
174
+ "--km",
175
+ help="从站点向上下左右各延伸的公里数,正方形边长为该值的两倍",
264
176
  ),
265
- level: str | None = typer.Option(
266
- None,
267
- "--level",
268
- "-l",
269
- help="强制指定级别: country / key_region / province / city / county",
177
+ output: str = typer.Option(
178
+ ...,
179
+ "--output",
180
+ help="输出 .png 文件路径(不能是目录),同时写同名 JSON",
181
+ ),
182
+ # --- Data selection and processing ---
183
+ sensor: str = typer.Option(
184
+ "tropomi", "--sensor", help="卫星来源: tropomi / gems"
270
185
  ),
271
- data_dir: str | None = typer.Option(
186
+ processing: str | None = typer.Option(
272
187
  None,
273
- "--data-dir",
274
- "-d",
275
- help="预报数据目录 (覆盖配置中的 forecast 路径)",
188
+ "--processing",
189
+ help="TROPOMI 处理流: nrti;省略时沿用原有目录与读取行为",
276
190
  ),
277
- station_overlay: bool = typer.Option(
278
- False,
279
- "--station-overlay",
280
- help="叠加同有效时次的国控站点散点",
191
+ days: int | None = typer.Option(
192
+ None,
193
+ "--days",
194
+ help="时间窗口天数;不指定且 DATE 为单日时走单日路径。"
195
+ "推荐值: 30 (月均,HCHO 首选) / 7 (周均) / 显式区间用 YYYYMMDD-YYYYMMDD",
281
196
  ),
282
197
  station_var: str | None = typer.Option(
283
198
  None,
284
199
  "--station-var",
285
- help="站点变量名;默认按预报变量自动匹配 PM2.5/PM10/SO2/NO2/CO/O3",
286
- ),
287
- station_data_dir: str | None = typer.Option(
288
- None,
289
- "--station-data-dir",
290
- help="国控站点数据目录 (覆盖配置中的 guokong 路径)",
200
+ help="站点变量,如 NO2 / O3 / PM2.5;省略只标位置",
291
201
  ),
292
202
  station_datetime: str | None = typer.Option(
293
203
  None,
294
204
  "--station-datetime",
295
- help="站点时次 YYYYMMDDHH 或 YYYYMMDD;默认使用预报有效时次",
205
+ help="站点小时 YYYYMMDDHH;只标位置或日均/窗口叠加变量时必填,GEMS 扫描叠加变量时默认匹配最近整点",
296
206
  ),
297
- output: str | None = typer.Option(
207
+ res: float | None = typer.Option(
298
208
  None,
299
- "--output",
300
- "-o",
301
- help="输出文件路径",
209
+ "--res",
210
+ help="目标网格间距 (度);GEMS 默认 0.05°,直接重映射原始像元",
211
+ ),
212
+ qa: float | None = typer.Option(
213
+ None, "--qa", help="TROPOMI QA 阈值 (0-1),默认取配置;GEMS 不适用"
214
+ ),
215
+ cf: float = typer.Option(
216
+ 0.5,
217
+ "--cf",
218
+ min=0.0,
219
+ max=1.0,
220
+ help="最大云量比例 (0-1),保留 CF <= 该值的卫星像元",
221
+ ),
222
+ smooth: float | None = typer.Option(
223
+ None, "--smooth", help="高斯平滑 sigma"
302
224
  ),
225
+ # --- Plotting ---
303
226
  dpi: int | None = typer.Option(300, "--dpi", help="输出 DPI"),
304
227
  basemap: str | None = typer.Option(
305
- None,
228
+ "none",
306
229
  "--basemap",
307
- "-b",
308
230
  help="底图控制: satellite / none (覆盖级别默认)",
309
231
  ),
310
232
  vmin: float | None = typer.Option(None, "--vmin", help="Colorbar 最小值"),
311
233
  vmax: float | None = typer.Option(None, "--vmax", help="Colorbar 最大值"),
312
234
  cmap: str | None = typer.Option(None, "--cmap", help="Colormap 名称"),
313
- smooth: float | None = typer.Option(
314
- None, "--smooth", help="高斯平滑 sigma"
315
- ),
316
235
  title: str | None = typer.Option(None, "--title", help="自定义标题"),
317
236
  ) -> None:
318
- """绘制空气质量预报栅格图。
237
+ """绘制站点居中、上下左右各延伸指定公里数的正方形卫星图,可叠加指定小时的站点变量。
319
238
 
320
239
  示例:
321
- rsplot forecast 安徽 2026063000 --lead 24 --var O3
322
- rsplot forecast 合肥 20260630 --lead 72 --var PM2.5
323
- rsplot forecast 合肥 2026041409 --lead 6 --var O3 --station-overlay
240
+ rsplot radius 1379A 20260414 --km 30 --product no2 \\
241
+ --station-datetime 2026041413 --output 1379A_no2.png
242
+ rsplot radius 1379A 20260414 --km 30 --product no2 --station-var NO2 \\
243
+ --station-datetime 2026041413 --output 1379A_no2_stations.png
324
244
  """
325
- from rsplot.commands.forecast import run_forecast
245
+ from rsplot.commands.radius import run_radius
326
246
 
327
- run_forecast(
328
- region=region,
329
- datetime_str=datetime_str,
330
- var=var,
331
- lead=lead,
332
- level=level,
333
- data_dir=data_dir,
334
- station_overlay=station_overlay,
247
+ run_radius(
248
+ station_id=station_id,
249
+ date_arg=date_arg,
250
+ km=km,
335
251
  station_var=station_var,
336
- station_data_dir=station_data_dir,
337
252
  station_datetime=station_datetime,
253
+ sensor=sensor,
254
+ processing=processing,
255
+ product=product,
256
+ days=days,
338
257
  output=output,
339
258
  dpi=dpi,
259
+ res=res,
340
260
  basemap=basemap,
341
261
  vmin=vmin,
342
262
  vmax=vmax,
343
263
  cmap=cmap,
344
264
  smooth=smooth,
345
265
  title=title,
266
+ qa=qa,
267
+ cf=cf,
346
268
  console=console,
347
269
  )
348
270
 
@@ -354,8 +276,15 @@ def meteo(
354
276
  ),
355
277
  datetime_str: str = typer.Argument(
356
278
  ...,
357
- help="中国时间 YYYYMMDDHH;使用 --station-var 时也可输入 YYYYMMDD",
279
+ help="YYYYMMDDHH;不接受仅日期,不自动选择最新小时",
358
280
  ),
281
+ # --- Required options ---
282
+ output: str = typer.Option(
283
+ ...,
284
+ "--output",
285
+ help="输出 .png 文件路径(不能是目录),同时写同名 JSON",
286
+ ),
287
+ # --- Data selection and processing ---
359
288
  temp_level: str | None = typer.Option(
360
289
  None,
361
290
  "--temp-level",
@@ -371,41 +300,13 @@ def meteo(
371
300
  "--station-var",
372
301
  help="叠加国控站点变量;必须同时指定 --wind-level",
373
302
  ),
374
- level: str | None = typer.Option(
375
- None,
376
- "--level",
377
- "-l",
378
- help="强制指定行政区级别: country/key_region/province/city/county",
379
- ),
380
- data_dir: str | None = typer.Option(
381
- None,
382
- "--data-dir",
383
- "-d",
384
- help="ERA5 数据目录 (覆盖配置中的 era5 路径)",
385
- ),
386
- station_data_dir: str | None = typer.Option(
387
- None,
388
- "--station-data-dir",
389
- help="国控站点数据目录 (覆盖配置中的 guokong 路径)",
390
- ),
391
- output: str | None = typer.Option(
392
- None,
393
- "--output",
394
- "-o",
395
- help="输出 PNG 路径;同时写同名 JSON",
396
- ),
303
+ # --- Plotting ---
397
304
  dpi: int | None = typer.Option(300, "--dpi", help="输出 DPI"),
398
305
  basemap: str | None = typer.Option(
399
306
  None,
400
307
  "--basemap",
401
- "-b",
402
308
  help="底图控制: satellite / none",
403
309
  ),
404
- cmap: str | None = typer.Option(
405
- None,
406
- "--cmap",
407
- help="温度色标;默认 RdYlBu_r",
408
- ),
409
310
  vmin: float | None = typer.Option(
410
311
  None,
411
312
  "--vmin",
@@ -416,6 +317,11 @@ def meteo(
416
317
  "--vmax",
417
318
  help="温度色标最大值 (°C),默认区域 98% 分位",
418
319
  ),
320
+ cmap: str | None = typer.Option(
321
+ None,
322
+ "--cmap",
323
+ help="温度色标;默认 RdYlBu_r",
324
+ ),
419
325
  wind_stride: int | None = typer.Option(
420
326
  None,
421
327
  "--wind-stride",
@@ -439,12 +345,12 @@ def meteo(
439
345
  ) -> None:
440
346
  """绘制温度、黑色风箭头及可选国控站点图层。
441
347
 
442
- DATETIME 按中国标准时间解释并匹配 ERA5 UTC:
348
+ DATETIME 为 YYYYMMDDHH:
443
349
 
444
- rsplot meteo 南京 2026051115 --temp-level 2m
445
- rsplot meteo 南京 2026051115 --wind-level 850
446
- rsplot meteo 南京 2026051115 --temp-level 850 --wind-level 850
447
- rsplot meteo 南京 2026051115 --station-var O3 --wind-level 850
350
+ rsplot meteo 南京 2026051115 --temp-level 2m --output nanjing_t2m.png
351
+ rsplot meteo 南京 2026051115 --wind-level 850 --output nanjing_wind.png
352
+ rsplot meteo 南京 2026051115 --temp-level 850 --wind-level 850 --output nanjing_850.png
353
+ rsplot meteo 南京 2026051115 --station-var O3 --wind-level 850 --output nanjing_o3.png
448
354
  """
449
355
  from rsplot.commands.meteo import run_meteo
450
356
 
@@ -454,9 +360,6 @@ def meteo(
454
360
  temp_level=temp_level,
455
361
  wind_level=wind_level,
456
362
  station_var=station_var,
457
- level=level,
458
- data_dir=data_dir,
459
- station_data_dir=station_data_dir,
460
363
  output=output,
461
364
  dpi=dpi,
462
365
  basemap=basemap,
@@ -477,48 +380,38 @@ def station(
477
380
  ..., help="区域名称,如 中国、安徽、合肥、YRD、合肥/蜀山"
478
381
  ),
479
382
  datetime_str: str = typer.Argument(
480
- ..., help="YYYYMMDDHH (精确小时) 或 YYYYMMDD (自动取最新小时)"
383
+ ...,
384
+ help="YYYYMMDDHH(必须指定小时,不自动选择最新小时)",
481
385
  ),
386
+ # --- Required options ---
482
387
  var: str = typer.Option(
483
- "AQI",
388
+ ...,
484
389
  "--var",
485
- "-v",
486
- help="变量名: AQI, PM2.5, PM10, NO2, O3, SO2, CO, O3_8h, *_24h",
390
+ help="变量名: AQI, PM2.5, PM2.5_24h, PM10, PM10_24h, SO2, SO2_24h, NO2, NO2_24h, O3, O3_24h, O3_8h, O3_8h_24h, CO, CO_24h",
487
391
  ),
488
- level: str | None = typer.Option(
489
- None,
490
- "--level",
491
- "-l",
492
- help="强制指定级别: country / key_region / province / city / county",
493
- ),
494
- data_dir: str | None = typer.Option(
495
- None,
496
- "--data-dir",
497
- "-d",
498
- help="数据目录 (覆盖配置默认值)",
499
- ),
500
- output: str | None = typer.Option(
501
- None,
392
+ output: str = typer.Option(
393
+ ...,
502
394
  "--output",
503
- "-o",
504
- help="输出文件路径",
395
+ help="输出 .png 文件路径(不能是目录),同时写同名 JSON",
505
396
  ),
397
+ # --- Data selection and processing ---
398
+ # --- Plotting ---
506
399
  dpi: int | None = typer.Option(300, "--dpi", help="输出 DPI"),
507
400
  basemap: str | None = typer.Option(
508
401
  None,
509
402
  "--basemap",
510
- "-b",
511
403
  help="底图控制: satellite / none",
512
404
  ),
513
405
  title: str | None = typer.Option(None, "--title", help="自定义标题"),
514
406
  ) -> None:
515
407
  """绘制国控站点污染物散点图。
516
408
 
409
+ 时间必须为 YYYYMMDDHH;不接受仅日期或自动选择最新小时。
410
+
517
411
  示例:
518
- rsplot station 安徽 20260414
519
- rsplot station 安徽 2026041415
520
- rsplot station 中国 20260414 --var PM2.5_24h
521
- rsplot station YRD 2026041415 --var NO2 -o logs/yrd_no2.png
412
+ rsplot station 安徽 2026041415 --var AQI --output anhui_aqi.png
413
+ rsplot station 中国 2026041415 --var PM2.5_24h --output china_pm25.png
414
+ rsplot station YRD 2026041415 --var NO2 --output yrd_no2.png
522
415
  """
523
416
  from rsplot.commands.station import run_station
524
417
 
@@ -526,8 +419,6 @@ def station(
526
419
  region=region,
527
420
  datetime_str=datetime_str,
528
421
  var=var,
529
- level=level,
530
- data_dir=data_dir,
531
422
  output=output,
532
423
  dpi=dpi,
533
424
  basemap=basemap,
@@ -546,22 +437,36 @@ def trend(
546
437
  ...,
547
438
  help="结束日期 YYYYMMDD,或显式范围 YYYYMMDD-YYYYMMDD",
548
439
  ),
549
- days: int = typer.Option(
550
- 7,
551
- "--days",
552
- help="最近天数;仅当 DATE 为单日时生效,默认 7",
553
- ),
440
+ # --- Required options ---
554
441
  var: str = typer.Option(
555
- "O3_8h_24h",
442
+ ...,
556
443
  "--var",
557
- "-v",
558
444
  help="变量名: AQI, PM2.5, PM10, NO2, O3, SO2, CO, O3_8h, O3_8h_24h",
559
445
  ),
446
+ output: str = typer.Option(
447
+ ...,
448
+ "--output",
449
+ help="输出 .png 文件路径(不能是目录),同时写同名 JSON",
450
+ ),
451
+ # --- Data selection and processing ---
452
+ days: int | None = typer.Option(
453
+ None,
454
+ "--days",
455
+ help="以单日 DATE 为结束日的天数;单日 DATE 必填,日期区间时不可用",
456
+ ),
560
457
  region: bool = typer.Option(
561
458
  False,
562
459
  "--region",
563
460
  help="将 TARGET 作为区域名称,绘制区域站点趋势",
564
461
  ),
462
+ threshold: float | None = typer.Option(
463
+ None,
464
+ "--threshold",
465
+ min=0.0,
466
+ help="覆盖变量默认超标阈值",
467
+ ),
468
+ # --- Plotting ---
469
+ dpi: int | None = typer.Option(300, "--dpi", help="输出 DPI"),
565
470
  view: str = typer.Option(
566
471
  "lines",
567
472
  "--view",
@@ -574,39 +479,15 @@ def trend(
574
479
  help="区域图中重点突出站点 ID;可重复指定",
575
480
  ),
576
481
  ] = None,
577
- threshold: float | None = typer.Option(
578
- None,
579
- "--threshold",
580
- min=0.0,
581
- help="覆盖变量默认超标阈值",
582
- ),
583
- level: str | None = typer.Option(
584
- None,
585
- "--level",
586
- "-l",
587
- help="区域模式强制级别: country / key_region / province / city / county",
588
- ),
589
- data_dir: str | None = typer.Option(
590
- None,
591
- "--data-dir",
592
- "-d",
593
- help="国控站点数据目录 (覆盖配置默认值)",
594
- ),
595
- output: str | None = typer.Option(
596
- None,
597
- "--output",
598
- "-o",
599
- help="PNG 输出文件路径",
600
- ),
601
- dpi: int | None = typer.Option(300, "--dpi", help="输出 DPI"),
602
482
  title: str | None = typer.Option(None, "--title", help="自定义标题"),
603
483
  ) -> None:
604
484
  """绘制单站点或区域国控站点小时观测趋势图。
605
485
 
606
486
  示例:
607
- rsplot trend 3347A 20260520 --days 7 --var O3
608
- rsplot trend 安徽 20260520 --days 7 --var O3 --region
609
- rsplot trend 安徽 20260520 --region --view mean --focus-station 3347A
487
+ rsplot trend 3347A 20260520 --days 7 --var O3 --output 3347A_o3.png
488
+ rsplot trend 安徽 20260520 --days 7 --var O3 --region --output anhui_o3.png
489
+ rsplot trend 安徽 20260514-20260520 --var O3 --region --view mean \\
490
+ --focus-station 3347A --output anhui_o3_mean.png
610
491
  """
611
492
  from rsplot.commands.station_trend import run_trend
612
493
 
@@ -619,8 +500,6 @@ def trend(
619
500
  view=view,
620
501
  focus_station_ids=focus_station,
621
502
  threshold=threshold,
622
- level=level,
623
- data_dir=data_dir,
624
503
  output=output,
625
504
  dpi=dpi,
626
505
  title=title,
@@ -634,66 +513,81 @@ def overlay(
634
513
  ...,
635
514
  help="区域名称;支持逗号分隔多个省市县街道,如 '中山市/东区街道,中山市/南区街道',无需配置",
636
515
  ),
637
- datetime_str: str = typer.Argument(
516
+ date_arg: str = typer.Argument(
638
517
  ...,
639
- help="GEMS: 北京时间 YYYYMMDD 日均(需 --station-datetime),或 YYYYMMDDHHMM 精确扫描(自动匹配最近站点整点);TROPOMI: YYYYMMDDHH (精确小时) 或 YYYYMMDD (自动取最新小时);"
640
- "日期部分用于卫星,小时部分用于站点",
641
- ),
642
- # --- satellite product ---
643
- sensor: str = typer.Option(
644
- "tropomi", "--sensor", help="卫星来源: tropomi / gems"
518
+ metavar="DATE",
519
+ help=(
520
+ "卫星时间,与 raster 相同。TROPOMI: YYYYMMDD 按文件名日期合并"
521
+ "当天轨道;GEMS: YYYYMMDD 日均或 YYYYMMDDHHMM 精确扫描。"
522
+ "两者均支持 YYYYMMDD-YYYYMMDD 闭区间,或结束日期 YYYYMMDD 配合"
523
+ " --days N,逐日等权平均。"
524
+ ),
645
525
  ),
526
+ # --- Required options ---
646
527
  product: str = typer.Option(
647
- "o3",
528
+ ...,
648
529
  "--product",
649
- "-p",
650
530
  help="卫星产品类型: no2 / o3 / o3pr / hcho",
651
531
  ),
652
- station_datetime: str | None = typer.Option(
653
- None,
654
- "--station-datetime",
655
- help="GEMS 叠加站点时间,北京时间 YYYYMMDDHH",
532
+ station_var: str = typer.Option(
533
+ ...,
534
+ "--station-var",
535
+ help="站点变量名,如 NO2 / O3 / O3_8h_24h;与卫星产品无默认配对",
656
536
  ),
657
- # --- station variable ---
658
- var: str | None = typer.Option(
659
- None,
660
- "--var",
661
- "-v",
662
- help="站点变量名,省略时按 product 自动选同名变量 (NO2 / O3)",
537
+ output: str = typer.Option(
538
+ ...,
539
+ "--output",
540
+ help="输出 .png 文件路径(不能是目录),同时写同名 JSON",
663
541
  ),
664
- # --- overrides ---
665
- level: str | None = typer.Option(
666
- None,
667
- "--level",
668
- "-l",
669
- help="强制指定级别: country / key_region / province / city / county",
542
+ # --- Data selection and processing ---
543
+ sensor: str = typer.Option(
544
+ "tropomi", "--sensor", help="卫星来源: tropomi / gems"
670
545
  ),
671
- raster_dir: str | None = typer.Option(
546
+ processing: str | None = typer.Option(
672
547
  None,
673
- "--raster-dir",
674
- help="卫星数据目录 (覆盖配置默认值)",
548
+ "--processing",
549
+ help="TROPOMI 处理流: nrti;省略时沿用原有目录与读取行为",
675
550
  ),
676
- station_dir: str | None = typer.Option(
551
+ days: int | None = typer.Option(
677
552
  None,
678
- "--station-dir",
679
- help="国控站点数据目录 (覆盖配置默认值)",
553
+ "--days",
554
+ help=(
555
+ "以 DATE 为结束日期、向前共 N 天(含当天),按日等权平均;"
556
+ "不能与日期区间同时使用。"
557
+ ),
680
558
  ),
681
- output: str | None = typer.Option(
559
+ station_datetime: str | None = typer.Option(
682
560
  None,
683
- "--output",
684
- "-o",
685
- help="输出文件路径,不指定则弹窗显示。",
561
+ "--station-datetime",
562
+ help=(
563
+ "站点观测小时 YYYYMMDDHH。TROPOMI、GEMS 日均及窗口"
564
+ "均值必须指定;GEMS 精确扫描默认匹配最近整点,也可显式覆盖。"
565
+ "不会自动选择最新小时。"
566
+ ),
686
567
  ),
687
- dpi: int | None = typer.Option(300, "--dpi", help="输出 DPI"),
688
568
  res: float | None = typer.Option(
689
569
  None,
690
570
  "--res",
691
- help="网格分辨率 (度);GEMS 绘图仅控制显示,分析网格固定 0.05°",
571
+ help="目标网格间距 (度);GEMS 默认 0.05°,直接重映射原始像元",
572
+ ),
573
+ qa: float | None = typer.Option(
574
+ None, "--qa", help="TROPOMI QA 阈值 (0-1),默认取配置;GEMS 不适用"
575
+ ),
576
+ cf: float = typer.Option(
577
+ 0.5,
578
+ "--cf",
579
+ min=0.0,
580
+ max=1.0,
581
+ help="最大云量比例 (0-1),保留 CF <= 该值的卫星像元",
582
+ ),
583
+ smooth: float | None = typer.Option(
584
+ None, "--smooth", help="高斯平滑 sigma"
692
585
  ),
586
+ # --- Plotting ---
587
+ dpi: int | None = typer.Option(300, "--dpi", help="输出 DPI"),
693
588
  basemap: str | None = typer.Option(
694
589
  None,
695
590
  "--basemap",
696
- "-b",
697
591
  help="底图控制: satellite / none (覆盖级别默认)",
698
592
  ),
699
593
  vmin: float | None = typer.Option(
@@ -703,44 +597,32 @@ def overlay(
703
597
  None, "--vmax", help="卫星 colorbar 最大值"
704
598
  ),
705
599
  cmap: str | None = typer.Option(None, "--cmap", help="卫星 colormap 名称"),
706
- smooth: float | None = typer.Option(
707
- None, "--smooth", help="高斯平滑 sigma"
708
- ),
709
- qa: float | None = typer.Option(
710
- None, "--qa", help="TROPOMI QA 阈值 (0-1),默认取配置;GEMS 不适用"
711
- ),
712
- cf: float = typer.Option(
713
- 0.5,
714
- "--cf",
715
- min=0.0,
716
- max=1.0,
717
- help="最大云量比例 (0-1),保留 CF <= 该值的卫星像元",
718
- ),
719
600
  title: str | None = typer.Option(None, "--title", help="自定义标题"),
720
601
  ) -> None:
721
602
  """叠加绘制卫星栅格+国控站点图。
722
603
 
723
604
  两种数据同时输出到一张 PNG 和一个合并的 JSON sidecar。
724
- 日期部分 (YYYYMMDD) 用于卫星,整串 (YYYYMMDDHH) 用于站点;
725
- YYYYMMDD 会自动选当天最新小时的站点数据。
605
+ DATE 只决定卫星时间;站点始终是一个整点,从不做时间平均。
726
606
 
727
607
  示例:
728
- rsplot overlay YRD 20260208 -p no2
729
- rsplot overlay 安徽 2026041415 -p o3 -v O3_8h
730
- rsplot overlay 中国 20260208 -p no2 -o logs/overlay/china_no2.png
608
+ rsplot overlay YRD 20260208 --product no2 --station-var NO2 \\
609
+ --station-datetime 2026020813 --output yrd_no2.png
610
+ rsplot overlay 安徽 20260414 --product o3 --days 7 --station-var O3 \\
611
+ --station-datetime 2026041414 --output anhui_o3.png
612
+ rsplot overlay 合肥 202604141200 --sensor gems --product no2 \\
613
+ --station-var NO2 --output hefei_gems_no2.png
731
614
  """
732
615
  from rsplot.commands.overlay import run_overlay
733
616
 
734
617
  run_overlay(
735
618
  region=region,
736
- datetime_str=datetime_str,
619
+ date_arg=date_arg,
620
+ days=days,
737
621
  station_datetime=station_datetime,
738
622
  product=product,
739
623
  sensor=sensor,
740
- var=var,
741
- level=level,
742
- raster_dir=raster_dir,
743
- station_dir=station_dir,
624
+ processing=processing,
625
+ station_var=station_var,
744
626
  output=output,
745
627
  dpi=dpi,
746
628
  res=res,
@@ -756,99 +638,6 @@ def overlay(
756
638
  )
757
639
 
758
640
 
759
- @app.command()
760
- def recent(
761
- region: str = typer.Argument(
762
- ..., help="区域名称,如 中国、安徽、合肥、YRD、合肥/蜀山"
763
- ),
764
- end_date: str = typer.Argument(
765
- ..., help="结束日期 YYYYMMDD,最近 N 天统计以该日期为窗口末端"
766
- ),
767
- days: int = typer.Option(
768
- 30,
769
- "--days",
770
- help="最近天数,如 7 / 30 / 365",
771
- ),
772
- source: str = typer.Option(
773
- "raster",
774
- "--source",
775
- help="数据源: raster / station",
776
- ),
777
- sensor: str = typer.Option(
778
- "tropomi", "--sensor", help="卫星来源: tropomi / gems"
779
- ),
780
- product: str = typer.Option(
781
- "o3",
782
- "--product",
783
- "-p",
784
- help="source=raster 时的产品: no2 / o3 / o3pr / hcho",
785
- ),
786
- var: str = typer.Option(
787
- "AQI",
788
- "--var",
789
- "-v",
790
- help="source=station 时的变量名: AQI, PM2.5, PM10, NO2, O3, SO2, CO...",
791
- ),
792
- level: str | None = typer.Option(
793
- None,
794
- "--level",
795
- "-l",
796
- help="强制指定级别: country / key_region / province / city / county",
797
- ),
798
- data_dir: str | None = typer.Option(
799
- None,
800
- "--data-dir",
801
- "-d",
802
- help="数据目录 (覆盖配置默认值)",
803
- ),
804
- output: str | None = typer.Option(
805
- None,
806
- "--output",
807
- "-o",
808
- help="输出 JSON 路径",
809
- ),
810
- res: float | None = typer.Option(
811
- None,
812
- "--res",
813
- help="TROPOMI 网格分辨率 (度);GEMS 统计固定使用 0.05°,忽略此选项",
814
- ),
815
- qa: float | None = typer.Option(
816
- None, "--qa", help="TROPOMI QA 阈值 (0-1),默认取配置;GEMS 不适用"
817
- ),
818
- cf: float = typer.Option(
819
- 0.5,
820
- "--cf",
821
- min=0.0,
822
- max=1.0,
823
- help="source=raster 时最大云量比例,保留 CF <= 该值的像元",
824
- ),
825
- ) -> None:
826
- """输出最近 N 天数据 JSON,用于周/月/年变化对比。
827
-
828
- 示例:
829
- rsplot recent 合肥 20260428 --days 30 -p hcho -o recent.json
830
- rsplot recent 安徽 20260428 --days 7 --source station --var O3
831
- """
832
- from rsplot.commands.recent import run_recent
833
-
834
- run_recent(
835
- region=region,
836
- end_date=end_date,
837
- days=days,
838
- source=source,
839
- product=product,
840
- sensor=sensor,
841
- var=var,
842
- level=level,
843
- data_dir=data_dir,
844
- output=output,
845
- res=res,
846
- qa=qa,
847
- cf=cf,
848
- console=console,
849
- )
850
-
851
-
852
641
  @app.command()
853
642
  def fnr(
854
643
  region: str = typer.Argument(
@@ -859,11 +648,22 @@ def fnr(
859
648
  help="单日 (YYYYMMDD,默认向前 --days 天) 或范围 "
860
649
  "(YYYYMMDD-YYYYMMDD,闭区间)",
861
650
  ),
862
- # --- window ---
863
- days: int = typer.Option(
864
- 7,
651
+ # --- Required options ---
652
+ output: str = typer.Option(
653
+ ...,
654
+ "--output",
655
+ help="输出 .png 文件路径(不能是目录),同时写同名 JSON",
656
+ ),
657
+ # --- Data selection and processing ---
658
+ processing: str | None = typer.Option(
659
+ None,
660
+ "--processing",
661
+ help="TROPOMI 处理流: nrti,同时用于 NO2 与 HCHO",
662
+ ),
663
+ days: int | None = typer.Option(
664
+ None,
865
665
  "--days",
866
- help="时间窗口天数(仅当 date_arg 为单日时生效,默认 7)",
666
+ help="以单日 DATE 为结束日的窗口天数;单日 DATE 必填,日期区间时不可用",
867
667
  ),
868
668
  n_min: int | None = typer.Option(
869
669
  None,
@@ -886,45 +686,7 @@ def fnr(
886
686
  "--nox-threshold",
887
687
  help="NOx-limited 分级阈值:FNR 大于该值判为 NOx-limited",
888
688
  ),
889
- display_max: float = typer.Option(
890
- 6.0,
891
- "--display-max",
892
- help="FNR 图例显示上限,必须大于 --nox-threshold",
893
- ),
894
- # --- overrides ---
895
- level: str | None = typer.Option(
896
- None,
897
- "--level",
898
- "-l",
899
- help="强制指定级别: country / key_region / province / city / county",
900
- ),
901
- raster_dir_no2: str | None = typer.Option(
902
- None,
903
- "--no2-dir",
904
- help="NO2 数据目录 (覆盖配置默认值)",
905
- ),
906
- raster_dir_hcho: str | None = typer.Option(
907
- None,
908
- "--hcho-dir",
909
- help="HCHO 数据目录 (覆盖配置默认值)",
910
- ),
911
- output: str | None = typer.Option(
912
- None,
913
- "--output",
914
- "-o",
915
- help="输出文件路径",
916
- ),
917
- dpi: int | None = typer.Option(300, "--dpi", help="输出 DPI"),
918
689
  res: float | None = typer.Option(None, "--res", help="网格分辨率 (度)"),
919
- basemap: str | None = typer.Option(
920
- None,
921
- "--basemap",
922
- "-b",
923
- help="底图控制: satellite / none",
924
- ),
925
- smooth: float | None = typer.Option(
926
- None, "--smooth", help="高斯平滑 sigma"
927
- ),
928
690
  qa: float | None = typer.Option(
929
691
  0.5,
930
692
  "--qa",
@@ -937,6 +699,21 @@ def fnr(
937
699
  max=1.0,
938
700
  help="最大云量比例,同时应用于 NO2 和 HCHO;保留 CF <= 该值的像元",
939
701
  ),
702
+ smooth: float | None = typer.Option(
703
+ None, "--smooth", help="高斯平滑 sigma"
704
+ ),
705
+ # --- Plotting ---
706
+ dpi: int | None = typer.Option(300, "--dpi", help="输出 DPI"),
707
+ basemap: str | None = typer.Option(
708
+ None,
709
+ "--basemap",
710
+ help="底图控制: satellite / none",
711
+ ),
712
+ display_max: float = typer.Option(
713
+ 6.0,
714
+ "--display-max",
715
+ help="FNR 图例显示上限,必须大于 --nox-threshold",
716
+ ),
940
717
  title: str | None = typer.Option(None, "--title", help="自定义标题"),
941
718
  ) -> None:
942
719
  """绘制 FNR (HCHO / NO2) 区域控制 regime 图。
@@ -945,13 +722,14 @@ def fnr(
945
722
  分级依据 Duncan 2010: FNR<1 VOC-limited, 1~2 过渡, >2 NOx-limited.
946
723
 
947
724
  示例:
948
- rsplot fnr 合肥 20260114 (7日窗口)
949
- rsplot fnr 安徽 20260131 --days 30 (30日窗口)
950
- rsplot fnr 长三角 20260101-20260130 (显式范围)
725
+ rsplot fnr 合肥 20260114 --days 7 --output hefei_fnr.png # 7 日窗口
726
+ rsplot fnr 安徽 20260131 --days 30 --output anhui_fnr.png # 30 日窗口
727
+ rsplot fnr 长三角 20260101-20260130 --output yrd_fnr.png # 显式区间
951
728
  """
952
729
  from rsplot.commands.fnr import run_fnr
953
730
 
954
731
  run_fnr(
732
+ processing=processing,
955
733
  region=region,
956
734
  date_arg=date_arg,
957
735
  days=days,
@@ -960,9 +738,6 @@ def fnr(
960
738
  voc_threshold=voc_threshold,
961
739
  nox_threshold=nox_threshold,
962
740
  display_max=display_max,
963
- level=level,
964
- raster_dir_no2=raster_dir_no2,
965
- raster_dir_hcho=raster_dir_hcho,
966
741
  output=output,
967
742
  dpi=dpi,
968
743
  res=res,