oafuncs 0.0.98.34__py3-none-any.whl → 0.0.98.36__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_cmap.py +1 -1
- oafuncs/oa_data.py +3 -2
- oafuncs/oa_down/hycom_3hourly.py +24 -4
- oafuncs/oa_draw.py +21 -4
- oafuncs/oa_nc.py +2 -1
- {oafuncs-0.0.98.34.dist-info → oafuncs-0.0.98.36.dist-info}/METADATA +1 -1
- {oafuncs-0.0.98.34.dist-info → oafuncs-0.0.98.36.dist-info}/RECORD +10 -11
- oafuncs/oa_down/hycom_3hourly_proxy.py +0 -1213
- {oafuncs-0.0.98.34.dist-info → oafuncs-0.0.98.36.dist-info}/WHEEL +0 -0
- {oafuncs-0.0.98.34.dist-info → oafuncs-0.0.98.36.dist-info}/licenses/LICENSE.txt +0 -0
- {oafuncs-0.0.98.34.dist-info → oafuncs-0.0.98.36.dist-info}/top_level.txt +0 -0
oafuncs/oa_cmap.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
from typing import List, Optional, Union
|
2
2
|
|
3
3
|
import matplotlib as mpl
|
4
|
-
import matplotlib.pyplot as plt
|
5
4
|
import numpy as np
|
6
5
|
import random
|
7
6
|
|
@@ -24,6 +23,7 @@ def show(
|
|
24
23
|
colormaps : Union[str, mpl.colors.Colormap, List[Union[str, mpl.colors.Colormap]]]
|
25
24
|
单个颜色映射或颜色映射列表;可以是名称字符串或颜色映射对象。
|
26
25
|
"""
|
26
|
+
import matplotlib.pyplot as plt
|
27
27
|
if not isinstance(colormaps, list):
|
28
28
|
colormaps = [colormaps]
|
29
29
|
|
oafuncs/oa_data.py
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
from typing import Any, List, Union
|
2
2
|
|
3
3
|
import numpy as np
|
4
|
-
import salem
|
5
4
|
import xarray as xr
|
6
5
|
from rich import print
|
7
|
-
|
6
|
+
|
8
7
|
|
9
8
|
__all__ = ["interp_along_dim", "interp_2d", "ensure_list", "mask_shapefile"]
|
10
9
|
|
@@ -59,6 +58,7 @@ def interp_along_dim(
|
|
59
58
|
>>> result = interp_along_dim(target_coordinates, source_coordinates, source_data)
|
60
59
|
>>> print(result) # Expected output: [20.0, 30.0]
|
61
60
|
"""
|
61
|
+
from scipy.interpolate import interp1d
|
62
62
|
target_coordinates = np.asarray(target_coordinates)
|
63
63
|
if target_coordinates.ndim != 1:
|
64
64
|
raise ValueError("[red]target_coordinates must be a 1D array.[/red]")
|
@@ -177,6 +177,7 @@ def mask_shapefile(
|
|
177
177
|
>>> print(masked_data) # Expected output: Masked DataArray
|
178
178
|
|
179
179
|
"""
|
180
|
+
import salem
|
180
181
|
try:
|
181
182
|
shp_f = salem.read_shapefile(shapefile_path)
|
182
183
|
data_da = xr.DataArray(data_array, coords=[("latitude", latitudes), ("longitude", longitudes)])
|
oafuncs/oa_down/hycom_3hourly.py
CHANGED
@@ -98,6 +98,18 @@ def _get_initial_data():
|
|
98
98
|
data_info["hourly"]["dataset"]["GLBu0.08"]["version"]["93.0"]["classification"] = "var_different"
|
99
99
|
data_info["hourly"]["dataset"]["GLBy0.08"]["version"]["93.0"]["classification"] = "var_year_different"
|
100
100
|
data_info["hourly"]["dataset"]["ESPC_D"]["version"]["V02"]["classification"] = "single_var_year_different"
|
101
|
+
|
102
|
+
# lon lat
|
103
|
+
data_info["hourly"]["dataset"]["GLBv0.08"]["version"]["53.X"]["lonlat"] = {'lon_min': -180.00, 'lon_max': 179.92, 'lat_min': -80.0, 'lat_max': 90.0}
|
104
|
+
data_info["hourly"]["dataset"]["GLBv0.08"]["version"]["56.3"]["lonlat"] = {'lon_min': -180.00, 'lon_max': 179.92, 'lat_min': -80.0, 'lat_max': 90.0}
|
105
|
+
data_info["hourly"]["dataset"]["GLBv0.08"]["version"]["57.2"]["lonlat"] = {'lon_min': -180.00, 'lon_max': 179.92, 'lat_min': -80.0, 'lat_max': 90.0}
|
106
|
+
data_info["hourly"]["dataset"]["GLBv0.08"]["version"]["92.8"]["lonlat"] = {'lon_min': 0.00, 'lon_max': 359.92, 'lat_min': -80.0, 'lat_max': 90.0}
|
107
|
+
data_info["hourly"]["dataset"]["GLBv0.08"]["version"]["57.7"]["lonlat"] = {'lon_min': -180.00, 'lon_max': 179.92, 'lat_min': -80.0, 'lat_max': 90.0}
|
108
|
+
data_info["hourly"]["dataset"]["GLBv0.08"]["version"]["92.9"]["lonlat"] = {'lon_min': 0.00, 'lon_max': 359.92, 'lat_min': -80.0, 'lat_max': 90.0}
|
109
|
+
data_info["hourly"]["dataset"]["GLBv0.08"]["version"]["93.0"]["lonlat"] = {'lon_min': 0.00, 'lon_max': 359.92, 'lat_min': -80.0, 'lat_max': 90.0}
|
110
|
+
data_info["hourly"]["dataset"]["GLBu0.08"]["version"]["93.0"]["lonlat"] = {'lon_min': 0.00, 'lon_max': 359.92, 'lat_min': -80.0, 'lat_max': 80.0}
|
111
|
+
data_info["hourly"]["dataset"]["GLBy0.08"]["version"]["93.0"]["lonlat"] = {'lon_min': 0.00, 'lon_max': 359.92, 'lat_min': -80.0, 'lat_max': 90.0}
|
112
|
+
data_info["hourly"]["dataset"]["ESPC_D"]["version"]["V02"]["lonlat"] = {'lon_min': 0.00, 'lon_max': 359.92, 'lat_min': -80.0, 'lat_max': 90.0}
|
101
113
|
|
102
114
|
# download info
|
103
115
|
# base url
|
@@ -851,6 +863,14 @@ def _get_submit_url_var(var, depth, level_num, lon_min, lon_max, lat_min, lat_ma
|
|
851
863
|
which_mode = "level"
|
852
864
|
else:
|
853
865
|
which_mode = "full"
|
866
|
+
if lon_min == 0.0:
|
867
|
+
lon_min = data_info["hourly"]["dataset"][dataset_name]["version"][version_name]["lonlat"]["lon_min"]
|
868
|
+
if lon_max == 359.92:
|
869
|
+
lon_max = data_info["hourly"]["dataset"][dataset_name]["version"][version_name]["lonlat"]["lon_max"]
|
870
|
+
if lat_min == -80.0:
|
871
|
+
lat_min = data_info["hourly"]["dataset"][dataset_name]["version"][version_name]["lonlat"]["lat_min"]
|
872
|
+
if lat_max == 90.0:
|
873
|
+
lat_max = data_info["hourly"]["dataset"][dataset_name]["version"][version_name]["lonlat"]["lat_max"]
|
854
874
|
query_dict = _get_query_dict(var, lon_min, lon_max, lat_min, lat_max, download_time, download_time_end, which_mode, depth, level_num)
|
855
875
|
submit_url = _get_submit_url(dataset_name, version_name, var, ymdh_str, query_dict)
|
856
876
|
return submit_url
|
@@ -1194,10 +1214,10 @@ if __name__ == "__main__":
|
|
1194
1214
|
"start_time": "2018010100",
|
1195
1215
|
"end_time": "2019063000",
|
1196
1216
|
"output_dir": r"G:\Data\HYCOM\china_sea\hourly_24",
|
1197
|
-
"lon_min": 105,
|
1198
|
-
"lon_max": 135,
|
1199
|
-
"lat_min": 10,
|
1200
|
-
"lat_max": 45,
|
1217
|
+
# "lon_min": 105,
|
1218
|
+
# "lon_max": 135,
|
1219
|
+
# "lat_min": 10,
|
1220
|
+
# "lat_max": 45,
|
1201
1221
|
"workers": 1,
|
1202
1222
|
"overwrite": False,
|
1203
1223
|
"depth": None,
|
oafuncs/oa_draw.py
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
import warnings
|
2
2
|
|
3
3
|
import cartopy.crs as ccrs
|
4
|
-
import cartopy.feature as cfeature
|
5
|
-
import cv2
|
6
4
|
import matplotlib as mpl
|
7
5
|
import matplotlib.pyplot as plt
|
8
6
|
import numpy as np
|
9
|
-
from cartopy.mpl.ticker import LatitudeFormatter, LongitudeFormatter
|
10
7
|
from rich import print
|
11
8
|
|
12
9
|
__all__ = ["fig_minus", "gif", "movie", "setup_map", "MidpointNormalize"]
|
@@ -74,7 +71,7 @@ def fig_minus(x_axis: plt.Axes = None, y_axis: plt.Axes = None, colorbar: mpl.co
|
|
74
71
|
elif colorbar is not None:
|
75
72
|
colorbar.set_ticklabels(out_ticks)
|
76
73
|
|
77
|
-
print("[green]Axis tick labels updated successfully.[/green]")
|
74
|
+
# print("[green]Axis tick labels updated successfully.[/green]")
|
78
75
|
return target_object
|
79
76
|
|
80
77
|
|
@@ -148,6 +145,7 @@ def movie(image_files: list[str], output_video_path: str, fps: int) -> None:
|
|
148
145
|
print("[red]Error:[/red] Image files list is empty.")
|
149
146
|
return
|
150
147
|
|
148
|
+
import cv2
|
151
149
|
# Read first image to get frame dimensions
|
152
150
|
try:
|
153
151
|
frame = cv2.imread(image_files[0])
|
@@ -235,6 +233,7 @@ def setup_map(
|
|
235
233
|
from matplotlib import ticker as mticker
|
236
234
|
|
237
235
|
# Add map features
|
236
|
+
import cartopy.feature as cfeature
|
238
237
|
if show_land:
|
239
238
|
axes.add_feature(cfeature.LAND, facecolor=land_color)
|
240
239
|
if show_ocean:
|
@@ -245,6 +244,7 @@ def setup_map(
|
|
245
244
|
axes.add_feature(cfeature.BORDERS, linewidth=coastline_linewidth, linestyle=":")
|
246
245
|
|
247
246
|
# Setup coordinate formatting
|
247
|
+
from cartopy.mpl.ticker import LatitudeFormatter, LongitudeFormatter
|
248
248
|
lon_formatter = LongitudeFormatter(zero_direction_label=False, number_format=f".{tick_decimals}f")
|
249
249
|
lat_formatter = LatitudeFormatter(number_format=f".{tick_decimals}f")
|
250
250
|
|
@@ -344,6 +344,23 @@ class MidpointNormalize(mpl.colors.Normalize):
|
|
344
344
|
result = np.clip(result, 0, 1)
|
345
345
|
|
346
346
|
return np.ma.masked_array(result)
|
347
|
+
|
348
|
+
def ticks(self, num_ticks: int = 7) -> np.ndarray:
|
349
|
+
"""Generate ticks for the normalization range, centered around vcenter."""
|
350
|
+
if self.vmin is None or self.vmax is None:
|
351
|
+
raise ValueError("vmin and vmax must be set to generate ticks.")
|
352
|
+
|
353
|
+
if num_ticks % 2 == 0:
|
354
|
+
num_ticks += 1
|
355
|
+
|
356
|
+
num_points_side = (num_ticks - 1) // 2 + 1
|
357
|
+
|
358
|
+
negative_ticks = np.linspace(self.vmin, self.vcenter, num_points_side)[:-1]
|
359
|
+
positive_ticks = np.linspace(self.vcenter, self.vmax, num_points_side)[1:]
|
360
|
+
|
361
|
+
ticks = np.concatenate([negative_ticks, [self.vcenter], positive_ticks])
|
362
|
+
|
363
|
+
return ticks
|
347
364
|
|
348
365
|
def inverse(self, value: np.ndarray) -> np.ndarray:
|
349
366
|
y, x = [self.vmin, self.vcenter, self.vmax], [0, 0.5, 1]
|
oafuncs/oa_nc.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
from typing import List, Optional, Tuple, Union
|
3
3
|
|
4
|
-
import netCDF4 as nc
|
5
4
|
import numpy as np
|
6
5
|
import xarray as xr
|
7
6
|
from rich import print
|
@@ -112,6 +111,7 @@ def rename(
|
|
112
111
|
Example:
|
113
112
|
>>> rename('file.nc', 'old_var', 'new_var')
|
114
113
|
"""
|
114
|
+
import netCDF4 as nc
|
115
115
|
try:
|
116
116
|
with nc.Dataset(file_path, "r+") as dataset:
|
117
117
|
if old_name not in dataset.variables and old_name not in dataset.dimensions:
|
@@ -159,6 +159,7 @@ def check(
|
|
159
159
|
return False
|
160
160
|
|
161
161
|
try:
|
162
|
+
import netCDF4 as nc
|
162
163
|
with nc.Dataset(file_path, "r") as ds_verify:
|
163
164
|
if not ds_verify.variables:
|
164
165
|
if print_messages:
|
@@ -1,11 +1,11 @@
|
|
1
1
|
oafuncs/__init__.py,sha256=T_-VtnWWllV3Q91twT5Yt2sUapeA051QbPNnBxmg9nw,1456
|
2
|
-
oafuncs/oa_cmap.py,sha256=
|
3
|
-
oafuncs/oa_data.py,sha256=
|
2
|
+
oafuncs/oa_cmap.py,sha256=h9QrOSwbzZJXuS2pjFZkJtck1bq9itPY1natIuIRB3s,13884
|
3
|
+
oafuncs/oa_data.py,sha256=u4H1ZazQf2jmGx3IAiaGxLjQHY9cQEMizRIaTQW4UiE,8075
|
4
4
|
oafuncs/oa_date.py,sha256=aU2wVIWXyWoRiSQ9dg8sHvShFTxw86RrgbV3Q6tDjD4,6841
|
5
|
-
oafuncs/oa_draw.py,sha256=
|
5
|
+
oafuncs/oa_draw.py,sha256=UnUyOcr6KHtEWCZG0TCnHFW0jrjkAW9XWZoUDcSs6oI,14386
|
6
6
|
oafuncs/oa_file.py,sha256=fLb0gRhq2AiPl-5ASDHMrx6Z267FmhqNcTV7CdCxTdI,16934
|
7
7
|
oafuncs/oa_help.py,sha256=0J5VaZX-cB0c090KxgmktQJBc0o00FsY-4wB8l5y00k,4178
|
8
|
-
oafuncs/oa_nc.py,sha256=
|
8
|
+
oafuncs/oa_nc.py,sha256=mKNxQ9jPxfRH7xINyrX7tBhitG5gmOKm6Dn7stk5mdw,15279
|
9
9
|
oafuncs/oa_python.py,sha256=xYMQnM0cGq9xUCtcoMpnN0LG5Rc_s94tai5nC6CNJ3E,4831
|
10
10
|
oafuncs/oa_tool.py,sha256=Zuaoa92wll0YqXGRf0oF_c7wlATtl7bvjCuLt9VLXp0,8046
|
11
11
|
oafuncs/_data/hycom.png,sha256=MadKs6Gyj5n9-TOu7L4atQfTXtF9dvN9w-tdU9IfygI,10945710
|
@@ -22,8 +22,7 @@ oafuncs/_script/plot_dataset.py,sha256=QrA4vOCzWbAJp3hf5YYzgIRUZdJB5_ugepgyT_Yfn
|
|
22
22
|
oafuncs/_script/replace_file_content.py,sha256=wIwvaISFNYWG58BLZHZP9ZgbC5OhoZ-cpR3y25U1EUM,5601
|
23
23
|
oafuncs/oa_down/User_Agent-list.txt,sha256=pHaMlElMvZ8TG4vf4BqkZYKqe0JIGkr4kCN0lM1Y9FQ,514295
|
24
24
|
oafuncs/oa_down/__init__.py,sha256=IT6oTqaxuV_mC6AwBut0HtkmnVtEu1MyX0x0oS7TKoA,218
|
25
|
-
oafuncs/oa_down/hycom_3hourly.py,sha256=
|
26
|
-
oafuncs/oa_down/hycom_3hourly_proxy.py,sha256=xNAPSuTP0fvBAGMv16eeB2TCvNhS2cJq3M5F4GUmPN8,54180
|
25
|
+
oafuncs/oa_down/hycom_3hourly.py,sha256=dFXSC_5o-Dic616KrLXir4tEHvCiZt8vGKPEYpXFMmA,57356
|
27
26
|
oafuncs/oa_down/idm.py,sha256=vAhRjt_Sb-rKhzFShmSf29QcFTqsHpHXCvTSD1uSXyQ,1455
|
28
27
|
oafuncs/oa_down/literature.py,sha256=7Qy5OphcjdRwY2uZ5hmmgK36U_QtVmEUSW0vQaxihC8,10960
|
29
28
|
oafuncs/oa_down/read_proxy.py,sha256=HQpr-Mwn0Z8ICAuf63NUUY9p05E_uNWyWmOK46-73Ec,2866
|
@@ -38,8 +37,8 @@ oafuncs/oa_sign/__init__.py,sha256=JSx1fcWpmNhQBvX_Bmq3xysfSkkFMrjbJASxV_V6aqE,1
|
|
38
37
|
oafuncs/oa_sign/meteorological.py,sha256=3MSjy7HTcvz2zsITkjUMr_0Y027Gas1LFE9pk99990k,6110
|
39
38
|
oafuncs/oa_sign/ocean.py,sha256=3uYEzaq-27yVy23IQoqy-clhWu1I_fhPFBAQyT-OF4M,5562
|
40
39
|
oafuncs/oa_sign/scientific.py,sha256=moIl2MEY4uitbXoD596JmXookXGQtQsS-8_1NBBTx84,4689
|
41
|
-
oafuncs-0.0.98.
|
42
|
-
oafuncs-0.0.98.
|
43
|
-
oafuncs-0.0.98.
|
44
|
-
oafuncs-0.0.98.
|
45
|
-
oafuncs-0.0.98.
|
40
|
+
oafuncs-0.0.98.36.dist-info/licenses/LICENSE.txt,sha256=rMtLpVg8sKiSlwClfR9w_Dd_5WubTQgoOzE2PDFxzs4,1074
|
41
|
+
oafuncs-0.0.98.36.dist-info/METADATA,sha256=N3OWTsj1i-CBXIdbbgy7WZJvEb5mNsHUl2SkoilJ3Oo,4326
|
42
|
+
oafuncs-0.0.98.36.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
43
|
+
oafuncs-0.0.98.36.dist-info/top_level.txt,sha256=bgC35QkXbN4EmPHEveg_xGIZ5i9NNPYWqtJqaKqTPsQ,8
|
44
|
+
oafuncs-0.0.98.36.dist-info/RECORD,,
|