shancx 1.8.92__py3-none-any.whl → 1.9.33.218__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.
- shancx/3D/__init__.py +25 -0
- shancx/Algo/Class.py +11 -0
- shancx/Algo/CudaPrefetcher1.py +112 -0
- shancx/Algo/Fake_image.py +24 -0
- shancx/Algo/Hsml.py +391 -0
- shancx/Algo/L2Loss.py +10 -0
- shancx/Algo/MetricTracker.py +132 -0
- shancx/Algo/Normalize.py +66 -0
- shancx/Algo/OptimizerWScheduler.py +38 -0
- shancx/Algo/Rmageresize.py +79 -0
- shancx/Algo/Savemodel.py +33 -0
- shancx/Algo/SmoothL1_losses.py +27 -0
- shancx/Algo/Tqdm.py +62 -0
- shancx/Algo/__init__.py +121 -0
- shancx/Algo/checknan.py +28 -0
- shancx/Algo/iouJU.py +83 -0
- shancx/Algo/mask.py +25 -0
- shancx/Algo/psnr.py +9 -0
- shancx/Algo/ssim.py +70 -0
- shancx/Algo/structural_similarity.py +308 -0
- shancx/Algo/tool.py +704 -0
- shancx/Calmetrics/__init__.py +97 -0
- shancx/Calmetrics/calmetrics.py +14 -0
- shancx/Calmetrics/calmetricsmatrixLib.py +147 -0
- shancx/Calmetrics/rmseR2score.py +35 -0
- shancx/Clip/__init__.py +50 -0
- shancx/Cmd.py +126 -0
- shancx/Config_.py +26 -0
- shancx/Df/DataFrame.py +11 -2
- shancx/Df/__init__.py +17 -0
- shancx/Df/tool.py +0 -0
- shancx/Diffm/Psamples.py +18 -0
- shancx/Diffm/__init__.py +0 -0
- shancx/Diffm/test.py +207 -0
- shancx/Doc/__init__.py +214 -0
- shancx/E/__init__.py +178 -152
- shancx/Fillmiss/__init__.py +0 -0
- shancx/Fillmiss/imgidwJU.py +46 -0
- shancx/Fillmiss/imgidwLatLonJU.py +82 -0
- shancx/Gpu/__init__.py +55 -0
- shancx/H9/__init__.py +126 -0
- shancx/H9/ahi_read_hsd.py +877 -0
- shancx/H9/ahisearchtable.py +298 -0
- shancx/H9/geometry.py +2439 -0
- shancx/Hug/__init__.py +81 -0
- shancx/Inst.py +22 -0
- shancx/Lib.py +31 -0
- shancx/Mos/__init__.py +37 -0
- shancx/NN/__init__.py +235 -106
- shancx/Path1.py +161 -0
- shancx/Plot/GlobMap.py +276 -116
- shancx/Plot/__init__.py +491 -1
- shancx/Plot/draw_day_CR_PNG.py +4 -21
- shancx/Plot/exam.py +116 -0
- shancx/Plot/plotGlobal.py +325 -0
- shancx/{radar_nmc.py → Plot/radarNmc.py} +4 -34
- shancx/{subplots_single_china_map.py → Plot/single_china_map.py} +1 -1
- shancx/Point.py +46 -0
- shancx/QC.py +223 -0
- shancx/RdPzl/__init__.py +32 -0
- shancx/Read.py +72 -0
- shancx/Resize.py +79 -0
- shancx/SN/__init__.py +62 -123
- shancx/Time/GetTime.py +9 -3
- shancx/Time/__init__.py +66 -1
- shancx/Time/timeCycle.py +302 -0
- shancx/Time/tool.py +0 -0
- shancx/Train/__init__.py +74 -0
- shancx/Train/makelist.py +187 -0
- shancx/Train/multiGpu.py +27 -0
- shancx/Train/prepare.py +161 -0
- shancx/Train/renet50.py +157 -0
- shancx/ZR.py +12 -0
- shancx/__init__.py +333 -262
- shancx/args.py +27 -0
- shancx/bak.py +768 -0
- shancx/df2database.py +62 -2
- shancx/geosProj.py +80 -0
- shancx/info.py +38 -0
- shancx/netdfJU.py +231 -0
- shancx/sendM.py +59 -0
- shancx/tensBoard/__init__.py +28 -0
- shancx/wait.py +246 -0
- {shancx-1.8.92.dist-info → shancx-1.9.33.218.dist-info}/METADATA +15 -5
- shancx-1.9.33.218.dist-info/RECORD +91 -0
- {shancx-1.8.92.dist-info → shancx-1.9.33.218.dist-info}/WHEEL +1 -1
- my_timer_decorator/__init__.py +0 -10
- shancx/Dsalgor/__init__.py +0 -19
- shancx/E/DFGRRIB.py +0 -30
- shancx/EN/DFGRRIB.py +0 -30
- shancx/EN/__init__.py +0 -148
- shancx/FileRead.py +0 -44
- shancx/Gray2RGB.py +0 -86
- shancx/M/__init__.py +0 -137
- shancx/MN/__init__.py +0 -133
- shancx/N/__init__.py +0 -131
- shancx/Plot/draw_day_CR_PNGUS.py +0 -206
- shancx/Plot/draw_day_CR_SVG.py +0 -275
- shancx/Plot/draw_day_pre_PNGUS.py +0 -205
- shancx/Plot/glob_nation_map.py +0 -116
- shancx/Plot/radar_nmc.py +0 -61
- shancx/Plot/radar_nmc_china_map_compare1.py +0 -50
- shancx/Plot/radar_nmc_china_map_f.py +0 -121
- shancx/Plot/radar_nmc_us_map_f.py +0 -128
- shancx/Plot/subplots_compare_devlop.py +0 -36
- shancx/Plot/subplots_single_china_map.py +0 -45
- shancx/S/__init__.py +0 -138
- shancx/W/__init__.py +0 -132
- shancx/WN/__init__.py +0 -132
- shancx/code.py +0 -331
- shancx/draw_day_CR_PNG.py +0 -200
- shancx/draw_day_CR_PNGUS.py +0 -206
- shancx/draw_day_CR_SVG.py +0 -275
- shancx/draw_day_pre_PNGUS.py +0 -205
- shancx/makenetCDFN.py +0 -42
- shancx/mkIMGSCX.py +0 -92
- shancx/netCDF.py +0 -130
- shancx/radar_nmc_china_map_compare1.py +0 -50
- shancx/radar_nmc_china_map_f.py +0 -125
- shancx/radar_nmc_us_map_f.py +0 -67
- shancx/subplots_compare_devlop.py +0 -36
- shancx/tool.py +0 -18
- shancx/user/H8mess.py +0 -317
- shancx/user/__init__.py +0 -137
- shancx/user/cinradHJN.py +0 -496
- shancx/user/examMeso.py +0 -293
- shancx/user/hjnDAAS.py +0 -26
- shancx/user/hjnFTP.py +0 -81
- shancx/user/hjnGIS.py +0 -320
- shancx/user/hjnGPU.py +0 -21
- shancx/user/hjnIDW.py +0 -68
- shancx/user/hjnKDTree.py +0 -75
- shancx/user/hjnLAPSTransform.py +0 -47
- shancx/user/hjnMiscellaneous.py +0 -182
- shancx/user/hjnProj.py +0 -162
- shancx/user/inotify.py +0 -41
- shancx/user/matplotlibMess.py +0 -87
- shancx/user/mkNCHJN.py +0 -623
- shancx/user/newTypeRadar.py +0 -492
- shancx/user/test.py +0 -6
- shancx/user/tlogP.py +0 -129
- shancx/util_log.py +0 -33
- shancx/wtx/H8mess.py +0 -315
- shancx/wtx/__init__.py +0 -151
- shancx/wtx/cinradHJN.py +0 -496
- shancx/wtx/colormap.py +0 -64
- shancx/wtx/examMeso.py +0 -298
- shancx/wtx/hjnDAAS.py +0 -26
- shancx/wtx/hjnFTP.py +0 -81
- shancx/wtx/hjnGIS.py +0 -330
- shancx/wtx/hjnGPU.py +0 -21
- shancx/wtx/hjnIDW.py +0 -68
- shancx/wtx/hjnKDTree.py +0 -75
- shancx/wtx/hjnLAPSTransform.py +0 -47
- shancx/wtx/hjnLog.py +0 -78
- shancx/wtx/hjnMiscellaneous.py +0 -201
- shancx/wtx/hjnProj.py +0 -161
- shancx/wtx/inotify.py +0 -41
- shancx/wtx/matplotlibMess.py +0 -87
- shancx/wtx/mkNCHJN.py +0 -613
- shancx/wtx/newTypeRadar.py +0 -492
- shancx/wtx/test.py +0 -6
- shancx/wtx/tlogP.py +0 -129
- shancx-1.8.92.dist-info/RECORD +0 -99
- /shancx/{Dsalgor → Algo}/dsalgor.py +0 -0
- {shancx-1.8.92.dist-info → shancx-1.9.33.218.dist-info}/top_level.txt +0 -0
shancx/makenetCDFN.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import xarray as xr
|
|
2
|
-
import numpy as np
|
|
3
|
-
def convert_longitude(nc_input_path, nc_output_path):
|
|
4
|
-
ds = xr.open_dataset(nc_input_path)
|
|
5
|
-
lon = 'lon'
|
|
6
|
-
if lon not in ds.coords:
|
|
7
|
-
raise ValueError("输入文件中没有'lon'坐标")
|
|
8
|
-
ds[lon] = xr.where(ds[lon] > 180, ds[lon] - 360, ds[lon])
|
|
9
|
-
ds = ds.sortby(lon)
|
|
10
|
-
ds = ds.sortby('lat', ascending=False)
|
|
11
|
-
ds.to_netcdf(nc_output_path)
|
|
12
|
-
print(f"成功将数据转换并保存到 {nc_output_path}")
|
|
13
|
-
convert_longitude('CMORPH2_0.25deg-30min_202410160100.RT.nc', 'CMORPH2_0.25deg-30min_202410160100.RT_N.nc')
|
|
14
|
-
|
|
15
|
-
import netCDF4 as nc
|
|
16
|
-
import numpy as np
|
|
17
|
-
with nc.Dataset(path) as dataNC:
|
|
18
|
-
hourlyPrecipRateGC = dataNC["hourlyPrecipRateGC"][:]
|
|
19
|
-
latArr = dataNC["Latitude"][:]
|
|
20
|
-
lonArr = dataNC["Longitude"][:]
|
|
21
|
-
latArr_flipped = latArr[::-1]
|
|
22
|
-
hourlyPrecipRateGC_flipped = hourlyPrecipRateGC[::-1, :]
|
|
23
|
-
|
|
24
|
-
with nc.Dataset(path) as dataNC:
|
|
25
|
-
ref = dataNC["var"][:][::-1] # 读取数据并翻转第一个维度(通常是纬度)
|
|
26
|
-
latArr = dataNC["lat"][:][::-1] # 翻转纬度数组
|
|
27
|
-
lonArr = dataNC["lon"][:] #
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
import netCDF4 as nc
|
|
31
|
-
with nc.Dataset(path) as dataNC:
|
|
32
|
-
# 翻转数据的纬度维度
|
|
33
|
-
ref = dataNC["var"][:][::-1] # 假设第一个维度是纬度
|
|
34
|
-
# 翻转纬度数组
|
|
35
|
-
latArr = dataNC["lat"][:][::-1]
|
|
36
|
-
# 经度转换:从 [0, 359] 转换为 [-179, 179]
|
|
37
|
-
lonArr = dataNC["lon"][:]
|
|
38
|
-
lonArr = ((lonArr + 180) % 360) - 180 # 将 [0, 359] 转换为 [-180, 180)
|
|
39
|
-
# 排序经度数组,并相应调整数据
|
|
40
|
-
lon_order = lonArr.argsort() # 获取排序索引
|
|
41
|
-
lonArr = lonArr[lon_order] # 按照索引重新排序经度数组
|
|
42
|
-
ref = ref[:, lon_order] # 重新排序数据的经度维度
|
shancx/mkIMGSCX.py
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import numpy as np
|
|
3
|
-
from matplotlib.colors import ListedColormap
|
|
4
|
-
import matplotlib.pyplot as plt
|
|
5
|
-
import datetime
|
|
6
|
-
cmp_hjnwtx={}
|
|
7
|
-
|
|
8
|
-
newcolorsNMC = np.array([
|
|
9
|
-
[68,157,237, 255],
|
|
10
|
-
[98,230,234, 255],
|
|
11
|
-
[104,249,82, 255],
|
|
12
|
-
[0,215,46, 255],
|
|
13
|
-
[0,143,27, 255],
|
|
14
|
-
[254,254,63, 255],
|
|
15
|
-
[231,192,48, 255],
|
|
16
|
-
[255,154,41, 255],
|
|
17
|
-
[255,19,27, 255],
|
|
18
|
-
[215,14,21, 255],
|
|
19
|
-
[193,11,18, 255],
|
|
20
|
-
[255,28,236, 255],
|
|
21
|
-
[152,15,177, 255],
|
|
22
|
-
[175,145,237, 255]])/255
|
|
23
|
-
cmp_hjnwtx["radar_nmc"] = ListedColormap(newcolorsNMC)
|
|
24
|
-
|
|
25
|
-
newcolorsNMC = np.array([
|
|
26
|
-
[68,157,237, 255],
|
|
27
|
-
[98,230,234, 255],
|
|
28
|
-
[104,249,82, 255],
|
|
29
|
-
[0,215,46, 255],
|
|
30
|
-
[0,143,27, 255],
|
|
31
|
-
[254,254,63, 255],
|
|
32
|
-
[231,192,48, 255],
|
|
33
|
-
[255,154,41, 255],
|
|
34
|
-
[255,19,27, 255],
|
|
35
|
-
[215,14,21, 255],
|
|
36
|
-
[193,11,18, 255],
|
|
37
|
-
[255,28,236, 255],
|
|
38
|
-
[152,15,177, 255],
|
|
39
|
-
[175,145,237, 255]])/255
|
|
40
|
-
cmp_hjnwtx["radar_moc"] = ListedColormap(newcolorsNMC)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
newcolorsPRE = np.array([
|
|
44
|
-
[128, 255, 255, 255],
|
|
45
|
-
[35, 182, 254, 255],
|
|
46
|
-
[0, 120, 180, 255],
|
|
47
|
-
[0, 82, 202, 255],
|
|
48
|
-
[0, 16, 220, 255],
|
|
49
|
-
[150, 2, 244, 255],
|
|
50
|
-
[110, 0, 182, 255],
|
|
51
|
-
[77, 0, 130, 255]])/255
|
|
52
|
-
cmp_hjnwtx["pre_tqw"] = ListedColormap(newcolorsPRE)
|
|
53
|
-
|
|
54
|
-
newcolorsWS = np.array([
|
|
55
|
-
[75, 140, 244, 255],
|
|
56
|
-
[0, 89, 235, 255],
|
|
57
|
-
[36, 173, 0, 255],
|
|
58
|
-
[18, 129, 1, 255],
|
|
59
|
-
[3, 64, 4, 255],
|
|
60
|
-
[218, 183, 5, 255],
|
|
61
|
-
[179, 125, 1, 255],
|
|
62
|
-
[155, 70, 16, 255],
|
|
63
|
-
[253, 3, 127, 255],
|
|
64
|
-
[255, 0, 55, 255],
|
|
65
|
-
[233, 0, 3, 255]])/255
|
|
66
|
-
cmp_hjnwtx["ws_nmic"] = ListedColormap(newcolorsWS)
|
|
67
|
-
|
|
68
|
-
import os
|
|
69
|
-
def mkDir(path):
|
|
70
|
-
if "." in path:
|
|
71
|
-
os.makedirs(os.path.dirname(path),exist_ok=True)
|
|
72
|
-
else:
|
|
73
|
-
os.makedirs(path, exist_ok=True)
|
|
74
|
-
|
|
75
|
-
def Radar_Nmc(array_dt,temp = "850"):
|
|
76
|
-
now_str = datetime.datetime.now().strftime("%Y%m%d%H%M")
|
|
77
|
-
if len(array_dt.shape)==3:
|
|
78
|
-
for i , img_ch_nel in enumerate(array_dt):
|
|
79
|
-
plt.imshow(img_ch_nel,vmin=0,vmax=100,cmap=cmp_hjnwtx["radar_nmc"])
|
|
80
|
-
plt.colorbar()
|
|
81
|
-
outpath = f"./radar_nmc/{temp}_{now_str}.png"
|
|
82
|
-
mkDir(outpath)
|
|
83
|
-
plt.savefig(outpath)
|
|
84
|
-
plt.close()
|
|
85
|
-
if len(array_dt.shape)==2:
|
|
86
|
-
plt.imshow(array_dt,vmin=0,vmax=100,cmap=cmp_hjnwtx["radar_nmc"])
|
|
87
|
-
plt.colorbar()
|
|
88
|
-
outpath = f"./radar_nmc/{temp}_{now_str}.png"
|
|
89
|
-
mkDir(outpath)
|
|
90
|
-
plt.savefig(outpath)
|
|
91
|
-
plt.close()
|
|
92
|
-
|
shancx/netCDF.py
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import netCDF4 as nc
|
|
4
|
-
import numpy as np
|
|
5
|
-
with nc.Dataset(path) as dataNC:
|
|
6
|
-
# 获取 'time' 变量
|
|
7
|
-
name_data = dataNC.variables[list(dataNC.variables)[0]][:]
|
|
8
|
-
print(list(dataNC.variables))
|
|
9
|
-
# 打印时间数据
|
|
10
|
-
name = list(dataNC.variables)[0]
|
|
11
|
-
print(f"{name}数据:")
|
|
12
|
-
print(name_data)
|
|
13
|
-
|
|
14
|
-
with nc.Dataset(path) as dataNC:
|
|
15
|
-
ref = dataNC["var"][:][::-1]*100
|
|
16
|
-
latArr = dataNC["lat"][:][::-1]
|
|
17
|
-
lonArr = dataNC["lon"][:]
|
|
18
|
-
|
|
19
|
-
with nc.Dataset(path) as dataNC:
|
|
20
|
-
ref = dataNC["var"][:]
|
|
21
|
-
latArr = dataNC["lat"][:]
|
|
22
|
-
lonArr = dataNC["lon"][:]
|
|
23
|
-
|
|
24
|
-
def readnetCDF4(path):
|
|
25
|
-
with nc.Dataset(path) as dataNC:
|
|
26
|
-
# 获取 'time' 变量
|
|
27
|
-
name_data = dataNC.variables[list(dataNC.variables)[0]][:]
|
|
28
|
-
print(list(dataNC.variables))
|
|
29
|
-
# 打印时间数据
|
|
30
|
-
name = list(dataNC.variables)[0]
|
|
31
|
-
print(f"{name}数据:")
|
|
32
|
-
print(name_data)
|
|
33
|
-
def readnetCDF4all(path):
|
|
34
|
-
with nc.Dataset(path) as dataNC:
|
|
35
|
-
# 获取 'time' 变量
|
|
36
|
-
print("开始读取呢台CDF4数据")
|
|
37
|
-
print(list(dataNC.variables))
|
|
38
|
-
for i in list(dataNC.variables):
|
|
39
|
-
name_data = dataNC.variables[i][:]
|
|
40
|
-
# 打印时间数据
|
|
41
|
-
name = i
|
|
42
|
-
print(f"{name}数据:")
|
|
43
|
-
print(name_data)
|
|
44
|
-
|
|
45
|
-
import pygrib
|
|
46
|
-
def grib(path):
|
|
47
|
-
grbs = pygrib.open(path) #"/mnt/wtx_weather_forecast/gfs_110/20231030/18/gfs.t18z.pgrb2.0p25.f002"
|
|
48
|
-
for grb in grbs:
|
|
49
|
-
print(grb)
|
|
50
|
-
|
|
51
|
-
import json
|
|
52
|
-
import gzip
|
|
53
|
-
import pandas as pd
|
|
54
|
-
# Assuming the file is a gzipped JSON
|
|
55
|
-
file_path = '/mnt/wtx_weather_forecast/scx/GeoEnvData/rawData/ZW_1.gz'
|
|
56
|
-
with gzip.open(file_path, 'rt') as file: # 'rt' mode to read as text
|
|
57
|
-
data = json.load(file)
|
|
58
|
-
|
|
59
|
-
# Normalize JSON data into a DataFrame
|
|
60
|
-
df = pd.json_normalize(data)
|
|
61
|
-
|
|
62
|
-
"""
|
|
63
|
-
def read_grib(fn, vars, var_name,high,stepRange=30):
|
|
64
|
-
# logger.info(f"{fn}, {vars}, {var_name},{high},{stepRange}")
|
|
65
|
-
fid = pygrib.open(fn)
|
|
66
|
-
|
|
67
|
-
data = {}
|
|
68
|
-
for ivar, ivar_name in zip(vars, var_name):
|
|
69
|
-
grbs = fid.select(shortName = ivar,level=high,stepRange=str(stepRange))
|
|
70
|
-
d = []
|
|
71
|
-
for grb in grbs:
|
|
72
|
-
d.append(grb.values)
|
|
73
|
-
d = np.squeeze(np.array(d))
|
|
74
|
-
data.update({ivar_name : d})
|
|
75
|
-
lat, lon = fid[1].latlons()
|
|
76
|
-
latArr = lat[:, 0]
|
|
77
|
-
lonArr = lon[0]
|
|
78
|
-
d_clip = clip(data[ivar_name], env, latArr[0], lonArr[0], 0.25)
|
|
79
|
-
# d = zoom(d_clip, [4201/169,6201/249], order=1)[:-1, :-1]
|
|
80
|
-
data.update({'lon':lon})
|
|
81
|
-
data.update({'lat': lat})
|
|
82
|
-
return d_clip
|
|
83
|
-
"""
|
|
84
|
-
|
|
85
|
-
"""
|
|
86
|
-
|
|
87
|
-
import netCDF4 as nc
|
|
88
|
-
|
|
89
|
-
# 设定NetCDF文件的路径
|
|
90
|
-
path = 'your_file.nc' # 请替换为您的实际文件路径
|
|
91
|
-
|
|
92
|
-
# 打开NetCDF文件
|
|
93
|
-
with nc.Dataset(path) as dataNC:
|
|
94
|
-
# 获取所有变量的名称
|
|
95
|
-
variables = dataNC.variables.keys()
|
|
96
|
-
# 输出所有变量
|
|
97
|
-
print("变量列表:")
|
|
98
|
-
for var in variables:
|
|
99
|
-
print(var)
|
|
100
|
-
|
|
101
|
-
with nc.Dataset(path) as dataNC:
|
|
102
|
-
for var_name in dataNC.variables:
|
|
103
|
-
var = dataNC.variables[var_name]
|
|
104
|
-
print(f"变量名称: {var_name}")
|
|
105
|
-
print(f"数据类型: {var.dtype}")
|
|
106
|
-
print(f"维度: {var.dimensions}")
|
|
107
|
-
print(f"属性: {var.__dict__}")
|
|
108
|
-
print() # 打印空行以
|
|
109
|
-
|
|
110
|
-
# 设定NetCDF文件的路径
|
|
111
|
-
path = 'your_file.nc' # 请替换为您的实际文件路径
|
|
112
|
-
|
|
113
|
-
with nc.Dataset(path) as dataNC:
|
|
114
|
-
time_data = dataNC.variables['time'][:]
|
|
115
|
-
# 打印时间数据
|
|
116
|
-
print("时间数据:")
|
|
117
|
-
print(time_data)
|
|
118
|
-
# 如果需要转换为可读的日期时间格式
|
|
119
|
-
time_units = dataNC.variables['time'].units
|
|
120
|
-
print(f"时间单位: {time_units}")
|
|
121
|
-
|
|
122
|
-
# 如果单位是 "days since YYYY-MM-DD" 形式,进行转换
|
|
123
|
-
if "days since" in time_units:
|
|
124
|
-
base_time = nc.num2date(time_data, units=time_units)
|
|
125
|
-
print("转换后的时间数据:")
|
|
126
|
-
for t in base_time:
|
|
127
|
-
print(t)
|
|
128
|
-
|
|
129
|
-
"""
|
|
130
|
-
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import matplotlib.pyplot as plt
|
|
2
|
-
import numpy as np
|
|
3
|
-
import datetime
|
|
4
|
-
from hjnwtx.colormap import cmp_hjnwtx # 假设这是您的自定义颜色映射库
|
|
5
|
-
import cartopy.crs as ccrs
|
|
6
|
-
import cartopy.feature as cfeature
|
|
7
|
-
import cartopy.io.shapereader as shpreader
|
|
8
|
-
from shancx import crDir
|
|
9
|
-
def drawpic_com(array_dt,array_dt1,name="temp"):
|
|
10
|
-
now_str = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
|
11
|
-
outpath = f"./radar_nmc/{name}_{now_str}.png"
|
|
12
|
-
crDir(outpath)
|
|
13
|
-
|
|
14
|
-
# 创建绘图和设置坐标系
|
|
15
|
-
fig = plt.figure(figsize=(10, 8))
|
|
16
|
-
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
|
|
17
|
-
|
|
18
|
-
# 设置图像显示的范围
|
|
19
|
-
ax.set_extent([73, 135, 18, 54], ccrs.PlateCarree()) # 根据需要调整
|
|
20
|
-
|
|
21
|
-
# 添加中国地图的边界和特征,包括省份轮廓
|
|
22
|
-
add_china_map(ax)
|
|
23
|
-
|
|
24
|
-
# 添加数据层
|
|
25
|
-
if len(array_dt.shape) == 3:
|
|
26
|
-
for i, img_ch_nel in enumerate(array_dt):
|
|
27
|
-
ax.imshow(img_ch_nel, vmin=50, vmax=500, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=[73, 134.99, 12.21, 54.2])
|
|
28
|
-
plt.colorbar(ax.images[0], ax=ax, orientation='vertical')
|
|
29
|
-
plt.savefig(f"{outpath}_layer_{i}.png")
|
|
30
|
-
plt.clf() # 清除图形以绘制下一个通道图像
|
|
31
|
-
elif len(array_dt.shape) == 2:
|
|
32
|
-
ax.imshow(array_dt, vmin=0, vmax=100, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=[73, 134.99, 12.21, 54.2], alpha=1)
|
|
33
|
-
ax.imshow(array_dt1, vmin=0, vmax=100, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=[73, 134.99, 12.21, 54.2], alpha=0.3)
|
|
34
|
-
plt.colorbar(ax.images[0], ax=ax, orientation='vertical')
|
|
35
|
-
plt.savefig(outpath)
|
|
36
|
-
plt.close(fig)
|
|
37
|
-
|
|
38
|
-
def add_china_map(ax):
|
|
39
|
-
# 在地图上添加地形特征
|
|
40
|
-
ax.add_feature(cfeature.COASTLINE, edgecolor='gray')
|
|
41
|
-
ax.add_feature(cfeature.BORDERS, linestyle=':', edgecolor='gray')
|
|
42
|
-
ax.add_feature(cfeature.LAKES, alpha=0.8)
|
|
43
|
-
# 添加省份轮廓
|
|
44
|
-
provinces = shpreader.natural_earth(resolution='10m', category='cultural', name='admin_1_states_provinces')
|
|
45
|
-
provinces_features = shpreader.Reader(provinces).geometries()
|
|
46
|
-
ax.add_geometries(provinces_features, ccrs.PlateCarree(), facecolor='none', edgecolor='gray', linestyle=':', linewidth=0.5, alpha=0.8)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
# 示例用法
|
shancx/radar_nmc_china_map_f.py
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import matplotlib.pyplot as plt
|
|
2
|
-
import numpy as np
|
|
3
|
-
import datetime
|
|
4
|
-
from hjnwtx.colormap import cmp_hjnwtx # 假设这是您的自定义颜色映射库
|
|
5
|
-
import cartopy.crs as ccrs
|
|
6
|
-
import cartopy.feature as cfeature
|
|
7
|
-
import cartopy.io.shapereader as shpreader
|
|
8
|
-
import os
|
|
9
|
-
from shancx import crDir
|
|
10
|
-
|
|
11
|
-
def drawCN(array_dt,ty="CR"):
|
|
12
|
-
env = [73, 135, 18, 54] #US [-119, -64, 22, 50]
|
|
13
|
-
now_str = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
|
14
|
-
outpath = f"./radar_nmc/CN_{now_str}.png"
|
|
15
|
-
crDir(outpath)
|
|
16
|
-
|
|
17
|
-
# 创建绘图和设置坐标系
|
|
18
|
-
fig = plt.figure(figsize=(10, 8))
|
|
19
|
-
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
|
|
20
|
-
|
|
21
|
-
# 设置图像显示的范围
|
|
22
|
-
ax.set_extent(env, ccrs.PlateCarree()) # 根据需要调整 [-119, -64, 22, 50]
|
|
23
|
-
|
|
24
|
-
# 添加中国地图的边界和特征,包括省份轮廓
|
|
25
|
-
add_china_map(ax)
|
|
26
|
-
|
|
27
|
-
# 添加数据层
|
|
28
|
-
if len(array_dt.shape) == 3:
|
|
29
|
-
for i, img_ch_nel in enumerate(array_dt):
|
|
30
|
-
ax.imshow(img_ch_nel, vmin=50, vmax=500, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=env)
|
|
31
|
-
plt.colorbar(ax.images[0], ax=ax, orientation='vertical')
|
|
32
|
-
plt.savefig(f"{outpath}_layer_{i}.png")
|
|
33
|
-
plt.clf() # 清除图形以绘制下一个通道图像
|
|
34
|
-
elif len(array_dt.shape) == 2 and ty=="pre":
|
|
35
|
-
# ax.imshow(array_dt, vmin=0, vmax=100, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=env)
|
|
36
|
-
ax.imshow(array_dt, vmin=0, vmax=10, cmap=cmp_hjnwtx["pre_tqw"], transform=ccrs.PlateCarree(), extent=[-119, -64, 22, 50]) #pre_tqw
|
|
37
|
-
plt.colorbar(ax.images[0], ax=ax, orientation='vertical')
|
|
38
|
-
plt.savefig(outpath)
|
|
39
|
-
else :
|
|
40
|
-
ax.imshow(array_dt, vmin=0, vmax=72, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=env)
|
|
41
|
-
# ax.imshow(array_dt, vmin=0, vmax=10, cmap=cmp_hjnwtx["pre_tqw"], transform=ccrs.PlateCarree(), extent=[-119, -64, 22, 50]) #pre_tqw
|
|
42
|
-
plt.colorbar(ax.images[0], ax=ax, orientation='vertical')
|
|
43
|
-
plt.savefig(outpath)
|
|
44
|
-
plt.close(fig)
|
|
45
|
-
|
|
46
|
-
def add_china_map(ax):
|
|
47
|
-
# 在地图上添加地形特征
|
|
48
|
-
ax.add_feature(cfeature.COASTLINE, edgecolor='gray')
|
|
49
|
-
ax.add_feature(cfeature.BORDERS, linestyle=':', edgecolor='gray')
|
|
50
|
-
ax.add_feature(cfeature.LAKES, alpha=0.8)
|
|
51
|
-
# 添加省份轮廓
|
|
52
|
-
if os.path.exists('/home/scx/ne_10m_admin_1_states_provinces.shp'):
|
|
53
|
-
provinces = '/home/scx/ne_10m_admin_1_states_provinces.shp'
|
|
54
|
-
else :
|
|
55
|
-
provinces = shpreader.natural_earth(resolution='10m', category='cultural', name='admin_1_states_provinces') ###自动下载
|
|
56
|
-
provinces_features = shpreader.Reader(provinces).geometries()
|
|
57
|
-
"""
|
|
58
|
-
本地路径读取 #'/home/scx/.local/share/cartopy/shapefiles/natural_earth/cultural/ne_10m_admin_1_states_provinces.shp' #ne_10m_admin_1_states_provinces.shx
|
|
59
|
-
# shapefile_path = '/home/scx/.local/share/cartopy/shapefiles/natural_earth/cultural/admin_1_states_provinces.shp'
|
|
60
|
-
# provinces_features = shpreader.Reader(shapefile_path).geometries()
|
|
61
|
-
"""
|
|
62
|
-
ax.add_geometries(provinces_features, ccrs.PlateCarree(), facecolor='none', edgecolor='gray', linestyle=':', linewidth=0.5, alpha=0.8)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
# 示例用法
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
import matplotlib.pyplot as plt
|
|
70
|
-
import numpy as np
|
|
71
|
-
import datetime
|
|
72
|
-
from hjnwtx.colormap import cmp_hjnwtx # 假设这是您的自定义颜色映射库
|
|
73
|
-
import cartopy.crs as ccrs
|
|
74
|
-
import cartopy.feature as cfeature
|
|
75
|
-
import cartopy.io.shapereader as shpreader
|
|
76
|
-
from shancx import crDir
|
|
77
|
-
import os
|
|
78
|
-
|
|
79
|
-
def drawCNXY(array_dt,XY = [3,2]): #x_coords2,y_coords2
|
|
80
|
-
now_str = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
|
81
|
-
outpath = f"./radar_nmc/{now_str}.png"
|
|
82
|
-
crDir(outpath)
|
|
83
|
-
|
|
84
|
-
# 创建绘图和设置坐标系
|
|
85
|
-
fig = plt.figure(figsize=(10, 8))
|
|
86
|
-
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
|
|
87
|
-
|
|
88
|
-
# 设置图像显示的范围
|
|
89
|
-
ax.set_extent([73, 135, 18, 54], ccrs.PlateCarree()) # 根据需要调整
|
|
90
|
-
|
|
91
|
-
# 添加中国地图的边界和特征,包括省份轮廓
|
|
92
|
-
add_china_map(ax)
|
|
93
|
-
# 添加数据层
|
|
94
|
-
if len(array_dt.shape) == 3:
|
|
95
|
-
for i, img_ch_nel in enumerate(array_dt):
|
|
96
|
-
ax.imshow(img_ch_nel, vmin=50, vmax=500, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=[73, 134.99, 12.21, 54.2])
|
|
97
|
-
plt.colorbar(ax.images[0], ax=ax, orientation='vertical')
|
|
98
|
-
plt.savefig(f"{outpath}_layer_{i}.png")
|
|
99
|
-
plt.clf() # 清除图形以绘制下一个通道图像
|
|
100
|
-
elif len(array_dt.shape) == 2:
|
|
101
|
-
ax.imshow(array_dt, vmin=0, vmax=10, cmap=cmp_hjnwtx["pre_tqw"], transform=ccrs.PlateCarree(), extent=[73, 134.99, 12.21, 54.2])
|
|
102
|
-
x_coords2 = XY[0]
|
|
103
|
-
y_coords2 = XY[1]
|
|
104
|
-
plt.plot(list(x_coords2), list(y_coords2), 'ro', markersize=1)
|
|
105
|
-
plt.colorbar(ax.images[0], ax=ax, orientation='vertical')
|
|
106
|
-
plt.savefig(outpath)
|
|
107
|
-
plt.close(fig)
|
|
108
|
-
|
|
109
|
-
def add_china_map(ax):
|
|
110
|
-
# 在地图上添加地形特征
|
|
111
|
-
ax.add_feature(cfeature.COASTLINE, edgecolor='gray')
|
|
112
|
-
ax.add_feature(cfeature.BORDERS, linestyle=':', edgecolor='gray')
|
|
113
|
-
ax.add_feature(cfeature.LAKES, alpha=0.8)
|
|
114
|
-
# 添加省份轮廓
|
|
115
|
-
if os.path.exists('/home/scx/ne_10m_admin_1_states_provinces.shp'):
|
|
116
|
-
provinces = '/home/scx/ne_10m_admin_1_states_provinces.shp'
|
|
117
|
-
else :
|
|
118
|
-
provinces = shpreader.natural_earth(resolution='10m', category='cultural', name='admin_1_states_provinces') ###自动下载
|
|
119
|
-
provinces_features = shpreader.Reader(provinces).geometries()
|
|
120
|
-
"""
|
|
121
|
-
本地路径读取 #'/home/scx/.local/share/cartopy/shapefiles/natural_earth/cultural/ne_10m_admin_1_states_provinces.shp' #ne_10m_admin_1_states_provinces.shx
|
|
122
|
-
# shapefile_path = '/home/scx/.local/share/cartopy/shapefiles/natural_earth/cultural/admin_1_states_provinces.shp'
|
|
123
|
-
# provinces_features = shpreader.Reader(shapefile_path).geometries()
|
|
124
|
-
"""
|
|
125
|
-
ax.add_geometries(provinces_features, ccrs.PlateCarree(), facecolor='none', edgecolor='gray', linestyle=':', linewidth=0.5, alpha=0.8)
|
shancx/radar_nmc_us_map_f.py
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import matplotlib.pyplot as plt
|
|
2
|
-
import numpy as np
|
|
3
|
-
import datetime
|
|
4
|
-
from hjnwtx.colormap import cmp_hjnwtx # Assuming this is your custom colormap library
|
|
5
|
-
import cartopy.crs as ccrs
|
|
6
|
-
import cartopy.feature as cfeature
|
|
7
|
-
import cartopy.io.shapereader as shpreader
|
|
8
|
-
import os
|
|
9
|
-
from shancx import crDir
|
|
10
|
-
|
|
11
|
-
def drawUS(array_dt,ty="CR"):
|
|
12
|
-
# env = [-119, -64, 22, 50]
|
|
13
|
-
env = [-132.0, -47.0, 0, 57.0]
|
|
14
|
-
now_str = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
|
15
|
-
outpath = f"./radar_nmc/US_{now_str}.png"
|
|
16
|
-
crDir(outpath)
|
|
17
|
-
|
|
18
|
-
# Create figure and set the coordinate system
|
|
19
|
-
fig = plt.figure(figsize=(10, 8))
|
|
20
|
-
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
|
|
21
|
-
|
|
22
|
-
# Set the extent for the United States
|
|
23
|
-
ax.set_extent(env, ccrs.PlateCarree()) # Adjust as needed
|
|
24
|
-
|
|
25
|
-
# Add the US map boundaries and features
|
|
26
|
-
add_us_map(ax)
|
|
27
|
-
|
|
28
|
-
# Add data layers
|
|
29
|
-
if len(array_dt.shape) == 3:
|
|
30
|
-
for i, img_ch_nel in enumerate(array_dt):
|
|
31
|
-
ax.imshow(img_ch_nel, vmin=50, vmax=500, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=env)
|
|
32
|
-
plt.colorbar(ax.images[0], ax=ax, orientation='vertical')
|
|
33
|
-
plt.savefig(f"{outpath}_layer_{i}.png")
|
|
34
|
-
plt.clf() # Clear the figure to draw the next channel image
|
|
35
|
-
elif len(array_dt.shape) == 2 and ty =="pre":
|
|
36
|
-
# ax.imshow(array_dt, vmin=0, vmax=100, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=env) #pre_tqw
|
|
37
|
-
ax.imshow(array_dt, vmin=0, vmax=10, cmap=cmp_hjnwtx["pre_tqw"], transform=ccrs.PlateCarree(), extent=env) #pre_tqw
|
|
38
|
-
plt.colorbar(ax.images[0], ax=ax, orientation='vertical')
|
|
39
|
-
plt.savefig(outpath)
|
|
40
|
-
else :
|
|
41
|
-
ax.imshow(array_dt, vmin=0, vmax=72, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=env)
|
|
42
|
-
# ax.imshow(array_dt, vmin=0, vmax=10, cmap=cmp_hjnwtx["pre_tqw"], transform=ccrs.PlateCarree(), extent=[-119, -64, 22, 50]) #pre_tqw
|
|
43
|
-
plt.colorbar(ax.images[0], ax=ax, orientation='vertical')
|
|
44
|
-
plt.savefig(outpath)
|
|
45
|
-
|
|
46
|
-
plt.close(fig)
|
|
47
|
-
|
|
48
|
-
def add_us_map(ax):
|
|
49
|
-
# Add geographic features for the US
|
|
50
|
-
ax.add_feature(cfeature.COASTLINE, edgecolor='gray')
|
|
51
|
-
ax.add_feature(cfeature.BORDERS, linestyle=':', edgecolor='gray')
|
|
52
|
-
ax.add_feature(cfeature.LAKES, alpha=0.8)
|
|
53
|
-
|
|
54
|
-
# Adding state boundaries
|
|
55
|
-
if os.path.exists('/home/scx/ne_10m_admin_1_states_provinces.shp'):
|
|
56
|
-
states = '/home/scx/ne_10m_admin_1_states_provinces.shp'
|
|
57
|
-
else:
|
|
58
|
-
states = shpreader.natural_earth(resolution='10m', category='cultural', name='admin_1_states_provinces') # Automatically download
|
|
59
|
-
|
|
60
|
-
states_features = shpreader.Reader(states).geometries()
|
|
61
|
-
|
|
62
|
-
ax.add_geometries(states_features, ccrs.PlateCarree(), facecolor='none', edgecolor='gray', linestyle=':', linewidth=0.5, alpha=0.8)
|
|
63
|
-
|
|
64
|
-
# Example usage
|
|
65
|
-
# Assuming array_dt is your data array, pass it to drawUS
|
|
66
|
-
# array_dt = np.random.rand(3, 100, 100) # Example random data; replace with your actual data
|
|
67
|
-
# drawUS(array_dt)
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import glob
|
|
3
|
-
import numpy as np
|
|
4
|
-
from hjnwtx.colormap import cmp_hjnwtx
|
|
5
|
-
PathList = glob.glob("/mnt/wtx_weather_forecast/scx/testDBscan/2024_p/20240312/*")
|
|
6
|
-
path = PathList[0]
|
|
7
|
-
print(path)
|
|
8
|
-
|
|
9
|
-
import numpy as np
|
|
10
|
-
import matplotlib.pyplot as plt
|
|
11
|
-
x = np.load(path)
|
|
12
|
-
# for i in range(35):
|
|
13
|
-
# plt.imshow(x[i])
|
|
14
|
-
# plt.savefig(f"./image/a{str(i)}.png")
|
|
15
|
-
# plt.show()
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
from hjnwtx.colormap import cmp_hjnwtx
|
|
19
|
-
import matplotlib.pyplot as plt
|
|
20
|
-
import datetime
|
|
21
|
-
def drawpic_com(base_up,base_down,shape_len, name="temp"):
|
|
22
|
-
now_str = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
|
23
|
-
Count = shape_len
|
|
24
|
-
data_all = np.concatenate([base_up,base_down], axis=0)
|
|
25
|
-
fig, axs = plt.subplots(2, Count, figsize=(10*shape_len, 10))
|
|
26
|
-
# data_all = data_all * 70
|
|
27
|
-
for i in range(2):
|
|
28
|
-
for j in range(Count):
|
|
29
|
-
index = i * Count + j
|
|
30
|
-
axs[i, j].imshow(data_all[index, :, :],vmax=70,vmin=0,cmap=cmp_hjnwtx["radar_nmc"])
|
|
31
|
-
axs[i, j].axis('off')
|
|
32
|
-
plt.tight_layout()
|
|
33
|
-
plt.savefig(name +now_str + '.png')
|
|
34
|
-
plt.close()
|
|
35
|
-
#drawpic(x,x,35)
|
|
36
|
-
print("done")
|
shancx/tool.py
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import netCDF4 as nc
|
|
3
|
-
import numpy as np
|
|
4
|
-
def getPoint(pre, df, lat0, lon0, resolution, decimal=1):
|
|
5
|
-
latIdx = ((lat0 - df["Lat"]) / resolution + 0.5).astype(np.int64)
|
|
6
|
-
lonIdx = ((df["Lon"] - lon0) / resolution + 0.5).astype(np.int64)
|
|
7
|
-
return pre[...,latIdx, lonIdx].round(decimals=decimal)
|
|
8
|
-
def Get_Lat_Lon_QPF(path,Lon_data,Lat_data):
|
|
9
|
-
with nc.Dataset(path) as dataNC:
|
|
10
|
-
latArr = dataNC["lat"][:]
|
|
11
|
-
lonArr = dataNC["lon"][:]
|
|
12
|
-
if "AIW_QPF" in path:
|
|
13
|
-
pre = dataNC[list(dataNC.variables.keys())[3]][:]
|
|
14
|
-
elif "AIW_REF" in path:
|
|
15
|
-
pre = dataNC[list(dataNC.variables.keys())[4]][:]
|
|
16
|
-
data = getPoint(pre , {"Lon":Lon_data,"Lat":Lat_data} , latArr[0], lonArr[0], 0.01)
|
|
17
|
-
data = getPoint(pre , {"Lon":Lon_data,"Lat":Lat_data} , latArr[0], lonArr[0], 0.01)
|
|
18
|
-
return data
|