oafuncs 0.0.64__py2.py3-none-any.whl → 0.0.65__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.
@@ -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-29 19:00:47
7
+ LastEditTime: 2024-11-29 20:40:26
8
8
  FilePath: \\Python\\My_Funcs\\OAFuncs\\oafuncs\\oa_down\\hycom_3hourly.py
9
9
  Description:
10
10
  EditPlatform: vscode
@@ -515,7 +515,7 @@ def clear_existing_file(file_full_path):
515
515
 
516
516
  def check_existing_file(file_full_path):
517
517
  if os.path.exists(file_full_path):
518
- print(f'{file_full_path} exists')
518
+ print(f'[bold #FFA54F]{file_full_path} exists')
519
519
  return True
520
520
  else:
521
521
  print(f'{file_full_path} does not exist')
@@ -620,6 +620,7 @@ def dlownload_file(target_url, store_path, file_name, check=False):
620
620
  download_success = False
621
621
  request_times = 0
622
622
  filename = Path(store_path) / file_name
623
+
623
624
  if check:
624
625
  if check_existing_file(filename):
625
626
  return
@@ -639,9 +640,10 @@ def dlownload_file(target_url, store_path, file_name, check=False):
639
640
  with open(filename, 'wb') as f:
640
641
  f.write(response.content)
641
642
  # print(f'\r文件 {filename} 下载成功', end="")
642
- print(f'[bold green]文件 {filename} 下载成功')
643
643
  # query_ncfile_time(filename) # 这个函数在linux上目前会出问题
644
- download_success = True
644
+ if os.path.exists(filename):
645
+ download_success = True
646
+ print(f'[bold green]文件 {filename} 下载成功')
645
647
 
646
648
  except requests.exceptions.HTTPError as errh:
647
649
  print(f"Http Error: {errh}")
@@ -1145,67 +1147,67 @@ def how_to_use():
1145
1147
 
1146
1148
 
1147
1149
  if __name__ == '__main__':
1148
- time_s, time_e = '2018010512', '2018010800'
1149
- merge_name = '201801'
1150
- root_path = r'I:\hycom_data_2018'
1151
- location_dict = {'west': 115, 'east': 130, 'south': 33, 'north': 45}
1150
+ # help(hycom3h.download)
1151
+ time_s, time_e = '2018010100', '2024103121'
1152
+ merge_name = '2018_010300-020100'
1153
+ root_path = r'G:\Data\HYCOM\3hourly'
1154
+ location_dict = {'west': 105, 'east': 130, 'south': 15, 'north': 45}
1152
1155
  download_dict = {
1153
1156
  'water_u': {'simple_name': 'u', 'download': 1},
1154
1157
  'water_v': {'simple_name': 'v', 'download': 1},
1155
1158
  'surf_el': {'simple_name': 'ssh', 'download': 1},
1156
1159
  'water_temp': {'simple_name': 'temp', 'download': 1},
1157
1160
  'salinity': {'simple_name': 'salt', 'download': 1},
1161
+ 'water_u_bottom': {'simple_name': 'u_b', 'download': 0},
1162
+ 'water_v_bottom': {'simple_name': 'v_b', 'download': 0},
1163
+ 'water_temp_bottom': {'simple_name': 'temp_b', 'download': 0},
1164
+ 'salinity_bottom': {'simple_name': 'salt_b', 'download': 0},
1158
1165
  }
1159
1166
 
1160
1167
  var_list = []
1161
1168
  for var_name in download_dict.keys():
1162
1169
  if download_dict[var_name]['download'] == 1:
1163
- var_list.append(download_dict[var_name]['simple_name'])
1170
+ var_list.append(var_name)
1164
1171
 
1165
1172
  # set depth or level, only one can be True
1166
1173
  # if you wanna download all depth or level, set both False
1167
- set_depth, depth = False, 0 # 0-4000 meters
1168
- set_level, level = False, 1 # 1-40 levels
1169
- num_workers = 1
1174
+ depth = None # or 0-4000 meters
1175
+ level = None # or 1-40 levels
1176
+ num_workers = 2
1177
+
1170
1178
  check = True
1171
1179
 
1172
- download_switch = True
1173
- combine_switch = False
1174
-
1175
- single_var = True
1176
-
1177
- def download_var(var):
1178
- if set_depth:
1179
- download(var=var, time_s=time_s, time_e=time_e, store_path=Path(root_path)/var, lon_min=location_dict[
1180
- 'west'], lon_max=location_dict['east'], lat_min=location_dict['south'], lat_max=location_dict['north'], depth=depth, num_workers=num_workers, check=check)
1181
- elif set_level:
1182
- download(var=var, time_s=time_s, time_e=time_e, store_path=Path(root_path)/var, lon_min=location_dict[
1183
- 'west'], lon_max=location_dict['east'], lat_min=location_dict['south'], lat_max=location_dict['north'], level=level, num_workers=num_workers, check=check)
1184
- else:
1185
- download(var=var, time_s=time_s, time_e=time_e, store_path=Path(root_path)/var, lon_min=location_dict[
1186
- 'west'], lon_max=location_dict['east'], lat_min=location_dict['south'], lat_max=location_dict['north'], num_workers=num_workers, check=check)
1180
+ download_switch, single_var = True, False
1181
+ combine_switch = True
1182
+ copy_switch, copy_dir = True, r'G:\Data\HYCOM\3hourly'
1187
1183
 
1188
1184
  if download_switch:
1189
1185
  if single_var:
1190
- # single var
1191
1186
  for var_name in var_list:
1192
- download_var(var_name)
1187
+ 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)
1193
1188
  else:
