shancx 1.9.33.226__tar.gz → 1.9.33.228__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.
- {shancx-1.9.33.226 → shancx-1.9.33.228}/PKG-INFO +1 -1
- {shancx-1.9.33.226 → shancx-1.9.33.228}/setup.py +1 -1
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Read.py +26 -27
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx.egg-info/PKG-INFO +1 -1
- {shancx-1.9.33.226 → shancx-1.9.33.228}/README.md +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/setup.cfg +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/3D/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/Class.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/CudaPrefetcher1.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/Fake_image.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/Hsml.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/L2Loss.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/MetricTracker.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/Normalize.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/OptimizerWScheduler.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/Rmageresize.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/Savemodel.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/SmoothL1_losses.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/Tqdm.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/checknan.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/dsalgor.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/iouJU.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/mask.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/psnr.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/ssim.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/structural_similarity.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Algo/tool.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Calmetrics/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Calmetrics/calmetrics.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Calmetrics/calmetricsmatrixLib.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Calmetrics/rmseR2score.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Clip/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Cmd.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Config_.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Df/DataFrame.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Df/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Df/tool.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Diffm/Psamples.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Diffm/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Diffm/test.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Doc/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/E/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Fillmiss/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Fillmiss/imgidwJU.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Fillmiss/imgidwLatLonJU.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Gpu/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/H9/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/H9/ahi_read_hsd.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/H9/ahisearchtable.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/H9/geometry.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Hug/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Inst.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Lib.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Mos/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/NN/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/NN/chainMul.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Path1.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Plot/GlobMap.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Plot/Gray2RGB.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Plot/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Plot/draw_day_CR_PNG.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Plot/exam.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Plot/plotGlobal.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Plot/radarNmc.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Plot/single_china_map.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Point.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/QC.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/RdPzl/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Resize.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/SN/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Time/GetTime.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Time/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Time/timeCycle.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Time/tool.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Train/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Train/makelist.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Train/multiGpu.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Train/prepare.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/Train/renet50.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/ZR.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/args.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/bak.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/cmp.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/df2database.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/geosProj.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/getResponse.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/info.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/netdfJU.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/npz.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/sendM.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/tensBoard/__init__.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx/wait.py +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx.egg-info/SOURCES.txt +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx.egg-info/dependency_links.txt +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx.egg-info/requires.txt +0 -0
- {shancx-1.9.33.226 → shancx-1.9.33.228}/shancx.egg-info/top_level.txt +0 -0
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
|
|
1
2
|
import xarray as xr
|
|
2
3
|
import numpy as np
|
|
3
4
|
import gzip
|
|
4
5
|
import tempfile
|
|
5
6
|
import os
|
|
7
|
+
backend_kwargs = {
|
|
8
|
+
'errors': 'ignore',
|
|
9
|
+
# 'errors': 'raise'
|
|
10
|
+
# 'errors': 'warn'
|
|
11
|
+
}
|
|
6
12
|
def getGrib(filepath):
|
|
7
13
|
tmp_path = filepath
|
|
8
14
|
if filepath.endswith('.gz'):
|
|
@@ -11,7 +17,7 @@ def getGrib(filepath):
|
|
|
11
17
|
tmp.write(f.read())
|
|
12
18
|
tmp_path = tmp.name
|
|
13
19
|
try:
|
|
14
|
-
ds = xr.open_dataset(tmp_path, engine='cfgrib')
|
|
20
|
+
ds = xr.open_dataset(tmp_path, engine='cfgrib', backend_kwargs=backend_kwargs)
|
|
15
21
|
var_name = list(ds.data_vars)[0]
|
|
16
22
|
data_var = ds[var_name]
|
|
17
23
|
data_values = np.where(data_var.values < -900, np.nan, data_var.values)
|
|
@@ -32,16 +38,15 @@ def getGrib(filepath):
|
|
|
32
38
|
lons = var.longitude.values
|
|
33
39
|
break
|
|
34
40
|
else:
|
|
35
|
-
raise ValueError("未找到经纬度坐标")
|
|
36
|
-
lat_range = (float(np.nanmin(lats)), float(np.nanmax(lats)))
|
|
37
|
-
lon_range = (float(np.nanmin(lons)), float(np.nanmax(lons)))
|
|
41
|
+
raise ValueError("未找到经纬度坐标")
|
|
38
42
|
return {
|
|
39
|
-
'data':
|
|
43
|
+
'data': data_values,
|
|
40
44
|
'lats': lats,
|
|
41
45
|
'lons': lons
|
|
42
46
|
}
|
|
43
47
|
finally:
|
|
44
48
|
os.unlink(tmp_path)
|
|
49
|
+
|
|
45
50
|
"""
|
|
46
51
|
input_Path = './Composite_00.50_20250701-010044.grib2.gz'
|
|
47
52
|
result = getGrib(input_Path)
|
|
@@ -52,26 +57,7 @@ import numpy as np
|
|
|
52
57
|
import pandas as pd
|
|
53
58
|
def readGrib(file_path, target_param=None):
|
|
54
59
|
try:
|
|
55
|
-
with pygrib.open(file_path) as grbs:
|
|
56
|
-
file_path= file_path
|
|
57
|
-
if filepath.endswith('.gz'):
|
|
58
|
-
with gzip.open(filepath, 'rb') as f:
|
|
59
|
-
with tempfile.NamedTemporaryFile(suffix='.grib2', delete=False) as tmp:
|
|
60
|
-
tmp.write(f.read())
|
|
61
|
-
file_path = tmp.name
|
|
62
|
-
if target_param:
|
|
63
|
-
try:
|
|
64
|
-
grb = grbs.select(shortName=target_param)[0]
|
|
65
|
-
except:
|
|
66
|
-
try:
|
|
67
|
-
grb = grbs.select(parameterName=target_param)[0]
|
|
68
|
-
except:
|
|
69
|
-
raise ValueError(f"未找到参数: {target_param}")
|
|
70
|
-
else:
|
|
71
|
-
grb = grbs[1]
|
|
72
|
-
data = grb.values
|
|
73
|
-
lats, lons = grb.latlons()
|
|
74
|
-
#data2
|
|
60
|
+
with pygrib.open(file_path) as grbs:
|
|
75
61
|
field_info = []
|
|
76
62
|
for grb in grbs:
|
|
77
63
|
field_info.append({
|
|
@@ -84,6 +70,18 @@ def readGrib(file_path, target_param=None):
|
|
|
84
70
|
'units': getattr(grb, 'units', 'N/A'),
|
|
85
71
|
'shape': grb.values.shape
|
|
86
72
|
})
|
|
73
|
+
if target_param:
|
|
74
|
+
try:
|
|
75
|
+
grb = grbs.select(shortName=target_param)[0]
|
|
76
|
+
except:
|
|
77
|
+
try:
|
|
78
|
+
grb = grbs.select(parameterName=target_param)[0]
|
|
79
|
+
except:
|
|
80
|
+
raise ValueError(f"未找到参数: {target_param}")
|
|
81
|
+
else:
|
|
82
|
+
grb = grbs[1]
|
|
83
|
+
data = grb.values
|
|
84
|
+
lats, lons = grb.latlons()
|
|
87
85
|
return {
|
|
88
86
|
'data': data,
|
|
89
87
|
'lats': lats,
|
|
@@ -92,13 +90,13 @@ def readGrib(file_path, target_param=None):
|
|
|
92
90
|
'parameterName': grb.parameterName,
|
|
93
91
|
'level': grb.level,
|
|
94
92
|
'validDate': grb.validDate,
|
|
95
|
-
'units': grb.units
|
|
96
|
-
"field_info":field_info
|
|
93
|
+
'units': grb.units
|
|
97
94
|
}
|
|
98
95
|
}
|
|
99
96
|
except Exception as e:
|
|
100
97
|
print(f"GRIB读取错误: {str(e)}")
|
|
101
98
|
return None
|
|
99
|
+
"""
|
|
102
100
|
if __name__ == "__main__":
|
|
103
101
|
path = "/mnt/wtx_weather_forecast/CMA_DATA/NAFP/EC/C1D/2024/2024112720/ECMFC1D_PRTY_1_2024112712_GLB_1_2.grib2"
|
|
104
102
|
result = readGrib(path)
|
|
@@ -107,5 +105,6 @@ if __name__ == "__main__":
|
|
|
107
105
|
print("经度范围:", np.min(result['lons']), "~", np.max(result['lons']))
|
|
108
106
|
print("纬度范围:", np.min(result['lats']), "~", np.max(result['lats']))
|
|
109
107
|
print("参数单位:", result['metadata']['units'])
|
|
108
|
+
"""
|
|
110
109
|
|
|
111
110
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|