oafuncs 0.0.98.39__py3-none-any.whl → 0.0.98.40__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/oa_draw.py CHANGED
@@ -247,44 +247,41 @@ def setup_map(
247
247
  from cartopy.mpl.ticker import LatitudeFormatter, LongitudeFormatter
248
248
  lon_formatter = LongitudeFormatter(zero_direction_label=False, number_format=f".{tick_decimals}f")
249
249
  lat_formatter = LatitudeFormatter(number_format=f".{tick_decimals}f")
250
-
251
- # Handle gridlines and ticks
252
- if show_gridlines:
253
- # Add gridlines with labels
254
- gl = axes.gridlines(crs=map_projection, draw_labels=show_labels, linewidth=grid_width, color=grid_color, alpha=grid_alpha, linestyle=grid_style)
255
-
256
- # Configure label positions
257
- gl.left_labels = left_labels
258
- gl.bottom_labels = bottom_labels
259
- gl.right_labels = right_labels
260
- gl.top_labels = top_labels
261
-
262
- # Set formatters
263
- gl.xformatter = lon_formatter
264
- gl.yformatter = lat_formatter
265
-
266
- # Set custom tick positions if provided
267
- if longitude_ticks is not None:
268
- gl.xlocator = mticker.FixedLocator(np.array(longitude_ticks))
269
- if latitude_ticks is not None:
270
- gl.ylocator = mticker.FixedLocator(np.array(latitude_ticks))
271
-
272
- elif show_labels:
250
+
251
+ # 只要传入经纬度数据就自动设置范围
252
+ # 范围必须在cartopy添加地图特征之后设置,因为添加特征可能会改变axes的范围
253
+ if longitude_data is not None and latitude_data is not None:
254
+ # 过滤掉NaN,避免极端值影响
255
+ lon_data = np.asarray(longitude_data)
256
+ lat_data = np.asarray(latitude_data)
257
+ lon_valid = lon_data[~np.isnan(lon_data)]
258
+ lat_valid = lat_data[~np.isnan(lat_data)]
259
+ if lon_valid.size > 0 and lat_valid.size > 0:
260
+ lon_min, lon_max = np.min(lon_valid), np.max(lon_valid)
261
+ lat_min, lat_max = np.min(lat_valid), np.max(lat_valid)
262
+ axes.set_extent([lon_min, lon_max, lat_min, lat_max], crs=map_projection)
263
+ else:
264
+ # 若全是NaN则不设置范围
265
+ pass
266
+
267
+ if show_labels:
273
268
  # Add tick labels without gridlines
274
269
  # Generate default tick positions based on current extent if not provided
275
270
  if longitude_ticks is None:
276
271
  current_extent = axes.get_extent(crs=map_projection)
277
272
  lon_range = current_extent[1] - current_extent[0]
278
273
  # Generate reasonable tick spacing
279
- tick_spacing = 1 if lon_range <= 10 else (5 if lon_range <= 30 else (10 if lon_range <= 90 else 20))
280
- longitude_ticks = np.arange(np.ceil(current_extent[0] / tick_spacing) * tick_spacing, current_extent[1] + tick_spacing, tick_spacing)
274
+ tick_spacing = 1 if lon_range <= 10 else (5 if lon_range <= 30 else (15 if lon_range <= 90 else (30 if lon_range <= 180 else 60)))
275
+ longitude_ticks = np.arange(np.ceil(current_extent[0] / tick_spacing) * tick_spacing, current_extent[1] + 0.1, tick_spacing)
276
+ # print(f"[green]Longitude ticks set to:[/green] {longitude_ticks}")
281
277
 
282
278
  if latitude_ticks is None:
283
279
  current_extent = axes.get_extent(crs=map_projection)
284
280
  lat_range = current_extent[3] - current_extent[2]
285
281
  # Generate reasonable tick spacing
286
- tick_spacing = 1 if lat_range <= 10 else (5 if lat_range <= 30 else (10 if lat_range <= 90 else 20))
287
- latitude_ticks = np.arange(np.ceil(current_extent[2] / tick_spacing) * tick_spacing, current_extent[3] + tick_spacing, tick_spacing)
282
+ tick_spacing = 1 if lat_range <= 10 else (5 if lat_range <= 30 else (15 if lat_range <= 90 else 30))
283
+ latitude_ticks = np.arange(np.ceil(current_extent[2] / tick_spacing) * tick_spacing, current_extent[3] + 0.1, tick_spacing)
284
+ # print(f"[green]Latitude ticks set to:[/green] {latitude_ticks}")
288
285
 
289
286
  # Set tick positions and formatters
290
287
  axes.set_xticks(longitude_ticks, crs=map_projection)
@@ -296,21 +293,27 @@ def setup_map(
296
293
  axes.tick_params(axis="x", labelbottom=bottom_labels, labeltop=top_labels)
297
294
  axes.tick_params(axis="y", labelleft=left_labels, labelright=right_labels)
298
295
 
299
- # 只要传入经纬度数据就自动设置范围
300
- # 范围必须在cartopy添加地图特征之后设置,因为添加特征可能会改变axes的范围
301
- if longitude_data is not None and latitude_data is not None:
302
- # 过滤掉NaN,避免极端值影响
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)]
307
- if lon_valid.size > 0 and lat_valid.size > 0:
308
- lon_min, lon_max = np.min(lon_valid), np.max(lon_valid)
309
- lat_min, lat_max = np.min(lat_valid), np.max(lat_valid)
310
- axes.set_extent([lon_min, lon_max, lat_min, lat_max], crs=map_projection)
311
- else:
312
- # 若全是NaN则不设置范围
313
- pass
296
+ # Handle gridlines and ticks
297
+ if show_gridlines:
298
+ # Add gridlines with labels
299
+ gl = axes.gridlines(crs=map_projection, draw_labels=show_labels, linewidth=grid_width, color=grid_color, alpha=grid_alpha, linestyle=grid_style)
300
+
301
+ # Configure label positions
302
+ gl.left_labels = left_labels
303
+ gl.bottom_labels = bottom_labels
304
+ gl.right_labels = right_labels
305
+ gl.top_labels = top_labels
306
+
307
+ # Set formatters
308
+ gl.xformatter = lon_formatter
309
+ gl.yformatter = lat_formatter
310
+
311
+ # Set custom tick positions if provided
312
+ if longitude_ticks is not None:
313
+ gl.xlocator = mticker.FixedLocator(np.array(longitude_ticks))
314
+ if latitude_ticks is not None:
315
+ gl.ylocator = mticker.FixedLocator(np.array(latitude_ticks))
316
+
314
317
  return axes
