oafuncs 0.0.91__tar.gz → 0.0.92__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.91/oafuncs.egg-info → oafuncs-0.0.92}/PKG-INFO +12 -2
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_down/hycom_3hourly.py +195 -93
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_down/idm.py +1 -1
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_down/literature.py +4 -3
- {oafuncs-0.0.91 → oafuncs-0.0.92/oafuncs.egg-info}/PKG-INFO +12 -2
- {oafuncs-0.0.91 → oafuncs-0.0.92}/setup.py +1 -1
- {oafuncs-0.0.91 → oafuncs-0.0.92}/LICENSE.txt +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/MANIFEST.in +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/README.md +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/__init__.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/data_store/OAFuncs.png +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_cmap.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_data.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_down/User_Agent-list.txt +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_down/__init__.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_down/test_ua.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_down/user_agent.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_draw.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_file.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_help.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_nc.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_python.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_sign/__init__.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_sign/meteorological.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_sign/ocean.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_sign/scientific.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_tool/__init__.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_tool/email.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs/oa_tool/parallel.py +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs.egg-info/SOURCES.txt +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs.egg-info/dependency_links.txt +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs.egg-info/requires.txt +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/oafuncs.egg-info/top_level.txt +0 -0
- {oafuncs-0.0.91 → oafuncs-0.0.92}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: oafuncs
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.92
|
4
4
|
Summary: Oceanic and Atmospheric Functions
|
5
5
|
Home-page: https://github.com/Industry-Pays/OAFuncs
|
6
6
|
Author: Kun Liu
|
@@ -30,6 +30,16 @@ Requires-Dist: matplotlib
|
|
30
30
|
Requires-Dist: Cartopy
|
31
31
|
Requires-Dist: netCDF4
|
32
32
|
Requires-Dist: xlrd
|
33
|
+
Dynamic: author
|
34
|
+
Dynamic: author-email
|
35
|
+
Dynamic: classifier
|
36
|
+
Dynamic: description
|
37
|
+
Dynamic: description-content-type
|
38
|
+
Dynamic: home-page
|
39
|
+
Dynamic: license
|
40
|
+
Dynamic: requires-dist
|
41
|
+
Dynamic: requires-python
|
42
|
+
Dynamic: summary
|
33
43
|
|
34
44
|
|
35
45
|
# oafuncs
|
@@ -26,13 +26,17 @@ from threading import Lock
|
|
26
26
|
import matplotlib.pyplot as plt
|
27
27
|
import numpy as np
|
28
28
|
import pandas as pd
|
29
|
+
import xarray as xr
|
29
30
|
import requests
|
30
31
|
from rich import print
|
31
32
|
from rich.progress import Progress
|
33
|
+
import netCDF4 as nc
|
32
34
|
|
33
35
|
from oafuncs.oa_down.user_agent import get_ua
|
34
36
|
from oafuncs.oa_file import file_size, mean_size
|
35
37
|
from oafuncs.oa_nc import check as check_nc
|
38
|
+
from oafuncs.oa_nc import modify as modify_nc
|
39
|
+
from oafuncs.oa_down.idm import downloader as idm_downloader
|
36
40
|
|
37
41
|
warnings.filterwarnings("ignore", category=RuntimeWarning, message="Engine '.*' loading failed:.*")
|
38
42
|
|
@@ -571,12 +575,18 @@ def _check_existing_file(file_full_path, avg_size):
|
|
571
575
|
if abs(delta_size_ratio) > 0.025:
|
572
576
|
if check_nc(file_full_path):
|
573
577
|
# print(f"File size is abnormal but can be opened normally, file size: {fsize:.2f} KB")
|
574
|
-
|
578
|
+
if not _check_ftime(file_full_path,if_print=True):
|
579
|
+
return False
|
580
|
+
else:
|
581
|
+
return True
|
575
582
|
else:
|
576
583
|
print(f"File size is abnormal and cannot be opened, {file_full_path}: {fsize:.2f} KB")
|
577
584
|
return False
|
578
585
|
else:
|
579
|
-
|
586
|
+
if not _check_ftime(file_full_path,if_print=True):
|
587
|
+
return False
|
588
|
+
else:
|
589
|
+
return True
|
580
590
|
else:
|
581
591
|
return False
|
582
592
|
|
@@ -633,6 +643,62 @@ def _get_mean_size_move(same_file, current_file):
|
|
633
643
|
return fsize_dict[same_file]["mean_size"]
|
634
644
|
|
635
645
|
|
646
|
+
def _check_ftime(nc_file, tname="time", if_print=False):
|
647
|
+
if not os.path.exists(nc_file):
|
648
|
+
return False
|
649
|
+
nc_file = str(nc_file)
|
650
|
+
try:
|
651
|
+
ds = xr.open_dataset(nc_file)
|
652
|
+
real_time = ds[tname].values[0]
|
653
|
+
ds.close()
|
654
|
+
real_time = str(real_time)[:13]
|
655
|
+
real_time = real_time.replace("-", "").replace("T", "")
|
656
|
+
# -----------------------------------------------------
|
657
|
+
f_time = re.findall(r"\d{10}", nc_file)[0]
|
658
|
+
if real_time == f_time:
|
659
|
+
return True
|
660
|
+
else:
|
661
|
+
if if_print:
|
662
|
+
print(f"[bold #daff5c]File time error, file/real time: [bold blue]{f_time}/{real_time}")
|
663
|
+
return False
|
664
|
+
except Exception as e:
|
665
|
+
if if_print:
|
666
|
+
print(f"[bold #daff5c]File time check failed, {nc_file}: {e}")
|
667
|
+
return False
|
668
|
+
|
669
|
+
|
670
|
+
def _correct_time(nc_file):
|
671
|
+
# 打开NC文件
|
672
|
+
dataset = nc.Dataset(nc_file)
|
673
|
+
|
674
|
+
# 读取时间单位
|
675
|
+
time_units = dataset.variables["time"].units
|
676
|
+
|
677
|
+
# 关闭文件
|
678
|
+
dataset.close()
|
679
|
+
|
680
|
+
# 解析时间单位字符串以获取时间原点
|
681
|
+
origin_str = time_units.split("since")[1].strip()
|
682
|
+
origin_datetime = datetime.datetime.strptime(origin_str, "%Y-%m-%d %H:%M:%S")
|
683
|
+
|
684
|
+
# 从文件名中提取日期字符串
|
685
|
+
given_date_str = re.findall(r"\d{10}", str(nc_file))[0]
|
686
|
+
|
687
|
+
# 将提取的日期字符串转换为datetime对象
|
688
|
+
given_datetime = datetime.datetime.strptime(given_date_str, "%Y%m%d%H")
|
689
|
+
|
690
|
+
# 计算给定日期与时间原点之间的差值(以小时为单位)
|
691
|
+
time_difference = (given_datetime - origin_datetime).total_seconds()
|
692
|
+
if "hours" in time_units:
|
693
|
+
time_difference /= 3600
|
694
|
+
elif "days" in time_units:
|
695
|
+
time_difference /= 3600 * 24
|
696
|
+
|
697
|
+
# 修改NC文件中的时间变量
|
698
|
+
modify_nc(nc_file, "time", None, time_difference)
|
699
|
+
|
700
|
+
|
701
|
+
|
636
702
|
def _download_file(target_url, store_path, file_name, check=False):
|
637
703
|
# Check if the file exists
|
638
704
|
fname = Path(store_path) / file_name
|
@@ -641,7 +707,7 @@ def _download_file(target_url, store_path, file_name, check=False):
|
|
641
707
|
# same_file = f"{file_name_split[0]}_{file_name_split[1]}*nc"
|
642
708
|
same_file = "_".join(file_name_split) + "*nc"
|
643
709
|
|
644
|
-
if check:
|
710
|
+
if check:
|
645
711
|
if same_file not in fsize_dict.keys(): # 对第一个文件单独进行检查,因为没有大小可以对比
|
646
712
|
check_nc(fname,if_delete=True)
|
647
713
|
|
@@ -653,95 +719,103 @@ def _download_file(target_url, store_path, file_name, check=False):
|
|
653
719
|
return
|
654
720
|
_clear_existing_file(fname)
|
655
721
|
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
722
|
+
if not use_idm:
|
723
|
+
# -----------------------------------------------
|
724
|
+
print(f"[bold #f0f6d0]Requesting {file_name} ...")
|
725
|
+
# 创建会话
|
726
|
+
s = requests.Session()
|
727
|
+
download_success = False
|
728
|
+
request_times = 0
|
662
729
|
|
663
|
-
|
664
|
-
|
665
|
-
|
730
|
+
def calculate_wait_time(time_str, target_url):
|
731
|
+
# 定义正则表达式,匹配YYYYMMDDHH格式的时间
|
732
|
+
time_pattern = r"\d{10}"
|
666
733
|
|
667
|
-
|
668
|
-
|
669
|
-
|
734
|
+
# 定义两个字符串
|
735
|
+
# str1 = 'HYCOM_water_u_2018010100-2018010112.nc'
|
736
|
+
# str2 = 'HYCOM_water_u_2018010100.nc'
|
670
737
|
|
671
|
-
|
672
|
-
|
738
|
+
# 使用正则表达式查找时间
|
739
|
+
times_in_str = re.findall(time_pattern, time_str)
|
673
740
|
|
674
|
-
|
675
|
-
|
741
|
+
# 计算每个字符串中的时间数量
|
742
|
+
num_times_str = len(times_in_str)
|
676
743
|
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
744
|
+
if num_times_str > 1:
|
745
|
+
delta_t = datetime.datetime.strptime(times_in_str[1], "%Y%m%d%H") - datetime.datetime.strptime(times_in_str[0], "%Y%m%d%H")
|
746
|
+
delta_t = delta_t.total_seconds() / 3600
|
747
|
+
delta_t = delta_t / 3 + 1
|
748
|
+
else:
|
749
|
+
delta_t = 1
|
750
|
+
# 单个要素最多等待5分钟,不宜太短,太短可能请求失败;也不宜太长,太长可能会浪费时间
|
751
|
+
num_var = int(target_url.count("var="))
|
752
|
+
if num_var <= 0:
|
753
|
+
num_var = 1
|
754
|
+
return int(delta_t * 5 * 60 * num_var)
|
755
|
+
|
756
|
+
max_timeout = calculate_wait_time(file_name, target_url)
|
757
|
+
print(f"[bold #912dbc]Max timeout: {max_timeout} seconds")
|
758
|
+
|
759
|
+
# print(f'Download_start_time: {datetime.datetime.now()}')
|
760
|
+
download_time_s = datetime.datetime.now()
|
761
|
+
order_list = ["1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th"]
|
762
|
+
while not download_success:
|
763
|
+
if request_times >= 10:
|
764
|
+
# print(f'下载失败,已重试 {request_times} 次\n可先跳过,后续再试')
|
765
|
+
print(f"[bold #ffe5c0]Download failed after {request_times} times\nYou can skip it and try again later")
|
766
|
+
count_dict["fail"] += 1
|
767
|
+
break
|
768
|
+
if request_times > 0:
|
769
|
+
# print(f'\r正在重试第 {request_times} 次', end="")
|
770
|
+
print(f"[bold #ffe5c0]Retrying the {order_list[request_times-1]} time...")
|
771
|
+
# 尝试下载文件
|
772
|
+
try:
|
773
|
+
headers = {"User-Agent": get_ua()}
|
774
|
+
""" response = s.get(target_url, headers=headers, timeout=random.randint(5, max_timeout))
|
775
|
+
response.raise_for_status() # 如果请求返回的不是200,将抛出HTTPError异常
|
776
|
+
|
777
|
+
# 保存文件
|
778
|
+
with open(filename, 'wb') as f:
|
779
|
+
f.write(response.content) """
|
780
|
+
|
781
|
+
response = s.get(target_url, headers=headers, stream=True, timeout=random.randint(5, max_timeout)) # 启用流式传输
|
782
|
+
response.raise_for_status() # 如果请求返回的不是200,将抛出HTTPError异常
|
783
|
+
# 保存文件
|
784
|
+
with open(fname, "wb") as f:
|
785
|
+
print(f"[bold #96cbd7]Downloading {file_name} ...")
|
786
|
+
for chunk in response.iter_content(chunk_size=1024):
|
787
|
+
if chunk:
|
788
|
+
f.write(chunk)
|
789
|
+
|
790
|
+
f.close()
|
791
|
+
|
792
|
+
if not _check_ftime(fname):
|
793
|
+
_correct_time(fname)
|
794
|
+
|
795
|
+
# print(f'\r文件 {fname} 下载成功', end="")
|
796
|
+
if os.path.exists(fname):
|
797
|
+
download_success = True
|
798
|
+
download_time_e = datetime.datetime.now()
|
799
|
+
download_delta = download_time_e - download_time_s
|
800
|
+
print(f"[#3dfc40]File [bold #dfff73]{fname} [#3dfc40]has been downloaded successfully, Time: [#39cbdd]{download_delta}")
|
801
|
+
count_dict["success"] += 1
|
802
|
+
# print(f'Download_end_time: {datetime.datetime.now()}')
|
803
|
+
|
804
|
+
except requests.exceptions.HTTPError as errh:
|
805
|
+
print(f"Http Error: {errh}")
|
806
|
+
except requests.exceptions.ConnectionError as errc:
|
807
|
+
print(f"Error Connecting: {errc}")
|
808
|
+
except requests.exceptions.Timeout as errt:
|
809
|
+
print(f"Timeout Error: {errt}")
|
810
|
+
except requests.exceptions.RequestException as err:
|
811
|
+
print(f"OOps: Something Else: {err}")
|
812
|
+
|
813
|
+
time.sleep(3)
|
814
|
+
request_times += 1
|
815
|
+
else:
|
816
|
+
idm_downloader(target_url, store_path, file_name, given_idm_engine)
|
817
|
+
idm_download_list.append(fname)
|
818
|
+
print(f"[bold #3dfc40]File [bold #dfff73]{fname} [#3dfc40]has been submit to IDM for downloading")
|
745
819
|
|
746
820
|
|
747
821
|
def _check_hour_is_valid(ymdh_str):
|
@@ -980,7 +1054,7 @@ def _download_hourly_func(var, time_s, time_e, lon_min=0, lon_max=359.92, lat_mi
|
|
980
1054
|
print("Please ensure the time_s is no more than time_e")
|
981
1055
|
|
982
1056
|
|
983
|
-
def download(var, time_s, time_e=None, lon_min=0, lon_max=359.92, lat_min=-80, lat_max=90, depth=None, level=None, store_path=None, dataset_name=None, version_name=None, num_workers=None, check=False, ftimes=1):
|
1057
|
+
def download(var, time_s, time_e=None, lon_min=0, lon_max=359.92, lat_min=-80, lat_max=90, depth=None, level=None, store_path=None, dataset_name=None, version_name=None, num_workers=None, check=False, ftimes=1, idm_engine=None):
|
984
1058
|
"""
|
985
1059
|
Description:
|
986
1060
|
Download the data of single time or a series of time
|
@@ -1001,6 +1075,7 @@ def download(var, time_s, time_e=None, lon_min=0, lon_max=359.92, lat_min=-80, l
|
|
1001
1075
|
num_workers: int, the number of workers, default is None, if not set, the number of workers will be 1; suggest not to set the number of workers too large
|
1002
1076
|
check: bool, whether to check the existing file, default is False, if set to True, the existing file will be checked and not downloaded again; else, the existing file will be covered
|
1003
1077
|
ftimes: int, the number of time in one file, default is 1, if set to 1, the data of single time will be downloaded; the maximum is 8, if set to 8, the data of 8 times will be downloaded in one file
|
1078
|
+
idm_engine: str, the IDM engine, default is None, if set, the IDM will be used to download the data; example: "D:\\Programs\\Internet Download Manager\\IDMan.exe"
|
1004
1079
|
|
1005
1080
|
Returns:
|
1006
1081
|
None
|
@@ -1071,8 +1146,34 @@ def download(var, time_s, time_e=None, lon_min=0, lon_max=359.92, lat_min=-80, l
|
|
1071
1146
|
|
1072
1147
|
global fsize_dict_lock
|
1073
1148
|
fsize_dict_lock = Lock()
|
1149
|
+
|
1150
|
+
global use_idm, given_idm_engine, idm_download_list
|
1151
|
+
if idm_engine is not None:
|
1152
|
+
use_idm = True
|
1153
|
+
given_idm_engine = idm_engine
|
1154
|
+
idm_download_list = []
|
1155
|
+
else:
|
1156
|
+
use_idm = False
|
1157
|
+
|
1074
1158
|
|
1075
1159
|
_download_hourly_func(var, time_s, time_e, lon_min, lon_max, lat_min, lat_max, depth, level, store_path, dataset_name, version_name, num_workers, check, ftimes)
|
1160
|
+
|
1161
|
+
if idm_download_list:
|
1162
|
+
for f in idm_download_list:
|
1163
|
+
wait_success = 0
|
1164
|
+
success = False
|
1165
|
+
while not success:
|
1166
|
+
if check_nc(f):
|
1167
|
+
_correct_time(f)
|
1168
|
+
success = True
|
1169
|
+
count_dict["success"] += 1
|
1170
|
+
else:
|
1171
|
+
wait_success += 1
|
1172
|
+
time.sleep(3)
|
1173
|
+
if wait_success >= 20:
|
1174
|
+
success = True
|
1175
|
+
# print(f'{f} download failed')
|
1176
|
+
count_dict["fail"] += 1
|
1076
1177
|
|
1077
1178
|
count_dict["total"] = count_dict["success"] + count_dict["fail"] + count_dict["skip"] + count_dict["no_data"]
|
1078
1179
|
|
@@ -1140,9 +1241,9 @@ def how_to_use():
|
|
1140
1241
|
|
1141
1242
|
|
1142
1243
|
if __name__ == "__main__":
|
1143
|
-
time_s, time_e = "
|
1244
|
+
time_s, time_e = "2018010800", "2024083121"
|
1144
1245
|
merge_name = f"{time_s}_{time_e}" # 合并后的文件名
|
1145
|
-
root_path = r"G:\Data\HYCOM\
|
1246
|
+
root_path = r"G:\Data\HYCOM\3hourly"
|
1146
1247
|
location_dict = {"west": 105, "east": 130, "south": 15, "north": 45}
|
1147
1248
|
download_dict = {
|
1148
1249
|
"water_u": {"simple_name": "u", "download": 1},
|
@@ -1162,10 +1263,11 @@ if __name__ == "__main__":
|
|
1162
1263
|
# if you wanna download all depth or level, set both False
|
1163
1264
|
depth = None # or 0-5000 meters
|
1164
1265
|
level = None # or 1-40 levels
|
1165
|
-
num_workers =
|
1266
|
+
num_workers = 1
|
1166
1267
|
|
1167
1268
|
check = True
|
1168
1269
|
ftimes = 1
|
1270
|
+
idm_engine = r"D:\Programs\Internet Download Manager\IDMan.exe"
|
1169
1271
|
|
1170
1272
|
download_switch, single_var = True, False
|
1171
1273
|
combine_switch = False
|
@@ -1176,9 +1278,9 @@ if __name__ == "__main__":
|
|
1176
1278
|
if download_switch:
|
1177
1279
|
if single_var:
|
1178
1280
|
for var_name in var_list:
|
1179
|
-
download(var=var_name, time_s=time_s, time_e=time_e, store_path=Path(root_path), lon_min=location_dict["west"], lon_max=location_dict["east"], lat_min=location_dict["south"], lat_max=location_dict["north"], num_workers=num_workers, check=check, depth=depth, level=level, ftimes=ftimes)
|
1281
|
+
download(var=var_name, time_s=time_s, time_e=time_e, store_path=Path(root_path), lon_min=location_dict["west"], lon_max=location_dict["east"], lat_min=location_dict["south"], lat_max=location_dict["north"], num_workers=num_workers, check=check, depth=depth, level=level, ftimes=ftimes, idm_engine=idm_engine)
|
1180
1282
|
else:
|
1181
|
-
download(var=var_list, time_s=time_s, time_e=time_e, store_path=Path(root_path), lon_min=location_dict["west"], lon_max=location_dict["east"], lat_min=location_dict["south"], lat_max=location_dict["north"], num_workers=num_workers, check=check, depth=depth, level=level, ftimes=ftimes)
|
1283
|
+
download(var=var_list, time_s=time_s, time_e=time_e, store_path=Path(root_path), lon_min=location_dict["west"], lon_max=location_dict["east"], lat_min=location_dict["south"], lat_max=location_dict["north"], num_workers=num_workers, check=check, depth=depth, level=level, ftimes=ftimes, idm_engine=idm_engine)
|
1182
1284
|
|
1183
1285
|
""" if combine_switch or copy_switch:
|
1184
1286
|
time_list = get_time_list(time_s, time_e, 3, 'hour')
|
@@ -38,7 +38,7 @@ def downloader(task_url, folder_path, file_name, idm_engine=r"D:\Programs\Intern
|
|
38
38
|
Return:
|
39
39
|
None
|
40
40
|
Example:
|
41
|
-
downloader("https://www.test.com/data.nc",
|
41
|
+
downloader("https://www.test.com/data.nc", "E:\\Data", "test.nc", "D:\\Programs\\Internet Download Manager\\IDMan.exe")
|
42
42
|
"""
|
43
43
|
os.makedirs(folder_path, exist_ok=True)
|
44
44
|
# 将任务添加至队列
|
@@ -23,6 +23,7 @@ import requests
|
|
23
23
|
from rich import print
|
24
24
|
from rich.progress import track
|
25
25
|
from oafuncs.oa_down.user_agent import get_ua
|
26
|
+
from oafuncs.oa_file import remove
|
26
27
|
|
27
28
|
__all__ = ["download5doi"]
|
28
29
|
|
@@ -274,6 +275,7 @@ def download5doi(store_path=None, doi_list=None, txt_file=None, excel_file=None,
|
|
274
275
|
doi_list = read_txt(txt_file)
|
275
276
|
if excel_file:
|
276
277
|
doi_list = read_excel(excel_file, col_name)
|
278
|
+
remove(Path(store_path) / "wrong_record.txt")
|
277
279
|
print(f"Downloading {len(doi_list)} PDF files...")
|
278
280
|
for doi in track(doi_list, description="Downloading..."):
|
279
281
|
download = _Downloader(doi, store_path)
|
@@ -281,7 +283,6 @@ def download5doi(store_path=None, doi_list=None, txt_file=None, excel_file=None,
|
|
281
283
|
|
282
284
|
|
283
285
|
if __name__ == "__main__":
|
284
|
-
store_path = r"F:\AAA-Delete\DOI_Reference\pdf"
|
285
|
-
excel_file = r"F:\AAA-Delete\DOI_Reference\savedrecs.xls"
|
286
|
-
# download5doi(store_path, doi_list='10.1007/s00382-022-06260-x')
|
286
|
+
store_path = r"F:\AAA-Delete\DOI_Reference\5\pdf"
|
287
|
+
excel_file = r"F:\AAA-Delete\DOI_Reference\5\savedrecs.xls"
|
287
288
|
download5doi(store_path, excel_file=excel_file)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: oafuncs
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.92
|
4
4
|
Summary: Oceanic and Atmospheric Functions
|
5
5
|
Home-page: https://github.com/Industry-Pays/OAFuncs
|
6
6
|
Author: Kun Liu
|
@@ -30,6 +30,16 @@ Requires-Dist: matplotlib
|
|
30
30
|
Requires-Dist: Cartopy
|
31
31
|
Requires-Dist: netCDF4
|
32
32
|
Requires-Dist: xlrd
|
33
|
+
Dynamic: author
|
34
|
+
Dynamic: author-email
|
35
|
+
Dynamic: classifier
|
36
|
+
Dynamic: description
|
37
|
+
Dynamic: description-content-type
|
38
|
+
Dynamic: home-page
|
39
|
+
Dynamic: license
|
40
|
+
Dynamic: requires-dist
|
41
|
+
Dynamic: requires-python
|
42
|
+
Dynamic: summary
|
33
43
|
|
34
44
|
|
35
45
|
# oafuncs
|
@@ -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.9.0' # 2025/01/05
|
21
|
-
VERSION = '0.0.
|
21
|
+
VERSION = '0.0.92'
|
22
22
|
|
23
23
|
# What packages are required for this module to be executed?
|
24
24
|
REQUIRED = [
|
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
|