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/wtx/newTypeRadar.py
DELETED
|
@@ -1,492 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
import netCDF4 as nc
|
|
3
|
-
import os
|
|
4
|
-
import datetime as dt
|
|
5
|
-
import bz2
|
|
6
|
-
import time
|
|
7
|
-
from dateutil.relativedelta import relativedelta
|
|
8
|
-
import pandas as pd
|
|
9
|
-
import urllib
|
|
10
|
-
|
|
11
|
-
# Author:hujunnan
|
|
12
|
-
|
|
13
|
-
np.set_printoptions(suppress=True)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def pad2D(data, col):
|
|
17
|
-
return np.asarray(list(map(lambda x: x + ([np.nan] * (col - len(x))), data)))
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def pad3D(data, radialMax, distance):
|
|
21
|
-
tmp = list(map(lambda x: x + ([[np.nan] * distance] * (radialMax - len(x))), data))
|
|
22
|
-
for i in range(len(tmp)):
|
|
23
|
-
tmp[i] = pad2D(tmp[i], distance)
|
|
24
|
-
return np.asarray(tmp)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class readCinrad():
|
|
28
|
-
def __init__(self, path):
|
|
29
|
-
self.path=path
|
|
30
|
-
self.datetime = 0
|
|
31
|
-
self.radarID=path.split("_")[3]
|
|
32
|
-
self.type = path.split("_")[7]
|
|
33
|
-
if ".bz2" in path:
|
|
34
|
-
self.unzipBZ2()
|
|
35
|
-
self.fi = open(self.path, "rb")
|
|
36
|
-
self.Cut_Number = 0
|
|
37
|
-
self.Log_Resolution = 0
|
|
38
|
-
self.Doppler_Resolution = 0
|
|
39
|
-
self.isDuelDict = {
|
|
40
|
-
True: "双",
|
|
41
|
-
False: "单"
|
|
42
|
-
}
|
|
43
|
-
self.isDual=False
|
|
44
|
-
|
|
45
|
-
def seconds2datetime(self,seconds):
|
|
46
|
-
return dt.datetime.strptime(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(seconds)), "%Y-%m-%d %H:%M:%S")
|
|
47
|
-
|
|
48
|
-
def unzipBZ2(self):
|
|
49
|
-
f = open(file=self.path, mode='rb')
|
|
50
|
-
un = f.read()
|
|
51
|
-
f.close()
|
|
52
|
-
username = bz2.decompress(un)
|
|
53
|
-
os.makedirs("./tmp",exist_ok=True)
|
|
54
|
-
self.path=os.path.join("./tmp",os.path.basename(self.path).replace(".bz2",""))
|
|
55
|
-
with open(self.path, 'wb')as fp:
|
|
56
|
-
fp.write(username)
|
|
57
|
-
|
|
58
|
-
def parse_GENERIC_HEADER(self):
|
|
59
|
-
# 站点参数
|
|
60
|
-
GENERIC_HEADER = np.dtype(
|
|
61
|
-
{'names': ['Magic_Number', 'Major_Version', 'Minor_Version', 'Generic_Type', 'Product_Type', 'reserve'],
|
|
62
|
-
'formats': ['i', 'h', 'h', 'i', 'i', 'S16']})
|
|
63
|
-
[Magic_Number, Major_Version, Minor_Version, Generic_Type, Product_Type, _] = \
|
|
64
|
-
np.fromfile(file=self.fi, dtype=GENERIC_HEADER, count=1, sep='')[0]
|
|
65
|
-
print(Magic_Number, Major_Version, Minor_Version, Generic_Type, Product_Type)
|
|
66
|
-
|
|
67
|
-
def parse_SITE_CONFIG(self):
|
|
68
|
-
# 站点参数
|
|
69
|
-
SITE_CONFIG = np.dtype(
|
|
70
|
-
{'names': ['Site_Code', 'Site_Name', 'Latitude', 'Longitude', 'Antenna_Height', 'Ground_Height',
|
|
71
|
-
'Frequency', 'Beam_Width_Hori', 'Beam_Width_Vert', 'RDA_Version', 'Radar_Type', 'reserve'],
|
|
72
|
-
'formats': ['S8', 'S32', 'f', 'f', 'i', 'i', 'f', 'f', 'f', 'i', 'h', 'S54']})
|
|
73
|
-
[Site_Code, Site_Name, Latitude, Longitude, Antenna_Height, Ground_Height, Frequency, Beam_Width_Hori,
|
|
74
|
-
Beam_Width_Vert, RDA_Version, Radar_Type, _] = np.fromfile(file=self.fi, dtype=SITE_CONFIG, count=1, sep='')[0]
|
|
75
|
-
print(Site_Code, Site_Name, Latitude, Longitude, Antenna_Height, Ground_Height, Frequency, Beam_Width_Hori,
|
|
76
|
-
Beam_Width_Vert, RDA_Version, Radar_Type)
|
|
77
|
-
|
|
78
|
-
def parse_TASK_CONFIG(self):
|
|
79
|
-
# //TASK CONFIG
|
|
80
|
-
TASK_CONFIG = np.dtype(
|
|
81
|
-
{'names': ['Task_Name', ' Task_Description', 'Polarization_Type', 'Scan_Type', 'Pulse_Width',
|
|
82
|
-
'Scan_Start_Time', 'Cut_Number', 'Horizontal_Noise', 'Vertical_Noise', 'Horizontal_Calibration',
|
|
83
|
-
'Vertical_Calibration', 'Horizontal_Noise_Temperature', 'Vertical_Noise_Temperature',
|
|
84
|
-
'ZDR_Calibration',
|
|
85
|
-
'PHIDP_Calibration', 'LDR_Calibration', 'reserve'],
|
|
86
|
-
'formats': ['S32', 'S128', 'i', 'i', 'i', 'i', 'i', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'S40']})
|
|
87
|
-
[Task_Name, Task_Description, Polarization_Type, Scan_Type, Pulse_Width, Scan_Start_Time, Cut_Number,
|
|
88
|
-
Horizontal_Noise, Vertical_Noise, Horizontal_Calibration, Vertical_Calibration, Horizontal_Noise_Temperature,
|
|
89
|
-
Vertical_Noise_Temperature, ZDR_Calibration, PHIDP_Calibration, LDR_Calibration, _] = \
|
|
90
|
-
np.fromfile(file=self.fi, dtype=TASK_CONFIG, count=1, sep='')[0]
|
|
91
|
-
|
|
92
|
-
self.datetime=self.seconds2datetime(Scan_Start_Time)
|
|
93
|
-
# //系统LDR标定偏差
|
|
94
|
-
# in.readStringHJN(40)
|
|
95
|
-
# //保留字段
|
|
96
|
-
#
|
|
97
|
-
self.Cut_Number = Cut_Number
|
|
98
|
-
if "dual" in str(Task_Description):
|
|
99
|
-
self.isDual = True
|
|
100
|
-
else:
|
|
101
|
-
self.isDual = False
|
|
102
|
-
print(Task_Name, Task_Description)
|
|
103
|
-
print(Polarization_Type, Scan_Type, Pulse_Width, Scan_Start_Time, Cut_Number, Horizontal_Noise, Vertical_Noise,
|
|
104
|
-
Horizontal_Calibration,
|
|
105
|
-
Vertical_Calibration, Horizontal_Noise_Temperature, Vertical_Noise_Temperature, ZDR_Calibration,
|
|
106
|
-
PHIDP_Calibration, LDR_Calibration)
|
|
107
|
-
|
|
108
|
-
print("%s偏振" % (self.isDuelDict[self.isDual]))
|
|
109
|
-
|
|
110
|
-
def parse_read_CUT_CONFIG(self):
|
|
111
|
-
CUT_CONFIG1 = np.dtype(
|
|
112
|
-
{'names': ['Process_Mode', 'Wave_Form', 'PRF_1', 'PRF_2', 'Dealiasing_Mode', 'Azimuth',
|
|
113
|
-
'Elevation', 'Start_Angle', 'End_Angle', 'Angular_Resolution', 'Scan_Speed',
|
|
114
|
-
'Log_Resolution', 'Doppler_Resolution', 'Maximum_Range1', 'Maximum_Range2', 'Start_Range',
|
|
115
|
-
'Sample_1', 'Sample_2', 'Phase_Mode', 'Atmospheric_Loss', 'Nyquist_Speed'],
|
|
116
|
-
'formats': ['i', 'i', 'f', 'f', 'i', 'f', 'f', 'f', 'f', 'f', 'f', 'i', 'i', 'i', 'i', 'i', 'i',
|
|
117
|
-
'i', 'i', 'f', 'f']})
|
|
118
|
-
[Process_Mode, Wave_Form, PRF_1, PRF_2, Dealiasing_Mode, Azimuth, Elevation, Start_Angle,
|
|
119
|
-
End_Angle, Angular_Resolution, Scan_Speed, Log_Resolution, Doppler_Resolution, Maximum_Range1, Maximum_Range2,
|
|
120
|
-
Start_Range, Sample_1, Sample_2, Phase_Mode, Atmospheric_Loss, Nyquist_Speed] = \
|
|
121
|
-
np.fromfile(file=self.fi, dtype=CUT_CONFIG1, count=1, sep='')[0]
|
|
122
|
-
print("扫描字块 Process_Mode:", Process_Mode, "Wave_Form:", Wave_Form, "PRF_1:", PRF_1, "PRF_2:", PRF_2,
|
|
123
|
-
"Dealiasing_Mode:", Dealiasing_Mode, "Azimuth:", Azimuth, "Elevation:", Elevation, "Start_Angle:",
|
|
124
|
-
Start_Angle, "End_Angle:", End_Angle, "Angular_Resolution:", Angular_Resolution, "Scan_Speed:",
|
|
125
|
-
Scan_Speed, "Log_Resolution:", Log_Resolution, "Doppler_Resolution:", Doppler_Resolution,
|
|
126
|
-
"Maximum_Range1:",
|
|
127
|
-
Maximum_Range1, "Maximum_Range2:", Maximum_Range2, "Start_Range:", Start_Range, "Sample_1:", Sample_1,
|
|
128
|
-
"Sample_2:", Sample_2, "Phase_Mode:", Phase_Mode, "Atmospheric_Loss:", Atmospheric_Loss, "Nyquist_Speed:",
|
|
129
|
-
Nyquist_Speed)
|
|
130
|
-
|
|
131
|
-
self.Log_Resolution = Log_Resolution
|
|
132
|
-
self.Doppler_Resolution = Doppler_Resolution
|
|
133
|
-
CUT_CONFIG2 = np.dtype(
|
|
134
|
-
{'names': ['Moments_Mask', 'Moments_Size_Mask', 'Misc_Filter_Mask', 'SQI_Threshold', 'SIG_Threshold',
|
|
135
|
-
'CSR_Threshold',
|
|
136
|
-
'LOG_Threshold', 'CPA_Threshold', 'PMI_Threshold', 'DPLOG_Threshold',
|
|
137
|
-
'Thresholds_r', 'dBT_Mask', 'dBZ_Mask', 'Velocity_Mask', 'Spectrum_Width_Mask', 'DP_Mask',
|
|
138
|
-
'Mask_Reserved', 'Scan_Sync',
|
|
139
|
-
'Direction'],
|
|
140
|
-
'formats': ['q', 'q', 'i', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'S4', 'i', 'i', 'i', 'i', 'i',
|
|
141
|
-
'S12', 'i', 'i']})
|
|
142
|
-
[Moments_Mask, Moments_Size_Mask, Misc_Filter_Mask, SQI_Threshold, SIG_Threshold, CSR_Threshold,
|
|
143
|
-
LOG_Threshold, CPA_Threshold, PMI_Threshold, DPLOG_Threshold,
|
|
144
|
-
Thresholds_r, dBT_Mask, dBZ_Mask, Velocity_Mask, Spectrum_Width_Mask, DP_Mask, Mask_Reserved, Scan_Sync,
|
|
145
|
-
Direction] = \
|
|
146
|
-
np.fromfile(file=self.fi, dtype=CUT_CONFIG2, count=1, sep='')[0]
|
|
147
|
-
|
|
148
|
-
print(Moments_Mask, Moments_Size_Mask, Misc_Filter_Mask, SQI_Threshold, SIG_Threshold, CSR_Threshold,
|
|
149
|
-
LOG_Threshold, CPA_Threshold, PMI_Threshold, DPLOG_Threshold,
|
|
150
|
-
Thresholds_r, dBT_Mask, dBZ_Mask, Velocity_Mask, Spectrum_Width_Mask, DP_Mask, Mask_Reserved, Scan_Sync,
|
|
151
|
-
Direction)
|
|
152
|
-
|
|
153
|
-
CUT_CONFIG3 = np.dtype(
|
|
154
|
-
{'names': ['Ground_Clutter_Classifier_Type', 'Ground_Clutter_Filter_Type',
|
|
155
|
-
'Ground_Clutter_Filter_Notch_Width',
|
|
156
|
-
'Ground_Clutter_Filter_Window', "reserve"],
|
|
157
|
-
'formats': ['h', 'h', 'h', 'h', 'S72']})
|
|
158
|
-
[Ground_Clutter_Classifier_Type, Ground_Clutter_Filter_Type, Ground_Clutter_Filter_Notch_Width,
|
|
159
|
-
Ground_Clutter_Filter_Window, _] = \
|
|
160
|
-
np.fromfile(file=self.fi, dtype=CUT_CONFIG3, count=1, sep='')[0]
|
|
161
|
-
print(Ground_Clutter_Classifier_Type, Ground_Clutter_Filter_Type, Ground_Clutter_Filter_Notch_Width,
|
|
162
|
-
Ground_Clutter_Filter_Window)
|
|
163
|
-
|
|
164
|
-
def parse_MOMENT_DATA(self, eleNum):
|
|
165
|
-
|
|
166
|
-
rData = []
|
|
167
|
-
vData = []
|
|
168
|
-
sData = []
|
|
169
|
-
tData = []
|
|
170
|
-
SQIData = []
|
|
171
|
-
ZDRData = []
|
|
172
|
-
CCData = []
|
|
173
|
-
DPData = []
|
|
174
|
-
KDPData = []
|
|
175
|
-
SNRHData = []
|
|
176
|
-
azimuthR = []
|
|
177
|
-
azimuthV = []
|
|
178
|
-
elevationR = []
|
|
179
|
-
elevationV = []
|
|
180
|
-
numGatesR = 0
|
|
181
|
-
numGatesV = 0
|
|
182
|
-
numRadialsR = 0
|
|
183
|
-
numRadialsV = 0
|
|
184
|
-
timeR = []
|
|
185
|
-
timeV = []
|
|
186
|
-
|
|
187
|
-
# /**
|
|
188
|
-
# * 径向数据状态
|
|
189
|
-
# * 0–仰角开始
|
|
190
|
-
# * 1–中间数据
|
|
191
|
-
# * 2–仰角结束
|
|
192
|
-
# * 3–体扫开始
|
|
193
|
-
# * 4–体扫结束
|
|
194
|
-
# * 5–RHI开始
|
|
195
|
-
# * 6–RHI结束
|
|
196
|
-
# */
|
|
197
|
-
isFinished = 0
|
|
198
|
-
Length_of_data_all = 0
|
|
199
|
-
|
|
200
|
-
while not (isFinished == 2 or isFinished == 4):
|
|
201
|
-
|
|
202
|
-
MOMENT_DATA_BLOCK_HEAD = np.dtype(
|
|
203
|
-
{'names': ['Radial_State', 'Spot_Blank', 'Sequence_Number', 'Radial_Number', 'Elevation_Number',
|
|
204
|
-
'Azimuth',
|
|
205
|
-
'Elevation', 'Seconds', 'Microseconds', 'Length_of_data', 'Moment_Number', "reserve"],
|
|
206
|
-
'formats': ['i', 'i', 'i', 'i', 'i', 'f', 'f', 'i', 'i', 'i', 'i', 'S20']})
|
|
207
|
-
[Radial_State, Spot_Blank, Sequence_Number, Radial_Number, Elevation_Number, Azimuth, Elevation, Seconds,
|
|
208
|
-
Microseconds
|
|
209
|
-
, Length_of_data, Moment_Number, _] = \
|
|
210
|
-
np.fromfile(file=self.fi, dtype=MOMENT_DATA_BLOCK_HEAD, count=1, sep='')[0]
|
|
211
|
-
isFinished = Radial_State
|
|
212
|
-
# print("径向数据块头 Radial_State:", Radial_State, "Spot_Blank:", Spot_Blank, "Sequence_Number:", Sequence_Number,
|
|
213
|
-
# "Radial_Number:", Radial_Number, "Elevation_Number:", Elevation_Number, "Azimuth3:", Azimuth,
|
|
214
|
-
# "Elevation:", Elevation, "Seconds:", Seconds, "Microseconds:", Microseconds, "Length_of_data:",
|
|
215
|
-
# Length_of_data, "Moment_Number:", Moment_Number)
|
|
216
|
-
|
|
217
|
-
if Elevation_Number != eleNum:
|
|
218
|
-
print("something wrong")
|
|
219
|
-
return None
|
|
220
|
-
|
|
221
|
-
azimuthR.append(Azimuth)
|
|
222
|
-
azimuthV.append(Azimuth)
|
|
223
|
-
|
|
224
|
-
elevationR.append(Elevation)
|
|
225
|
-
elevationV.append(Elevation)
|
|
226
|
-
|
|
227
|
-
timeR.append(Seconds)
|
|
228
|
-
timeV.append(Seconds)
|
|
229
|
-
|
|
230
|
-
for i in range(Moment_Number):
|
|
231
|
-
MOMENT_DATA_HEAD = np.dtype(
|
|
232
|
-
{'names': ['Data_Type', 'Scale', 'Offset', 'Bin_Length', 'Flags', 'Length', 'reserve'],
|
|
233
|
-
'formats': ['i', 'i', 'i', 'h', 'h', 'i', 'S12']})
|
|
234
|
-
[Data_Type, Scale, Offset, Bin_Length, Flags, Length, _] = \
|
|
235
|
-
np.fromfile(file=self.fi, dtype=MOMENT_DATA_HEAD, count=1, sep='')[0]
|
|
236
|
-
|
|
237
|
-
# print(" 径向数据头 Data_Type:", Data_Type, "Scale:", Scale, "Offset:", Offset, "Bin_Length:", Bin_Length, "Flags:",
|
|
238
|
-
# Flags, "Length:", Length)
|
|
239
|
-
|
|
240
|
-
dtypeType = None
|
|
241
|
-
if Bin_Length == 1:
|
|
242
|
-
dtypeType = np.uint8
|
|
243
|
-
else:
|
|
244
|
-
dtypeType = np.uint16
|
|
245
|
-
data = np.fromfile(file=self.fi, dtype=dtypeType, count=Length // Bin_Length)
|
|
246
|
-
data = data.astype(np.float32)
|
|
247
|
-
data[data < 5] = np.nan
|
|
248
|
-
data = list((data - Offset) / Scale)
|
|
249
|
-
|
|
250
|
-
# //添加数据块
|
|
251
|
-
if Data_Type == 2:
|
|
252
|
-
rData.append(data)
|
|
253
|
-
numGatesR = Length / Bin_Length
|
|
254
|
-
numRadialsR = Radial_Number
|
|
255
|
-
# print("lengthR:", numGatesR, numGatesV)
|
|
256
|
-
|
|
257
|
-
elif (Data_Type == 3):
|
|
258
|
-
vData.append(data)
|
|
259
|
-
numGatesV = Length / Bin_Length
|
|
260
|
-
numRadialsV = Radial_Number
|
|
261
|
-
# print("lengthV:", numGatesR, numGatesV)
|
|
262
|
-
|
|
263
|
-
elif (Data_Type == 4):
|
|
264
|
-
sData.append(data)
|
|
265
|
-
|
|
266
|
-
elif (Data_Type == 1):
|
|
267
|
-
tData.append(data)
|
|
268
|
-
elif (Data_Type == 5):
|
|
269
|
-
SQIData.append(data)
|
|
270
|
-
elif (Data_Type == 7) :
|
|
271
|
-
ZDRData.append(data)
|
|
272
|
-
elif (Data_Type == 9) :
|
|
273
|
-
CCData.append(data)
|
|
274
|
-
elif (Data_Type == 10) :
|
|
275
|
-
DPData.append(data)
|
|
276
|
-
elif (Data_Type == 11) :
|
|
277
|
-
KDPData.append(data)
|
|
278
|
-
elif (Data_Type == 16):
|
|
279
|
-
SNRHData.append(data)
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return {"Length_of_data_all": Length_of_data_all, "azimuthR": azimuthR, "azimuthV": azimuthV,
|
|
283
|
-
"elevationR": elevationR, "elevationV": elevationV, "numGatesR": numGatesR, "numGatesV": numGatesV,
|
|
284
|
-
"numRadialsR": numRadialsR, "numRadialsV": numRadialsV, "timeR": timeR, "timeV": timeV,
|
|
285
|
-
"RadialVelocity": vData, "Reflectivity": rData, "SpectrumWidth": sData, "TotalReflectivity": tData,
|
|
286
|
-
"SignalQualityIndex": SQIData, "DifferentialReflectivity": ZDRData,
|
|
287
|
-
"CrossCorrelationCoefficient": CCData, "DifferentialPhase": DPData,
|
|
288
|
-
"SpecificDifferentialPhase": KDPData, "HorizontalSignalNoiseRatio": SNRHData}
|
|
289
|
-
|
|
290
|
-
def mkNC(self, outpath, rC):
|
|
291
|
-
os.makedirs(os.path.dirname(outpath), exist_ok=True)
|
|
292
|
-
a = nc.Dataset(outpath, "w", format='NETCDF4')
|
|
293
|
-
a.createDimension("scanR", len(rC["elevationR"]))
|
|
294
|
-
a.createDimension("scanV", len(rC["elevationV"]))
|
|
295
|
-
radialMax = max(np.max(rC["numRadialsR"]), np.max(rC["numRadialsV"]))
|
|
296
|
-
|
|
297
|
-
# println(radialMax)
|
|
298
|
-
a.createDimension("radial", radialMax)
|
|
299
|
-
a.createDimension("gateR", len(rC["distanceR"]))
|
|
300
|
-
a.createDimension("gateV", len(rC["distanceV"]))
|
|
301
|
-
|
|
302
|
-
a.createVariable("azimuthR", "f", ["scanR", "radial"])
|
|
303
|
-
a.createVariable("azimuthV", "f", ["scanV", "radial"])
|
|
304
|
-
a.createVariable("distanceR", "f", ["gateR"])
|
|
305
|
-
a.createVariable("distanceV", "f", ["gateV"])
|
|
306
|
-
a.createVariable("elevationR", "f", ["scanR", "radial"])
|
|
307
|
-
a.createVariable("elevationV", "f", ["scanV", "radial"])
|
|
308
|
-
a.createVariable("numGatesR", "i", ["scanR"])
|
|
309
|
-
a.createVariable("numGatesV", "i", ["scanV"])
|
|
310
|
-
a.createVariable("numRadialsR", "i", ["scanR"])
|
|
311
|
-
a.createVariable("numRadialsV", "i", ["scanV"])
|
|
312
|
-
tR = a.createVariable("timeR", "i", ["scanR", "radial"])
|
|
313
|
-
tR.missing_value = -1
|
|
314
|
-
tV = a.createVariable("timeV", "i", ["scanV", "radial"])
|
|
315
|
-
tV.missing_value = -1
|
|
316
|
-
v = a.createVariable("RadialVelocity", "f", ["scanV", "radial", "gateV"], zlib=True)
|
|
317
|
-
v.valid_range = [-62, 62]
|
|
318
|
-
a.createVariable("SpectrumWidth", "f", ["scanV", "radial", "gateV"], zlib=True)
|
|
319
|
-
a.createVariable("Reflectivity", "f", ["scanR", "radial", "gateR"], zlib=True)
|
|
320
|
-
if self.isDual:
|
|
321
|
-
a.createVariable("TotalReflectivity", "f", ["scanR", "radial", "gateR"], zlib=True)
|
|
322
|
-
a.createVariable("SignalQualityIndex", "f", ["radial", "gateR"], zlib=True)
|
|
323
|
-
a.createVariable("DifferentialReflectivity", "f", ["scanR", "radial", "gateR"], zlib=True)
|
|
324
|
-
a.createVariable("CrossCorrelationCoefficient", "f", ["scanR", "radial", "gateR"], zlib=True)
|
|
325
|
-
a.createVariable("DifferentialPhase", "f", ["scanR", "radial", "gateR"], zlib=True)
|
|
326
|
-
a.createVariable("SpecificDifferentialPhase", "f4", ["scanR", "radial", "gateR"], zlib=True)
|
|
327
|
-
a.createVariable("HorizontalSignalNoiseRatio", "f4", ["scanR", "radial", "gateR"], zlib=True)
|
|
328
|
-
|
|
329
|
-
# print(len(rC["azimuthR"]), len(rC["azimuthR"][0]))
|
|
330
|
-
# print(rC["azimuthR"])
|
|
331
|
-
# print(a.variables["azimuthR"][:].shape)
|
|
332
|
-
# print(rC["azimuthR"].shape)
|
|
333
|
-
a.variables["azimuthR"][:] = rC["azimuthR"]
|
|
334
|
-
a.variables["azimuthV"][:] = rC["azimuthV"]
|
|
335
|
-
a.variables["distanceR"][:] = rC["distanceR"]
|
|
336
|
-
a.variables["distanceV"][:] = rC["distanceV"]
|
|
337
|
-
a.variables["elevationR"][:] = rC["elevationR"]
|
|
338
|
-
a.variables["elevationV"][:] = rC["elevationV"]
|
|
339
|
-
a.variables["numGatesR"][:] = rC["numGatesR"]
|
|
340
|
-
a.variables["numGatesV"][:] = rC["numGatesV"]
|
|
341
|
-
a.variables["numRadialsR"][:] = rC["numRadialsR"]
|
|
342
|
-
a.variables["numRadialsV"][:] = rC["numRadialsV"]
|
|
343
|
-
a.variables["timeR"][:] = rC["timeR"]
|
|
344
|
-
a.variables["timeV"][:] = rC["timeV"]
|
|
345
|
-
a.variables["RadialVelocity"][:] = rC["RadialVelocity"]
|
|
346
|
-
a.variables["SpectrumWidth"][:] = rC["SpectrumWidth"]
|
|
347
|
-
a.variables["Reflectivity"][:] = rC["Reflectivity"]
|
|
348
|
-
if self.isDual:
|
|
349
|
-
a.variables["TotalReflectivity"][:]=rC["TotalReflectivity"]
|
|
350
|
-
a.variables["SignalQualityIndex"][:]=rC["SignalQualityIndex"]
|
|
351
|
-
a.variables["DifferentialReflectivity"][:]=rC["DifferentialReflectivity"]
|
|
352
|
-
a.variables["CrossCorrelationCoefficient"][:]=rC["CrossCorrelationCoefficient"]
|
|
353
|
-
a.variables["DifferentialPhase"][:]=rC["DifferentialPhase"]
|
|
354
|
-
a.variables["SpecificDifferentialPhase"][:]=rC["SpecificDifferentialPhase"]
|
|
355
|
-
a.variables["HorizontalSignalNoiseRatio"][:]=rC["HorizontalSignalNoiseRatio"]
|
|
356
|
-
|
|
357
|
-
a.close()
|
|
358
|
-
|
|
359
|
-
return None
|
|
360
|
-
|
|
361
|
-
def main(self,outparent):
|
|
362
|
-
self.parse_GENERIC_HEADER()
|
|
363
|
-
self.parse_SITE_CONFIG()
|
|
364
|
-
self.parse_TASK_CONFIG()
|
|
365
|
-
for i in range(self.Cut_Number):
|
|
366
|
-
self.parse_read_CUT_CONFIG()
|
|
367
|
-
|
|
368
|
-
rData = []
|
|
369
|
-
vData = []
|
|
370
|
-
sData = []
|
|
371
|
-
azimuthR = []
|
|
372
|
-
azimuthV = []
|
|
373
|
-
tData = []
|
|
374
|
-
SQIData = []
|
|
375
|
-
SQIData2D = []
|
|
376
|
-
ZDRData = []
|
|
377
|
-
CCData = []
|
|
378
|
-
DPData = []
|
|
379
|
-
KDPData = []
|
|
380
|
-
SNRHData = []
|
|
381
|
-
distanceR = []
|
|
382
|
-
distanceV = []
|
|
383
|
-
elevationR = []
|
|
384
|
-
elevationV = []
|
|
385
|
-
numGatesR = []
|
|
386
|
-
numGatesV = []
|
|
387
|
-
numRadialsR = []
|
|
388
|
-
numRadialsV = []
|
|
389
|
-
timeR = []
|
|
390
|
-
timeV = []
|
|
391
|
-
|
|
392
|
-
for i in range(self.Cut_Number):
|
|
393
|
-
a = self.parse_MOMENT_DATA(i + 1)
|
|
394
|
-
|
|
395
|
-
if len(a["Reflectivity"]) != 0:
|
|
396
|
-
azimuthR.append(a["azimuthR"])
|
|
397
|
-
elevationR.append(a["elevationR"])
|
|
398
|
-
|
|
399
|
-
# // println(a.Reflectivity.length)
|
|
400
|
-
# // println(s"a.numGatesR:${a.numGatesR}")
|
|
401
|
-
numGatesR.append(a["numGatesR"])
|
|
402
|
-
numRadialsR.append(a["numRadialsR"])
|
|
403
|
-
timeR.append(a["timeR"])
|
|
404
|
-
rData.append(a["Reflectivity"])
|
|
405
|
-
|
|
406
|
-
if len(a["RadialVelocity"]) != 0:
|
|
407
|
-
azimuthV.append(a["azimuthV"])
|
|
408
|
-
elevationV.append(a["elevationV"])
|
|
409
|
-
numGatesV.append(a["numGatesV"])
|
|
410
|
-
numRadialsV.append(a["numRadialsV"])
|
|
411
|
-
timeV.append(a["timeV"])
|
|
412
|
-
vData.append(a["RadialVelocity"])
|
|
413
|
-
sData.append(a["SpectrumWidth"])
|
|
414
|
-
|
|
415
|
-
if len(a["SignalQualityIndex"]) != 0:
|
|
416
|
-
SQIData.append(a["SignalQualityIndex"])
|
|
417
|
-
if len(a["TotalReflectivity"]) != 0:
|
|
418
|
-
tData.append(a["TotalReflectivity"])
|
|
419
|
-
ZDRData.append(a["DifferentialReflectivity"])
|
|
420
|
-
CCData.append(a["CrossCorrelationCoefficient"])
|
|
421
|
-
DPData.append(a["DifferentialPhase"])
|
|
422
|
-
KDPData.append(a["SpecificDifferentialPhase"])
|
|
423
|
-
SNRHData.append(a["HorizontalSignalNoiseRatio"])
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
if (len(azimuthR) == 11):
|
|
428
|
-
azimuthR = azimuthR[0:1] + azimuthR[2:3] + azimuthR[4:11]
|
|
429
|
-
elevationR = elevationR[0:1] + elevationR[2:3] + elevationR[4:11]
|
|
430
|
-
numGatesR = numGatesR[0:1] + numGatesR[2:3] + numGatesR[4:11]
|
|
431
|
-
numRadialsR = numRadialsR[0:1] + numRadialsR[2:3] + numRadialsR[4:11]
|
|
432
|
-
timeR = timeR[0:1] + timeR[2:3] + timeR[4:11]
|
|
433
|
-
rData = rData[0:1] + rData[2:3] + rData[4:11]
|
|
434
|
-
azimuthV = azimuthV[1:2] + azimuthV[3:11]
|
|
435
|
-
elevationV = elevationV[1:2] + elevationV[3:11]
|
|
436
|
-
numGatesV = numGatesV[1:2] + numGatesV[3:11]
|
|
437
|
-
numRadialsV = numRadialsV[1:2] + numRadialsV[3:11]
|
|
438
|
-
timeV = timeV[1:2] + timeV[3:11]
|
|
439
|
-
vData = vData[1:2] + vData[3:11]
|
|
440
|
-
sData = sData[1:2] + sData[3:11]
|
|
441
|
-
|
|
442
|
-
# 选取最大的库数
|
|
443
|
-
print(numGatesR)
|
|
444
|
-
distanceR = list(map(lambda x: x * self.Log_Resolution, range(int(np.max(numGatesR)))))
|
|
445
|
-
distanceV = list(map(lambda x: x * self.Doppler_Resolution, range(int(np.max(numGatesV)))))
|
|
446
|
-
|
|
447
|
-
print(numRadialsR, numRadialsV)
|
|
448
|
-
radialMax = max(np.max(np.asarray(numRadialsR)), np.max(np.asarray(numRadialsV)))
|
|
449
|
-
gateRMax = int(np.max(np.asarray(numGatesR)))
|
|
450
|
-
gateVMax = int(np.max(np.asarray(numGatesV)))
|
|
451
|
-
print(gateRMax, gateVMax)
|
|
452
|
-
azimuthR = pad2D(azimuthR, radialMax)
|
|
453
|
-
azimuthV = pad2D(azimuthV, radialMax)
|
|
454
|
-
elevationR = pad2D(elevationR, radialMax)
|
|
455
|
-
elevationV = pad2D(elevationV, radialMax)
|
|
456
|
-
timeR = pad2D(timeR, radialMax)
|
|
457
|
-
timeV = pad2D(timeV, radialMax)
|
|
458
|
-
tData = pad3D(tData, radialMax, gateRMax)
|
|
459
|
-
vData = pad3D(vData, radialMax, gateVMax)
|
|
460
|
-
sData = pad3D(sData, radialMax, gateVMax)
|
|
461
|
-
rData = pad3D(rData, radialMax, gateRMax)
|
|
462
|
-
|
|
463
|
-
print(SQIData)
|
|
464
|
-
if self.isDual:
|
|
465
|
-
SQIData2D = pad3D([SQIData[0]], radialMax, gateRMax)
|
|
466
|
-
ZDRData = pad3D(ZDRData, radialMax, gateRMax)
|
|
467
|
-
CCData = pad3D(CCData, radialMax, gateRMax)
|
|
468
|
-
DPData = pad3D(DPData, radialMax, gateRMax)
|
|
469
|
-
KDPData = pad3D(KDPData, radialMax, gateRMax)
|
|
470
|
-
SNRHData = pad3D(SNRHData, radialMax, gateRMax)
|
|
471
|
-
print(rData.shape)
|
|
472
|
-
|
|
473
|
-
b = {"azimuthR": azimuthR, "azimuthV": azimuthV, "distanceR": distanceR, "distanceV": distanceV,
|
|
474
|
-
"elevationR": elevationR, "elevationV": elevationV, "numGatesR": numGatesR, "numGatesV": numGatesV,
|
|
475
|
-
"numRadialsR": numRadialsR, "numRadialsV": numRadialsV, "timeR": timeR, "timeV": timeV,
|
|
476
|
-
"RadialVelocity": vData,
|
|
477
|
-
"Reflectivity": rData, "SpectrumWidth": sData, "TotalReflectivity": tData,
|
|
478
|
-
"SignalQualityIndex": SQIData2D, "DifferentialReflectivity": ZDRData,
|
|
479
|
-
"CrossCorrelationCoefficient": CCData,
|
|
480
|
-
"DifferentialPhase": DPData, "SpecificDifferentialPhase": KDPData, "HorizontalSignalNoiseRatio": SNRHData}
|
|
481
|
-
timtStr=self.datetime.strftime("%Y%m%d%H%M%S")
|
|
482
|
-
outputPath="%s/%s/%s/%s/Z_RADR_I_%s_%s_O_DOR_%s_CAP_FMT.nc"%(outparent,timtStr[:4],timtStr[:8],self.radarID,self.radarID,timtStr,self.type)
|
|
483
|
-
os.makedirs(os.path.dirname(outputPath),exist_ok=True)
|
|
484
|
-
self.mkNC(outputPath, b)
|
|
485
|
-
self.fi.close()
|
|
486
|
-
os.remove(self.path)
|
|
487
|
-
|
|
488
|
-
if __name__ == "__main__":
|
|
489
|
-
outputFile = "Z_RADR_I_Z9891_20200909000044_O_DOR_CD_CAP_FMT.bin.bz2"
|
|
490
|
-
a = readCinrad(outputFile)
|
|
491
|
-
a.main("./radarNC")
|
|
492
|
-
|
shancx/wtx/test.py
DELETED
shancx/wtx/tlogP.py
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
from contextlib import ExitStack
|
|
2
|
-
|
|
3
|
-
from matplotlib.axes import Axes
|
|
4
|
-
import matplotlib.transforms as transforms
|
|
5
|
-
import matplotlib.axis as maxis
|
|
6
|
-
import matplotlib.spines as mspines
|
|
7
|
-
from matplotlib.projections import register_projection
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# The sole purpose of this class is to look at the upper, lower, or total
|
|
11
|
-
# interval as appropriate and see what parts of the tick to draw, if any.
|
|
12
|
-
class SkewXTick(maxis.XTick):
|
|
13
|
-
def draw(self, renderer):
|
|
14
|
-
# When adding the callbacks with `stack.callback`, we fetch the current
|
|
15
|
-
# visibility state of the artist with `get_visible`; the ExitStack will
|
|
16
|
-
# restore these states (`set_visible`) at the end of the block (after
|
|
17
|
-
# the draw).
|
|
18
|
-
with ExitStack() as stack:
|
|
19
|
-
for artist in [self.gridline, self.tick1line, self.tick2line,
|
|
20
|
-
self.label1, self.label2]:
|
|
21
|
-
stack.callback(artist.set_visible, artist.get_visible())
|
|
22
|
-
needs_lower = transforms.interval_contains(
|
|
23
|
-
self.axes.lower_xlim, self.get_loc())
|
|
24
|
-
needs_upper = transforms.interval_contains(
|
|
25
|
-
self.axes.upper_xlim, self.get_loc())
|
|
26
|
-
self.tick1line.set_visible(
|
|
27
|
-
self.tick1line.get_visible() and needs_lower)
|
|
28
|
-
self.label1.set_visible(
|
|
29
|
-
self.label1.get_visible() and needs_lower)
|
|
30
|
-
self.tick2line.set_visible(
|
|
31
|
-
self.tick2line.get_visible() and needs_upper)
|
|
32
|
-
self.label2.set_visible(
|
|
33
|
-
self.label2.get_visible() and needs_upper)
|
|
34
|
-
super(SkewXTick, self).draw(renderer)
|
|
35
|
-
|
|
36
|
-
def get_view_interval(self):
|
|
37
|
-
return self.axes.xaxis.get_view_interval()
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# This class exists to provide two separate sets of intervals to the tick,
|
|
41
|
-
# as well as create instances of the custom tick
|
|
42
|
-
class SkewXAxis(maxis.XAxis):
|
|
43
|
-
def _get_tick(self, major):
|
|
44
|
-
return SkewXTick(self.axes, None, major=major)
|
|
45
|
-
|
|
46
|
-
def get_view_interval(self):
|
|
47
|
-
return self.axes.upper_xlim[0], self.axes.lower_xlim[1]
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
# This class exists to calculate the separate data range of the
|
|
51
|
-
# upper X-axis and draw the spine there. It also provides this range
|
|
52
|
-
# to the X-axis artist for ticking and gridlines
|
|
53
|
-
class SkewSpine(mspines.Spine):
|
|
54
|
-
def _adjust_location(self):
|
|
55
|
-
pts = self._path.vertices
|
|
56
|
-
if self.spine_type == 'top':
|
|
57
|
-
pts[:, 0] = self.axes.upper_xlim
|
|
58
|
-
else:
|
|
59
|
-
pts[:, 0] = self.axes.lower_xlim
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# This class handles registration of the skew-xaxes as a projection as well
|
|
63
|
-
# as setting up the appropriate transformations. It also overrides standard
|
|
64
|
-
# spines and axes instances as appropriate.
|
|
65
|
-
class SkewXAxes(Axes):
|
|
66
|
-
# The projection must specify a name. This will be used be the
|
|
67
|
-
# user to select the projection, i.e. ``subplot(111,
|
|
68
|
-
# projection='skewx')``.
|
|
69
|
-
name = 'skewx'
|
|
70
|
-
|
|
71
|
-
def _init_axis(self):
|
|
72
|
-
# Taken from Axes and modified to use our modified X-axis
|
|
73
|
-
self.xaxis = SkewXAxis(self)
|
|
74
|
-
self.spines['top'].register_axis(self.xaxis)
|
|
75
|
-
self.spines['bottom'].register_axis(self.xaxis)
|
|
76
|
-
self.yaxis = maxis.YAxis(self)
|
|
77
|
-
self.spines['left'].register_axis(self.yaxis)
|
|
78
|
-
self.spines['right'].register_axis(self.yaxis)
|
|
79
|
-
|
|
80
|
-
def _gen_axes_spines(self):
|
|
81
|
-
spines = {'top': SkewSpine.linear_spine(self, 'top'),
|
|
82
|
-
'bottom': mspines.Spine.linear_spine(self, 'bottom'),
|
|
83
|
-
'left': mspines.Spine.linear_spine(self, 'left'),
|
|
84
|
-
'right': mspines.Spine.linear_spine(self, 'right')}
|
|
85
|
-
return spines
|
|
86
|
-
|
|
87
|
-
def _set_lim_and_transforms(self):
|
|
88
|
-
"""
|
|
89
|
-
This is called once when the plot is created to set up all the
|
|
90
|
-
transforms for the data, text and grids.
|
|
91
|
-
"""
|
|
92
|
-
rot = 30
|
|
93
|
-
|
|
94
|
-
# Get the standard transform setup from the Axes base class
|
|
95
|
-
super()._set_lim_and_transforms()
|
|
96
|
-
|
|
97
|
-
# Need to put the skew in the middle, after the scale and limits,
|
|
98
|
-
# but before the transAxes. This way, the skew is done in Axes
|
|
99
|
-
# coordinates thus performing the transform around the proper origin
|
|
100
|
-
# We keep the pre-transAxes transform around for other users, like the
|
|
101
|
-
# spines for finding bounds
|
|
102
|
-
self.transDataToAxes = (
|
|
103
|
-
self.transScale
|
|
104
|
-
+ self.transLimits
|
|
105
|
-
+ transforms.Affine2D().skew_deg(rot, 0)
|
|
106
|
-
)
|
|
107
|
-
# Create the full transform from Data to Pixels
|
|
108
|
-
self.transData = self.transDataToAxes + self.transAxes
|
|
109
|
-
|
|
110
|
-
# Blended transforms like this need to have the skewing applied using
|
|
111
|
-
# both axes, in axes coords like before.
|
|
112
|
-
self._xaxis_transform = (
|
|
113
|
-
transforms.blended_transform_factory(
|
|
114
|
-
self.transScale + self.transLimits,
|
|
115
|
-
transforms.IdentityTransform())
|
|
116
|
-
+ transforms.Affine2D().skew_deg(rot, 0)
|
|
117
|
-
+ self.transAxes
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
@property
|
|
121
|
-
def lower_xlim(self):
|
|
122
|
-
return self.axes.viewLim.intervalx
|
|
123
|
-
|
|
124
|
-
@property
|
|
125
|
-
def upper_xlim(self):
|
|
126
|
-
pts = [[0., 1.], [1., 1.]]
|
|
127
|
-
return self.transDataToAxes.inverted().transform(pts)[:, 0]
|
|
128
|
-
|
|
129
|
-
|