315
318
 
316
319
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oafuncs
3
- Version: 0.0.98.39
3
+ Version: 0.0.98.40
4
4
  Summary: Oceanic and Atmospheric Functions
5
5
  Home-page: https://github.com/Industry-Pays/OAFuncs
6
6
  Author: Kun Liu
@@ -2,7 +2,7 @@ oafuncs/__init__.py,sha256=T_-VtnWWllV3Q91twT5Yt2sUapeA051QbPNnBxmg9nw,1456
2
2
  oafuncs/oa_cmap.py,sha256=JwZMJ36uNwiCnzXqEtH2_PpeLtEaRaXP9YeGSl0PJSU,13886
3
3
  oafuncs/oa_data.py,sha256=u4H1ZazQf2jmGx3IAiaGxLjQHY9cQEMizRIaTQW4UiE,8075
4
4
  oafuncs/oa_date.py,sha256=aU2wVIWXyWoRiSQ9dg8sHvShFTxw86RrgbV3Q6tDjD4,6841
5
- oafuncs/oa_draw.py,sha256=zxwxmTsS6-s6YFvrVJTr06_O39y0ykVxtOrShgDM4Qg,13754
5
+ oafuncs/oa_draw.py,sha256=zal0Y3RPpN0TCGN4Gw9qLtjQdT6V0ZqpSUBFVOPL0x4,13952
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=mKNxQ9jPxfRH7xINyrX7tBhitG5gmOKm6Dn7stk5mdw,15279
@@ -37,8 +37,8 @@ oafuncs/oa_sign/__init__.py,sha256=JSx1fcWpmNhQBvX_Bmq3xysfSkkFMrjbJASxV_V6aqE,1
37
37
  oafuncs/oa_sign/meteorological.py,sha256=3MSjy7HTcvz2zsITkjUMr_0Y027Gas1LFE9pk99990k,6110
38
38
  oafuncs/oa_sign/ocean.py,sha256=3uYEzaq-27yVy23IQoqy-clhWu1I_fhPFBAQyT-OF4M,5562
39
39
  oafuncs/oa_sign/scientific.py,sha256=moIl2MEY4uitbXoD596JmXookXGQtQsS-8_1NBBTx84,4689
40
- oafuncs-0.0.98.39.dist-info/licenses/LICENSE.txt,sha256=rMtLpVg8sKiSlwClfR9w_Dd_5WubTQgoOzE2PDFxzs4,1074
41
- oafuncs-0.0.98.39.dist-info/METADATA,sha256=2hppaUc6XZv609HGI_ZRS8GRPARn1Q9MI8xgb4JBfhs,4326
42
- oafuncs-0.0.98.39.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
43
- oafuncs-0.0.98.39.dist-info/top_level.txt,sha256=bgC35QkXbN4EmPHEveg_xGIZ5i9NNPYWqtJqaKqTPsQ,8
44
- oafuncs-0.0.98.39.dist-info/RECORD,,
40
+ oafuncs-0.0.98.40.dist-info/licenses/LICENSE.txt,sha256=rMtLpVg8sKiSlwClfR9w_Dd_5WubTQgoOzE2PDFxzs4,1074
41
+ oafuncs-0.0.98.40.dist-info/METADATA,sha256=oD8heaDgtaCRU2T3HJZK1UXU7hnasx6dVk9WtC9TwQ4,4326
42
+ oafuncs-0.0.98.40.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
43
+ oafuncs-0.0.98.40.dist-info/top_level.txt,sha256=bgC35QkXbN4EmPHEveg_xGIZ5i9NNPYWqtJqaKqTPsQ,8
44
+ oafuncs-0.0.98.40.dist-info/RECORD,,