oafuncs 0.0.98.12__tar.gz → 0.0.98.13__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.12/oafuncs.egg-info → oafuncs-0.0.98.13}/PKG-INFO +1 -1
  2. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/_script/netcdf_merge.py +6 -31
  3. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_tool.py +6 -1
  4. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13/oafuncs.egg-info}/PKG-INFO +1 -1
  5. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/setup.py +1 -1
  6. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/LICENSE.txt +0 -0
  7. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/MANIFEST.in +0 -0
  8. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/README.md +0 -0
  9. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/__init__.py +0 -0
  10. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/_data/hycom.png +0 -0
  11. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/_data/oafuncs.png +0 -0
  12. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/_script/cprogressbar.py +0 -0
  13. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/_script/email.py +0 -0
  14. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/_script/netcdf_modify.py +0 -0
  15. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/_script/netcdf_write.py +0 -0
  16. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/_script/parallel.py +0 -0
  17. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/_script/parallel_test.py +0 -0
  18. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/_script/plot_dataset.py +0 -0
  19. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/_script/replace_file_content.py +0 -0
  20. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_cmap.py +0 -0
  21. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_data.py +0 -0
  22. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_date.py +0 -0
  23. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_down/User_Agent-list.txt +0 -0
  24. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_down/__init__.py +0 -0
  25. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_down/hycom_3hourly.py +0 -0
  26. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_down/hycom_3hourly_proxy.py +0 -0
  27. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_down/idm.py +0 -0
  28. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_down/literature.py +0 -0
  29. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_down/read_proxy.py +0 -0
  30. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_down/test_ua.py +0 -0
  31. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_down/user_agent.py +0 -0
  32. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_draw.py +0 -0
  33. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_file.py +0 -0
  34. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_help.py +0 -0
  35. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_model/__init__.py +0 -0
  36. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_model/roms/__init__.py +0 -0
  37. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_model/roms/test.py +0 -0
  38. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_model/wrf/__init__.py +0 -0
  39. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_model/wrf/little_r.py +0 -0
  40. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_nc.py +0 -0
  41. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_python.py +0 -0
  42. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_sign/__init__.py +0 -0
  43. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_sign/meteorological.py +0 -0
  44. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_sign/ocean.py +0 -0
  45. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs/oa_sign/scientific.py +0 -0
  46. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs.egg-info/SOURCES.txt +0 -0
  47. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs.egg-info/dependency_links.txt +0 -0
  48. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs.egg-info/requires.txt +0 -0
  49. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/oafuncs.egg-info/top_level.txt +0 -0
  50. {oafuncs-0.0.98.12 → oafuncs-0.0.98.13}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oafuncs
3
- Version: 0.0.98.12
3
+ Version: 0.0.98.13
4
4
  Summary: Oceanic and Atmospheric Functions
5
5
  Home-page: https://github.com/Industry-Pays/OAFuncs
6
6
  Author: Kun Liu
@@ -3,10 +3,8 @@ from typing import List, Optional, Union
3
3
 
4
4
  import numpy as np
5
5
  import xarray as xr
6
- from dask.diagnostics import ProgressBar
7
6
 
8
7
  from oafuncs import pbar
9
- from oafuncs._script.netcdf_write import _calculate_scale_and_offset # 新增导入
10
8
 
11
9
 
12
10
  def merge_nc(file_list: Union[str, List[str]], var_name: Optional[Union[str, List[str]]] = None, dim_name: Optional[str] = None, target_filename: Optional[str] = None) -> None:
