oafuncs 0.0.98.6__tar.gz → 0.0.98.7__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.
Files changed (50) hide show
  1. {oafuncs-0.0.98.6/oafuncs.egg-info → oafuncs-0.0.98.7}/PKG-INFO +2 -1
  2. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_down/hycom_3hourly.py +23 -12
  3. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_draw.py +65 -0
  4. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7/oafuncs.egg-info}/PKG-INFO +2 -1
  5. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs.egg-info/requires.txt +1 -0
  6. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/setup.py +2 -1
  7. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/LICENSE.txt +0 -0
  8. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/MANIFEST.in +0 -0
  9. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/README.md +0 -0
  10. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/__init__.py +0 -0
  11. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/_data/hycom.png +0 -0
  12. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/_data/oafuncs.png +0 -0
  13. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/_script/cprogressbar.py +0 -0
  14. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/_script/email.py +0 -0
  15. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/_script/netcdf_merge.py +0 -0
  16. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/_script/netcdf_modify.py +0 -0
  17. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/_script/netcdf_write.py +0 -0
  18. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/_script/parallel.py +0 -0
  19. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/_script/parallel_test.py +0 -0
  20. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/_script/plot_dataset.py +0 -0
  21. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/_script/replace_file_content.py +0 -0
  22. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_cmap.py +0 -0
  23. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_data.py +0 -0
  24. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_date.py +0 -0
  25. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_down/User_Agent-list.txt +0 -0
  26. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_down/__init__.py +0 -0
  27. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_down/hycom_3hourly_proxy.py +0 -0
  28. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_down/idm.py +0 -0
  29. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_down/literature.py +0 -0
  30. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_down/read_proxy.py +0 -0
  31. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_down/test_ua.py +0 -0
  32. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_down/user_agent.py +0 -0
  33. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_file.py +0 -0
  34. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_help.py +0 -0
  35. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_model/__init__.py +0 -0
  36. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_model/roms/__init__.py +0 -0
  37. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_model/roms/test.py +0 -0
  38. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_model/wrf/__init__.py +0 -0
  39. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_model/wrf/little_r.py +0 -0
  40. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_nc.py +0 -0
  41. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_python.py +0 -0
  42. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_sign/__init__.py +0 -0
  43. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_sign/meteorological.py +0 -0
  44. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_sign/ocean.py +0 -0
  45. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_sign/scientific.py +0 -0
  46. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs/oa_tool.py +0 -0
  47. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs.egg-info/SOURCES.txt +0 -0
  48. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs.egg-info/dependency_links.txt +0 -0
  49. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/oafuncs.egg-info/top_level.txt +0 -0
  50. {oafuncs-0.0.98.6 → oafuncs-0.0.98.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oafuncs
3
- Version: 0.0.98.6
3
+ Version: 0.0.98.7
4
4
  Summary: Oceanic and Atmospheric Functions
5
5
  Home-page: https://github.com/Industry-Pays/OAFuncs
6
6
  Author: Kun Liu
@@ -27,6 +27,7 @@ Requires-Dist: requests
27
27
  Requires-Dist: bs4
28
28
  Requires-Dist: httpx
29
29
  Requires-Dist: matplotlib
30
+ Requires-Dist: opencv-python
30
31
  Requires-Dist: netCDF4
31
32
  Requires-Dist: xlrd
32
33
  Requires-Dist: geopandas
@@ -19,7 +19,6 @@ import logging
19
19
  import os
20
20
  import random
21
21
  import re
22
- import time
23
22
  import warnings
24
23
  from concurrent.futures import ThreadPoolExecutor, as_completed
25
24
  from pathlib import Path
@@ -728,9 +727,15 @@ class _HycomDownloader:
728
727
 
729
728
  elapsed = datetime.datetime.now() - start
730
729
  # logging.info(f"File {file_name} downloaded, Time: {elapsed}")
731
- logging.info(f"Saving {file_name}, Time: {elapsed}")
730
+ logging.info(f"Saving {file_name} ...")
731
+ logging.info(f"Timing {elapsed} ...")
732
732
  self.count["success"] += 1
733
733
  count_dict["success"] += 1
734
+ # 输出一条绿色的成功消息
735
+ timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S,%f")[:-3]
736
+ # print(f"{timestamp} - INFO - ", end="") # Output log prefix without newline
737
+ # print("[bold #3dfc40]Success")
738
+ print(f"{timestamp} - RESULT - [bold #3dfc40]Success")
734
739
  return
735
740
 
736
741
  except Exception as e:
@@ -744,6 +749,10 @@ class _HycomDownloader:
744
749
  logging.error(f"Giving up on {file_name}")
745
750
  self.count["fail"] += 1
746
751
  count_dict["fail"] += 1
752
+ timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S,%f")[:-3]
753
+ # print(f"{timestamp} - ERROR - ", end="")
754
+ # print("[bold red]Failed")
755
+ print(f"{timestamp} - RESULT - [bold red]Failure")
747
756
  return
748
757
 
749
758
  async def run(self):
@@ -757,8 +766,7 @@ class _HycomDownloader:
757
766
 
758
767
  def _download_file(target_url, store_path, file_name, cover=False):
759
768
  save_path = Path(store_path) / file_name
760
- file_name_split = file_name.split("_")
761
- file_name_split = file_name_split[:-1]
769
+ file_name_split = file_name.split("_")[:-1]
762
770
  same_file = "_".join(file_name_split) + "*nc"
763
771
 
764
772
  if match_time is not None:
@@ -775,10 +783,12 @@ def _download_file(target_url, store_path, file_name, cover=False):
775
783
  print(f"[bold green]{file_name} is correct")
776
784
  return
777
785
 
778
- if not cover and os.path.exists(save_path):
779
- print(f"[bold #FFA54F]{save_path} exists, skipping ...")
780
- count_dict["skip"] += 1
781
- return
786
+ # if not cover and os.path.exists(save_path):
787
+ # print(f"[bold #FFA54F]{save_path} exists, skipping ...")
788
+ # count_dict["skip"] += 1
789
+ # return
790
+ if cover and os.path.exists(save_path):
791
+ _clear_existing_file(save_path)
782
792
 
783
793
  if same_file not in fsize_dict.keys():
784
794
  check_nc(save_path, delete_if_invalid=True, print_messages=False)
@@ -786,6 +796,7 @@ def _download_file(target_url, store_path, file_name, cover=False):
786
796
  get_mean_size = _get_mean_size_move(same_file, save_path)
787
797
 
788
798
  if _check_existing_file(save_path, get_mean_size):
799
+ print(f"[bold #FFA54F]{save_path} exists, skipping ...")
789
800
  count_dict["skip"] += 1
790
801
  return
791
802
 
@@ -794,12 +805,12 @@ def _download_file(target_url, store_path, file_name, cover=False):
794
805
  if not use_idm:
795
806
  python_downloader = _HycomDownloader([(target_url, save_path)])
796
807
  asyncio.run(python_downloader.run())
797
- time.sleep(3 + random.uniform(0, 10))
808
+ # time.sleep(3 + random.uniform(0, 10))
798
809
  else:
799
810
  idm_downloader(target_url, store_path, file_name, given_idm_engine)
800
811
  idm_download_list.append(save_path)
801
812
  # print(f"[bold #3dfc40]File [bold #dfff73]{save_path} [#3dfc40]has been submit to IDM for downloading")
802
- time.sleep(3 + random.uniform(0, 10))
813
+ # time.sleep(3 + random.uniform(0, 10))
803
814
 
804
815
 
805
816
  def _check_hour_is_valid(ymdh_str):
@@ -890,7 +901,7 @@ def _prepare_url_to_download(var, lon_min=0, lon_max=359.92, lat_min=-80, lat_ma
890
901
  else:
891
902
  if download_time < "2024081012":
892
903
  varlist = [_ for _ in var]
893
- for key, value in pbar(var_group.items(), description=f"Var_group {download_time} ->", total=len(var_group), cmap="bwr", next_line=True):
904
+ for key, value in pbar(var_group.items(), description=f"Var Group {download_time} ->", total=len(var_group), color="#d7feb9", next_line=True):
894
905
  current_group = []
895
906
  for v in varlist:
896
907
  if v in value:
@@ -912,7 +923,7 @@ def _prepare_url_to_download(var, lon_min=0, lon_max=359.92, lat_min=-80, lat_ma
912
923
  file_name = f"HYCOM_{key}_{download_time}-{download_time_end}.nc"
913
924
  _download_file(submit_url, store_path, file_name, cover)
914
925
  else:
915
- for v in pbar(var,description=f'Var {download_time} ->', total=len(var), cmap='bwr', next_line=True):
926
+ for v in pbar(var, description=f"Var {download_time} ->", total=len(var), color="#d7feb9", next_line=True):
916
927
  submit_url = _get_submit_url_var(v, depth, level_num, lon_min, lon_max, lat_min, lat_max, dataset_name, version_name, download_time, download_time_end)
917
928
  file_name = f"HYCOM_{variable_info[v]['var_name']}_{download_time}.nc"
918
929
  if download_time_end is not None:
@@ -15,6 +15,7 @@ Python Version: 3.11
15
15
 
16
16
  import warnings
17
17
 
18
+ import cv2
18
19
  import cartopy.crs as ccrs
19
20
  import cartopy.feature as cfeature
20
21
  import matplotlib as mpl
@@ -132,6 +133,70 @@ def gif(image_paths: list[str], output_gif_name: str, frame_duration: float = 20
132
133
  return
133
134
 
134
135
 
136
+ def movie(image_files, output_video_path, fps):
137
+ """
138
+ 从图像文件列表创建视频。
139
+
140
+ Args:
141
+ image_files (list): 按顺序排列的图像文件路径列表。
142
+ output_video_path (str): 输出视频文件的路径 (例如 'output.mp4')。
143
+ fps (int): 视频的帧率。
144
+ """
145
+ if not image_files:
146
+ print("错误:图像文件列表为空。")
147
+ return
148
+
149
+ # 读取第一张图片以获取帧尺寸
150
+ try:
151
+ frame = cv2.imread(image_files[0])
152
+ if frame is None:
153
+ print(f"错误:无法读取第一张图片:{image_files[0]}")
154
+ return
155
+ height, width, layers = frame.shape
156
+ size = (width, height)
157
+ print(f"视频尺寸设置为:{size}")
158
+ except Exception as e:
159
+ print(f"读取第一张图片时出错:{e}")
160
+ return
161
+
162
+ # 选择编解码器并创建VideoWriter对象
163
+ # 对于 .mp4 文件,常用 'mp4v' 或 'avc1'
164
+ # 对于 .avi 文件,常用 'XVID' 或 'MJPG'
165
+ fourcc = cv2.VideoWriter_fourcc(*"mp4v") # 或者尝试 'avc1', 'XVID' 等
166
+ out = cv2.VideoWriter(output_video_path, fourcc, fps, size)
167
+
168
+ if not out.isOpened():
169
+ print(f"错误:无法打开视频文件进行写入:{output_video_path}")
170
+ print("请检查编解码器 ('fourcc') 是否受支持以及路径是否有效。")
171
+ return
172
+
173
+ print(f"开始将图像写入视频:{output_video_path}...")
174
+ for i, filename in enumerate(image_files):
175
+ try:
176
+ frame = cv2.imread(filename)
177
+ if frame is None:
178
+ print(f"警告:跳过无法读取的图像:{filename}")
179
+ continue
180
+ # 确保帧尺寸与初始化时相同,如果需要可以调整大小
181
+ current_height, current_width, _ = frame.shape
182
+ if (current_width, current_height) != size:
183
+ print(f"警告:图像 {filename} 的尺寸 ({current_width}, {current_height}) 与初始尺寸 {size} 不同。将调整大小。")
184
+ frame = cv2.resize(frame, size)
185
+
186
+ out.write(frame)
187
+ # 打印进度(可选)
188
+ if (i + 1) % 50 == 0 or (i + 1) == len(image_files):
189
+ print(f"已处理 {i + 1}/{len(image_files)} 帧")
190
+
191
+ except Exception as e:
192
+ print(f"处理图像 {filename} 时出错:{e}")
193
+ continue # 跳过有问题的帧
194
+
195
+ # 释放资源
196
+ out.release()
197
+ print(f"视频创建成功:{output_video_path}")
198
+
199
+
135
200
  def add_lonlat_unit(longitudes: list[float] = None, latitudes: list[float] = None, decimal_places: int = 2) -> tuple[list[str], list[str]] | list[str]:
136
201
  """Convert longitude and latitude values to formatted string labels.
137
202
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oafuncs
3
- Version: 0.0.98.6
3
+ Version: 0.0.98.7
4
4
  Summary: Oceanic and Atmospheric Functions
5
5
  Home-page: https://github.com/Industry-Pays/OAFuncs
6
6
  Author: Kun Liu
@@ -27,6 +27,7 @@ Requires-Dist: requests
27
27
  Requires-Dist: bs4
28
28
  Requires-Dist: httpx
29
29
  Requires-Dist: matplotlib
30
+ Requires-Dist: opencv-python
30
31
  Requires-Dist: netCDF4
31
32
  Requires-Dist: xlrd
32
33
  Requires-Dist: geopandas
@@ -8,6 +8,7 @@ requests
8
8
  bs4
9
9
  httpx
10
10
  matplotlib
11
+ opencv-python
11
12
  netCDF4
12
13
  xlrd
13
14
  geopandas
@@ -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/03/13
21
- VERSION = "0.0.98.6"
21
+ VERSION = "0.0.98.7"
22
22
 
23
23
  # What packages are required for this module to be executed?
24
24
  REQUIRED = [
@@ -37,6 +37,7 @@ REQUIRED = [
37
37
  "httpx",
38
38
  # ------ Picture ------
39
39
  "matplotlib",
40
+ "opencv-python", # cv2
40
41
  # ------ File ------
41
42
  "netCDF4",
42
43
  "xlrd",
File without changes
File without changes
File without changes
File without changes
File without changes