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
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
1.00000 0.992157 0.992157
|
|
2
|
+
1.00000 0.992157 0.992157
|
|
3
|
+
1.00000 0.988235 0.988235
|
|
4
|
+
1.00000 0.984314 0.984314
|
|
5
|
+
1.00000 0.980392 0.980392
|
|
6
|
+
1.00000 0.976471 0.976471
|
|
7
|
+
1.00000 0.972549 0.972549
|
|
8
|
+
1.00000 0.968627 0.972549
|
|
9
|
+
1.00000 0.964706 0.968627
|
|
10
|
+
1.00000 0.960784 0.968627
|
|
11
|
+
1.00000 0.956863 0.964706
|
|
12
|
+
1.00000 0.952941 0.964706
|
|
13
|
+
1.00000 0.949020 0.960784
|
|
14
|
+
1.00000 0.945098 0.960784
|
|
15
|
+
1.00000 0.941176 0.956863
|
|
16
|
+
1.00000 0.937255 0.956863
|
|
17
|
+
1.00000 0.933333 0.956863
|
|
18
|
+
1.00000 0.929412 0.956863
|
|
19
|
+
1.00000 0.925490 0.952941
|
|
20
|
+
1.00000 0.921569 0.952941
|
|
21
|
+
1.00000 0.917647 0.952941
|
|
22
|
+
1.00000 0.913725 0.952941
|
|
23
|
+
1.00000 0.909804 0.952941
|
|
24
|
+
1.00000 0.905882 0.952941
|
|
25
|
+
1.00000 0.901961 0.952941
|
|
26
|
+
1.00000 0.898039 0.952941
|
|
27
|
+
1.00000 0.894118 0.956863
|
|
28
|
+
1.00000 0.890196 0.956863
|
|
29
|
+
1.00000 0.886275 0.956863
|
|
30
|
+
1.00000 0.882353 0.956863
|
|
31
|
+
1.00000 0.878431 0.960784
|
|
32
|
+
1.00000 0.874510 0.960784
|
|
33
|
+
1.00000 0.870588 0.964706
|
|
34
|
+
1.00000 0.866667 0.964706
|
|
35
|
+
1.00000 0.862745 0.968627
|
|
36
|
+
1.00000 0.858824 0.968627
|
|
37
|
+
1.00000 0.854902 0.972549
|
|
38
|
+
1.00000 0.850980 0.976471
|
|
39
|
+
1.00000 0.847059 0.980392
|
|
40
|
+
1.00000 0.843137 0.980392
|
|
41
|
+
1.00000 0.839216 0.984314
|
|
42
|
+
1.00000 0.835294 0.988235
|
|
43
|
+
1.00000 0.831373 0.992157
|
|
44
|
+
1.00000 0.827451 0.996078
|
|
45
|
+
0.996078 0.823529 1.00000
|
|
46
|
+
0.992157 0.819608 1.00000
|
|
47
|
+
0.988235 0.815686 1.00000
|
|
48
|
+
0.984314 0.811765 1.00000
|
|
49
|
+
0.976471 0.807843 1.00000
|
|
50
|
+
0.972549 0.803922 1.00000
|
|
51
|
+
0.968627 0.800000 1.00000
|
|
52
|
+
0.964706 0.796078 1.00000
|
|
53
|
+
0.956863 0.792157 1.00000
|
|
54
|
+
0.952941 0.788235 1.00000
|
|
55
|
+
0.945098 0.784314 1.00000
|
|
56
|
+
0.941176 0.780392 1.00000
|
|
57
|
+
0.933333 0.776471 1.00000
|
|
58
|
+
0.929412 0.772549 1.00000
|
|
59
|
+
0.921569 0.768627 1.00000
|
|
60
|
+
0.913725 0.764706 1.00000
|
|
61
|
+
0.905882 0.760784 1.00000
|
|
62
|
+
0.901961 0.756863 1.00000
|
|
63
|
+
0.894118 0.752941 1.00000
|
|
64
|
+
0.886275 0.749020 1.00000
|
|
65
|
+
0.878431 0.745098 1.00000
|
|
66
|
+
0.870588 0.741176 1.00000
|
|
67
|
+
0.862745 0.737255 1.00000
|
|
68
|
+
0.854902 0.733333 1.00000
|
|
69
|
+
0.847059 0.729412 1.00000
|
|
70
|
+
0.835294 0.725490 1.00000
|
|
71
|
+
0.827451 0.721569 1.00000
|
|
72
|
+
0.819608 0.717647 1.00000
|
|
73
|
+
0.811765 0.713726 1.00000
|
|
74
|
+
0.800000 0.709804 1.00000
|
|
75
|
+
0.792157 0.705882 1.00000
|
|
76
|
+
0.780392 0.701961 1.00000
|
|
77
|
+
0.772549 0.698039 1.00000
|
|
78
|
+
0.760784 0.694118 1.00000
|
|
79
|
+
0.752941 0.690196 1.00000
|
|
80
|
+
0.741176 0.686275 1.00000
|
|
81
|
+
0.733333 0.682353 1.00000
|
|
82
|
+
0.721569 0.678431 1.00000
|
|
83
|
+
0.709804 0.674510 1.00000
|
|
84
|
+
0.698039 0.670588 1.00000
|
|
85
|
+
0.686275 0.666667 1.00000
|
|
86
|
+
0.674510 0.662745 1.00000
|
|
87
|
+
0.666667 0.662745 1.00000
|
|
88
|
+
0.658824 0.662745 1.00000
|
|
89
|
+
0.654902 0.666667 1.00000
|
|
90
|
+
0.650980 0.670588 1.00000
|
|
91
|
+
0.647059 0.674510 1.00000
|
|
92
|
+
0.643137 0.678431 1.00000
|
|
93
|
+
0.639216 0.682353 1.00000
|
|
94
|
+
0.635294 0.690196 1.00000
|
|
95
|
+
0.631373 0.694118 1.00000
|
|
96
|
+
0.627451 0.698039 1.00000
|
|
97
|
+
0.623529 0.705882 1.00000
|
|
98
|
+
0.619608 0.709804 1.00000
|
|
99
|
+
0.615686 0.717647 1.00000
|
|
100
|
+
0.611765 0.721569 1.00000
|
|
101
|
+
0.607843 0.729412 1.00000
|
|
102
|
+
0.603922 0.737255 1.00000
|
|
103
|
+
0.600000 0.741176 1.00000
|
|
104
|
+
0.596078 0.749020 1.00000
|
|
105
|
+
0.592157 0.756863 1.00000
|
|
106
|
+
0.588235 0.764706 1.00000
|
|
107
|
+
0.584314 0.772549 1.00000
|
|
108
|
+
0.580392 0.780392 1.00000
|
|
109
|
+
0.576471 0.788235 1.00000
|
|
110
|
+
0.572549 0.796078 1.00000
|
|
111
|
+
0.568627 0.803922 1.00000
|
|
112
|
+
0.564706 0.811765 1.00000
|
|
113
|
+
0.560784 0.819608 1.00000
|
|
114
|
+
0.556863 0.827451 1.00000
|
|
115
|
+
0.552941 0.839216 1.00000
|
|
116
|
+
0.549020 0.847059 1.00000
|
|
117
|
+
0.545098 0.854902 1.00000
|
|
118
|
+
0.541176 0.866667 1.00000
|
|
119
|
+
0.537255 0.874510 1.00000
|
|
120
|
+
0.533333 0.886275 1.00000
|
|
121
|
+
0.529412 0.894118 1.00000
|
|
122
|
+
0.525490 0.905882 1.00000
|
|
123
|
+
0.521569 0.913725 1.00000
|
|
124
|
+
0.517647 0.925490 1.00000
|
|
125
|
+
0.513726 0.937255 1.00000
|
|
126
|
+
0.509804 0.945098 1.00000
|
|
127
|
+
0.505882 0.956863 1.00000
|
|
128
|
+
0.501961 0.968627 1.00000
|
|
129
|
+
0.498039 0.980392 1.00000
|
|
130
|
+
0.494118 0.992157 1.00000
|
|
131
|
+
0.490196 1.00000 0.992157
|
|
132
|
+
0.486275 1.00000 0.980392
|
|
133
|
+
0.482353 1.00000 0.968627
|
|
134
|
+
0.478431 1.00000 0.956863
|
|
135
|
+
0.474510 1.00000 0.945098
|
|
136
|
+
0.470588 1.00000 0.929412
|
|
137
|
+
0.466667 1.00000 0.917647
|
|
138
|
+
0.462745 1.00000 0.905882
|
|
139
|
+
0.458824 1.00000 0.890196
|
|
140
|
+
0.454902 1.00000 0.878431
|
|
141
|
+
0.450980 1.00000 0.862745
|
|
142
|
+
0.447059 1.00000 0.850980
|
|
143
|
+
0.443137 1.00000 0.835294
|
|
144
|
+
0.439216 1.00000 0.823529
|
|
145
|
+
0.435294 1.00000 0.807843
|
|
146
|
+
0.431373 1.00000 0.796078
|
|
147
|
+
0.427451 1.00000 0.780392
|
|
148
|
+
0.423529 1.00000 0.764706
|
|
149
|
+
0.419608 1.00000 0.749020
|
|
150
|
+
0.415686 1.00000 0.733333
|
|
151
|
+
0.411765 1.00000 0.717647
|
|
152
|
+
0.407843 1.00000 0.701961
|
|
153
|
+
0.403922 1.00000 0.686275
|
|
154
|
+
0.400000 1.00000 0.670588
|
|
155
|
+
0.396078 1.00000 0.654902
|
|
156
|
+
0.392157 1.00000 0.639216
|
|
157
|
+
0.388235 1.00000 0.623529
|
|
158
|
+
0.384314 1.00000 0.607843
|
|
159
|
+
0.380392 1.00000 0.588235
|
|
160
|
+
0.376471 1.00000 0.572549
|
|
161
|
+
0.372549 1.00000 0.556863
|
|
162
|
+
0.368627 1.00000 0.537255
|
|
163
|
+
0.364706 1.00000 0.521569
|
|
164
|
+
0.360784 1.00000 0.501961
|
|
165
|
+
0.356863 1.00000 0.486275
|
|
166
|
+
0.352941 1.00000 0.466667
|
|
167
|
+
0.349020 1.00000 0.447059
|
|
168
|
+
0.345098 1.00000 0.431373
|
|
169
|
+
0.341176 1.00000 0.411765
|
|
170
|
+
0.337255 1.00000 0.392157
|
|
171
|
+
0.333333 1.00000 0.372549
|
|
172
|
+
0.333333 1.00000 0.352941
|
|
173
|
+
0.329412 1.00000 0.337255
|
|
174
|
+
0.329412 1.00000 0.325490
|
|
175
|
+
0.345098 1.00000 0.321569
|
|
176
|
+
0.356863 1.00000 0.317647
|
|
177
|
+
0.368627 1.00000 0.313726
|
|
178
|
+
0.380392 1.00000 0.309804
|
|
179
|
+
0.392157 1.00000 0.305882
|
|
180
|
+
0.403922 1.00000 0.301961
|
|
181
|
+
0.419608 1.00000 0.298039
|
|
182
|
+
0.431373 1.00000 0.294118
|
|
183
|
+
0.447059 1.00000 0.290196
|
|
184
|
+
0.458824 1.00000 0.286275
|
|
185
|
+
0.474510 1.00000 0.282353
|
|
186
|
+
0.486275 1.00000 0.278431
|
|
187
|
+
0.501961 1.00000 0.274510
|
|
188
|
+
0.513726 1.00000 0.270588
|
|
189
|
+
0.529412 1.00000 0.266667
|
|
190
|
+
0.545098 1.00000 0.262745
|
|
191
|
+
0.560784 1.00000 0.258824
|
|
192
|
+
0.572549 1.00000 0.254902
|
|
193
|
+
0.588235 1.00000 0.250980
|
|
194
|
+
0.603922 1.00000 0.247059
|
|
195
|
+
0.619608 1.00000 0.243137
|
|
196
|
+
0.635294 1.00000 0.239216
|
|
197
|
+
0.650980 1.00000 0.235294
|
|
198
|
+
0.666667 1.00000 0.231373
|
|
199
|
+
0.682353 1.00000 0.227451
|
|
200
|
+
0.701961 1.00000 0.223529
|
|
201
|
+
0.717647 1.00000 0.219608
|
|
202
|
+
0.733333 1.00000 0.215686
|
|
203
|
+
0.749020 1.00000 0.211765
|
|
204
|
+
0.768627 1.00000 0.207843
|
|
205
|
+
0.784314 1.00000 0.203922
|
|
206
|
+
0.803922 1.00000 0.200000
|
|
207
|
+
0.819608 1.00000 0.196078
|
|
208
|
+
0.839216 1.00000 0.192157
|
|
209
|
+
0.854902 1.00000 0.188235
|
|
210
|
+
0.874510 1.00000 0.184314
|
|
211
|
+
0.894118 1.00000 0.180392
|
|
212
|
+
0.913725 1.00000 0.176471
|
|
213
|
+
0.929412 1.00000 0.172549
|
|
214
|
+
0.949020 1.00000 0.168627
|
|
215
|
+
0.968627 1.00000 0.164706
|
|
216
|
+
0.988235 1.00000 0.160784
|
|
217
|
+
1.00000 0.988235 0.156863
|
|
218
|
+
1.00000 0.968627 0.152941
|
|
219
|
+
1.00000 0.949020 0.149020
|
|
220
|
+
1.00000 0.929412 0.145098
|
|
221
|
+
1.00000 0.909804 0.141176
|
|
222
|
+
1.00000 0.886275 0.137255
|
|
223
|
+
1.00000 0.866667 0.133333
|
|
224
|
+
1.00000 0.847059 0.129412
|
|
225
|
+
1.00000 0.827451 0.125490
|
|
226
|
+
1.00000 0.803922 0.121569
|
|
227
|
+
1.00000 0.784314 0.117647
|
|
228
|
+
1.00000 0.760784 0.113725
|
|
229
|
+
1.00000 0.741176 0.109804
|
|
230
|
+
1.00000 0.717647 0.105882
|
|
231
|
+
1.00000 0.698039 0.101961
|
|
232
|
+
1.00000 0.674510 0.0980392
|
|
233
|
+
1.00000 0.650980 0.0941176
|
|
234
|
+
1.00000 0.627451 0.0901961
|
|
235
|
+
1.00000 0.607843 0.0862745
|
|
236
|
+
1.00000 0.584314 0.0823529
|
|
237
|
+
1.00000 0.560784 0.0784314
|
|
238
|
+
1.00000 0.537255 0.0745098
|
|
239
|
+
1.00000 0.513726 0.0705882
|
|
240
|
+
1.00000 0.490196 0.0666667
|
|
241
|
+
1.00000 0.466667 0.0627451
|
|
242
|
+
1.00000 0.443137 0.0588235
|
|
243
|
+
1.00000 0.419608 0.0549020
|
|
244
|
+
1.00000 0.392157 0.0509804
|
|
245
|
+
1.00000 0.368627 0.0470588
|
|
246
|
+
1.00000 0.345098 0.0431373
|
|
247
|
+
1.00000 0.317647 0.0509804
|
|
248
|
+
1.00000 0.294118 0.0352941
|
|
249
|
+
1.00000 0.270588 0.0313726
|
|
250
|
+
1.00000 0.243137 0.0274510
|
|
251
|
+
1.00000 0.219608 0.0235294
|
|
252
|
+
1.00000 0.192157 0.0196078
|
|
253
|
+
1.00000 0.164706 0.0156863
|
|
254
|
+
1.00000 0.141176 0.0117647
|
|
255
|
+
1.00000 0.113725 0.00784314
|
|
256
|
+
1.00000 0.113725 0.00784314
|
rsplot/plotting/colormaps.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
import os
|
|
6
5
|
from pathlib import Path
|
|
7
6
|
|
|
8
7
|
import matplotlib as mpl
|
|
@@ -10,12 +9,31 @@ import matplotlib.colors as mcolors
|
|
|
10
9
|
import numpy as np
|
|
11
10
|
|
|
12
11
|
HCHO_CMAP = "rsplot_hcho"
|
|
12
|
+
NO2_CMAP = "rsplot_no2"
|
|
13
|
+
COLORMAP_22 = "rsplot_colormap_22"
|
|
13
14
|
STATION_CONCENTRATION_CMAP = "rsplot_station_concentration"
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
def register_rsplot_colormaps(
|
|
17
|
+
def register_rsplot_colormaps() -> None:
|
|
17
18
|
"""Register custom colormaps used by rsplot plots."""
|
|
18
|
-
_register(
|
|
19
|
+
_register(_build_colormap_22(COLORMAP_22))
|
|
20
|
+
_register(_build_colormap_22(HCHO_CMAP))
|
|
21
|
+
_register(
|
|
22
|
+
mcolors.LinearSegmentedColormap.from_list(
|
|
23
|
+
NO2_CMAP,
|
|
24
|
+
[
|
|
25
|
+
"#C2C8E1",
|
|
26
|
+
"#9BA9DC",
|
|
27
|
+
"#4C9DF4",
|
|
28
|
+
"#86D1F9",
|
|
29
|
+
"#A7E5EF",
|
|
30
|
+
"#FEFC59",
|
|
31
|
+
"#FD7822",
|
|
32
|
+
"#FC131F",
|
|
33
|
+
"#A3090E",
|
|
34
|
+
],
|
|
35
|
+
)
|
|
36
|
+
)
|
|
19
37
|
_register(
|
|
20
38
|
mcolors.LinearSegmentedColormap.from_list(
|
|
21
39
|
STATION_CONCENTRATION_CMAP,
|
|
@@ -34,32 +52,9 @@ def register_rsplot_colormaps(hcho_cmap_file: str | None = None) -> None:
|
|
|
34
52
|
)
|
|
35
53
|
|
|
36
54
|
|
|
37
|
-
def
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if not cmap_file.exists():
|
|
41
|
-
raise FileNotFoundError(
|
|
42
|
-
f"Configured HCHO colormap file does not exist: {cmap_file}"
|
|
43
|
-
)
|
|
44
|
-
data = np.loadtxt(cmap_file)
|
|
45
|
-
if data.shape != (256, 3):
|
|
46
|
-
raise ValueError(
|
|
47
|
-
f"{cmap_file} must contain a 256x3 RGB colormap table, "
|
|
48
|
-
f"got shape {data.shape}"
|
|
49
|
-
)
|
|
50
|
-
cmap = mcolors.ListedColormap(data, name=HCHO_CMAP)
|
|
51
|
-
else:
|
|
52
|
-
cmap = mcolors.LinearSegmentedColormap.from_list(
|
|
53
|
-
HCHO_CMAP,
|
|
54
|
-
[
|
|
55
|
-
"#ffffff",
|
|
56
|
-
"#fff7bc",
|
|
57
|
-
"#fec44f",
|
|
58
|
-
"#fd8d3c",
|
|
59
|
-
"#e31a1c",
|
|
60
|
-
"#800026",
|
|
61
|
-
],
|
|
62
|
-
)
|
|
55
|
+
def _build_colormap_22(name: str) -> mcolors.Colormap:
|
|
56
|
+
cmap_file = Path(__file__).with_name("colormap_22.txt")
|
|
57
|
+
cmap = mcolors.ListedColormap(np.loadtxt(cmap_file), name=name)
|
|
63
58
|
cmap.set_under("w")
|
|
64
59
|
return cmap
|
|
65
60
|
|
rsplot/plotting/map_frame.py
CHANGED
|
@@ -9,7 +9,6 @@ draw order stays explicit.
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
11
|
from dataclasses import dataclass
|
|
12
|
-
from pathlib import Path
|
|
13
12
|
from typing import TYPE_CHECKING
|
|
14
13
|
|
|
15
14
|
import cartopy.crs as ccrs
|
|
@@ -69,7 +68,11 @@ def create_map_frame(
|
|
|
69
68
|
projection = tiles.crs
|
|
70
69
|
else:
|
|
71
70
|
tiles = None
|
|
72
|
-
projection =
|
|
71
|
+
projection = (
|
|
72
|
+
ccrs.AzimuthalEquidistant(*region.projection_center)
|
|
73
|
+
if region.projection_center is not None
|
|
74
|
+
else ccrs.PlateCarree()
|
|
75
|
+
)
|
|
73
76
|
|
|
74
77
|
fig, ax = plt.subplots(
|
|
75
78
|
figsize=figure_size_for_level(region.level),
|
|
@@ -149,6 +152,18 @@ def add_region_boundaries(ax: GeoAxes, region: RegionInfo) -> None:
|
|
|
149
152
|
)
|
|
150
153
|
)
|
|
151
154
|
|
|
155
|
+
if region.geometry_kind == "station_radius":
|
|
156
|
+
from dataclasses import replace
|
|
157
|
+
|
|
158
|
+
add_subdivision_labels(
|
|
159
|
+
ax,
|
|
160
|
+
replace(
|
|
161
|
+
region,
|
|
162
|
+
sub_boundary_gdf=region.main_boundary_gdf,
|
|
163
|
+
subdivision_level="city",
|
|
164
|
+
),
|
|
165
|
+
)
|
|
166
|
+
|
|
152
167
|
if getattr(region, "members", ()):
|
|
153
168
|
add_member_labels(ax, region)
|
|
154
169
|
|
|
@@ -171,7 +186,29 @@ def add_subdivision_labels(ax: GeoAxes, region: RegionInfo) -> None:
|
|
|
171
186
|
if key in selected_geometry or (row[name_field], key) in seen_labels:
|
|
172
187
|
continue
|
|
173
188
|
seen_labels.add((row[name_field], key))
|
|
174
|
-
|
|
189
|
+
geometry = row.geometry
|
|
190
|
+
if region.geometry_kind == "station_radius":
|
|
191
|
+
from shapely.geometry import box
|
|
192
|
+
|
|
193
|
+
west, east, south, north = region.extent
|
|
194
|
+
pad = region.params.pad
|
|
195
|
+
geometry = geometry.intersection(
|
|
196
|
+
box(west - pad, south - pad, east + pad, north + pad)
|
|
197
|
+
)
|
|
198
|
+
if geometry.is_empty:
|
|
199
|
+
continue
|
|
200
|
+
if region.subdivision_level == "city":
|
|
201
|
+
upper = geometry.intersection(
|
|
202
|
+
box(
|
|
203
|
+
west - pad,
|
|
204
|
+
south + (north - south) * 0.85,
|
|
205
|
+
east + pad,
|
|
206
|
+
north + pad,
|
|
207
|
+
)
|
|
208
|
+
)
|
|
209
|
+
if not upper.is_empty:
|
|
210
|
+
geometry = upper
|
|
211
|
+
point = geometry.representative_point()
|
|
175
212
|
if region.level in (
|
|
176
213
|
"key_region",
|
|
177
214
|
"province",
|
|
@@ -238,6 +275,14 @@ def configure_map_axes(
|
|
|
238
275
|
crs=ccrs.PlateCarree(),
|
|
239
276
|
)
|
|
240
277
|
|
|
278
|
+
if region.projection_center is not None and not use_basemap:
|
|
279
|
+
projected = ax.projection.project_geometry(
|
|
280
|
+
region.geometry, ccrs.PlateCarree()
|
|
281
|
+
)
|
|
282
|
+
west, south, east, north = projected.bounds
|
|
283
|
+
ax.set_xlim(west, east)
|
|
284
|
+
ax.set_ylim(south, north)
|
|
285
|
+
|
|
241
286
|
gridlines = ax.gridlines(
|
|
242
287
|
draw_labels=True,
|
|
243
288
|
linewidth=0.2,
|
|
@@ -247,7 +292,9 @@ def configure_map_axes(
|
|
|
247
292
|
gridlines.top_labels = gridlines.right_labels = False
|
|
248
293
|
gridlines.xformatter = LONGITUDE_FORMATTER
|
|
249
294
|
gridlines.yformatter = LATITUDE_FORMATTER
|
|
250
|
-
if
|
|
295
|
+
if region.projection_center is not None:
|
|
296
|
+
gridlines.rotate_labels = False
|
|
297
|
+
if region.members or region.geometry_kind == "station_radius":
|
|
251
298
|
gridlines.xlocator = mticker.MaxNLocator(nbins=5)
|
|
252
299
|
gridlines.ylocator = mticker.MaxNLocator(nbins=5)
|
|
253
300
|
else:
|
|
@@ -255,6 +302,35 @@ def configure_map_axes(
|
|
|
255
302
|
gridlines.ylocator = mticker.MultipleLocator(region.params.grid_step)
|
|
256
303
|
|
|
257
304
|
|
|
305
|
+
TITLE_FONTSIZE = 14
|
|
306
|
+
SUBTITLE_FONTSIZE = 10
|
|
307
|
+
SUBTITLE_COLOR = "#555555"
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def set_map_title(
|
|
311
|
+
ax: GeoAxes, title: str, subtitle: str | None = None
|
|
312
|
+
) -> None:
|
|
313
|
+
"""Draw the title, with an optional grey subtitle just above the map."""
|
|
314
|
+
if not subtitle:
|
|
315
|
+
ax.set_title(title, fontsize=TITLE_FONTSIZE)
|
|
316
|
+
return
|
|
317
|
+
gap = 6 # points between the axes, the subtitle and the title
|
|
318
|
+
ax.annotate(
|
|
319
|
+
subtitle,
|
|
320
|
+
xy=(0.5, 1.0),
|
|
321
|
+
xycoords="axes fraction",
|
|
322
|
+
xytext=(0, gap),
|
|
323
|
+
textcoords="offset points",
|
|
324
|
+
ha="center",
|
|
325
|
+
va="bottom",
|
|
326
|
+
fontsize=SUBTITLE_FONTSIZE,
|
|
327
|
+
color=SUBTITLE_COLOR,
|
|
328
|
+
)
|
|
329
|
+
ax.set_title(
|
|
330
|
+
title, fontsize=TITLE_FONTSIZE, pad=2 * gap + 1.3 * SUBTITLE_FONTSIZE
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
|
|
258
334
|
def finalize_map_figure(
|
|
259
335
|
fig: Figure,
|
|
260
336
|
*,
|
|
@@ -269,8 +345,10 @@ def finalize_map_figure(
|
|
|
269
345
|
fig.tight_layout(rect=layout_rect)
|
|
270
346
|
|
|
271
347
|
if output:
|
|
272
|
-
|
|
273
|
-
|
|
348
|
+
from rsplot.atomic import atomic_write
|
|
349
|
+
|
|
350
|
+
with atomic_write(output) as temp:
|
|
351
|
+
fig.savefig(temp, dpi=dpi, bbox_inches="tight")
|
|
274
352
|
plt.close(fig)
|
|
275
353
|
else:
|
|
276
354
|
plt.show()
|
rsplot/plotting/meteo.py
CHANGED
|
@@ -15,7 +15,10 @@ from rsplot.plotting.map_frame import (
|
|
|
15
15
|
create_map_frame,
|
|
16
16
|
finalize_map_figure,
|
|
17
17
|
)
|
|
18
|
-
from rsplot.plotting.station import
|
|
18
|
+
from rsplot.plotting.station import (
|
|
19
|
+
add_station_colorbar,
|
|
20
|
+
draw_station_layer,
|
|
21
|
+
)
|
|
19
22
|
from rsplot.plotting.wind import draw_wind_vectors
|
|
20
23
|
|
|
21
24
|
if TYPE_CHECKING:
|
|
@@ -120,7 +123,9 @@ def plot_meteo(
|
|
|
120
123
|
field_colorbar.ax.tick_params(labelsize=8)
|
|
121
124
|
|
|
122
125
|
station_axis = ax.inset_axes([1.03, 0.04, 0.025, 0.42])
|
|
123
|
-
station_colorbar =
|
|
126
|
+
station_colorbar = add_station_colorbar(
|
|
127
|
+
fig, station_scatter, station.var_name, cax=station_axis
|
|
128
|
+
)
|
|
124
129
|
if station_colorbar_label:
|
|
125
130
|
station_colorbar.set_label(station_colorbar_label, fontsize=9)
|
|
126
131
|
station_colorbar.ax.tick_params(labelsize=8)
|
|
@@ -133,8 +138,10 @@ def plot_meteo(
|
|
|
133
138
|
)
|
|
134
139
|
field_colorbar.set_label(f"Temperature ({field.unit})")
|
|
135
140
|
elif station_scatter is not None:
|
|
136
|
-
station_colorbar =
|
|
141
|
+
station_colorbar = add_station_colorbar(
|
|
142
|
+
fig,
|
|
137
143
|
station_scatter,
|
|
144
|
+
station.var_name,
|
|
138
145
|
ax=ax,
|
|
139
146
|
shrink=0.7,
|
|
140
147
|
pad=0.05,
|
rsplot/plotting/overlay.py
CHANGED
|
@@ -12,10 +12,7 @@ from typing import TYPE_CHECKING
|
|
|
12
12
|
import cartopy.crs as ccrs
|
|
13
13
|
import numpy as np
|
|
14
14
|
|
|
15
|
-
from rsplot.plotting.colormaps import
|
|
16
|
-
STATION_CONCENTRATION_CMAP,
|
|
17
|
-
register_rsplot_colormaps,
|
|
18
|
-
)
|
|
15
|
+
from rsplot.plotting.colormaps import register_rsplot_colormaps
|
|
19
16
|
from rsplot.plotting.map_frame import (
|
|
20
17
|
add_basemap_tiles,
|
|
21
18
|
add_region_boundaries,
|
|
@@ -23,9 +20,11 @@ from rsplot.plotting.map_frame import (
|
|
|
23
20
|
configure_map_axes,
|
|
24
21
|
create_map_frame,
|
|
25
22
|
finalize_map_figure,
|
|
23
|
+
set_map_title,
|
|
26
24
|
)
|
|
27
25
|
from rsplot.plotting.station import (
|
|
28
|
-
|
|
26
|
+
add_station_colorbar,
|
|
27
|
+
build_station_colormap,
|
|
29
28
|
station_marker_size,
|
|
30
29
|
)
|
|
31
30
|
|
|
@@ -33,6 +32,7 @@ if TYPE_CHECKING:
|
|
|
33
32
|
from shapely.geometry.base import BaseGeometry
|
|
34
33
|
|
|
35
34
|
from rsplot.geo.boundaries import RegionInfo
|
|
35
|
+
from rsplot.plotting.station_focus import StationFocus
|
|
36
36
|
from rsplot.readers.guokong import StationData
|
|
37
37
|
|
|
38
38
|
|
|
@@ -55,10 +55,11 @@ def plot_overlay(
|
|
|
55
55
|
dpi: int = 300,
|
|
56
56
|
basemap: bool | None = None,
|
|
57
57
|
tianditu_key: str | None = None,
|
|
58
|
-
hcho_cmap_file: str | None = None,
|
|
59
58
|
title: str | None = None,
|
|
59
|
+
subtitle: str | None = None,
|
|
60
60
|
output: str | None = None,
|
|
61
61
|
coverage_geometry: BaseGeometry | None = None,
|
|
62
|
+
station_focus: StationFocus | None = None,
|
|
62
63
|
) -> None:
|
|
63
64
|
"""Draw satellite raster + station scatter on the same axes.
|
|
64
65
|
|
|
@@ -67,7 +68,7 @@ def plot_overlay(
|
|
|
67
68
|
colorbars share the right side — raster on top, stations below —
|
|
68
69
|
so each quantity keeps its own scale.
|
|
69
70
|
"""
|
|
70
|
-
register_rsplot_colormaps(
|
|
71
|
+
register_rsplot_colormaps()
|
|
71
72
|
|
|
72
73
|
# --- Figure setup ---
|
|
73
74
|
frame = create_map_frame(
|
|
@@ -109,37 +110,21 @@ def plot_overlay(
|
|
|
109
110
|
if len(vals) > 0:
|
|
110
111
|
marker_size = station_marker_size(region.level)
|
|
111
112
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
else:
|
|
128
|
-
p5 = float(np.nanpercentile(vals, 5))
|
|
129
|
-
p95 = float(np.nanpercentile(vals, 95))
|
|
130
|
-
sc = ax.scatter(
|
|
131
|
-
lon,
|
|
132
|
-
lat,
|
|
133
|
-
c=vals,
|
|
134
|
-
cmap=STATION_CONCENTRATION_CMAP,
|
|
135
|
-
vmin=p5,
|
|
136
|
-
vmax=p95,
|
|
137
|
-
s=marker_size,
|
|
138
|
-
edgecolors="#111",
|
|
139
|
-
linewidths=0.4,
|
|
140
|
-
transform=ccrs.PlateCarree(),
|
|
141
|
-
zorder=5,
|
|
142
|
-
)
|
|
113
|
+
cmap, norm = build_station_colormap(
|
|
114
|
+
data, expand_constant=station_focus is not None
|
|
115
|
+
)
|
|
116
|
+
sc = ax.scatter(
|
|
117
|
+
lon,
|
|
118
|
+
lat,
|
|
119
|
+
c=vals,
|
|
120
|
+
cmap=cmap,
|
|
121
|
+
norm=norm,
|
|
122
|
+
s=marker_size,
|
|
123
|
+
edgecolors="#111",
|
|
124
|
+
linewidths=0.4,
|
|
125
|
+
transform=ccrs.PlateCarree(),
|
|
126
|
+
zorder=5,
|
|
127
|
+
)
|
|
143
128
|
|
|
144
129
|
# Red circle for exceedance
|
|
145
130
|
if station_threshold is not None:
|
|
@@ -156,6 +141,10 @@ def plot_overlay(
|
|
|
156
141
|
zorder=6,
|
|
157
142
|
)
|
|
158
143
|
|
|
144
|
+
if station_focus is not None:
|
|
145
|
+
from rsplot.plotting.station_focus import add_station_focus
|
|
146
|
+
|
|
147
|
+
add_station_focus(ax, region, station_focus)
|
|
159
148
|
configure_map_axes(ax, region, use_basemap=frame.use_basemap)
|
|
160
149
|
|
|
161
150
|
# --- Twin colorbars, hugging the right edge of the map ---
|
|
@@ -171,7 +160,9 @@ def plot_overlay(
|
|
|
171
160
|
|
|
172
161
|
if sc is not None:
|
|
173
162
|
cax_station = ax.inset_axes([1.03, 0.04, 0.025, 0.42])
|
|
174
|
-
cb_station =
|
|
163
|
+
cb_station = add_station_colorbar(
|
|
164
|
+
fig, sc, data.var_name, cax=cax_station
|
|
165
|
+
)
|
|
175
166
|
if station_label:
|
|
176
167
|
cb_station.set_label(station_label, fontsize=9)
|
|
177
168
|
cb_station.ax.tick_params(labelsize=8)
|
|
@@ -179,7 +170,7 @@ def plot_overlay(
|
|
|
179
170
|
# Title
|
|
180
171
|
if title is None:
|
|
181
172
|
title = f"{region.name} · raster + stations"
|
|
182
|
-
ax
|
|
173
|
+
set_map_title(ax, title, subtitle)
|
|
183
174
|
|
|
184
175
|
# Reserve room on the right for the two inset colorbars.
|
|
185
176
|
finalize_map_figure(
|