oafuncs 0.0.70__py2.py3-none-any.whl → 0.0.71__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 +21 -20
- {oafuncs-0.0.70.dist-info → oafuncs-0.0.71.dist-info}/METADATA +1 -1
- {oafuncs-0.0.70.dist-info → oafuncs-0.0.71.dist-info}/RECORD +6 -6
- {oafuncs-0.0.70.dist-info → oafuncs-0.0.71.dist-info}/LICENSE.txt +0 -0
- {oafuncs-0.0.70.dist-info → oafuncs-0.0.71.dist-info}/WHEEL +0 -0
- {oafuncs-0.0.70.dist-info → oafuncs-0.0.71.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-12-01
|
7
|
+
LastEditTime: 2024-12-01 11:21:49
|
8
8
|
FilePath: \\Python\\My_Funcs\\OAFuncs\\oafuncs\\oa_down\\hycom_3hourly.py
|
9
9
|
Description:
|
10
10
|
EditPlatform: vscode
|
@@ -730,6 +730,8 @@ def prepare_url_to_download(var, lon_min=0, lon_max=359.92, lat_min=-80, lat_max
|
|
730
730
|
var = var[0]
|
731
731
|
submit_url = get_submit_url_var(var, depth, level_num, lon_min, lon_max, lat_min, lat_max, dataset_name, version_name, download_time, download_time_end)
|
732
732
|
file_name = f"HYCOM_{variable_info[var]['var_name']}_{download_time}.nc"
|
733
|
+
if download_time_end is not None:
|
734
|
+
file_name = f"HYCOM_{variable_info[var]['var_name']}_{download_time}_{download_time_end}.nc"
|
733
735
|
dlownload_file(submit_url, store_path, file_name, check)
|
734
736
|
else:
|
735
737
|
varlist = [_ for _ in var]
|
@@ -752,6 +754,8 @@ def prepare_url_to_download(var, lon_min=0, lon_max=359.92, lat_min=-80, lat_max
|
|
752
754
|
submit_url = submit_url.replace(old_str, new_str)
|
753
755
|
# file_name = f'HYCOM_{'-'.join([variable_info[v]["var_name"] for v in current_group])}_{download_time}.nc'
|
754
756
|
file_name = f'HYCOM_{key}_{download_time}.nc'
|
757
|
+
if download_time_end is not None:
|
758
|
+
file_name = f'HYCOM_{key}_{download_time}_{download_time_end}.nc'
|
755
759
|
dlownload_file(submit_url, store_path, file_name, check)
|
756
760
|
|
757
761
|
|
@@ -779,7 +783,7 @@ def download_task(var, time_str, time_str_end, lon_min, lon_max, lat_min, lat_ma
|
|
779
783
|
prepare_url_to_download(var, lon_min, lon_max, lat_min, lat_max, time_str, time_str_end, depth, level, store_path, dataset_name, version_name, check)
|
780
784
|
|
781
785
|
|
782
|
-
def download_hourly_func(var, time_s, time_e
|
786
|
+
def download_hourly_func(var, time_s, time_e, 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):
|
783
787
|
'''
|
784
788
|
Description:
|
785
789
|
Download the data of single time or a series of time
|
@@ -802,15 +806,7 @@ def download_hourly_func(var, time_s, time_e=None, lon_min=0, lon_max=359.92, la
|
|
802
806
|
Returns:
|
803
807
|
None
|
804
808
|
'''
|
805
|
-
ymdh_time_s = str(time_s)
|
806
|
-
if len(ymdh_time_s) == 8:
|
807
|
-
ymdh_time_s += '00'
|
808
|
-
if time_e is None:
|
809
|
-
ymdh_time_e = ymdh_time_s[:]
|
810
|
-
else:
|
811
|
-
ymdh_time_e = str(time_e)
|
812
|
-
if len(ymdh_time_e) == 8:
|
813
|
-
ymdh_time_e += '21'
|
809
|
+
ymdh_time_s, ymdh_time_e = str(time_s), str(time_e)
|
814
810
|
if ymdh_time_s == ymdh_time_e:
|
815
811
|
prepare_url_to_download(var, lon_min, lon_max, lat_min, lat_max, ymdh_time_s, None, depth, level, store_path, dataset_name, version_name)
|
816
812
|
elif int(ymdh_time_s) < int(ymdh_time_e):
|
@@ -826,10 +822,6 @@ def download_hourly_func(var, time_s, time_e=None, lon_min=0, lon_max=359.92, la
|
|
826
822
|
progress.update(task, advance=1, description=f'[cyan]Downloading... {i+1}/{len(time_list)}')
|
827
823
|
else:
|
828
824
|
# 并行方式
|
829
|
-
if num_workers > 10:
|
830
|
-
print('The number of workers is too large!')
|
831
|
-
print('In order to avoid the server being blocked, the number of workers is set to 10')
|
832
|
-
num_workers = 10
|
833
825
|
with ThreadPoolExecutor(max_workers=num_workers) as executor:
|
834
826
|
futures = [executor.submit(download_task, var, time_str, None, lon_min, lon_max, lat_min, lat_max, depth, level, store_path, dataset_name, version_name, check) for time_str in time_list]
|
835
827
|
for i, future in enumerate(futures):
|
@@ -846,16 +838,12 @@ def download_hourly_func(var, time_s, time_e=None, lon_min=0, lon_max=359.92, la
|
|
846
838
|
progress.update(task, advance=1, description=f'[cyan]Downloading... {i+1}/{total_num}')
|
847
839
|
else:
|
848
840
|
# 并行方式
|
849
|
-
if num_workers > 10:
|
850
|
-
print('The number of workers is too large!')
|
851
|
-
print('In order to avoid the server being blocked, the number of workers is set to 10')
|
852
|
-
num_workers = 10
|
853
841
|
with ThreadPoolExecutor(max_workers=num_workers) as executor:
|
854
842
|
futures = [executor.submit(download_task, var, new_time_list[i], time_list[int(min(len(time_list), int(i*ftimes+ftimes-1)))], lon_min, lon_max, lat_min, lat_max, depth, level, store_path, dataset_name, version_name, check) for i in range(total_num)]
|
855
843
|
for i, future in enumerate(futures):
|
856
844
|
future.add_done_callback(lambda _: progress.update(task, advance=1, description=f'[cyan]Downloading... {i+1}/{total_num}'))
|
857
845
|
else:
|
858
|
-
print('Please ensure the time_s is
|
846
|
+
print('Please ensure the time_s is no more than time_e')
|
859
847
|
|
860
848
|
|
861
849
|
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):
|
@@ -923,6 +911,19 @@ def download(var, time_s, time_e=None, lon_min=0, lon_max=359.92, lat_min=-80, l
|
|
923
911
|
else:
|
924
912
|
os.makedirs(str(store_path), exist_ok=True)
|
925
913
|
|
914
|
+
if num_workers is not None:
|
915
|
+
num_workers = max(min(num_workers, 10), 1)
|
916
|
+
|
917
|
+
time_s = str(time_s)
|
918
|
+
if len(time_s) == 8:
|
919
|
+
time_s += '00'
|
920
|
+
if time_e is None:
|
921
|
+
time_e = time_s[:]
|
922
|
+
else:
|
923
|
+
time_e = str(time_e)
|
924
|
+
if len(time_e) == 8:
|
925
|
+
time_e += '21'
|
926
|
+
|
926
927
|
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)
|
927
928
|
|
928
929
|
|
@@ -7,7 +7,7 @@ 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=
|
10
|
+
oafuncs/oa_down/hycom_3hourly.py,sha256=fSTAdHhWWTm7X_yx2RFg61FBvvJ6eROC9IANdcR20Wc,56524
|
11
11
|
oafuncs/oa_down/literature.py,sha256=dT3-7-beEzQ9mTP8LNV9Gf3q5Z1Pqqjc6FOS010HZeQ,17833
|
12
12
|
oafuncs/oa_down/refs_pdf.py,sha256=lgGKO2gQ0hRjuaBYOLeBgksJB_KXYpFcXMDwMQeYVkI,18719
|
13
13
|
oafuncs/oa_sign/__init__.py,sha256=QKqTFrJDFK40C5uvk48GlRRbGFzO40rgkYwu6dYxatM,563
|
@@ -16,8 +16,8 @@ oafuncs/oa_sign/ocean.py,sha256=xrW-rWD7xBWsB5PuCyEwQ1Q_RDKq2KCLz-LOONHgldU,5932
|
|
16
16
|
oafuncs/oa_sign/scientific.py,sha256=a4JxOBgm9vzNZKpJ_GQIQf7cokkraV5nh23HGbmTYKw,5064
|
17
17
|
oafuncs/oa_tool/__init__.py,sha256=IKOlqpWlb4cMDCtq2VKR_RTxQHDNqR_vfqqsOsp_lKQ,466
|
18
18
|
oafuncs/oa_tool/email.py,sha256=4lJxV_KUzhxgLYfVwYTqp0qxRugD7fvsZkXDe5WkUKo,3052
|
19
|
-
oafuncs-0.0.
|
20
|
-
oafuncs-0.0.
|
21
|
-
oafuncs-0.0.
|
22
|
-
oafuncs-0.0.
|
23
|
-
oafuncs-0.0.
|
19
|
+
oafuncs-0.0.71.dist-info/LICENSE.txt,sha256=rMtLpVg8sKiSlwClfR9w_Dd_5WubTQgoOzE2PDFxzs4,1074
|
20
|
+
oafuncs-0.0.71.dist-info/METADATA,sha256=jIn5cFJMOTb0iQTdegUEdOIuFAqj5b8DhYh65RUYH7E,22531
|
21
|
+
oafuncs-0.0.71.dist-info/WHEEL,sha256=pxeNX5JdtCe58PUSYP9upmc7jdRPgvT0Gm9kb1SHlVw,109
|
22
|
+
oafuncs-0.0.71.dist-info/top_level.txt,sha256=bgC35QkXbN4EmPHEveg_xGIZ5i9NNPYWqtJqaKqTPsQ,8
|
23
|
+
oafuncs-0.0.71.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|