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