oafuncs 0.0.67__py2.py3-none-any.whl → 0.0.68__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/oa_down/hycom_3hourly.py +41 -30
- oafuncs/oa_down/refs_pdf.py +6 -1
- {oafuncs-0.0.67.dist-info → oafuncs-0.0.68.dist-info}/METADATA +1 -1
- {oafuncs-0.0.67.dist-info → oafuncs-0.0.68.dist-info}/RECORD +7 -9
- oafuncs/oa_down/hycom_3hourly_20241130.py +0 -1232
- oafuncs/oa_down/hycom_3hourly_wholeday.py +0 -1173
- {oafuncs-0.0.67.dist-info → oafuncs-0.0.68.dist-info}/LICENSE.txt +0 -0
- {oafuncs-0.0.67.dist-info → oafuncs-0.0.68.dist-info}/WHEEL +0 -0
- {oafuncs-0.0.67.dist-info → oafuncs-0.0.68.dist-info}/top_level.txt +0 -0
oafuncs/oa_down/hycom_3hourly.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
Author: Liu Kun && 16031215@qq.com
|
5
5
|
Date: 2024-11-01 10:31:09
|
6
6
|
LastEditors: Liu Kun && 16031215@qq.com
|
7
|
-
LastEditTime: 2024-11-30
|
7
|
+
LastEditTime: 2024-11-30 20:24:34
|
8
8
|
FilePath: \\Python\\My_Funcs\\OAFuncs\\oafuncs\\oa_down\\hycom_3hourly.py
|
9
9
|
Description:
|
10
10
|
EditPlatform: vscode
|
@@ -483,7 +483,7 @@ def check_existing_file(file_full_path):
|
|
483
483
|
print(f'[bold #FFA54F]{file_full_path} exists')
|
484
484
|
return True
|
485
485
|
else:
|
486
|
-
print(f'{file_full_path} does not exist')
|
486
|
+
# print(f'{file_full_path} does not exist')
|
487
487
|
return False
|
488
488
|
|
489
489
|
|
@@ -579,7 +579,7 @@ def get_proxy():
|
|
579
579
|
|
580
580
|
|
581
581
|
def dlownload_file(target_url, store_path, file_name, check=False):
|
582
|
-
print(f'[bold
|
582
|
+
print(f'[bold #96cbd7]Downloading {file_name}...')
|
583
583
|
# 创建会话
|
584
584
|
s = requests.Session()
|
585
585
|
download_success = False
|
@@ -590,10 +590,16 @@ def dlownload_file(target_url, store_path, file_name, check=False):
|
|
590
590
|
if check_existing_file(filename):
|
591
591
|
return
|
592
592
|
clear_existing_file(filename)
|
593
|
-
print(f'Download_start_time: {datetime.datetime.now()}')
|
593
|
+
# print(f'Download_start_time: {datetime.datetime.now()}')
|
594
|
+
download_time_s = datetime.datetime.now()
|
594
595
|
while not download_success:
|
596
|
+
if request_times >= 10:
|
597
|
+
# print(f'下载失败,已重试 {request_times} 次\n可先跳过,后续再试')
|
598
|
+
print(f'[bold #ffe5c0]Download failed after {request_times} times\nYou can skip it and try again later')
|
599
|
+
break
|
595
600
|
if request_times > 0:
|
596
|
-
print(f'\r正在重试第 {request_times} 次', end="")
|
601
|
+
# print(f'\r正在重试第 {request_times} 次', end="")
|
602
|
+
print(f'[bold #ffe5c0]Retrying the {request_times} time...')
|
597
603
|
# 尝试下载文件
|
598
604
|
try:
|
599
605
|
headers = {'User-Agent': get_ua()}
|
@@ -604,10 +610,12 @@ def dlownload_file(target_url, store_path, file_name, check=False):
|
|
604
610
|
with open(filename, 'wb') as f:
|
605
611
|
f.write(response.content)
|
606
612
|
# print(f'\r文件 {filename} 下载成功', end="")
|
607
|
-
# query_ncfile_time(filename) # 这个函数在linux上目前会出问题
|
608
613
|
if os.path.exists(filename):
|
609
614
|
download_success = True
|
610
|
-
|
615
|
+
download_time_e = datetime.datetime.now()
|
616
|
+
download_delta = download_time_e - download_time_s
|
617
|
+
print(f'[#65b168]File [bold #dfff73]{filename} [#65b168]has been downloaded successfully, Time: [#39cbdd]{download_delta}')
|
618
|
+
# print(f'Download_end_time: {datetime.datetime.now()}')
|
611
619
|
|
612
620
|
except requests.exceptions.HTTPError as errh:
|
613
621
|
print(f"Http Error: {errh}")
|
@@ -620,7 +628,6 @@ def dlownload_file(target_url, store_path, file_name, check=False):
|
|
620
628
|
|
621
629
|
time.sleep(3)
|
622
630
|
request_times += 1
|
623
|
-
print(f'Download_end_time: {datetime.datetime.now()}')
|
624
631
|
|
625
632
|
|
626
633
|
def check_hour_is_valid(ymdh_str):
|
@@ -640,19 +647,6 @@ def check_dataset_version(dataset_name, version_name, download_time, download_ti
|
|
640
647
|
else:
|
641
648
|
return None, None
|
642
649
|
|
643
|
-
# 打印信息并处理数据集和版本名称
|
644
|
-
if dataset_name is None and version_name is None:
|
645
|
-
print('The dataset_name and version_name are None, so the dataset and version will be chosen according to the download_time.\nIf there is more than one dataset and version in the time range, the first one will be chosen.')
|
646
|
-
print('If you wanna choose the dataset and version by yourself, please set the dataset_name and version_name together.')
|
647
|
-
elif dataset_name is None and version_name is not None:
|
648
|
-
print('Please ensure the dataset_name is not None')
|
649
|
-
print('If you do not add the dataset_name, both the dataset and version will be chosen according to the download_time.')
|
650
|
-
elif dataset_name is not None and version_name is None:
|
651
|
-
print('Please ensure the version_name is not None')
|
652
|
-
print('If you do not add the version_name, both the dataset and version will be chosen according to the download_time.')
|
653
|
-
else:
|
654
|
-
print('The dataset_name and version_name are both set by yourself.')
|
655
|
-
|
656
650
|
# 确保下载时间是一个字符串
|
657
651
|
download_time_str = str(download_time)
|
658
652
|
|
@@ -686,7 +680,7 @@ def get_submit_url_var(var, depth, level_num, lon_min, lon_max, lat_min, lat_max
|
|
686
680
|
print('Progress will use the depth')
|
687
681
|
which_mode = 'depth'
|
688
682
|
elif depth is not None and level_num is None:
|
689
|
-
print(f'Data of single depth ({depth}m) will be downloaded...')
|
683
|
+
print(f'Data of single depth (~{depth} m) will be downloaded...')
|
690
684
|
which_mode = 'depth'
|
691
685
|
elif level_num is not None and depth is None:
|
692
686
|
print(f'Data of single level ({level_num}) will be downloaded...')
|
@@ -701,6 +695,7 @@ def get_submit_url_var(var, depth, level_num, lon_min, lon_max, lat_min, lat_max
|
|
701
695
|
|
702
696
|
|
703
697
|
def direct_download_single_hour(var, lon_min=0, lon_max=359.92, lat_min=-80, lat_max=90, download_time='2024083100', depth=None, level_num=None, store_path=None, dataset_name=None, version_name=None, check=False):
|
698
|
+
print('[bold #ecdbfe]-'*150)
|
704
699
|
download_time = str(download_time)
|
705
700
|
dataset_name, version_name = check_dataset_version(dataset_name, version_name, download_time)
|
706
701
|
if dataset_name is None and version_name is None:
|
@@ -745,6 +740,7 @@ def direct_download_single_hour(var, lon_min=0, lon_max=359.92, lat_min=-80, lat
|
|
745
740
|
|
746
741
|
|
747
742
|
def direct_download_whole_day(var, lon_min=0, lon_max=359.92, lat_min=-80, lat_max=90, download_time='20240831', depth=None, level_num=None, store_path=None, dataset_name=None, version_name=None, check=False):
|
743
|
+
print('[bold #ecdbfe]-'*150)
|
748
744
|
download_time = str(download_time)[:8]+'00'
|
749
745
|
dataset_name, version_name = check_dataset_version(dataset_name, version_name, download_time, str(download_time)[:8]+'21')
|
750
746
|
if dataset_name is None and version_name is None:
|
@@ -885,9 +881,9 @@ def download_single_hour(var, time_s, time_e=None, lon_min=0, lon_max=359.92, la
|
|
885
881
|
task = progress.add_task("[cyan]Downloading...", total=len(time_list))
|
886
882
|
if num_workers is None or num_workers <= 1:
|
887
883
|
# 串行方式
|
888
|
-
for time_str in time_list:
|
884
|
+
for i, time_str in enumerate(time_list):
|
889
885
|
direct_download_single_hour(var, lon_min, lon_max, lat_min, lat_max, time_str, depth, level, store_path, dataset_name, version_name, check)
|
890
|
-
progress.update(task, advance=1)
|
886
|
+
progress.update(task, advance=1, description=f'[cyan]Downloading... {i+1}/{len(time_list)}')
|
891
887
|
else:
|
892
888
|
# 并行方式
|
893
889
|
if num_workers > 10:
|
@@ -896,8 +892,8 @@ def download_single_hour(var, time_s, time_e=None, lon_min=0, lon_max=359.92, la
|
|
896
892
|
num_workers = 10
|
897
893
|
with ThreadPoolExecutor(max_workers=num_workers) as executor:
|
898
894
|
futures = [executor.submit(download_task, var, time_str, lon_min, lon_max, lat_min, lat_max, depth, level, store_path, dataset_name, version_name, check) for time_str in time_list]
|
899
|
-
for future in futures:
|
900
|
-
future.add_done_callback(lambda _: progress.update(task, advance=1))
|
895
|
+
for i, future in enumerate(futures):
|
896
|
+
future.add_done_callback(lambda _: progress.update(task, advance=1, description=f'[cyan]Downloading... {i+1}/{len(time_list)}'))
|
901
897
|
else:
|
902
898
|
print('Please ensure the time_s is less than the time_e')
|
903
899
|
|
@@ -956,9 +952,9 @@ def download_whole_day(var, time_s, time_e=None, lon_min=0, lon_max=359.92, lat_
|
|
956
952
|
task = progress.add_task("[cyan]Downloading...", total=len(time_list))
|
957
953
|
if num_workers is None or num_workers <= 1:
|
958
954
|
# 串行方式
|
959
|
-
for time_str in time_list:
|
955
|
+
for i, time_str in enumerate(time_list):
|
960
956
|
direct_download_whole_day(var, lon_min, lon_max, lat_min, lat_max, time_str, depth, level, store_path, dataset_name, version_name, check)
|
961
|
-
progress.update(task, advance=1)
|
957
|
+
progress.update(task, advance=1, description=f'[cyan]Downloading... {i+1}/{len(time_list)}')
|
962
958
|
else:
|
963
959
|
# 并行方式
|
964
960
|
if num_workers > 10:
|
@@ -967,8 +963,8 @@ def download_whole_day(var, time_s, time_e=None, lon_min=0, lon_max=359.92, lat_
|
|
967
963
|
num_workers = 10
|
968
964
|
with ThreadPoolExecutor(max_workers=num_workers) as executor:
|
969
965
|
futures = [executor.submit(download_task, var, time_str, lon_min, lon_max, lat_min, lat_max, depth, level, store_path, dataset_name, version_name, check) for time_str in time_list]
|
970
|
-
for future in futures:
|
971
|
-
future.add_done_callback(lambda _: progress.update(task, advance=1))
|
966
|
+
for i, future in enumerate(futures):
|
967
|
+
future.add_done_callback(lambda _: progress.update(task, advance=1, description=f'[cyan]Downloading... {i+1}/{len(time_list)}'))
|
972
968
|
else:
|
973
969
|
print('Please ensure the time_s is less than the time_e')
|
974
970
|
|
@@ -996,6 +992,20 @@ def download(var, time_s, time_e=None, lon_min=0, lon_max=359.92, lat_min=-80, l
|
|
996
992
|
Returns:
|
997
993
|
None
|
998
994
|
'''
|
995
|
+
# 打印信息并处理数据集和版本名称
|
996
|
+
if dataset_name is None and version_name is None:
|
997
|
+
print('The dataset_name and version_name are None, so the dataset and version will be chosen according to the download_time.\nIf there is more than one dataset and version in the time range, the first one will be chosen.')
|
998
|
+
print('If you wanna choose the dataset and version by yourself, please set the dataset_name and version_name together.')
|
999
|
+
elif dataset_name is None and version_name is not None:
|
1000
|
+
print('Please ensure the dataset_name is not None')
|
1001
|
+
print('If you do not add the dataset_name, both the dataset and version will be chosen according to the download_time.')
|
1002
|
+
elif dataset_name is not None and version_name is None:
|
1003
|
+
print('Please ensure the version_name is not None')
|
1004
|
+
print('If you do not add the version_name, both the dataset and version will be chosen according to the download_time.')
|
1005
|
+
else:
|
1006
|
+
print('The dataset_name and version_name are both set by yourself.')
|
1007
|
+
print('Please ensure the dataset_name and version_name are correct.')
|
1008
|
+
|
999
1009
|
if resolution == 'hour':
|
1000
1010
|
download_single_hour(var, time_s, time_e, lon_min, lon_max, lat_min, lat_max, depth, level, store_path, dataset_name, version_name, num_workers, check)
|
1001
1011
|
elif resolution == 'day':
|
@@ -1117,6 +1127,7 @@ if __name__ == '__main__':
|
|
1117
1127
|
fname = 'surf_el'
|
1118
1128
|
for time_str in time_list:
|
1119
1129
|
file_list.append(Path(root_path)/f'HYCOM_{fname}_{time_str}.nc')
|
1130
|
+
merge_path_name = Path(root_path)/f'HYCOM_{fname}_{merge_name}.nc'
|
1120
1131
|
if combine_switch:
|
1121
1132
|
merge5nc(file_list, var_name, 'time', merge_path_name)
|
1122
1133
|
if copy_switch:
|
oafuncs/oa_down/refs_pdf.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
Author: Liu Kun && 16031215@qq.com
|
5
5
|
Date: 2024-11-09 13:58:28
|
6
6
|
LastEditors: Liu Kun && 16031215@qq.com
|
7
|
-
LastEditTime: 2024-11-
|
7
|
+
LastEditTime: 2024-11-30 20:29:51
|
8
8
|
FilePath: \\Python\\My_Funcs\\OAFuncs\\oafuncs\\oa_down\\refs_pdf.py
|
9
9
|
Description:
|
10
10
|
EditPlatform: vscode
|
@@ -306,6 +306,11 @@ def download5doi(store_path=None, doi_list=None, txt_file=None, excel_file=None,
|
|
306
306
|
download5doi(store_path=r'I:\Delete\ref_pdf', excel_file=r'I:\Delete\ref_pdf\wrong_record.xlsx', col_name='DOI')
|
307
307
|
'''
|
308
308
|
print('[bold #EE33fA]Note:\n 升级0.0.62版本后,函数路径将改为oafuncs.oa_down.literature.download5doi,此路径将被弃用。')
|
309
|
+
print('[bold #EE33fA]Note:\n 升级0.0.62版本后,函数路径将改为oafuncs.oa_down.literature.download5doi,此路径将被弃用。')
|
310
|
+
print('[bold #EE33fA]Note:\n 升级0.0.62版本后,函数路径将改为oafuncs.oa_down.literature.download5doi,此路径将被弃用。')
|
311
|
+
print('[bold #EE33fA]Note:\n 升级0.0.62版本后,函数路径将改为oafuncs.oa_down.literature.download5doi,此路径将被弃用。')
|
312
|
+
print('[bold #EE33fA]Note:\n 升级0.0.62版本后,函数路径将改为oafuncs.oa_down.literature.download5doi,此路径将被弃用。')
|
313
|
+
print('[bold #EE33fA]Note:\n 升级0.0.62版本后,函数路径将改为oafuncs.oa_down.literature.download5doi,此路径将被弃用。')
|
309
314
|
|
310
315
|
if not store_path:
|
311
316
|
store_path = Path.cwd()
|
@@ -7,19 +7,17 @@ oafuncs/oa_help.py,sha256=ppNktmtNzs15R20MD1bM7yImlTQ_ngMwvoIglePOKXA,1000
|
|
7
7
|
oafuncs/oa_nc.py,sha256=ALAYfqDy5lbUNJsTU29j6ZWkM4wgqQU3p2Fxn5pkvsQ,12102
|
8
8
|
oafuncs/oa_python.py,sha256=XPTP3o7zTFzfJR_YhsKfQksa3bSYwXsne9YxlJplCEA,3994
|
9
9
|
oafuncs/oa_down/__init__.py,sha256=a6rgxHQi8spvlI-TaVEqnrDNhYsKm5_IQf7ckAZ8U4w,603
|
10
|
-
oafuncs/oa_down/hycom_3hourly.py,sha256=
|
11
|
-
oafuncs/oa_down/hycom_3hourly_20241130.py,sha256=pXF_-e4DGnuRRkmzlFCPfLcw9Y6H22ui-VX08R38utw,65820
|
12
|
-
oafuncs/oa_down/hycom_3hourly_wholeday.py,sha256=bEl-hdSPJqN_9IaJIF-la0jEPw-sbCaKnciPirsWgP8,62598
|
10
|
+
oafuncs/oa_down/hycom_3hourly.py,sha256=AcSIxnM8_Gop3Jc2JWxiPGPB_i51yAdRLu38CyPy_1g,60994
|
13
11
|
oafuncs/oa_down/literature.py,sha256=dT3-7-beEzQ9mTP8LNV9Gf3q5Z1Pqqjc6FOS010HZeQ,17833
|
14
|
-
oafuncs/oa_down/refs_pdf.py,sha256=
|
12
|
+
oafuncs/oa_down/refs_pdf.py,sha256=lgGKO2gQ0hRjuaBYOLeBgksJB_KXYpFcXMDwMQeYVkI,18719
|
15
13
|
oafuncs/oa_sign/__init__.py,sha256=QKqTFrJDFK40C5uvk48GlRRbGFzO40rgkYwu6dYxatM,563
|
16
14
|
oafuncs/oa_sign/meteorological.py,sha256=mLbupsZSq427HTfVbZMvIlFzDHwSzQAbK3X19o8anFY,6525
|
17
15
|
oafuncs/oa_sign/ocean.py,sha256=xrW-rWD7xBWsB5PuCyEwQ1Q_RDKq2KCLz-LOONHgldU,5932
|
18
16
|
oafuncs/oa_sign/scientific.py,sha256=a4JxOBgm9vzNZKpJ_GQIQf7cokkraV5nh23HGbmTYKw,5064
|
19
17
|
oafuncs/oa_tool/__init__.py,sha256=IKOlqpWlb4cMDCtq2VKR_RTxQHDNqR_vfqqsOsp_lKQ,466
|
20
18
|
oafuncs/oa_tool/email.py,sha256=4lJxV_KUzhxgLYfVwYTqp0qxRugD7fvsZkXDe5WkUKo,3052
|
21
|
-
oafuncs-0.0.
|
22
|
-
oafuncs-0.0.
|
23
|
-
oafuncs-0.0.
|
24
|
-
oafuncs-0.0.
|
25
|
-
oafuncs-0.0.
|
19
|
+
oafuncs-0.0.68.dist-info/LICENSE.txt,sha256=rMtLpVg8sKiSlwClfR9w_Dd_5WubTQgoOzE2PDFxzs4,1074
|
20
|
+
oafuncs-0.0.68.dist-info/METADATA,sha256=rSvgCLyt6-4IE0y_gmAQ7M9CQEF9-Gfpi1PR2ytkB-U,22378
|
21
|
+
oafuncs-0.0.68.dist-info/WHEEL,sha256=pxeNX5JdtCe58PUSYP9upmc7jdRPgvT0Gm9kb1SHlVw,109
|
22
|
+
oafuncs-0.0.68.dist-info/top_level.txt,sha256=bgC35QkXbN4EmPHEveg_xGIZ5i9NNPYWqtJqaKqTPsQ,8
|
23
|
+
oafuncs-0.0.68.dist-info/RECORD,,
|