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/df2database.py
CHANGED
|
@@ -8,7 +8,7 @@ enginestr = 'postgresql://postgres:{}@{}:{}/exam_data'.format(passwd,ip,port)
|
|
|
8
8
|
def get_create_engine(enginestr):
|
|
9
9
|
engine = create_engine(enginestr)
|
|
10
10
|
return engine
|
|
11
|
-
|
|
11
|
+
engine = get_create_engine(enginestr)
|
|
12
12
|
# 创建一个示例 DataFrame
|
|
13
13
|
def data_column_lower(exam_data):
|
|
14
14
|
exam_data.columns = [col.lower() for col in exam_data.columns]
|
|
@@ -26,4 +26,64 @@ def write_to_postgresql(df):
|
|
|
26
26
|
def read_from_postgresql():
|
|
27
27
|
df_from_sql = pd.read_sql('qurey sql', con=engine)
|
|
28
28
|
return df_from_sql
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
def databasequerystr(sCST, eCST,tb =table):
|
|
31
|
+
sCSTStr = sCST.strftime('%Y%m%d%H%M')
|
|
32
|
+
eCSTStr = eCST.strftime('%Y%m%d%H%M')
|
|
33
|
+
if len(eCSTStr)!=12 or len(eCSTStr) !=12:
|
|
34
|
+
raise Exception("The time format is incorrect")
|
|
35
|
+
timerange = list({sCSTStr,eCSTStr})
|
|
36
|
+
if tb =="1":
|
|
37
|
+
if len(timerange) == 1 :
|
|
38
|
+
querystr = f" SELECT * FROM {table1} where datetime1 = '{sCSTStr}'"
|
|
39
|
+
else:
|
|
40
|
+
querystr = f" SELECT * FROM {table1} where datetime1 >='{sCSTStr}' and datetime1 <'{eCSTStr}' "
|
|
41
|
+
else:
|
|
42
|
+
if len(timerange) == 1 :
|
|
43
|
+
querystr = f" SELECT * FROM {table} where datetime = '{sCSTStr}'"
|
|
44
|
+
else:
|
|
45
|
+
querystr = f" SELECT * FROM {table} where datetime >='{sCSTStr}' and datetime <'{eCSTStr}' "
|
|
46
|
+
return querystr
|
|
47
|
+
|
|
48
|
+
querystr = databasequerystr(sCST, eCST)
|
|
49
|
+
with engine.connect() as connection:
|
|
50
|
+
df1d = pd.read_sql(querystr, con=connection)
|
|
51
|
+
df1d = pd.read_sql(querystr, con=engine)
|
|
52
|
+
engine.dispose()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
from postsql.baseconfig import *
|
|
57
|
+
from shancx import loggers as logger
|
|
58
|
+
import argparse
|
|
59
|
+
import datetime
|
|
60
|
+
import pandas as pd
|
|
61
|
+
|
|
62
|
+
def options():
|
|
63
|
+
parser = argparse.ArgumentParser(description='examdatabasedata')
|
|
64
|
+
parser.add_argument('--times', type=str, default='202411100000,202411101000')
|
|
65
|
+
config= parser.parse_args()
|
|
66
|
+
print(config)
|
|
67
|
+
config.times = config.times.split(",")
|
|
68
|
+
if len(config.times) == 1:
|
|
69
|
+
config.times = [config.times[0], config.times[0]]
|
|
70
|
+
config.times = [datetime.datetime.strptime(config.times[0], "%Y%m%d%H%M"),
|
|
71
|
+
datetime.datetime.strptime(config.times[1], "%Y%m%d%H%M")]
|
|
72
|
+
return config
|
|
73
|
+
if __name__ == '__main__':
|
|
74
|
+
cfg = options()
|
|
75
|
+
sCST = cfg.times[0]
|
|
76
|
+
eCST = cfg.times[-1]
|
|
77
|
+
querystr = databasequerystr(sCST, eCST)
|
|
78
|
+
df1d = pd.read_sql(querystr, con=engine)
|
|
79
|
+
print()
|
|
80
|
+
|
|
81
|
+
"""
|
|
82
|
+
SELECT pg_size_pretty(pg_total_relation_size('your_table_name')) AS total_size
|
|
83
|
+
ftp://ftp.ncdc.noaa.gov/pub/data/noaa/isd-lite/
|
|
84
|
+
tgftp.nws.noaa.gov
|
|
85
|
+
/data/observations/metar/decoded
|
|
86
|
+
ftp://ftp.cpc.ncep.noaa.gov/precip/cmorph/
|
|
87
|
+
https://www.ncei.noaa.gov/data/global-hourly/access/2024/
|
|
88
|
+
ftp://ftp.cpc.ncep.noaa.gov 路径文件 /precip/CMORPH2/CMORPH2NRT/DATA/2024 全球25公里 逐30min 卫星 降雨 nc文件
|
|
89
|
+
"""
|
shancx/geosProj.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import warnings
|
|
3
|
+
|
|
4
|
+
class goesProj():
|
|
5
|
+
def __init__(self,lonD=-75.2,resolution=2000):
|
|
6
|
+
|
|
7
|
+
self.ea=6378.137
|
|
8
|
+
self.eb=6356.7523
|
|
9
|
+
self.h=42164
|
|
10
|
+
self.lambdaD=np.radians(lonD)
|
|
11
|
+
|
|
12
|
+
OFF = {500: 10991.5, 1000: 5495.5, 1250: 4576, 2000: 2747.5, 4000: 1373.5, 5000: 1144}
|
|
13
|
+
FAC = {500: 81865099, 1000: 40932549, 1250: 32746038, 2000: 20466274, 4000: 10233137, 5000: 8186510}
|
|
14
|
+
|
|
15
|
+
self.COFF=OFF[resolution]
|
|
16
|
+
self.LOFF=OFF[resolution]
|
|
17
|
+
self.CFAC=FAC[resolution]
|
|
18
|
+
self.LFAC=FAC[resolution]
|
|
19
|
+
|
|
20
|
+
def transform(self,latD,lonDe,RO=22):
|
|
21
|
+
lat=np.radians(latD)
|
|
22
|
+
lon=np.radians(lonDe)
|
|
23
|
+
ba2=np.square(self.eb/self.ea)
|
|
24
|
+
phie=np.arctan(ba2*np.tan(lat))
|
|
25
|
+
diffLon0=lon-self.lambdaD
|
|
26
|
+
re=self.eb/np.sqrt(1-(1-ba2)*np.square(np.cos(phie)))
|
|
27
|
+
|
|
28
|
+
r1=self.h-re*np.cos(phie)*np.cos(diffLon0)
|
|
29
|
+
r2= -re*np.cos(phie)*np.sin(diffLon0)
|
|
30
|
+
r3=re*np.sin(phie)
|
|
31
|
+
rn=np.sqrt(np.square(r1)+np.square(r2)+np.square(r3))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
x= np.degrees(np.arctan(-r2/r1))
|
|
35
|
+
y= np.degrees(np.arcsin(-r3/rn))
|
|
36
|
+
|
|
37
|
+
c=(self.COFF+x*np.power(2.0,-16)*self.CFAC -RO).astype(np.int32)
|
|
38
|
+
l=(self.LOFF+y*np.power(2.0,-16)*self.LFAC -RO).astype(np.int32)
|
|
39
|
+
return (l,c)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
import numpy as np
|
|
43
|
+
import warnings
|
|
44
|
+
|
|
45
|
+
class goesProjMSG10():
|
|
46
|
+
def __init__(self,lonD=-75.2,resolution=2000):
|
|
47
|
+
|
|
48
|
+
self.ea=6378.137
|
|
49
|
+
self.eb=6356.7523
|
|
50
|
+
self.h=42164
|
|
51
|
+
self.lambdaD=np.radians(lonD)
|
|
52
|
+
|
|
53
|
+
OFF = {500: 10991.5, 1000: 5495.5, 1250: 4576, 2000: 2747.5, 4000: 1373.5, 5000: 1144}
|
|
54
|
+
FAC = {500: 81865099, 1000: 40932549, 1250: 32746038, 2000: 20466274, 4000: 10233137, 5000: 8186510}
|
|
55
|
+
|
|
56
|
+
self.COFF=OFF[resolution]
|
|
57
|
+
self.LOFF=OFF[resolution]
|
|
58
|
+
self.CFAC=FAC[resolution]
|
|
59
|
+
self.LFAC=FAC[resolution]
|
|
60
|
+
|
|
61
|
+
def transform(self,latD,lonDe,ROC=-10,ROL=-30):
|
|
62
|
+
lat=np.radians(latD)
|
|
63
|
+
lon=np.radians(lonDe)
|
|
64
|
+
ba2=np.square(self.eb/self.ea)
|
|
65
|
+
phie=np.arctan(ba2*np.tan(lat))
|
|
66
|
+
diffLon0=lon-self.lambdaD
|
|
67
|
+
re=self.eb/np.sqrt(1-(1-ba2)*np.square(np.cos(phie)))
|
|
68
|
+
|
|
69
|
+
r1=self.h-re*np.cos(phie)*np.cos(diffLon0)
|
|
70
|
+
r2= -re*np.cos(phie)*np.sin(diffLon0)
|
|
71
|
+
r3=re*np.sin(phie)
|
|
72
|
+
rn=np.sqrt(np.square(r1)+np.square(r2)+np.square(r3))
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
x= np.degrees(np.arctan(-r2/r1))
|
|
76
|
+
y= np.degrees(np.arcsin(-r3/rn))
|
|
77
|
+
|
|
78
|
+
c=(self.COFF+x*np.power(2.0,-16)*self.CFAC -ROC).astype(np.int32)
|
|
79
|
+
l=(self.LOFF+y*np.power(2.0,-16)*self.LFAC -ROL).astype(np.int32)
|
|
80
|
+
return (l,c)
|
shancx/info.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
dict_pro = {"安徽省":"34"
|
|
2
|
+
,"北京市":"11"
|
|
3
|
+
,"福建省":"35"
|
|
4
|
+
,"甘肃省":"62"
|
|
5
|
+
,"广东省":"44"
|
|
6
|
+
,"广西壮族自治区":"45"
|
|
7
|
+
,"贵州省":"52"
|
|
8
|
+
,"海南省":"46"
|
|
9
|
+
,"河北省":"13"
|
|
10
|
+
,"河南省":"41"
|
|
11
|
+
,"黑龙江省":"23"
|
|
12
|
+
,"湖北省":"42"
|
|
13
|
+
,"湖南省":"43"
|
|
14
|
+
,"吉林省":"22"
|
|
15
|
+
,"江苏省":"32"
|
|
16
|
+
,"江西省":"36"
|
|
17
|
+
,"辽宁省":"21"
|
|
18
|
+
,"内蒙古自治区":"15"
|
|
19
|
+
,"宁夏回族自治区":"64"
|
|
20
|
+
,"青海省":"63"
|
|
21
|
+
,"山东省":"37"
|
|
22
|
+
,"山西省":"14"
|
|
23
|
+
,"陕西省":"61"
|
|
24
|
+
,"上海市":"31"
|
|
25
|
+
,"四川省":"51"
|
|
26
|
+
,"天津市":"12"
|
|
27
|
+
,"西藏自治区":"54"
|
|
28
|
+
,"新疆维吾尔自治区":"65"
|
|
29
|
+
,"云南省":"53"
|
|
30
|
+
,"省":"33"
|
|
31
|
+
,"重庆市":"50"
|
|
32
|
+
,"合肥":"3401"
|
|
33
|
+
,"全国":"100000"
|
|
34
|
+
,"广州市":"4401"
|
|
35
|
+
,"深圳市":"4403"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
shancx/netdfJU.py
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
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
|
+
import pygrib
|
|
51
|
+
grbs = pygrib.open(path)
|
|
52
|
+
for grb in grbs:
|
|
53
|
+
print(f"Message {grb.messagenumber}:")
|
|
54
|
+
print(f" Parameter: {grb.parameterName} ({grb.shortName})")
|
|
55
|
+
print(f" Level: {grb.level} ({grb.typeOfLevel})")
|
|
56
|
+
print(f" Time: {grb.validDate} (forecast time: {grb.forecastTime} hours)")
|
|
57
|
+
print(f" Grid: {grb.gridType}")
|
|
58
|
+
print(f" Values shape: {grb.values.shape}")
|
|
59
|
+
print("-" * 50)
|
|
60
|
+
|
|
61
|
+
path = '/mnt/wtx_weather_forecast/CMA_DATA/NAFP/EC/C1D/2024/2024112720/ECMFC1D_PRTY_1_2024112712_GLB_1_2.grib2'
|
|
62
|
+
# grib_ls /mnt/wtx_weather_forecast/CMA_DATA/NAFP/EC/C1D/2024/2024112720/ECMFC1D_PRTY_1_2024112712_GLB_1_2.grib2
|
|
63
|
+
import pygrib as pg
|
|
64
|
+
with pg.open(path) as dataPG:
|
|
65
|
+
# for i in dataPG:
|
|
66
|
+
# print(i)
|
|
67
|
+
preInfo = dataPG.select(shortName="ptype")[0]
|
|
68
|
+
latMat,lonMat = preInfo.latlons()
|
|
69
|
+
latMat = latMat[::-1]
|
|
70
|
+
lonMat = lonMat[::-1]
|
|
71
|
+
latArr = latMat[:,0]
|
|
72
|
+
lonArr = lonMat[0]
|
|
73
|
+
pre = preInfo.values
|
|
74
|
+
pre = pre[::-1]
|
|
75
|
+
|
|
76
|
+
grbs = pg.open(path) #"/mnt/wtx_weather_forecast/gfs_110/20231030/18/gfs.t18z.pgrb2.0p25.f002"
|
|
77
|
+
for grb in grbs:
|
|
78
|
+
print(grb)
|
|
79
|
+
grbs.close()
|
|
80
|
+
|
|
81
|
+
import json
|
|
82
|
+
import gzip
|
|
83
|
+
import pandas as pd
|
|
84
|
+
# Assuming the file is a gzipped JSON
|
|
85
|
+
file_path = '/mnt/wtx_weather_forecast/scx/GeoEnvData/rawData/ZW_1.gz'
|
|
86
|
+
with gzip.open(file_path, 'rt') as file: # 'rt' mode to read as text
|
|
87
|
+
data = json.load(file)
|
|
88
|
+
|
|
89
|
+
# Normalize JSON data into a DataFrame
|
|
90
|
+
df = pd.json_normalize(data)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
import h5py
|
|
96
|
+
|
|
97
|
+
file_path = "/mnt/wtx_weather_forecast/zhangshuo/QYDL/DATA/GPM/3B-HHR-L.MS.MRG.3IMERG.20241001-S000000-E002959.0000.V07B.HDF5"
|
|
98
|
+
|
|
99
|
+
def inspect_file(file_path):
|
|
100
|
+
with h5py.File(file_path, 'r') as f:
|
|
101
|
+
print("文件结构:")
|
|
102
|
+
def print_objects(name, obj):
|
|
103
|
+
if isinstance(obj, h5py.Dataset):
|
|
104
|
+
print(f" Dataset: {name} (Shape: {obj.shape}, Dtype: {obj.dtype})")
|
|
105
|
+
elif isinstance(obj, h5py.Group):
|
|
106
|
+
print(f" Group: {name}")
|
|
107
|
+
f.visititems(print_objects)
|
|
108
|
+
|
|
109
|
+
inspect_file(file_path)
|
|
110
|
+
|
|
111
|
+
##############################
|
|
112
|
+
import h5py
|
|
113
|
+
import numpy as np
|
|
114
|
+
|
|
115
|
+
file_path = "/mnt/wtx_weather_forecast/zhangshuo/QYDL/DATA/GPM/3B-HHR-L.MS.MRG.3IMERG.20241001-S000000-E002959.0000.V07B.HDF5"
|
|
116
|
+
|
|
117
|
+
def read_precipitation(file_path):
|
|
118
|
+
with h5py.File(file_path, 'r') as f:
|
|
119
|
+
# 读取降水数据(形状: (1, 3600, 1800))
|
|
120
|
+
precip = np.array(f['Grid/precipitation'][0, :, :]) # 去掉时间维度
|
|
121
|
+
|
|
122
|
+
# 读取坐标
|
|
123
|
+
lons = np.array(f['Grid/lon']) # 经度 (3600,)
|
|
124
|
+
lats = np.array(f['Grid/lat']) # 纬度 (1800,)
|
|
125
|
+
|
|
126
|
+
# 处理无效值
|
|
127
|
+
fill_value = f['Grid/precipitation'].attrs.get('_FillValue', -9999.0)
|
|
128
|
+
precip[precip == fill_value] = np.nan
|
|
129
|
+
|
|
130
|
+
# 获取单位
|
|
131
|
+
units = f['Grid/precipitation'].attrs.get('units', 'mm/h')
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
"precipitation": precip, # 形状: (3600, 1800)
|
|
135
|
+
"longitude": lons, # 经度数组
|
|
136
|
+
"latitude": lats, # 纬度数组
|
|
137
|
+
"units": units # 单位(如 mm/h)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
# 调用函数
|
|
141
|
+
data = read_precipitation(file_path)
|
|
142
|
+
print(f"降水数据形状: {data['precipitation'].shape}")
|
|
143
|
+
print(f"经度范围: {data['longitude'].min()} ~ {data['longitude'].max()}")
|
|
144
|
+
print(f"纬度范围: {data['latitude'].min()} ~ {data['latitude'].max()}")
|
|
145
|
+
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
path = '/mnt/wtx_weather_forecast/CMA_DATA/NAFP/EC/C1D/2024/2024112720/ECMFC1D_PRTY_1_2024112712_GLB_1_2.grib2'
|
|
152
|
+
# grib_ls /mnt/wtx_weather_forecast/CMA_DATA/NAFP/EC/C1D/2024/2024112720/ECMFC1D_PRTY_1_2024112712_GLB_1_2.grib2
|
|
153
|
+
import pygrib as pg
|
|
154
|
+
with pg.open(path) as dataPG:
|
|
155
|
+
# for i in dataPG:
|
|
156
|
+
# print(i)
|
|
157
|
+
preInfo = dataPG.select(shortName="ptype",stepRange="0")[0]
|
|
158
|
+
latMat,lonMat = preInfo.latlons()
|
|
159
|
+
latMat = latMat[::-1]
|
|
160
|
+
lonMat = lonMat[::-1]
|
|
161
|
+
latArr = latMat[:,0]
|
|
162
|
+
lonArr = lonMat[0]
|
|
163
|
+
pre = preInfo.values
|
|
164
|
+
pre = pre[::-1]
|
|
165
|
+
|
|
166
|
+
path = '/mnt/wtx_weather_forecast/CMA_DATA/NAFP/EC/C1D/2024/2024112720/ECMFC1D_PRTY_1_2024112712_GLB_1_2.grib2'
|
|
167
|
+
# grib_ls /mnt/wtx_weather_forecast/CMA_DATA/NAFP/EC/C1D/2024/2024112720/ECMFC1D_PRTY_1_2024112712_GLB_1_2.grib2 查看select 参数
|
|
168
|
+
import pygrib as pg
|
|
169
|
+
with pg.open(path) as dataPG:
|
|
170
|
+
# for i in dataPG:
|
|
171
|
+
# print(i)
|
|
172
|
+
preInfo = dataPG.select(shortName="ptype",stepRange="0")[0]
|
|
173
|
+
latMat,lonMat = preInfo.latlons()
|
|
174
|
+
# latMat = latMat[::-1]
|
|
175
|
+
# lonMat = lonMat[::-1]
|
|
176
|
+
latArr = latMat[:,0]
|
|
177
|
+
lonArr = lonMat[0]
|
|
178
|
+
pre = preInfo.values
|
|
179
|
+
d_clip = clip(data[ivar_name], env, latArr[0], lonArr[0], 0.25)
|
|
180
|
+
# d = zoom(d_clip, [4201/169,6201/249], order=1)[:-1, :-1]
|
|
181
|
+
data.update({'lon':lon})
|
|
182
|
+
data.update({'lat': lat})
|
|
183
|
+
return d_clip
|
|
184
|
+
"""
|
|
185
|
+
|
|
186
|
+
"""
|
|
187
|
+
|
|
188
|
+
import netCDF4 as nc
|
|
189
|
+
|
|
190
|
+
# 设定NetCDF文件的路径
|
|
191
|
+
path = 'your_file.nc' # 请替换为您的实际文件路径
|
|
192
|
+
|
|
193
|
+
# 打开NetCDF文件
|
|
194
|
+
with nc.Dataset(path) as dataNC:
|
|
195
|
+
# 获取所有变量的名称
|
|
196
|
+
variables = dataNC.variables.keys()
|
|
197
|
+
# 输出所有变量
|
|
198
|
+
print("变量列表:")
|
|
199
|
+
for var in variables:
|
|
200
|
+
print(var)
|
|
201
|
+
|
|
202
|
+
with nc.Dataset(path) as dataNC:
|
|
203
|
+
for var_name in dataNC.variables:
|
|
204
|
+
var = dataNC.variables[var_name]
|
|
205
|
+
print(f"变量名称: {var_name}")
|
|
206
|
+
print(f"数据类型: {var.dtype}")
|
|
207
|
+
print(f"维度: {var.dimensions}")
|
|
208
|
+
print(f"属性: {var.__dict__}")
|
|
209
|
+
print() # 打印空行以
|
|
210
|
+
|
|
211
|
+
# 设定NetCDF文件的路径
|
|
212
|
+
path = 'your_file.nc' # 请替换为您的实际文件路径
|
|
213
|
+
|
|
214
|
+
with nc.Dataset(path) as dataNC:
|
|
215
|
+
time_data = dataNC.variables['time'][:]
|
|
216
|
+
# 打印时间数据
|
|
217
|
+
print("时间数据:")
|
|
218
|
+
print(time_data)
|
|
219
|
+
# 如果需要转换为可读的日期时间格式
|
|
220
|
+
time_units = dataNC.variables['time'].units
|
|
221
|
+
print(f"时间单位: {time_units}")
|
|
222
|
+
|
|
223
|
+
# 如果单位是 "days since YYYY-MM-DD" 形式,进行转换
|
|
224
|
+
if "days since" in time_units:
|
|
225
|
+
base_time = nc.num2date(time_data, units=time_units)
|
|
226
|
+
print("转换后的时间数据:")
|
|
227
|
+
for t in base_time:
|
|
228
|
+
print(t)
|
|
229
|
+
|
|
230
|
+
"""
|
|
231
|
+
|
shancx/sendM.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import datetime
|
|
3
|
+
def sendMES(message,key='0f313-17b2-4e3d-84b8-3f9c290fa596',NN = None):
|
|
4
|
+
webHookUrl = f'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={NN}{key}'
|
|
5
|
+
if NN=="MT":
|
|
6
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=8b7df0c1-bde0-4091-9e11-f77519439823"
|
|
7
|
+
elif NN=="MT1":
|
|
8
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=461a6eab-90e1-48d9-bb7e-ee91f6e16131"
|
|
9
|
+
elif NN=="WT":
|
|
10
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=de0c3cc5-d32b-4631-b807-9db3ae44c6df"
|
|
11
|
+
elif NN=="H9":
|
|
12
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=652ed7d5-7f31-437c-90e2-25efce6a8a8a"
|
|
13
|
+
elif NN=="GOES18":
|
|
14
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=32c59698-92ff-4049-a1bb-12908fb7b0da"
|
|
15
|
+
elif NN=="GOES19":
|
|
16
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=aac8d435-2d21-4c5e-a465-7b51396f4b25"
|
|
17
|
+
elif NN=="FY4B":
|
|
18
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=0f4e28f6-af3b-44b0-9889-827df8f3dcc1"
|
|
19
|
+
elif NN=="MSGIN":
|
|
20
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=7a4e8f4a-27a7-451b-9b31-dd0339a25e85"
|
|
21
|
+
elif NN=="MSG":
|
|
22
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=a4222299-a66a-4909-834a-8deeda35c60a"
|
|
23
|
+
elif NN=="LAST":
|
|
24
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=1b975d3f-0f8c-4ac8-97aa-7de3c5b75802"
|
|
25
|
+
elif NN=="MTGH":
|
|
26
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=64ec68e0-28dd-40d2-9c23-7b7f3808030c"
|
|
27
|
+
elif NN=="GOES19NA":
|
|
28
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=790f59bc-64c5-4f37-9795-f1c848ab3fa0"
|
|
29
|
+
elif NN=="GOES19SA":
|
|
30
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=a195b0e1-ab72-4071-9300-2a148b5e4744"
|
|
31
|
+
|
|
32
|
+
elif NN=="H9CHNNEAS":
|
|
33
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=504d8947-b69d-4f0e-8de4-384a1966d7e2"
|
|
34
|
+
elif NN=="H9SEAS":
|
|
35
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=2db6e407-5397-44c9-b3cf-3aa27900627c"
|
|
36
|
+
elif NN=="H9OC":
|
|
37
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=b11a7591-f917-48ba-9bdf-8754aebefd01"
|
|
38
|
+
|
|
39
|
+
elif NN=="MSGER":
|
|
40
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=ad6cd972-599d-426f-8dfd-81e930ad40cd"
|
|
41
|
+
elif NN=="MSGAF":
|
|
42
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=5797fbe9-1c19-4a67-a6fc-83a85cb464a7"
|
|
43
|
+
elif NN=="GOES18C":
|
|
44
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4ddac32b-692b-4aa0-9d69-0e655552ff17"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
elif NN=="GFS":
|
|
48
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=13f39c2f-e191-4100-b1ee-7316ac9c2451"
|
|
49
|
+
else:
|
|
50
|
+
webHookUrl ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=13f39c2f-e191-4100-b1ee-7316ac9c2451"
|
|
51
|
+
|
|
52
|
+
try:
|
|
53
|
+
url=webHookUrl
|
|
54
|
+
headers = {"Content-Type":"application/json"}
|
|
55
|
+
data = {'msgtype':'text','text':{"content":message}}
|
|
56
|
+
res = requests.post(url,json=data,headers=headers)
|
|
57
|
+
except Exception as e:
|
|
58
|
+
print(e)
|
|
59
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# @Time : 2025/03/14 下午19:22
|
|
4
|
+
# @Author : shancx
|
|
5
|
+
# @File : __init__.py
|
|
6
|
+
# @email : shanhe12@163.com
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
from torch.utils.tensorboard import SummaryWriter
|
|
10
|
+
from datetime import datetime
|
|
11
|
+
class Boardlogger:
|
|
12
|
+
def __init__(self, log_dir=None): self.writer = SummaryWriter(log_dir or f'runs/{datetime.now().strftime("%Y%m%d_%H%M%S")}')
|
|
13
|
+
def log(self, tag, value, step): self.writer.add_scalar(tag, value, step)
|
|
14
|
+
def close(self): self.writer.close()
|
|
15
|
+
"""
|
|
16
|
+
Board = Boardlogger()
|
|
17
|
+
Board.log('Train/Loss', 0.1, 1) # 记录训练损失
|
|
18
|
+
Board.log('Val/IoU', 0.8, 1) # 记录验证 IoU
|
|
19
|
+
Board.close()
|
|
20
|
+
tensorboard --logdir=runs --port=6006 --bind_all 进入到训练目录文件夹下 启动才可以
|
|
21
|
+
|
|
22
|
+
from torch.utils.tensorboard import SummaryWriter
|
|
23
|
+
writer = SummaryWriter(f'runs/{datetime.now().strftime("%Y%m%d_%H%M%S")}')
|
|
24
|
+
writer.add_scalar('Train/Loss', loss.item(), epoch * len(train_loader) + i)
|
|
25
|
+
writer.close()
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
|