oafuncs 0.0.98.33__py3-none-any.whl → 0.0.98.34__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.
- oafuncs/_script/plot_dataset.py +1 -1
- oafuncs/oa_cmap.py +10 -1
- oafuncs/oa_draw.py +11 -56
- {oafuncs-0.0.98.33.dist-info → oafuncs-0.0.98.34.dist-info}/METADATA +1 -1
- {oafuncs-0.0.98.33.dist-info → oafuncs-0.0.98.34.dist-info}/RECORD +8 -8
- {oafuncs-0.0.98.33.dist-info → oafuncs-0.0.98.34.dist-info}/WHEEL +0 -0
- {oafuncs-0.0.98.33.dist-info → oafuncs-0.0.98.34.dist-info}/licenses/LICENSE.txt +0 -0
- {oafuncs-0.0.98.33.dist-info → oafuncs-0.0.98.34.dist-info}/top_level.txt +0 -0
oafuncs/_script/plot_dataset.py
CHANGED
@@ -91,7 +91,7 @@ def plot_2d(data: xr.DataArray, output_path: str, data_range: Optional[Tuple[flo
|
|
91
91
|
lon_lat_ratio = np.abs(np.max(lon_range) - np.min(lon_range)) / (np.max(lat_range) - np.min(lat_range))
|
92
92
|
figsize = (10, 10 / lon_lat_ratio)
|
93
93
|
fig, ax = plt.subplots(figsize=figsize, subplot_kw={"projection": ccrs.PlateCarree()})
|
94
|
-
oafuncs.oa_draw.
|
94
|
+
oafuncs.oa_draw.setup_map(ax, lon_range, lat_range)
|
95
95
|
else:
|
96
96
|
fig, ax = plt.subplots(figsize=(10, 8))
|
97
97
|
|
oafuncs/oa_cmap.py
CHANGED
@@ -3,8 +3,9 @@ from typing import List, Optional, Union
|
|
3
3
|
import matplotlib as mpl
|
4
4
|
import matplotlib.pyplot as plt
|
5
5
|
import numpy as np
|
6
|
+
import random
|
6
7
|
|
7
|
-
__all__ = ["show", "to_color", "create", "get"]
|
8
|
+
__all__ = ["show", "to_color", "create", "get", "random_color"]
|
8
9
|
|
9
10
|
|
10
11
|
# ** 将cmap用填色图可视化(官网摘抄函数)
|
@@ -304,6 +305,14 @@ def get(colormap_name: Optional[str] = None, show_available: bool = False) -> Op
|
|
304
305
|
return mpl.colormaps.get_cmap("rainbow") # 默认返回 'rainbow'
|
305
306
|
|
306
307
|
|
308
|
+
# ** 生成随机颜色
|
309
|
+
def random_color():
|
310
|
+
"""Generate a random color in hexadecimal format."""
|
311
|
+
r = random.randint(0, 255)
|
312
|
+
g = random.randint(0, 255)
|
313
|
+
b = random.randint(0, 255)
|
314
|
+
return f"#{r:02x}{g:02x}{b:02x}"
|
315
|
+
|
307
316
|
if __name__ == "__main__":
|
308
317
|
# ** 测试自制cmap
|
309
318
|
colors = ["#C2B7F3", "#B3BBF2", "#B0CBF1", "#ACDCF0", "#A8EEED"]
|
oafuncs/oa_draw.py
CHANGED
@@ -231,58 +231,7 @@ def setup_map(
|
|
231
231
|
right_labels: bool = False,
|
232
232
|
top_labels: bool = False,
|
233
233
|
) -> plt.Axes:
|
234
|
-
"""Setup a complete cartopy map with customizable features.
|
235
|
-
|
236
|
-
Args:
|
237
|
-
axes (plt.Axes): The axes to setup as a map.
|
238
|
-
longitude_data (np.ndarray, optional): Array of longitudes to set map extent.
|
239
|
-
latitude_data (np.ndarray, optional): Array of latitudes to set map extent.
|
240
|
-
map_projection (ccrs.Projection, optional): Coordinate reference system. Defaults to PlateCarree.
|
241
|
-
|
242
|
-
show_land (bool, optional): Whether to show land features. Defaults to True.
|
243
|
-
show_ocean (bool, optional): Whether to show ocean features. Defaults to True.
|
244
|
-
show_coastline (bool, optional): Whether to show coastlines. Defaults to True.
|
245
|
-
show_borders (bool, optional): Whether to show country borders. Defaults to False.
|
246
|
-
land_color (str, optional): Color of land. Defaults to "lightgrey".
|
247
|
-
ocean_color (str, optional): Color of oceans. Defaults to "lightblue".
|
248
|
-
coastline_linewidth (float, optional): Line width for coastlines. Defaults to 0.5.
|
249
|
-
|
250
|
-
show_gridlines (bool, optional): Whether to show gridlines. Defaults to False.
|
251
|
-
longitude_ticks (list[float], optional): Longitude tick positions.
|
252
|
-
latitude_ticks (list[float], optional): Latitude tick positions.
|
253
|
-
tick_decimals (int, optional): Number of decimal places for tick labels. Defaults to 0.
|
254
|
-
|
255
|
-
grid_color (str, optional): Gridline color. Defaults to "k".
|
256
|
-
grid_alpha (float, optional): Gridline transparency. Defaults to 0.5.
|
257
|
-
grid_style (str, optional): Gridline style. Defaults to "--".
|
258
|
-
grid_width (float, optional): Gridline width. Defaults to 0.5.
|
259
|
-
|
260
|
-
show_labels (bool, optional): Whether to show coordinate labels. Defaults to True.
|
261
|
-
left_labels (bool, optional): Show labels on left side. Defaults to True.
|
262
|
-
bottom_labels (bool, optional): Show labels on bottom. Defaults to True.
|
263
|
-
right_labels (bool, optional): Show labels on right side. Defaults to False.
|
264
|
-
top_labels (bool, optional): Show labels on top. Defaults to False.
|
265
|
-
|
266
|
-
Returns:
|
267
|
-
plt.Axes: The configured map axes.
|
268
|
-
|
269
|
-
Examples:
|
270
|
-
>>> # Basic map setup
|
271
|
-
>>> ax = setup_map(ax)
|
272
|
-
|
273
|
-
>>> # Map with gridlines and custom extent
|
274
|
-
>>> ax = setup_map(ax, longitude_data=lon, latitude_data=lat, show_gridlines=True)
|
275
|
-
|
276
|
-
>>> # Customized map
|
277
|
-
>>> ax = setup_map(
|
278
|
-
... ax,
|
279
|
-
... show_gridlines=True,
|
280
|
-
... longitude_ticks=[0, 30, 60],
|
281
|
-
... latitude_ticks=[-30, 0, 30],
|
282
|
-
... land_color='wheat',
|
283
|
-
... ocean_color='lightcyan'
|
284
|
-
... )
|
285
|
-
"""
|
234
|
+
"""Setup a complete cartopy map with customizable features."""
|
286
235
|
from matplotlib import ticker as mticker
|
287
236
|
|
288
237
|
# Add map features
|
@@ -327,14 +276,14 @@ def setup_map(
|
|
327
276
|
current_extent = axes.get_extent(crs=map_projection)
|
328
277
|
lon_range = current_extent[1] - current_extent[0]
|
329
278
|
# Generate reasonable tick spacing
|
330
|
-
tick_spacing = 5 if lon_range <= 30 else (10 if lon_range <= 90 else 20)
|
279
|
+
tick_spacing = 1 if lon_range <= 10 else (5 if lon_range <= 30 else (10 if lon_range <= 90 else 20))
|
331
280
|
longitude_ticks = np.arange(np.ceil(current_extent[0] / tick_spacing) * tick_spacing, current_extent[1] + tick_spacing, tick_spacing)
|
332
281
|
|
333
282
|
if latitude_ticks is None:
|
334
283
|
current_extent = axes.get_extent(crs=map_projection)
|
335
284
|
lat_range = current_extent[3] - current_extent[2]
|
336
285
|
# Generate reasonable tick spacing
|
337
|
-
tick_spacing = 5 if lat_range <= 30 else (10 if lat_range <= 90 else 20)
|
286
|
+
tick_spacing = 1 if lat_range <= 10 else (5 if lat_range <= 30 else (10 if lat_range <= 90 else 20))
|
338
287
|
latitude_ticks = np.arange(np.ceil(current_extent[2] / tick_spacing) * tick_spacing, current_extent[3] + tick_spacing, tick_spacing)
|
339
288
|
|
340
289
|
# Set tick positions and formatters
|
@@ -343,12 +292,18 @@ def setup_map(
|
|
343
292
|
axes.xaxis.set_major_formatter(lon_formatter)
|
344
293
|
axes.yaxis.set_major_formatter(lat_formatter)
|
345
294
|
|
295
|
+
# Control label visibility based on input parameters
|
296
|
+
axes.tick_params(axis="x", labelbottom=bottom_labels, labeltop=top_labels)
|
297
|
+
axes.tick_params(axis="y", labelleft=left_labels, labelright=right_labels)
|
298
|
+
|
346
299
|
# 只要传入经纬度数据就自动设置范围
|
347
300
|
# 范围必须在cartopy添加地图特征之后设置,因为添加特征可能会改变axes的范围
|
348
301
|
if longitude_data is not None and latitude_data is not None:
|
349
302
|
# 过滤掉NaN,避免极端值影响
|
350
|
-
|
351
|
-
|
303
|
+
lon_data = np.asarray(longitude_data)
|
304
|
+
lat_data = np.asarray(latitude_data)
|
305
|
+
lon_valid = lon_data[~np.isnan(lon_data)]
|
306
|
+
lat_valid = lat_data[~np.isnan(lat_data)]
|
352
307
|
if lon_valid.size > 0 and lat_valid.size > 0:
|
353
308
|
lon_min, lon_max = np.min(lon_valid), np.max(lon_valid)
|
354
309
|
lat_min, lat_max = np.min(lat_valid), np.max(lat_valid)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
oafuncs/__init__.py,sha256=T_-VtnWWllV3Q91twT5Yt2sUapeA051QbPNnBxmg9nw,1456
|
2
|
-
oafuncs/oa_cmap.py,sha256=
|
2
|
+
oafuncs/oa_cmap.py,sha256=LL2JSIofwVRymgEILjMCB4Iuz7hOYF-QemfNkaZqbk0,13880
|
3
3
|
oafuncs/oa_data.py,sha256=Wp7Yn6n-WNddAp1UtwK5CSEdGSrzzgOH5gtaOHBaxtw,8065
|
4
4
|
oafuncs/oa_date.py,sha256=aU2wVIWXyWoRiSQ9dg8sHvShFTxw86RrgbV3Q6tDjD4,6841
|
5
|
-
oafuncs/oa_draw.py,sha256=
|
5
|
+
oafuncs/oa_draw.py,sha256=37Zok96Pn7aIpNqZ082cSycT8dSccgwHzScXZXNnfik,13701
|
6
6
|
oafuncs/oa_file.py,sha256=fLb0gRhq2AiPl-5ASDHMrx6Z267FmhqNcTV7CdCxTdI,16934
|
7
7
|
oafuncs/oa_help.py,sha256=0J5VaZX-cB0c090KxgmktQJBc0o00FsY-4wB8l5y00k,4178
|
8
8
|
oafuncs/oa_nc.py,sha256=TMrrPBdPz1IJ-7dMOD_gzzTbG6FHSgm-ZfdlvoJDtcY,15245
|
@@ -18,7 +18,7 @@ oafuncs/_script/netcdf_modify.py,sha256=XDlAEToe_lwfAetkBSENqU5df-wnH7MGuxNTjG1g
|
|
18
18
|
oafuncs/_script/netcdf_write.py,sha256=GvyUyUhzMonzSp3y4pT8ZAfbQrsh5J3dLnmINYJKhuE,21422
|
19
19
|
oafuncs/_script/parallel.py,sha256=07-BJVHxXJNlrOrhrSGt7qCZiKWq6dBvNDBA1AANYnI,8861
|
20
20
|
oafuncs/_script/parallel_test.py,sha256=0GBqZOX7IaCOKF2t1y8N8YYu53GJ33OkfsWgpvZNqM4,372
|
21
|
-
oafuncs/_script/plot_dataset.py,sha256=
|
21
|
+
oafuncs/_script/plot_dataset.py,sha256=QrA4vOCzWbAJp3hf5YYzgIRUZdJB5_ugepgyT_YfnaY,16327
|
22
22
|
oafuncs/_script/replace_file_content.py,sha256=wIwvaISFNYWG58BLZHZP9ZgbC5OhoZ-cpR3y25U1EUM,5601
|
23
23
|
oafuncs/oa_down/User_Agent-list.txt,sha256=pHaMlElMvZ8TG4vf4BqkZYKqe0JIGkr4kCN0lM1Y9FQ,514295
|
24
24
|
oafuncs/oa_down/__init__.py,sha256=IT6oTqaxuV_mC6AwBut0HtkmnVtEu1MyX0x0oS7TKoA,218
|
@@ -38,8 +38,8 @@ oafuncs/oa_sign/__init__.py,sha256=JSx1fcWpmNhQBvX_Bmq3xysfSkkFMrjbJASxV_V6aqE,1
|
|
38
38
|
oafuncs/oa_sign/meteorological.py,sha256=3MSjy7HTcvz2zsITkjUMr_0Y027Gas1LFE9pk99990k,6110
|
39
39
|
oafuncs/oa_sign/ocean.py,sha256=3uYEzaq-27yVy23IQoqy-clhWu1I_fhPFBAQyT-OF4M,5562
|
40
40
|
oafuncs/oa_sign/scientific.py,sha256=moIl2MEY4uitbXoD596JmXookXGQtQsS-8_1NBBTx84,4689
|
41
|
-
oafuncs-0.0.98.
|
42
|
-
oafuncs-0.0.98.
|
43
|
-
oafuncs-0.0.98.
|
44
|
-
oafuncs-0.0.98.
|
45
|
-
oafuncs-0.0.98.
|
41
|
+
oafuncs-0.0.98.34.dist-info/licenses/LICENSE.txt,sha256=rMtLpVg8sKiSlwClfR9w_Dd_5WubTQgoOzE2PDFxzs4,1074
|
42
|
+
oafuncs-0.0.98.34.dist-info/METADATA,sha256=fUtjS8AeoOMXC6t8r1_JbgOrKytjNumx_gD89e3Sb30,4326
|
43
|
+
oafuncs-0.0.98.34.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
44
|
+
oafuncs-0.0.98.34.dist-info/top_level.txt,sha256=bgC35QkXbN4EmPHEveg_xGIZ5i9NNPYWqtJqaKqTPsQ,8
|
45
|
+
oafuncs-0.0.98.34.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|