shancx 1.9.33.109__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.
Files changed (65) hide show
  1. shancx/{Dsalgor → Algo}/__init__.py +37 -1
  2. shancx/Calmetrics/__init__.py +78 -9
  3. shancx/Calmetrics/calmetrics.py +14 -0
  4. shancx/Calmetrics/rmseR2score.py +14 -3
  5. shancx/{Command.py → Cmd.py} +20 -15
  6. shancx/Config_.py +26 -0
  7. shancx/Df/__init__.py +11 -0
  8. shancx/Df/tool.py +0 -1
  9. shancx/NN/__init__.py +200 -11
  10. shancx/{path.py → Path1.py} +2 -3
  11. shancx/Plot/__init__.py +129 -403
  12. shancx/Plot/draw_day_CR_PNG.py +4 -21
  13. shancx/Plot/exam.py +116 -0
  14. shancx/Plot/plotGlobal.py +325 -0
  15. shancx/Plot/radarNmc.py +1 -48
  16. shancx/Plot/single_china_map.py +1 -1
  17. shancx/Point.py +46 -0
  18. shancx/QC.py +223 -0
  19. shancx/Read.py +17 -10
  20. shancx/Resize.py +79 -0
  21. shancx/SN/__init__.py +8 -1
  22. shancx/Time/timeCycle.py +97 -23
  23. shancx/Train/makelist.py +161 -155
  24. shancx/__init__.py +79 -232
  25. shancx/bak.py +78 -53
  26. shancx/geosProj.py +2 -2
  27. shancx/wait.py +35 -1
  28. {shancx-1.9.33.109.dist-info → shancx-1.9.33.218.dist-info}/METADATA +12 -4
  29. shancx-1.9.33.218.dist-info/RECORD +91 -0
  30. {shancx-1.9.33.109.dist-info → shancx-1.9.33.218.dist-info}/WHEEL +1 -1
  31. shancx/Plot/Mip.py +0 -42
  32. shancx/Plot/border.py +0 -44
  33. shancx/Plot/draw_day_CR_PNGUS.py +0 -206
  34. shancx/Plot/draw_day_CR_SVG.py +0 -275
  35. shancx/Plot/draw_day_pre_PNGUS.py +0 -205
  36. shancx/Plot/radar_nmc_china_map_compare1.py +0 -50
  37. shancx/makenetCDFN.py +0 -42
  38. shancx-1.9.33.109.dist-info/RECORD +0 -91
  39. /shancx/{3DJU → 3D}/__init__.py +0 -0
  40. /shancx/{Dsalgor → Algo}/Class.py +0 -0
  41. /shancx/{Dsalgor → Algo}/CudaPrefetcher1.py +0 -0
  42. /shancx/{Dsalgor → Algo}/Fake_image.py +0 -0
  43. /shancx/{Dsalgor → Algo}/Hsml.py +0 -0
  44. /shancx/{Dsalgor → Algo}/L2Loss.py +0 -0
  45. /shancx/{Dsalgor → Algo}/MetricTracker.py +0 -0
  46. /shancx/{Dsalgor → Algo}/Normalize.py +0 -0
  47. /shancx/{Dsalgor → Algo}/OptimizerWScheduler.py +0 -0
  48. /shancx/{Dsalgor → Algo}/Rmageresize.py +0 -0
  49. /shancx/{Dsalgor → Algo}/Savemodel.py +0 -0
  50. /shancx/{Dsalgor → Algo}/SmoothL1_losses.py +0 -0
  51. /shancx/{Dsalgor → Algo}/Tqdm.py +0 -0
  52. /shancx/{Dsalgor → Algo}/checknan.py +0 -0
  53. /shancx/{Dsalgor → Algo}/dsalgor.py +0 -0
  54. /shancx/{Dsalgor → Algo}/iouJU.py +0 -0
  55. /shancx/{Dsalgor → Algo}/mask.py +0 -0
  56. /shancx/{Dsalgor → Algo}/psnr.py +0 -0
  57. /shancx/{Dsalgor → Algo}/ssim.py +0 -0
  58. /shancx/{Dsalgor → Algo}/structural_similarity.py +0 -0
  59. /shancx/{Dsalgor → Algo}/tool.py +0 -0
  60. /shancx/Calmetrics/{matrixLib.py → calmetricsmatrixLib.py} +0 -0
  61. /shancx/{Diffmodel → Diffm}/Psamples.py +0 -0
  62. /shancx/{Diffmodel → Diffm}/__init__.py +0 -0
  63. /shancx/{Diffmodel → Diffm}/test.py +0 -0
  64. /shancx/{Board → tensBoard}/__init__.py +0 -0
  65. {shancx-1.9.33.109.dist-info → shancx-1.9.33.218.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,91 @@
1
+ shancx/Cmd.py,sha256=FjbNHOAp9g6Y0BHr4R5f9PxqfK9BaHqNrWzdyL87CdU,4860
2
+ shancx/Config_.py,sha256=CgkvFXXDwuXgyHDrNWkvlOY7rNRQ-dMaDvcUouBJ9y0,733
3
+ shancx/Inst.py,sha256=Q8dULK2djqBU0JFyhMAf1mhWzFDwx9SaAJuTIO0AWig,751
4
+ shancx/Lib.py,sha256=GUAspllSxk39mvj-F1Q8Ys0EcY_lQfZPRGPE7L3x4SE,977
5
+ shancx/Path1.py,sha256=vX4A5RgdwVyIVVNZRocl18rOu1Z8YMLfDb0B92-0bE8,5334
6
+ shancx/Point.py,sha256=gyIomOVbNoz6SOcAhhTS26NHBeJ0TOwB-ljNsBWN1ZE,1909
7
+ shancx/QC.py,sha256=MFxbPMEwrnk5l0sTFMrx13wPlXJ5WI5TovzaiBoEr0E,9848
8
+ shancx/Read.py,sha256=x0nMlTXhxb5utkr9Tn9Aawz32m-dmLUXpG2HM9KywtI,2924
9
+ shancx/Resize.py,sha256=uwiOhD-aWPDLvIwOYEX-XXN_suOXv6hPDcaGyr4JLC4,4044
10
+ shancx/ZR.py,sha256=5APchqVoI1G2MkrN9YJSWCwfLUygcSFIsUXSo9aq1Qg,341
11
+ shancx/__init__.py,sha256=6sfiHElECqfy5eEEGqaCAw4YiKxgKfJ5IFFh9yvtewk,11442
12
+ shancx/args.py,sha256=Nr80vgQpT3m31_crKGf5DvofCxyERJFbqJ1sHb1BIqs,1042
13
+ shancx/bak.py,sha256=SvxKomcukMkWvOlBil77AP0BWcrPNdkz2H3DoFOWLw0,26640
14
+ shancx/cmp.py,sha256=cIQv-QTl-22FJa6tmHyBu_IQmMq5LnsQGGFK5jc5hMA,893
15
+ shancx/df2database.py,sha256=h9_n9tZBWKyGKnpGPRHPSZgMn5kylX0sV5APwmi2SHM,3315
16
+ shancx/geosProj.py,sha256=JMmtj3kV8rtFkKbmwvTKuDWlC8AkgLG8JvCPzkn8Dfs,2685
17
+ shancx/getResponse.py,sha256=QmJfa4czGCOiKb8RuCLXKE7AAKVADAptNiwn7v1tfbM,1055
18
+ shancx/info.py,sha256=0rk_L8Z5uj9RliaZrzT-CArH9ZObmdmcp-1RxAItL08,1122
19
+ shancx/netdfJU.py,sha256=96KR9NMLr2Kcs_OOMpX7QPujdWUj0GCEUIZ7_4_pBxw,7741
20
+ shancx/sendM.py,sha256=CEpeHavseWILlfevhfOMYxYUIWhh4fCNkXGRsEjMxBE,3352
21
+ shancx/wait.py,sha256=OgT9JmEgMH7d3ir3TEksx0_Kyl_S4bkOKl50jvVpdFA,8575
22
+ shancx/3D/__init__.py,sha256=pDFvW1OOEW-ueXH50NJIYdWlySHZU6sr5htzHUSeROo,1000
23
+ shancx/Algo/Class.py,sha256=bxJ9JhIjoxl0hJfjO126YrnyHWDpxCEAZ7qcPs0Y0ic,377
24
+ shancx/Algo/CudaPrefetcher1.py,sha256=mUVlS3txsriET26ZMZ6DYOnyzWr8Tz6wThifzWrC7k8,3951
25
+ shancx/Algo/Fake_image.py,sha256=PEha7w0mMVEOodcAXEGNv_FvrWUipsqAJPkhTYDk6l4,1264
26
+ shancx/Algo/Hsml.py,sha256=GzAMS30DxJm8_y8lq8bk-6F_3_Xah4eHdLqHuZQWenw,16874
27
+ shancx/Algo/L2Loss.py,sha256=m68uMLLUfgvP066_gKaKvjWGmLTlbHQwGAKUmzIt4qQ,261
28
+ shancx/Algo/MetricTracker.py,sha256=shXN8OUsmbFIAX0aC5hgf-hMuX5Jts3ebAbjYDgmce0,4268
29
+ shancx/Algo/Normalize.py,sha256=arUrZ6d4L2DiJRSsefpAe3wvkeVICvvnJ6RbvMoyIDE,3191
30
+ shancx/Algo/OptimizerWScheduler.py,sha256=oC7OmYCuYfVRVSzP2-zPvHB7lgmE4UuAUhdBPob87H0,1529
31
+ shancx/Algo/Rmageresize.py,sha256=TQfVLnCLJYSLC88dI7x6IZJJv43s1zJYE9HzCZpPb0M,2979
32
+ shancx/Algo/Savemodel.py,sha256=l4XfuNJ4WMfVy8qalH8AhtR3RsQmZfpJF53zIwQxrUs,1009
33
+ shancx/Algo/SmoothL1_losses.py,sha256=P7YpSjrlIhyVgBxyxDxehuVtTbffbbrnKmuZ-Po-UvE,1056
34
+ shancx/Algo/Tqdm.py,sha256=JZz8SwqQjql4eT0GUmFX6xAwLNEx1YwpGM2hL1LDyk8,2707
35
+ shancx/Algo/__init__.py,sha256=05Kzre38HFbhmqdj-U1W3m_lc8pkUypaEhgh3UjVAmg,4466
36
+ shancx/Algo/checknan.py,sha256=Oi7yU-UTSQgE4tgvuXTdgPmhlaus6G7gB2suaV7QgeQ,1188
37
+ shancx/Algo/dsalgor.py,sha256=jNlD8TJuAOKT6H_8xc-l8sI-mXf8upemeA7Jpf5Eftk,398
38
+ shancx/Algo/iouJU.py,sha256=pZYQ-KPE-hgsuPUL0KxZZcuemDCt_LWAyw9GuKgvZNE,3602
39
+ shancx/Algo/mask.py,sha256=Dx7mLfcfEDIudu-DzdowFGoS1D3IxLHC8Mtw_kAen4w,1060
40
+ shancx/Algo/psnr.py,sha256=mrepcNyWTdB5UrHXZpSvyLsbZ-i_evyZtAmk3mIOwT8,267
41
+ shancx/Algo/ssim.py,sha256=eW_RXovDhVvwvFg2kEG_Xd3SasGKQt5BpQr6yNOiepk,2896
42
+ shancx/Algo/structural_similarity.py,sha256=zc4wjCKVkkDgySneB1uPuBWu-9KVD5TXPLubXKhMR7o,10204
43
+ shancx/Algo/tool.py,sha256=NpSoeX0r61k7_iBlMYCTv1IfcZQZv1sFecxJk_afa0g,26690
44
+ shancx/Calmetrics/__init__.py,sha256=hnahHA7FxxmCvd6X5Buu2MSSbwagaUDgNnjkxeGBL14,3104
45
+ shancx/Calmetrics/calmetrics.py,sha256=O_0aCoGh1n4b6lyBP9iX_qMu_-GxQ66Ky0aDgx4JtgI,498
46
+ shancx/Calmetrics/calmetricsmatrixLib.py,sha256=MO1E04hBjZZ93Uzlgth6ilNwmY666cjFR9SwOM6YN4I,6749
47
+ shancx/Calmetrics/rmseR2score.py,sha256=MOK6RKW4nxBjdna8dy8vHm9wncrzjEDvb7BLSUhhoHM,1243
48
+ shancx/Clip/__init__.py,sha256=8JDd5X42LfAGVbd0Qk0Z1pXx7Qx3t6drVjoQNlhC8lg,1808
49
+ shancx/Df/DataFrame.py,sha256=KvwKPHmVxFLCPPyfesKjZl-Se1oAdGyLbbJoCjzP4YY,661
50
+ shancx/Df/__init__.py,sha256=FxFvYlgg79eBqaWl_XmDC7Tv5e7wLm0iIPSvz_XgXIY,906
51
+ shancx/Df/tool.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
+ shancx/Diffm/Psamples.py,sha256=9Uu5w-bsBaFvoTH6ZWU-8MOefkLUh6lYzhIlzO9O6D0,662
53
+ shancx/Diffm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
+ shancx/Diffm/test.py,sha256=uRldWrcqiZpHeBY9WD9gtsPsLWobDyt8Y02Zc3q_78o,8180
55
+ shancx/Doc/__init__.py,sha256=nLQzA4V8yA7KvzzVmV00Kfn57PK1bNi9P1EBYcsOHk4,7772
56
+ shancx/E/__init__.py,sha256=UJZugggSzsRkyT3Zi1R-1i-vfD5UnoNoEgCHEiS84bg,5393
57
+ shancx/Fillmiss/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
+ shancx/Fillmiss/imgidwJU.py,sha256=CyP4ZlhPpXPqGVzzcLR7lohVl8bWjEceJLo7yvKgtEM,1708
59
+ shancx/Fillmiss/imgidwLatLonJU.py,sha256=ltYZj9CwN8cVs4Kow64oVN1EiBERgW9FceTUBFkCOAs,4314
60
+ shancx/Gpu/__init__.py,sha256=4Ahq04phTGVlFWN9Vih0WAh-IqFrhtwM5hj4G1IU2Dk,1950
61
+ shancx/H9/__init__.py,sha256=FCarcXfU2tVD2KrCGKNNUuL51zAWZYHV7lrP7gntvaI,4911
62
+ shancx/H9/ahi_read_hsd.py,sha256=bt9oOOARcXijmyGpmHYXj0NKnuTntZjqx0_tu6Vp2vs,33522
63
+ shancx/H9/ahisearchtable.py,sha256=e2kpz-P5npgL4gzNxn8igERJuWWIysvTNLkptr5_Zcc,9579
64
+ shancx/H9/geometry.py,sha256=ZoCfgP07ANqDxyLf8uFN016DPl7QqW9pAV3sr2ekCng,95893
65
+ shancx/Hug/__init__.py,sha256=NvcqXM0CSwXYtTr5yj4zfkag_7PZcI5tCsIHjuLNXTQ,3040
66
+ shancx/Mos/__init__.py,sha256=IDlCLNN6a_mguYmRcAPcevHSDaud5ZhvYNSuASqztcE,1563
67
+ shancx/NN/__init__.py,sha256=ENgZxIzUJzkuxArkcH-1JlxQA08Urq2ppFkGCbIURZk,9219
68
+ shancx/Plot/GlobMap.py,sha256=WRvZOf5bo8IfECk1-sN4g6K0CrcJhSoEJAiLvZAWDwg,13021
69
+ shancx/Plot/Gray2RGB.py,sha256=yDXu1xWVi7OtrS8_ExxK_ev1988kj1ZxoNCWf-kl4Zc,2734
70
+ shancx/Plot/__init__.py,sha256=_fmDFZfh9HzDPBPKCMPrDT2DsblLVfrO-uFvUg76a74,19194
71
+ shancx/Plot/draw_day_CR_PNG.py,sha256=ftOYdk80Xmry_H1uaypjrTUA0mJZBV7EGt5T7JfVg0E,7267
72
+ shancx/Plot/exam.py,sha256=XXyBQp1Eb1siNiu7FY8ACiWH0g43ZSLTOGLqs3aKomE,3966
73
+ shancx/Plot/plotGlobal.py,sha256=B2887VhMop6B3jEg7zD7ADlyIbKfyUOKffSJ2oEmEbo,15270
74
+ shancx/Plot/radarNmc.py,sha256=ixmoDaoT6whmmrv4wD4p7H_DiNsyOEb2tUoz2KQgDeM,1273
75
+ shancx/Plot/single_china_map.py,sha256=cRmZW6TtLBwLb-Y3syim_K1jM350CmB5zkK1nrAcaRQ,2116
76
+ shancx/RdPzl/__init__.py,sha256=I5Isz3KfDgFZAdlRk4D-Hvp-8xH4F2Dl0XGxYGzUcKc,1166
77
+ shancx/SN/__init__.py,sha256=6BOmiKkAEeFPpDhMYo0Kpp8PvVn4XCpQ0qF0fQM0sls,2786
78
+ shancx/Time/GetTime.py,sha256=lFdjKpFHxOgvyCUzeGi8MrGUIEPrGzcaRX3CVZi8B4o,1262
79
+ shancx/Time/__init__.py,sha256=ftYQdlJotvBYGtMWtTnooUBJOvjNOsFJ9i5ACFTjtDU,3826
80
+ shancx/Time/timeCycle.py,sha256=YD_r-pS7uIR2ZqNIzZtEWTD_mUPu5vBHJSZiFh8fNgg,9959
81
+ shancx/Time/tool.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
82
+ shancx/Train/__init__.py,sha256=clWzZpsVEhJqEvRCDCEn3tZxrG-wf-BiiCsGvTTGR6I,2379
83
+ shancx/Train/makelist.py,sha256=0NTU4mUqvUJUT496mROorLAmUTIVSsn9k1LQWYL_vEA,6871
84
+ shancx/Train/multiGpu.py,sha256=D_oZeiSc7VWktpnVDwrFOC1CYZSt9rxOKY5lngE5vFg,820
85
+ shancx/Train/prepare.py,sha256=vL_8UOA66oZCBIwCICtihsGibivtNgaVJGulJxfNdn8,6793
86
+ shancx/Train/renet50.py,sha256=wEhYk1X96WE5zuqHqVxWLJa-A5jDNkz4z6edORNufnA,6428
87
+ shancx/tensBoard/__init__.py,sha256=ga2C5YyJITvvQA1ocpxna_KNFnNRJVwkTjLoIglLZUQ,993
88
+ shancx-1.9.33.218.dist-info/METADATA,sha256=EbrBBFNqDUpu1A02IPoPAi9kDXpSeDHK_lN8P911HFg,850
89
+ shancx-1.9.33.218.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
90
+ shancx-1.9.33.218.dist-info/top_level.txt,sha256=akfCS1vKWz3pNmEN_yN9ZiGp-60IQY5ET38mRx_i_-4,7
91
+ shancx-1.9.33.218.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
shancx/Plot/Mip.py DELETED
@@ -1,42 +0,0 @@
1
- import numpy as np
2
- import matplotlib.pyplot as plt
3
- import datetime
4
- from hjnwtx.colormap import cmp_hjnwtx
5
- from mpl_toolkits.axes_grid1 import make_axes_locatable
6
- from shancx import crDir
7
- def radarcom(base_up, base_down, name="radar_composite",saveDir="plotRadar_composite",ty="radar_nmc"):
8
- now_str = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
9
- combined_data = np.concatenate([base_up, base_down], axis=0)
10
- num_frames = base_up.shape[0]
11
- fig, axes = plt.subplots(
12
- 2, # 行数(上下两层)
13
- num_frames, # 列数(每层图像数量)
14
- figsize=(10 * num_frames, 10),
15
- squeeze=False
16
- )
17
- vmin, vmax = 0, 70
18
- for i in range(2):
19
- for j in range(num_frames):
20
- data_index = i * num_frames + j
21
- im = axes[i, j].imshow(
22
- combined_data[data_index, :, :],
23
- vmin=vmin,
24
- vmax=vmax,
25
- cmap=cmp_hjnwtx[ty] #pre_tqw radar_nmc
26
- )
27
- axes[i, j].axis('off')
28
- divider = make_axes_locatable(axes[i, j])
29
- cax = divider.append_axes("right", size="5%", pad=0.5)
30
- plt.colorbar(im, cax=cax)
31
- plt.tight_layout()
32
- outpath = f"./{saveDir}/{name}_{now_str}.png" if name=="radar_composite" else f"./{saveDir}/{name}.png"
33
- crDir(outpath)
34
- plt.savefig(outpath, bbox_inches='tight', dpi=300)
35
- plt.close()
36
- print(f"图像已保存为: {outpath}")
37
-
38
-
39
- #使用示例:
40
- #draw_radar_composite(upper_data, lower_data, "my_radar_image")
41
- #comP(base_up, base_down, name="UTCstr",vmin=150,vmax=320,cmap='summer')
42
- #radarcomP(base_up, base_down,name="UTCstr",ty="radar_nmc")
shancx/Plot/border.py DELETED
@@ -1,44 +0,0 @@
1
-
2
- import numpy as np
3
- import matplotlib.pyplot as plt
4
- import cartopy.crs as ccrs
5
- import cartopy.feature as cfeature
6
- from mpl_toolkits.axes_grid1 import make_axes_locatable
7
- def plotBorder(matrix,name='plotBorder',saveDir="plotBorder",extent=None,title='Matrix Plot', xlabel='X-axis', ylabel='Y-axis', color_label='Value', cmap='viridis'):
8
- # 地理范围 (lat_min, lat_max, lon_min, lon_max)
9
- if extent is None:
10
- lat_min, lat_max = -3, 13
11
- lon_min, lon_max = -0, 28
12
- else:
13
- lat_min, lat_max, lon_min, lon_max = extent
14
- # 创建地图
15
- now_str = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
16
- fig = plt.figure(figsize=(12, 8))
17
- ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
18
- ax.set_extent([lon_min, lon_max, lat_min, lat_max], crs=ccrs.PlateCarree())
19
- im = ax.imshow(
20
- matrix,
21
- extent=[lon_min, lon_max, lat_min, lat_max],
22
- origin='upper', # 卫星数据通常 origin='upper'
23
- cmap='viridis', # 选择合适的 colormap
24
- transform=ccrs.PlateCarree()
25
- )
26
- ax.add_feature(cfeature.COASTLINE, linewidth=0.5)
27
- ax.add_feature(cfeature.BORDERS, linestyle=':', linewidth=0.5)
28
- # 添加美国州边界(50m 分辨率)
29
- states = cfeature.NaturalEarthFeature(
30
- category='cultural',
31
- name='admin_1_states_provinces_lines',
32
- scale='50m',
33
- facecolor='none'
34
- )
35
- ax.add_feature(states, edgecolor='red', linewidth=0.5)
36
- divider = make_axes_locatable(ax)
37
- cax = divider.append_axes("right", size="5%", pad=0.1, axes_class=plt.Axes)
38
- cbar = plt.colorbar(im, cax=cax, label='Data Values')
39
- ax.set_title('Sat data Boundaries', fontsize=14)
40
- plt.tight_layout() # 优化布局
41
- outpath = f'./{saveDir}/{name}_{now_str}.png' if name=="plotBorder" else f"./{saveDir}/{name}.png"
42
- crDir(outpath)
43
- plt.savefig(outpath)
44
- plt.close()
@@ -1,206 +0,0 @@
1
- import matplotlib.pyplot as plt
2
- import datetime
3
- from hjnwtx.colormap import cmp_hjnwtx
4
- import time
5
- import os
6
- import time
7
- import shutil
8
-
9
- from dateutil.relativedelta import relativedelta
10
- import glob
11
- from config import logger
12
- import argparse
13
- import pandas as pd
14
- import re
15
- import netCDF4 as nc
16
- from multiprocessing import Pool
17
- from itertools import product
18
- import numpy as np
19
- import copy
20
- import traceback
21
-
22
-
23
- from multiprocessing import Process, Queue
24
-
25
- import io
26
- import cartopy.crs as ccrs
27
- import cartopy.feature as cfeature
28
- import cartopy.io.shapereader as shpreader
29
- from hjnwtx.mkNCHJN import mkDir
30
-
31
- shape_ = (1, 5701, 8501)
32
- def add_china_map(ax):
33
- # 在地图上添加地形特征
34
- ax.add_feature(cfeature.COASTLINE, edgecolor='gray')
35
- ax.add_feature(cfeature.BORDERS, linestyle=':', edgecolor='gray')
36
- ax.add_feature(cfeature.LAKES, alpha=0.8)
37
- # 添加省份轮廓
38
- provinces = shpreader.natural_earth(resolution='10m', category='cultural', name='admin_1_states_provinces')
39
- provinces_features = shpreader.Reader(provinces).geometries()
40
- ax.add_geometries(provinces_features, ccrs.PlateCarree(), facecolor='none', edgecolor='gray', linestyle=':', linewidth=0.5, alpha=0.8)
41
-
42
- def draw_subplot(args):
43
- env = [-132.0, -47.0, 0, 57.0]
44
- index, tp, vmax, vmin, cmap,time_index, name = args
45
- # print(time_index)
46
- # logger.info(f"Processing index: {index}")
47
- # logger.info(time_index)
48
- fig, ax = plt.subplots(figsize=(10, 10))
49
-
50
- # 创建绘图和设置坐标系
51
- # fig = plt.figure(figsize=(10, 8))
52
- ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
53
-
54
- # 设置图像显示的范围
55
- ax.set_extent(env, ccrs.PlateCarree()) # 根据需要调整
56
-
57
- # 添加中国地图的边界和特征,包括省份轮廓
58
- add_china_map(ax)
59
- tp = np.where(tp >= 0, tp, np.nan)
60
- ax.imshow(tp, vmin=0, vmax=100, cmap=cmp_hjnwtx["radar_nmc"], transform=ccrs.PlateCarree(), extent=env, alpha=1)
61
-
62
-
63
- # ax.imshow(tp, vmax=vmax, vmin=vmin, cmap=cmap)
64
- ax.axis('off')
65
- # ax.text(0.5, 0.5, str(index), transform=ax.transAxes, color='white', fontsize=20, ha='center', va='center')
66
- ax.text(0.95, 0.95, f'{time_index}', transform=ax.transAxes, color='white', fontsize=20, ha='right', va='bottom')
67
- ax.text(0.925, 0.925, f'{str(index)}', transform=ax.transAxes, color='white', fontsize=20, ha='right', va='top')
68
- fig.tight_layout()
69
-
70
- buf = io.BytesIO()
71
- plt.savefig(buf, format='png')
72
- buf.seek(0)
73
- plt.close(fig)
74
- return (index, buf) #返回两个数为元组
75
-
76
- # 修改读取部分
77
- def drawpic(tp, Count,timeList, name="temp"):
78
- vmax = 70
79
- vmin = 0
80
- cmap = cmp_hjnwtx["radar_nmc"]
81
- args_list = [ (index, tp[index, :, :], vmax, vmin, cmap,timeList[index], name) for index in range(2 * Count)]
82
-
83
- with Pool(31) as pool:
84
- results = pool.map(draw_subplot, args_list)
85
-
86
- buffers = [result[1] for result in results]
87
- combined_fig, axs = plt.subplots(2, Count, figsize=(10 * Count, 20))
88
- for i in range(2):
89
- for j in range(Count):
90
- index = i * Count + j
91
- ax = axs[i, j]
92
- ax.imshow(plt.imread(buffers[index]), cmap=cmap)
93
- ax.axis('off')
94
-
95
- now_str = datetime.datetime.now().strftime("%Y%m%d%H%M")
96
- plt.tight_layout()
97
- outpath = f"./{timeList[0].strftime('%Y%m%d%H%M')}_CR/{name}_{now_str}.png"
98
- mkDir(outpath)
99
- plt.savefig(outpath)
100
- plt.close(combined_fig)
101
-
102
-
103
-
104
- BASE_TARGET_PATH = "/mnt/wtx_weather_forecast/WTX_DATA/RADA/MQPF_GLB" #/mnt/wtx_weather_forecast/WTX_DATA/RADA/MQPF_PMSC
105
- # BASE_TARGET_PATH = "/mnt/wtx_weather_forecast/WTX_DATA/RADA/MQPF_PMSC" #/mnt/wtx_weather_forecast/WTX_DATA/RADA/MQPF_PMSC
106
-
107
- def get_mqpf_paths(UCTstr):
108
- year = UCTstr[:4]
109
- date = UCTstr[:8]
110
- mqpfPath_pattern = os.path.join(BASE_TARGET_PATH,year, date,f"MSP2_WTX_AIW_REF_L88_NA_{UCTstr}_00000-00300-00006.nc") #MSP2_WTX_AIW_QPF_L88_NA_202410222254_00000-00300-00006.nc
111
- # mqpfPath_pattern = os.path.join(BASE_TARGET_PATH,year, date,f"MSP2_WTX_AIW_MQPF_L88_CHN_{UCTstr}_00000-00300-00006.nc")
112
-
113
- return mqpfPath_pattern
114
-
115
- def map_data(conf):
116
- CST = conf[0]
117
- UCT = CST + relativedelta(hours=-8)
118
- UCTstr = UCT.strftime("%Y%m%d%H%M")
119
- mqpfPath_pattern = get_mqpf_paths(UCTstr)
120
- mqpfPath_list = glob.glob(mqpfPath_pattern)
121
- if len(mqpfPath_list) == 0:
122
- data_loss = re.findall(r"(2024\d{8}?)",mqpfPath_pattern)
123
- print("data_loss",data_loss)
124
- print("data_loss_path",mqpfPath_pattern)
125
- tj_list.append(data_loss[0])
126
- return np.full(shape_, np.nan)
127
- else:
128
- try:
129
- with nc.Dataset(mqpfPath_list[0]) as dataNC:
130
- mqpf = dataNC.variables["CR"][:]
131
- mqpf = mqpf[:1]
132
- if mqpf.shape != shape_:
133
- logger.info(mqpf.shape )
134
- logger.info(mqpfPath_list[0])
135
- print("mqpf shape error",mqpf.shape)
136
- mqpf = mqpf[:,:-1, :-1]
137
- if mqpf.shape != shape_:
138
- return np.full(shape_, np.nan)
139
- else:
140
- return mqpf
141
- print("mqpf",UCTstr,mqpf.shape)
142
- tj_list1.append(mqpfPath_pattern)
143
- return mqpf
144
- except Exception as e:
145
- print(traceback.format_exc())
146
- return np.full(shape_, np.nan)
147
-
148
- def options():
149
- parser = argparse.ArgumentParser(description='plot radar')
150
- # parser.add_argument('--times', type=str, default='202406290000,202406300000')
151
- parser.add_argument('--times', type=str, default='202407310000,202408010000')
152
- parser.add_argument('--pac', type=str, default='100000')
153
- # parser.add_argument('--combine', action='store_true', default=False)
154
- parser.add_argument('--combine',action='store_true',default=False)
155
- parser.add_argument('--isDebug',action='store_true',default=False)
156
- parser.add_argument('--isDraw',action='store_true',default=False)
157
- parser.add_argument('--freq', type=str, default="1h")
158
- parser.add_argument('--tag',type=str, default=datetime.datetime.now().strftime("%Y%m%d%H%M"))
159
- config= parser.parse_args()
160
- print(config)
161
- config.times = config.times.split(",")
162
- config.pac = config.pac.split(",")
163
- if len(config.times) == 1:
164
- config.times = [config.times[0], config.times[0]]
165
- config.times = [datetime.datetime.strptime(config.times[0], "%Y%m%d%H%M"),
166
- datetime.datetime.strptime(config.times[1], "%Y%m%d%H%M")]
167
- return config
168
- if __name__ == '__main__':
169
- cfg = options()
170
- sCST = cfg.times[0]
171
- eCST = cfg.times[-1]
172
- sCSTstr = sCST.strftime("%Y%m%d")
173
- tj_list = []
174
- tj_list1= []
175
- start = datetime.datetime.now()
176
- logger.info(f"{sCST}")
177
- logger.info(f"{eCST}")
178
- logger.info(f"PNG")
179
- timeList = pd.date_range(sCST,eCST,freq="360s",inclusive="left")
180
- # for CST in timeList:
181
- productList = product(timeList)
182
- with Pool(31) as p:
183
- Data = p.map(map_data,productList)
184
- end = datetime.datetime.now()
185
- print(start-end)
186
- Data_con = np.concatenate(Data,axis=0)
187
- loss_len = 240 - Data_con.shape[0]
188
- sCSTstr = sCST.strftime("%Y%m%d")
189
- eCSTstr = eCST.strftime("%Y%m%d")
190
- # Data_con1 = Data_con.filled()
191
- # np.save(f"data_{sCSTstr}_{eCSTstr}.npy",Data_con1)
192
- Data_con_120 = copy.copy(Data_con)
193
- drawpic(Data_con_120[:int(len(Data_con_120)/2)], int(len(Data_con_120)/4),timeList[:int(len(Data_con_120)/2)],name=f"temp120_{sCSTstr}_loss_{loss_len}_")
194
- print("done 120")
195
- end1 = datetime.datetime.now()
196
- print(end1-end)
197
- Data_con_240 = copy.copy(Data_con)
198
- print(Data_con_240[120:].shape)
199
- drawpic(Data_con_120[int(len(Data_con_120)/2):], int(len(Data_con_120)/4),timeList[int(len(Data_con_120)/2):],name=f"temp120_240_{sCSTstr}_{loss_len}_")
200
- print(datetime.datetime.now()-end1)
201
- print("done 120-240")
202
- logger.info("success")
203
-
204
-
205
- # "/mnt/wtx_weather_forecast/WTX_DATA/RADA/MQPF/2024/20240704/MSP2_WTX_AIW_REF_L88_CHN_202407040324_00000-00300-00006.nc"
206
-
@@ -1,275 +0,0 @@
1
- import matplotlib.pyplot as plt
2
- import matplotlib
3
- matplotlib.use("svg")
4
- import datetime
5
- from hjnwtx.colormap import cmp_hjnwtx
6
- import time
7
- import os
8
- import time
9
- import shutil
10
-
11
- from dateutil.relativedelta import relativedelta
12
- import glob
13
- from config import logger
14
- import argparse
15
- import pandas as pd
16
- import re
17
- import netCDF4 as nc
18
- from multiprocessing import Pool
19
- from itertools import product
20
- import numpy as np
21
- import copy
22
- import traceback
23
-
24
-
25
- from multiprocessing import Process, Queue
26
-
27
- import io
28
- import cartopy.crs as ccrs
29
- import cartopy.feature as cfeature
30
- import cartopy.io.shapereader as shpreader
31
- from shancx import crDir
32
-
33
- import matplotlib.pyplot as plt
34
- import matplotlib.cbook as cbook
35
- import matplotlib.image as image
36
- import matplotlib.cm as cm
37
- import matplotlib.colors as colors
38
- import io
39
- import datetime
40
- import numpy as np
41
- from multiprocessing import Pool
42
- import cartopy.crs as ccrs
43
- import cartopy.feature as cfeature
44
- import cartopy.io.shapereader as shpreader
45
- import matplotlib.pyplot as plt
46
- import matplotlib.cm as cm
47
- import datetime
48
- import numpy as np
49
- from multiprocessing import Pool
50
- import io
51
- import os
52
- from shancx import crDir
53
-
54
- # Assuming these are defined somewhere else in your code
55
- # cmp_hjnwtx = {"radar_nmc": your_cmap_definition}
56
- # shpreader = your_shpreader_definition
57
- # cfeature = your_cfeature_definition
58
- # ccrs = your_ccrs_definition
59
-
60
-
61
- import matplotlib.pyplot as plt
62
- import datetime
63
- import os
64
- import io
65
- from multiprocessing import Pool
66
-
67
- # Assuming these are defined somewhere else in your code
68
- # cmp_hjnwtx = {"radar_nmc": your_cmap_definition}
69
- # shpreader = your_shpreader_definition
70
- # cfeature = your_cfeature_definition
71
- # ccrs = your_ccrs_definition
72
- import matplotlib.pyplot as plt
73
- import datetime
74
- import os
75
- import io
76
- from multiprocessing import Pool
77
-
78
-
79
- import matplotlib.pyplot as plt
80
- import datetime
81
- import os
82
- import io
83
- from multiprocessing import Pool
84
- import cairosvg # Install using pip if not already installed
85
-
86
-
87
- # Assuming these are defined somewhere else in your code
88
- # cmp_hjnwtx = {"radar_nmc": your_cmap_definition}
89
- # shpreader = your_shpreader_definition
90
- # cfeature = your_cfeature_definition
91
- # ccrs = your_ccrs_definition
92
- def add_china_map(ax):
93
- # Add terrain features on the map
94
- ax.add_feature(cfeature.COASTLINE, edgecolor='gray')
95
- ax.add_feature(cfeature.BORDERS, linestyle=':', edgecolor='gray')
96
- ax.add_feature(cfeature.LAKES, alpha=0.8)
97
-
98
- # Add province outlines
99
- provinces = shpreader.natural_earth(resolution='10m', category='cultural', name='admin_1_states_provinces')
100
- provinces_features = shpreader.Reader(provinces).geometries()
101
- ax.add_geometries(provinces_features, ccrs.PlateCarree(), facecolor='none', edgecolor='gray', linestyle=':', linewidth=0.5, alpha=0.8)
102
-
103
- def draw_subplot(args):
104
- index, tp, vmax, vmin, cmap, time_index, name = args
105
-
106
- fig, ax = plt.subplots(figsize=(10, 10), subplot_kw={'projection': ccrs.PlateCarree()})
107
-
108
- ax.set_extent([73, 135, 18, 54], ccrs.PlateCarree()) # Adjust as needed
109
-
110
- add_china_map(ax)
111
-
112
- # Plot the data
113
- img = ax.imshow(tp, vmin=vmin, vmax=vmax, cmap=cmap, extent=[73, 134.99, 12.21, 54.2], transform=ccrs.PlateCarree(), alpha=1)
114
-
115
- # Turn off axis
116
- ax.axis('off')
117
-
118
- # Add text annotations
119
- ax.text(0.95, 0.95, f'{time_index}', transform=ax.transAxes, color='white', fontsize=20, ha='right', va='bottom')
120
- ax.text(0.925, 0.925, f'{str(index)}', transform=ax.transAxes, color='white', fontsize=20, ha='right', va='top')
121
-
122
- fig.tight_layout()
123
-
124
- # Save the figure to a buffer as SVG
125
- buf = io.BytesIO()
126
- plt.savefig(buf, format='svg', bbox_inches='tight')
127
- buf.seek(0)
128
- plt.close(fig)
129
-
130
- return (index, buf)
131
-
132
- def drawpic(tp, Count, timeList, name="temp"):
133
- vmax = 70
134
- vmin = 0
135
- cmap = cmp_hjnwtx["radar_nmc"]
136
-
137
- # Create arguments list for multiprocessing
138
- args_list = [(index, tp[index, :, :], vmax, vmin, cmap, timeList[index], name) for index in range(2 * Count)]
139
-
140
- with Pool(31) as pool:
141
- results = pool.map(draw_subplot, args_list)
142
-
143
- # Convert SVG data to PNG using cairosvg
144
- png_buffers = []
145
- for result in results:
146
- svg_data = result[1].getvalue().decode('utf-8')
147
- png_bytes = cairosvg.svg2png(bytestring=svg_data.encode('utf-8'))
148
- png_buffers.append(io.BytesIO(png_bytes))
149
-
150
- # Create a grid of subplots
151
- combined_fig, axs = plt.subplots(2, Count, figsize=(10 * Count, 20))
152
-
153
- for i in range(2):
154
- for j in range(Count):
155
- index = i * Count + j
156
- ax = axs[i, j]
157
- # Use the PNG data directly for display
158
- png_buf = png_buffers[index]
159
- png_buf.seek(0)
160
- png_data = plt.imread(png_buf)
161
- ax.imshow(png_data, cmap=cmap) # Display PNG data
162
- ax.axis('off')
163
-
164
- # Save the combined figure as SVG
165
- now_str = datetime.datetime.now().strftime("%Y%m%d%H%M")
166
- outdir = f"./{timeList[0].strftime('%Y%m%d%H%M')}_CR"
167
- crDir(outdir)
168
- outpath = os.path.join(outdir, f"{name}_{now_str}.svg")
169
-
170
- plt.tight_layout()
171
- plt.savefig(outpath, format='svg', bbox_inches='tight')
172
- plt.close(combined_fig)
173
-
174
-
175
-
176
- BASE_TARGET_PATH = "/mnt/wtx_weather_forecast/WTX_DATA/RADA/MQPF"
177
-
178
-
179
- def get_mqpf_paths(UCTstr):
180
- year = UCTstr[:4]
181
- date = UCTstr[:8]
182
- mqpfPath_pattern = os.path.join(BASE_TARGET_PATH,year, date,f"MSP2_WTX_AIW_REF_L88_CHN_{UCTstr}_00000-00300-00006.nc")
183
- # mqpfPath_pattern = os.path.join(BASE_TARGET_PATH,year, date,f"MSP2_WTX_AIW_MQPF_L88_CHN_{UCTstr}_00000-00300-00006.nc")
184
-
185
- return mqpfPath_pattern
186
-
187
- def map_data(conf):
188
- CST = conf[0]
189
- UCT = CST + relativedelta(hours=-8)
190
- UCTstr = UCT.strftime("%Y%m%d%H%M")
191
- mqpfPath_pattern = get_mqpf_paths(UCTstr)
192
- mqpfPath_list = glob.glob(mqpfPath_pattern)
193
- if len(mqpfPath_list) == 0:
194
- data_loss = re.findall(r"(2024\d{8}?)",mqpfPath_pattern)
195
- print("data_loss",data_loss)
196
- print("data_loss_path",mqpfPath_pattern)
197
- tj_list.append(data_loss[0])
198
- return np.full((1, 4200, 6200), np.nan)
199
- else:
200
- try:
201
- with nc.Dataset(mqpfPath_list[0]) as dataNC:
202
- mqpf = dataNC.variables["CR"][:]
203
- mqpf = mqpf[:1]
204
- if mqpf.shape != (1, 4200, 6200):
205
- logger.info(mqpf.shape )
206
- logger.info(mqpfPath_list[0])
207
- print("mqpf shape error",mqpf.shape)
208
- mqpf = mqpf[:,:-1, :-1]
209
- if mqpf.shape != (1, 4200, 6200):
210
- return np.full((1, 4200, 6200), np.nan)
211
- else:
212
- return mqpf
213
- print("mqpf",UCTstr,mqpf.shape)
214
- tj_list1.append(mqpfPath_pattern)
215
- return mqpf
216
- except Exception as e:
217
- print(traceback.format_exc())
218
- return np.full((1, 4200, 6200), np.nan)
219
-
220
- def options():
221
- parser = argparse.ArgumentParser(description='draw CR')
222
- # parser.add_argument('--times', type=str, default='202406290000,202406300000')
223
- parser.add_argument('--times', type=str, default='202407220000,202407230000')
224
- parser.add_argument('--pac', type=str, default='100000')
225
- # parser.add_argument('--combine', action='store_true', default=False)
226
- parser.add_argument('--combine',action='store_true',default=False)
227
- parser.add_argument('--isDebug',action='store_true',default=False)
228
- parser.add_argument('--isDraw',action='store_true',default=False)
229
- parser.add_argument('--freq', type=str, default="1h")
230
- parser.add_argument('--tag',type=str, default=datetime.datetime.now().strftime("%Y%m%d%H%M"))
231
- config= parser.parse_args()
232
- print(config)
233
- config.times = config.times.split(",")
234
- config.pac = config.pac.split(",")
235
- if len(config.times) == 1:
236
- config.times = [config.times[0], config.times[0]]
237
- config.times = [datetime.datetime.strptime(config.times[0], "%Y%m%d%H%M"),
238
- datetime.datetime.strptime(config.times[1], "%Y%m%d%H%M")]
239
- return config
240
- if __name__ == '__main__':
241
- cfg = options()
242
- sCST = cfg.times[0]
243
- eCST = cfg.times[-1]
244
- sCSTstr = sCST.strftime("%Y%m%d")
245
- tj_list = []
246
- tj_list1= []
247
- start = datetime.datetime.now()
248
- timeList = pd.date_range(sCST,eCST,freq="360s",inclusive="left")
249
- # for CST in timeList:
250
- productList = product(timeList)
251
- with Pool(31) as p:
252
- Data = p.map(map_data,productList)
253
- end = datetime.datetime.now()
254
- print(start-end)
255
- Data_con = np.concatenate(Data,axis=0)
256
- loss_len = 240 - Data_con.shape[0]
257
- sCSTstr = sCST.strftime("%Y%m%d")
258
- eCSTstr = eCST.strftime("%Y%m%d")
259
- # Data_con1 = Data_con.filled()
260
- # np.save(f"data_{sCSTstr}_{eCSTstr}.npy",Data_con1)
261
- Data_con_120 = copy.copy(Data_con)
262
- drawpic(Data_con_120[:int(len(Data_con_120)/2)], int(len(Data_con_120)/4),timeList[:int(len(Data_con_120)/2)],name=f"temp120_{sCSTstr}_loss_{loss_len}_")
263
- print("done 120")
264
- end1 = datetime.datetime.now()
265
- print(end1-end)
266
- Data_con_240 = copy.copy(Data_con)
267
- print(Data_con_240[120:].shape)
268
- drawpic(Data_con_120[int(len(Data_con_120)/2):], int(len(Data_con_120)/4),timeList[int(len(Data_con_120)/2):],name=f"temp120_240_{sCSTstr}_{loss_len}_")
269
- print(datetime.datetime.now()-end1)
270
- print("done 120-240")
271
- logger.info("success")
272
-
273
-
274
- # "/mnt/wtx_weather_forecast/WTX_DATA/RADA/MQPF/2024/20240704/MSP2_WTX_AIW_REF_L88_CHN_202407040324_00000-00300-00006.nc"
275
-