oafuncs 0.0.98.39__tar.gz → 0.0.98.41__tar.gz
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-0.0.98.39/oafuncs.egg-info → oafuncs-0.0.98.41}/PKG-INFO +2 -1
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/_script/cprogressbar.py +2 -1
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_draw.py +45 -42
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_file.py +12 -8
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_nc.py +27 -4
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41/oafuncs.egg-info}/PKG-INFO +2 -1
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs.egg-info/requires.txt +1 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/setup.py +2 -1
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/LICENSE.txt +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/MANIFEST.in +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/README.md +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/__init__.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/_data/hycom.png +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/_data/oafuncs.png +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/_script/data_interp.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/_script/email.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/_script/netcdf_merge.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/_script/netcdf_modify.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/_script/netcdf_write.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/_script/parallel.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/_script/parallel_bak.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/_script/plot_dataset.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/_script/replace_file_content.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_cmap.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_data.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_date.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_down/User_Agent-list.txt +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_down/__init__.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_down/hycom_3hourly.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_down/idm.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_down/literature.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_down/read_proxy.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_down/test_ua.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_down/user_agent.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_help.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_model/__init__.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_model/roms/__init__.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_model/roms/test.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_model/wrf/__init__.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_model/wrf/little_r.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_python.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_sign/__init__.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_sign/meteorological.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_sign/ocean.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_sign/scientific.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs/oa_tool.py +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs.egg-info/SOURCES.txt +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs.egg-info/dependency_links.txt +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/oafuncs.egg-info/top_level.txt +0 -0
- {oafuncs-0.0.98.39 → oafuncs-0.0.98.41}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: oafuncs
|
3
|
-
Version: 0.0.98.
|
3
|
+
Version: 0.0.98.41
|
4
4
|
Summary: Oceanic and Atmospheric Functions
|
5
5
|
Home-page: https://github.com/Industry-Pays/OAFuncs
|
6
6
|
Author: Kun Liu
|
@@ -24,6 +24,7 @@ Requires-Dist: pandas
|
|
24
24
|
Requires-Dist: xarray
|
25
25
|
Requires-Dist: rich
|
26
26
|
Requires-Dist: pathlib
|
27
|
+
Requires-Dist: lxml
|
27
28
|
Requires-Dist: requests
|
28
29
|
Requires-Dist: bs4
|
29
30
|
Requires-Dist: httpx
|
@@ -189,7 +189,8 @@ class ColorProgressBar:
|
|
189
189
|
self._is_jupyter = "ipykernel" in sys.modules
|
190
190
|
|
191
191
|
# 输出样式
|
192
|
-
filled_list = ["▊", "█", "▓", "▒", "░", "#", "=", ">", "▌", "▍", "▎", "▏", "*"]
|
192
|
+
# filled_list = ["▊", "█", "▓", "▒", "░", "#", "=", ">", "▌", "▍", "▎", "▏", "*"]
|
193
|
+
filled_list = ["█", "▓", "▒", "░", "#", "=", ">", "*"]
|
193
194
|
self.filled = random.choice(filled_list)
|
194
195
|
|
195
196
|
def _generate_gradient(self) -> Optional[List[str]]:
|
@@ -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
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
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 (
|
280
|
-
longitude_ticks = np.arange(np.ceil(current_extent[0] / tick_spacing) * tick_spacing, current_extent[1] +
|
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 (
|
287
|
-
latitude_ticks = np.arange(np.ceil(current_extent[2] / tick_spacing) * tick_spacing, current_extent[3] +
|
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
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
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
|
|
@@ -160,14 +160,18 @@ def move_file(source_pattern: str, destination: str) -> None:
|
|
160
160
|
if dst_dir:
|
161
161
|
os.makedirs(dst_dir, exist_ok=True)
|
162
162
|
|
163
|
-
|
164
|
-
|
165
|
-
if os.path.
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
163
|
+
if os.path.exists(src_file):
|
164
|
+
# Remove existing destination if it exists
|
165
|
+
if os.path.exists(dst_file):
|
166
|
+
if os.path.isdir(dst_file):
|
167
|
+
shutil.rmtree(dst_file)
|
168
|
+
else:
|
169
|
+
os.remove(dst_file)
|
170
|
+
|
171
|
+
shutil.move(src_file, dst_file)
|
172
|
+
else:
|
173
|
+
print(f"[yellow]Source file not found:[/yellow] [bold]{src_file}[/bold]")
|
174
|
+
continue
|
171
175
|
print(f"[green]Successfully moved:[/green] [bold]{src_file}[/bold] -> [bold]{dst_file}[/bold]")
|
172
176
|
except Exception as e:
|
173
177
|
print(f"[red]Failed to move:[/red] [bold]{src_file}[/bold]. Error: {e}")
|
@@ -207,14 +207,37 @@ def convert_longitude(
|
|
207
207
|
>>> dataset = convert_longitude(dataset, longitude_name="lon", target_range=360)
|
208
208
|
"""
|
209
209
|
if target_range not in [180, 360]:
|
210
|
-
raise ValueError("target_range
|
210
|
+
raise ValueError("target_range must be 180 or 360")
|
211
211
|
|
212
|
+
lon = dataset[longitude_name]
|
213
|
+
current_min, current_max = np.nanmin(lon), np.nanmax(lon)
|
214
|
+
|
215
|
+
# 检查是否已在目标范围
|
216
|
+
if target_range == 180:
|
217
|
+
if -180 <= current_min and current_max <= 180:
|
218
|
+
return dataset # 已在[-180,180]范围
|
219
|
+
else:
|
220
|
+
if 0 <= current_min and current_max <= 360:
|
221
|
+
return dataset # 已在[0,360]范围
|
222
|
+
|
223
|
+
# 执行转换(带边界平滑)
|
212
224
|
if target_range == 180:
|
213
|
-
|
225
|
+
# 将 >180 的值减去360,保持连续性
|
226
|
+
new_lon = xr.where(lon > 180, lon - 360, lon)
|
227
|
+
# 处理负值(如-200 -> 160)
|
228
|
+
new_lon = xr.where(new_lon < -180, new_lon + 360, new_lon)
|
214
229
|
else:
|
215
|
-
|
230
|
+
new_lon = lon % 360 # 自动处理负值
|
231
|
+
|
232
|
+
# 检查并处理重复坐标
|
233
|
+
if len(new_lon) != len(np.unique(new_lon)):
|
234
|
+
raise ValueError("转换导致经度坐标重复,请检查数据边界值")
|
235
|
+
|
236
|
+
# 仅当非单调时排序
|
237
|
+
if not new_lon.is_monotonic_increasing:
|
238
|
+
dataset = dataset.sortby(longitude_name)
|
216
239
|
|
217
|
-
return dataset.
|
240
|
+
return dataset.assign_coords({longitude_name: new_lon})
|
218
241
|
|
219
242
|
|
220
243
|
def isel(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: oafuncs
|
3
|
-
Version: 0.0.98.
|
3
|
+
Version: 0.0.98.41
|
4
4
|
Summary: Oceanic and Atmospheric Functions
|
5
5
|
Home-page: https://github.com/Industry-Pays/OAFuncs
|
6
6
|
Author: Kun Liu
|
@@ -24,6 +24,7 @@ Requires-Dist: pandas
|
|
24
24
|
Requires-Dist: xarray
|
25
25
|
Requires-Dist: rich
|
26
26
|
Requires-Dist: pathlib
|
27
|
+
Requires-Dist: lxml
|
27
28
|
Requires-Dist: requests
|
28
29
|
Requires-Dist: bs4
|
29
30
|
Requires-Dist: httpx
|
@@ -18,7 +18,7 @@ URL = "https://github.com/Industry-Pays/OAFuncs"
|
|
18
18
|
EMAIL = "liukun0312@stu.ouc.edu.cn"
|
19
19
|
AUTHOR = "Kun Liu"
|
20
20
|
REQUIRES_PYTHON = ">=3.10.0" # 2025/03/13
|
21
|
-
VERSION = "0.0.98.
|
21
|
+
VERSION = "0.0.98.41"
|
22
22
|
|
23
23
|
# What packages are required for this module to be executed?
|
24
24
|
REQUIRED = [
|
@@ -32,6 +32,7 @@ REQUIRED = [
|
|
32
32
|
# ------ Path ------
|
33
33
|
"pathlib",
|
34
34
|
# ------ Internet ------
|
35
|
+
"lxml",
|
35
36
|
"requests",
|
36
37
|
"bs4",
|
37
38
|
"httpx",
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|