@@ -27,6 +25,7 @@ def merge_nc(file_list: Union[str, List[str]], var_name: Optional[Union[str, Lis
27
25
  merge(file_list, var_name=['u', 'v'], dim_name='time', target_filename='merged.nc')
28
26
  merge(file_list, var_name=None, dim_name='time', target_filename='merged.nc')
29
27
  """
28
+ from oafuncs._script.netcdf_write import save_to_nc
30
29
 
31
30
  if target_filename is None:
32
31
  target_filename = "merged.nc"
@@ -53,7 +52,7 @@ def merge_nc(file_list: Union[str, List[str]], var_name: Optional[Union[str, Lis
53
52
  # 初始化合并数据字典
54
53
  merged_data = {}
55
54
 
56
- for i, file in pbar(enumerate(file_list), description="Reading files", color="#f8bbd0", total=len(file_list)):
55
+ for i, file in pbar(enumerate(file_list), description="Reading files", total=len(file_list)):
57
56
  with xr.open_dataset(file) as ds:
58
57
  for var in var_names:
59
58
  data_var = ds[var]
@@ -66,48 +65,24 @@ def merge_nc(file_list: Union[str, List[str]], var_name: Optional[Union[str, Lis
66
65
  else:
67
66
  merged_data[var] = data_var.fillna(0)
68
67
 
69
- for var in pbar(merged_data, description="Merging variables", color="#9b45d1"):
68
+ for var in pbar(merged_data, description="Merging variables"):
70
69
  if isinstance(merged_data[var], list):
71
70
  # 判断类型,时间类型用NaT填充
72
71
  if np.issubdtype(merged_data[var][0].dtype, np.datetime64):
73
72
  merged_data[var] = xr.concat(merged_data[var], dim=dim_name).fillna(np.datetime64("NaT"))
74
73
  else:
75
74
  merged_data[var] = xr.concat(merged_data[var], dim=dim_name).fillna(0)
76
- # print(f"Variable '{var}' merged: min={merged_data[var].min().values:.3f}, max={merged_data[var].max().values:.3f}, mean={merged_data[var].mean().values:.3f}")
77
75
 
78
- # 修改写入数据部分,支持压缩并设置基数和比例因子
79
- # print("\nWriting data to file ...")
80
76
  if os.path.exists(target_filename):
81
77
  print("Warning: The target file already exists. Removing it ...")
82
78
  os.remove(target_filename)
83
-
84
- with xr.Dataset(merged_data) as merged_dataset:
85
- encoding = {}
86
- for var in merged_dataset.data_vars:
87
- data = merged_dataset[var].values
88
- if data.dtype.kind in {"i", "u", "f"}: # 仅对数值型数据进行压缩
89
- # 统一调用 netcdf_write 中的 scale/offset 计算
90
- scale_factor, add_offset = _calculate_scale_and_offset(data, n=16)
91
- encoding[var] = {
92
- "zlib": True,
93
- "complevel": 4,
94
- "dtype": "int16",
95
- "scale_factor": scale_factor,
96
- "add_offset": add_offset,
97
- "_FillValue": -32767,
98
- }
99
- else:
100
- encoding[var] = {"zlib": True, "complevel": 4}
101
-
102
- # 确保写入时不会因编码问题导致数据丢失
103
- # merged_dataset.to_netcdf(target_filename, encoding=encoding)
104
- delayed_write = merged_dataset.to_netcdf(target_filename, encoding=encoding, compute=False)
105
- with ProgressBar():
106
- delayed_write.compute()
79
+
80
+ save_to_nc(target_filename, merged_data)
107
81
 
108
82
  print(f'\nFile "{target_filename}" has been successfully created.')
109
83
 
110
84
 
85
+
111
86
  # Example usage
112
87
  if __name__ == "__main__":
113
88
  files_to_merge = ["file1.nc", "file2.nc", "file3.nc"]
@@ -2,6 +2,7 @@ import datetime
2
2
  import logging
3
3
  from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union
4
4
 
5
+
5
6
  from rich import print
6
7
 
7
8
  from ._script.parallel import ParallelExecutor
@@ -174,6 +175,8 @@ def pbar(
174
175
  """
175
176
  from ._script.cprogressbar import ColorProgressBar
176
177
  import random
178
+
179
+ # number = random.randint(1, 999)
177
180
 
178
181
  def _generate_random_color_hex():
179
182
  """Generate a random color in hexadecimal format."""
@@ -186,9 +189,11 @@ def pbar(
186
189
  color = _generate_random_color_hex()
187
190
 
188
191
  style = f"bold {color if color != 'None' else 'green'}"
192
+ # print(f"[{style}]~*^* {description} *^*~ -> {number:03d}[/{style}]")
189
193
  print(f"[{style}]~*^* {description} *^*~[/{style}]")
190
194
 
191
- description=''
195
+ # description=f'{number:03d}'
196
+ description = ""
192
197
 
193
198
  return ColorProgressBar(
194
199
  iterable=iterable,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oafuncs
3
- Version: 0.0.98.12
3
+ Version: 0.0.98.13
4
4
  Summary: Oceanic and Atmospheric Functions
5
5
  Home-page: https://github.com/Industry-Pays/OAFuncs
6
6
  Author: Kun Liu
@@ -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.12"
21
+ VERSION = "0.0.98.13"
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