oafuncs 0.0.93__py2.py3-none-any.whl → 0.0.95__py2.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/data_store/OAFuncs.png +0 -0
- oafuncs/oa_data.py +33 -5
- oafuncs/oa_down/hycom_3hourly.py +53 -58
- oafuncs/oa_down/hycom_3hourly_20250129.py +1307 -0
- oafuncs/oa_nc.py +46 -28
- {oafuncs-0.0.93.dist-info → oafuncs-0.0.95.dist-info}/METADATA +5 -2
- {oafuncs-0.0.93.dist-info → oafuncs-0.0.95.dist-info}/RECORD +10 -9
- {oafuncs-0.0.93.dist-info → oafuncs-0.0.95.dist-info}/LICENSE.txt +0 -0
- {oafuncs-0.0.93.dist-info → oafuncs-0.0.95.dist-info}/WHEEL +0 -0
- {oafuncs-0.0.93.dist-info → oafuncs-0.0.95.dist-info}/top_level.txt +0 -0
oafuncs/oa_nc.py
CHANGED
@@ -199,6 +199,12 @@ def merge(file_list, var_name=None, dim_name=None, target_filename=None):
|
|
199
199
|
merge(file_list, var_name=['u', 'v'], dim_name='time', target_filename='merged.nc')
|
200
200
|
merge(file_list, var_name=None, dim_name='time', target_filename='merged.nc')
|
201
201
|
"""
|
202
|
+
# 看看保存文件是单纯文件名还是包含路径的,如果有路径,需要确保路径存在
|
203
|
+
if target_filename is None:
|
204
|
+
target_filename = "merged.nc"
|
205
|
+
if not os.path.exists(os.path.dirname(str(target_filename))):
|
206
|
+
os.makedirs(os.path.dirname(str(target_filename)))
|
207
|
+
|
202
208
|
if isinstance(file_list, str):
|
203
209
|
file_list = [file_list]
|
204
210
|
|
@@ -372,44 +378,56 @@ def rename(ncfile_path, old_name, new_name):
|
|
372
378
|
print(f"An error occurred: {e}")
|
373
379
|
|
374
380
|
|
375
|
-
def check(ncfile,
|
381
|
+
def check(ncfile: str, delete_switch: bool = False) -> bool:
|
376
382
|
"""
|
377
|
-
|
378
|
-
Check if the NetCDF file is corrupted using xarray.
|
383
|
+
Check if a NetCDF file is corrupted with enhanced error handling.
|
379
384
|
|
380
|
-
|
381
|
-
ncfile (str): The path to the NetCDF file.
|
382
|
-
if_delete (bool): Whether to delete the file if it is corrupted, default is False.
|
383
|
-
|
384
|
-
Returns:
|
385
|
-
bool: True if the file is not corrupted, False otherwise.
|
385
|
+
Handles HDF5 library errors gracefully without terminating program.
|
386
386
|
"""
|
387
|
+
is_valid = False
|
388
|
+
|
387
389
|
if not os.path.exists(ncfile):
|
390
|
+
print(f"File missing: {ncfile}")
|
388
391
|
return False
|
389
392
|
|
390
393
|
try:
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
+
# # 深度验证文件结构
|
395
|
+
# with nc.Dataset(ncfile, "r") as ds:
|
396
|
+
# # 显式检查文件结构完整性
|
397
|
+
# ds.sync() # 强制刷新缓冲区
|
398
|
+
# ds.close() # 显式关闭后重新打开验证
|
399
|
+
|
400
|
+
# 二次验证确保变量可访问
|
401
|
+
with nc.Dataset(ncfile, "r") as ds_verify:
|
402
|
+
if not ds_verify.variables:
|
403
|
+
print(f"Empty variables: {ncfile}")
|
394
404
|
else:
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
405
|
+
# 尝试访问元数据
|
406
|
+
_ = ds_verify.__dict__
|
407
|
+
# 抽样检查第一个变量
|
408
|
+
for var in ds_verify.variables.values():
|
409
|
+
_ = var.shape # 触发实际数据访问
|
410
|
+
break
|
411
|
+
is_valid = True
|
412
|
+
|
413
|
+
except Exception as e: # 捕获所有异常类型
|
414
|
+
print(f"HDF5 validation failed for {ncfile}: {str(e)}")
|
415
|
+
error_type = type(e).__name__
|
416
|
+
if "HDF5" in error_type or "h5" in error_type.lower():
|
417
|
+
print(f"Critical HDF5 structure error detected in {ncfile}")
|
418
|
+
|
419
|
+
# 安全删除流程
|
420
|
+
if not is_valid:
|
421
|
+
if delete_switch:
|
422
|
+
try:
|
423
|
+
os.remove(ncfile)
|
424
|
+
print(f"Removed corrupted: {ncfile}")
|
425
|
+
except Exception as del_error:
|
426
|
+
print(f"Delete failed: {ncfile} - {str(del_error)}")
|
411
427
|
return False
|
412
428
|
|
429
|
+
return True
|
430
|
+
|
413
431
|
|
414
432
|
def convert_longitude(ds, lon_name="longitude", convert=180):
|
415
433
|
"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: oafuncs
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.95
|
4
4
|
Summary: Oceanic and Atmospheric Functions
|
5
5
|
Home-page: https://github.com/Industry-Pays/OAFuncs
|
6
6
|
Author: Kun Liu
|
@@ -27,9 +27,12 @@ Requires-Dist: pathlib
|
|
27
27
|
Requires-Dist: requests
|
28
28
|
Requires-Dist: bs4
|
29
29
|
Requires-Dist: matplotlib
|
30
|
-
Requires-Dist: Cartopy
|
31
30
|
Requires-Dist: netCDF4
|
32
31
|
Requires-Dist: xlrd
|
32
|
+
Requires-Dist: geopandas
|
33
|
+
Requires-Dist: Cartopy
|
34
|
+
Requires-Dist: rasterio
|
35
|
+
Requires-Dist: salem
|
33
36
|
Dynamic: author
|
34
37
|
Dynamic: author-email
|
35
38
|
Dynamic: classifier
|
@@ -1,15 +1,16 @@
|
|
1
1
|
oafuncs/__init__.py,sha256=glcIlhQ9xSK4WtL58dq7Od2S3JPqsuEyhUQ-VWO8hOc,1426
|
2
2
|
oafuncs/oa_cmap.py,sha256=azVg9QR_IlG9lXCCXXVs1LS1kFci8yjxDmb_VA_TdTQ,7408
|
3
|
-
oafuncs/oa_data.py,sha256=
|
3
|
+
oafuncs/oa_data.py,sha256=Skhi70IY7T4lHd_eu3BxcSAfpXMH8SzUURR8gB7bj74,7679
|
4
4
|
oafuncs/oa_draw.py,sha256=QypQp4vJIrbAyFddEVxd9K9Q4d85PRYqYQi9xDUmSZw,11150
|
5
5
|
oafuncs/oa_file.py,sha256=EUL9osp7scZ3JTCwTUlKNfS1d_9xOsFrIkmFxzZAbdg,14233
|
6
6
|
oafuncs/oa_help.py,sha256=loyzTbjU_0VpSIBvAEUA_tqxG8MVsO0xFE_2hgQ3zMw,4188
|
7
|
-
oafuncs/oa_nc.py,sha256=
|
7
|
+
oafuncs/oa_nc.py,sha256=pdc3vEI-5uFYnyzXHAIHNlyeci4MJkeWgKJwjHJ3olI,18343
|
8
8
|
oafuncs/oa_python.py,sha256=Q-6UGGw_dJff7Ef8i87fsLPoGeHV5jBzfb-7HP4THR0,4018
|
9
|
-
oafuncs/data_store/OAFuncs.png,sha256=
|
9
|
+
oafuncs/data_store/OAFuncs.png,sha256=Ekgwb6DNX_jNo3F7EIyIDWPZ0KUAFPEb2njzi_DcD3U,3439715
|
10
10
|
oafuncs/oa_down/User_Agent-list.txt,sha256=pazxSip8_lphEBOPHG902zmIBUg8sBKXgmqp_g6j_E4,661062
|
11
11
|
oafuncs/oa_down/__init__.py,sha256=kRX5eTUCbAiz3zTaQM1501paOYS_3fizDN4Pa0mtNUA,585
|
12
|
-
oafuncs/oa_down/hycom_3hourly.py,sha256=
|
12
|
+
oafuncs/oa_down/hycom_3hourly.py,sha256=9ge6l8xMB-VBzCd1Fr4pIDZfUY_PbrBkWyvur0V27bs,64941
|
13
|
+
oafuncs/oa_down/hycom_3hourly_20250129.py,sha256=zbUp5NNBMzDXEqSC0-Z9H_EoM6Fg-6tXymK0AXH9qRk,65553
|
13
14
|
oafuncs/oa_down/idm.py,sha256=XfYCNnQWADxOhhJd-T8sNYN0nGiRrAs7zbQcsB5-UmI,1668
|
14
15
|
oafuncs/oa_down/literature.py,sha256=2bF9gSKQbzcci9LcKE81j8JEjIJwON7jbwQB3gDDA3E,11331
|
15
16
|
oafuncs/oa_down/test_ua.py,sha256=0IQq3NjqfNr7KkyjS_U-a4mYu-r-E7gzawwo4IfEa6Y,10851
|
@@ -21,8 +22,8 @@ oafuncs/oa_sign/scientific.py,sha256=a4JxOBgm9vzNZKpJ_GQIQf7cokkraV5nh23HGbmTYKw
|
|
21
22
|
oafuncs/oa_tool/__init__.py,sha256=bNTy9abznDhg3k_Irx0YieXl37r-oDRMtTAxf57Stzs,487
|
22
23
|
oafuncs/oa_tool/email.py,sha256=4lJxV_KUzhxgLYfVwYTqp0qxRugD7fvsZkXDe5WkUKo,3052
|
23
24
|
oafuncs/oa_tool/parallel.py,sha256=kYbiIFDB7EoxasmXGSomaEDVUsg9Rfvdgbw93lBOY7o,3770
|
24
|
-
oafuncs-0.0.
|
25
|
-
oafuncs-0.0.
|
26
|
-
oafuncs-0.0.
|
27
|
-
oafuncs-0.0.
|
28
|
-
oafuncs-0.0.
|
25
|
+
oafuncs-0.0.95.dist-info/LICENSE.txt,sha256=rMtLpVg8sKiSlwClfR9w_Dd_5WubTQgoOzE2PDFxzs4,1074
|
26
|
+
oafuncs-0.0.95.dist-info/METADATA,sha256=338EOy1HaTm46EOciOekPlYvoqta75nqX65vhvIQVFI,3618
|
27
|
+
oafuncs-0.0.95.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
|
28
|
+
oafuncs-0.0.95.dist-info/top_level.txt,sha256=bgC35QkXbN4EmPHEveg_xGIZ5i9NNPYWqtJqaKqTPsQ,8
|
29
|
+
oafuncs-0.0.95.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|