oafuncs 0.0.98.8__tar.gz → 0.0.98.9__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.8/oafuncs.egg-info → oafuncs-0.0.98.9}/PKG-INFO +1 -1
  2. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/_script/netcdf_merge.py +15 -4
  3. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_data.py +3 -2
  4. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_date.py +21 -2
  5. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9/oafuncs.egg-info}/PKG-INFO +1 -1
  6. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/setup.py +1 -1
  7. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/LICENSE.txt +0 -0
  8. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/MANIFEST.in +0 -0
  9. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/README.md +0 -0
  10. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/__init__.py +0 -0
  11. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/_data/hycom.png +0 -0
  12. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/_data/oafuncs.png +0 -0
  13. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/_script/cprogressbar.py +0 -0
  14. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/_script/email.py +0 -0
  15. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/_script/netcdf_modify.py +0 -0
  16. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/_script/netcdf_write.py +0 -0
  17. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/_script/parallel.py +0 -0
  18. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/_script/parallel_test.py +0 -0
  19. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/_script/plot_dataset.py +0 -0
  20. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/_script/replace_file_content.py +0 -0
  21. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_cmap.py +0 -0
  22. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_down/User_Agent-list.txt +0 -0
  23. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_down/__init__.py +0 -0
  24. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_down/hycom_3hourly.py +0 -0
  25. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_down/hycom_3hourly_proxy.py +0 -0
  26. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_down/idm.py +0 -0
  27. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_down/literature.py +0 -0
  28. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_down/read_proxy.py +0 -0
  29. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_down/test_ua.py +0 -0
  30. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_down/user_agent.py +0 -0
  31. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_draw.py +0 -0
  32. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_file.py +0 -0
  33. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_help.py +0 -0
  34. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_model/__init__.py +0 -0
  35. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_model/roms/__init__.py +0 -0
  36. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_model/roms/test.py +0 -0
  37. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_model/wrf/__init__.py +0 -0
  38. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_model/wrf/little_r.py +0 -0
  39. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_nc.py +0 -0
  40. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_python.py +0 -0
  41. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_sign/__init__.py +0 -0
  42. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_sign/meteorological.py +0 -0
  43. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_sign/ocean.py +0 -0
  44. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_sign/scientific.py +0 -0
  45. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs/oa_tool.py +0 -0
  46. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs.egg-info/SOURCES.txt +0 -0
  47. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs.egg-info/dependency_links.txt +0 -0
  48. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs.egg-info/requires.txt +0 -0
  49. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/oafuncs.egg-info/top_level.txt +0 -0
  50. {oafuncs-0.0.98.8 → oafuncs-0.0.98.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oafuncs
3
- Version: 0.0.98.8
3
+ Version: 0.0.98.9
4
4
  Summary: Oceanic and Atmospheric Functions
5
5
  Home-page: https://github.com/Industry-Pays/OAFuncs
6
6
  Author: Kun Liu
@@ -1,9 +1,12 @@
1
1
  import os
2
2
  from typing import List, Optional, Union
3
- from dask.diagnostics import ProgressBar
3
+
4
+ import numpy as np
4
5
  import xarray as xr
6
+ from dask.diagnostics import ProgressBar
5
7
  from oafuncs import pbar
6
8
 
9
+
7
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:
8
11
  """
9
12
  Description:
@@ -22,7 +25,7 @@ def merge_nc(file_list: Union[str, List[str]], var_name: Optional[Union[str, Lis
22
25
  merge(file_list, var_name=['u', 'v'], dim_name='time', target_filename='merged.nc')
23
26
  merge(file_list, var_name=None, dim_name='time', target_filename='merged.nc')
24
27
  """
25
-
28
+
26
29
  if target_filename is None:
27
30
  target_filename = "merged.nc"
28
31
 
@@ -55,11 +58,19 @@ def merge_nc(file_list: Union[str, List[str]], var_name: Optional[Union[str, Lis
55
58
  if dim_name in data_var.dims:
56
59
  merged_data.setdefault(var, []).append(data_var)
57
60
  elif var not in merged_data:
58
- merged_data[var] = data_var.fillna(0) # 用0填充NaN值
61
+ # 判断类型,时间类型用NaT填充
62
+ if np.issubdtype(data_var.dtype, np.datetime64):
63
+ merged_data[var] = data_var.fillna(np.datetime64("NaT"))
64
+ else:
65
+ merged_data[var] = data_var.fillna(0)
59
66
 
60
67
  for var in pbar(merged_data, description="Merging variables", color="#9b45d1"):
61
68
  if isinstance(merged_data[var], list):
62
- merged_data[var] = xr.concat(merged_data[var], dim=dim_name).fillna(0)
69
+ # 判断类型,时间类型用NaT填充
70
+ if np.issubdtype(merged_data[var][0].dtype, np.datetime64):
71
+ merged_data[var] = xr.concat(merged_data[var], dim=dim_name).fillna(np.datetime64("NaT"))
72
+ else:
73
+ merged_data[var] = xr.concat(merged_data[var], dim=dim_name).fillna(0)
63
74
  # 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}")
64
75
 
65
76
  # 修改写入数据部分,支持压缩并设置基数和比例因子
@@ -190,8 +190,9 @@ def interp_2d(
190
190
  for t_index in range(t):
191
191
  for z_index in range(z):
192
192
  paras.append((new_src_data[t_index, z_index], origin_points, target_points, interpolation_method, target_shape))
193
- excutor = PEx()
194
- result = excutor.run(_interp_single_worker, paras)
193
+
194
+ with PEx() as excutor:
195
+ result = excutor.run(_interp_single_worker, paras)
195
196
 
196
197
  return np.squeeze(np.array(result))
197
198
 
@@ -64,7 +64,6 @@ def hour_range(start_time: str, end_time: str, hour_interval: int = 6) -> List[s
64
64
  date_s += datetime.timedelta(hours=hour_interval)
65
65
  return date_list
66
66
 
67
-
68
67
  def adjust_time(base_time: str, time_delta: int, delta_unit: str = "hours", output_format: Optional[str] = None) -> str:
69
68
  """
70
69
  Adjust a given base time by adding a specified time delta.
@@ -89,7 +88,12 @@ def adjust_time(base_time: str, time_delta: int, delta_unit: str = "hours", outp
89
88
  """
90
89
  # Normalize the input time to "yyyymmddHHMMSS" format
91
90
  time_format = "%Y%m%d%H%M%S"
91
+ if len(base_time) == 4:
92
+ base_time += "0101"
93
+ elif len(base_time) == 6:
94
+ base_time += "01"
92
95
  base_time = base_time.ljust(14, "0")
96
+
93
97
  time_obj = datetime.datetime.strptime(base_time, time_format)
94
98
 
95
99
  # Add the specified amount of time
@@ -101,8 +105,19 @@ def adjust_time(base_time: str, time_delta: int, delta_unit: str = "hours", outp
101
105
  time_obj += datetime.timedelta(hours=time_delta)
102
106
  elif delta_unit == "days":
103
107
  time_obj += datetime.timedelta(days=time_delta)
108
+ elif delta_unit == "months":
109
+ # Handle month addition separately
110
+ month = time_obj.month - 1 + time_delta
111
+ year = time_obj.year + month // 12
112
+ month = month % 12 + 1
113
+ day = min(time_obj.day, month_days(year, month))
114
+ time_obj = time_obj.replace(year=year, month=month, day=day)
115
+ elif delta_unit == "years":
116
+ # Handle year addition separately
117
+ year = time_obj.year + time_delta
118
+ time_obj = time_obj.replace(year=year)
104
119
  else:
105
- raise ValueError("Invalid time unit. Use 'seconds', 'minutes', 'hours', or 'days'.")
120
+ raise ValueError("Invalid time unit. Use 'seconds', 'minutes', 'hours', 'days', 'months', or 'years'.")
106
121
 
107
122
  # Determine the output format
108
123
  if output_format:
@@ -116,6 +131,10 @@ def adjust_time(base_time: str, time_delta: int, delta_unit: str = "hours", outp
116
131
  default_format = "%Y%m%d%H"
117
132
  elif delta_unit == "days":
118
133
  default_format = "%Y%m%d"
134
+ elif delta_unit == "months":
135
+ default_format = "%Y%m"
136
+ elif delta_unit == "years":
137
+ default_format = "%Y"
119
138
  return time_obj.strftime(default_format)
120
139
 
121
140
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oafuncs
3
- Version: 0.0.98.8
3
+ Version: 0.0.98.9
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.8"
21
+ VERSION = "0.0.98.9"
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