1194
- # multiple var
1195
- download_var(var_list)
1196
-
1197
- # draw_time_range(r'I:\Delete')
1198
-
1199
- """ if combine_switch:
1200
- time_list = get_time_list(time_s, time_e, 3)
1201
- for var_name in download_dict.keys():
1202
- var = download_dict[var_name]['simple_name']
1203
- if_download = download_dict[var_name]['download']
1204
- if if_download == 0:
1205
- continue
1189
+ 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)
1190
+
1191
+ """ if combine_switch or copy_switch:
1192
+ time_list = get_hour_list(time_s, time_e, 3)
1193
+ for var_name in var_list:
1206
1194
  file_list = []
1207
- for time_str in time_list:
1208
- file_list.append(
1209
- Path(root_path)/var/f'HYCOM_{var_name}_{time_str}.nc')
1210
- merge5nc(file_list, var_name, 'time',
1211
- Path(root_path)/var/f'HYCOM_{var_name}_{merge_name}.nc') """
1195
+ if single_var:
1196
+ for time_str in time_list:
1197
+ file_list.append(Path(root_path)/f'HYCOM_{var_name}_{time_str}.nc')
1198
+ merge_path_name = Path(root_path)/f'HYCOM_{var_name}_{merge_name}.nc'
1199
+ else:
1200
+ # 如果混合,需要看情况获取文件列表
1201
+ fname = ''
1202
+ if var_name in ['water_u', 'water_v', 'water_u_bottom', 'water_v_bottom'] or var_name in ['u', 'v', 'u_b', 'v_b']:
1203
+ fname = 'uv3z'
1204
+ elif var_name in ['water_temp', 'salinity', 'water_temp_bottom', 'salinity_bottom'] or var_name in ['temp', 'salt', 'temp_b', 'salt_b']:
1205
+ fname = 'ts3z'
1206
+ elif var_name in ['surf_el'] or var_name in ['ssh']:
1207
+ fname = 'surf_el'
1208
+ for time_str in time_list:
1209
+ file_list.append(Path(root_path)/f'HYCOM_{fname}_{time_str}.nc')
1210
+ if combine_switch:
1211
+ merge5nc(file_list, var_name, 'time', merge_path_name)
1212
+ if copy_switch:
1213
+ copy_file(merge_path_name, copy_dir) """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oafuncs
3
- Version: 0.0.64
3
+ Version: 0.0.65
4
4
  Summary: My short description for my project.
5
5
  Home-page: https://github.com/Industry-Pays/OAFuncs
6
6
  Author: Kun Liu
@@ -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=zfecVo9DQ0oT_V1DuRpddOyU_1JEj3b_rXBCeDwsWPw,65097
10
+ oafuncs/oa_down/hycom_3hourly.py,sha256=MU1QEVrINKXdFLlZf1RDjPO97HMKym8JvxYnyDphslA,65626
11
11
  oafuncs/oa_down/hycom_3hourly_wholeday.py,sha256=bEl-hdSPJqN_9IaJIF-la0jEPw-sbCaKnciPirsWgP8,62598
12
12
  oafuncs/oa_down/literature.py,sha256=dT3-7-beEzQ9mTP8LNV9Gf3q5Z1Pqqjc6FOS010HZeQ,17833
13
13
  oafuncs/oa_down/refs_pdf.py,sha256=wr1sIYO2FUBJTn-K79NylbRUvCAFaee6_fQljxSI_Q8,17979
@@ -17,8 +17,8 @@ oafuncs/oa_sign/ocean.py,sha256=xrW-rWD7xBWsB5PuCyEwQ1Q_RDKq2KCLz-LOONHgldU,5932
17
17
  oafuncs/oa_sign/scientific.py,sha256=a4JxOBgm9vzNZKpJ_GQIQf7cokkraV5nh23HGbmTYKw,5064
18
18
  oafuncs/oa_tool/__init__.py,sha256=IKOlqpWlb4cMDCtq2VKR_RTxQHDNqR_vfqqsOsp_lKQ,466
19
19
  oafuncs/oa_tool/email.py,sha256=7EX3VkD8TxYAKPLOuC_yS104p9zbKilZlGfkVa2C6BQ,2947
20
- oafuncs-0.0.64.dist-info/LICENSE.txt,sha256=rMtLpVg8sKiSlwClfR9w_Dd_5WubTQgoOzE2PDFxzs4,1074
21
- oafuncs-0.0.64.dist-info/METADATA,sha256=P9tmhxGoarpgYD3NAGg5AmDcOmlxmH3MUuHMOuJmTv8,22378
22
- oafuncs-0.0.64.dist-info/WHEEL,sha256=pxeNX5JdtCe58PUSYP9upmc7jdRPgvT0Gm9kb1SHlVw,109
23
- oafuncs-0.0.64.dist-info/top_level.txt,sha256=bgC35QkXbN4EmPHEveg_xGIZ5i9NNPYWqtJqaKqTPsQ,8
24
- oafuncs-0.0.64.dist-info/RECORD,,
20
+ oafuncs-0.0.65.dist-info/LICENSE.txt,sha256=rMtLpVg8sKiSlwClfR9w_Dd_5WubTQgoOzE2PDFxzs4,1074
21
+ oafuncs-0.0.65.dist-info/METADATA,sha256=H-VYmc1lwVJwwY1Z3RYL-48Ei0jOLZSJLTVxU_1J_N4,22378
22
+ oafuncs-0.0.65.dist-info/WHEEL,sha256=pxeNX5JdtCe58PUSYP9upmc7jdRPgvT0Gm9kb1SHlVw,109
23
+ oafuncs-0.0.65.dist-info/top_level.txt,sha256=bgC35QkXbN4EmPHEveg_xGIZ5i9NNPYWqtJqaKqTPsQ,8
24
+ oafuncs-0.0.65.dist-info/RECORD,,