Skip to content

Commit

Permalink
修改相控阵sweep_start_ray_index计算方式
Browse files Browse the repository at this point in the history
  • Loading branch information
YvZheng committed Aug 2, 2021
1 parent aeffdf0 commit 1921e65
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions pycwr/io/PAFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ def __init__(self, filename, station_lon=None, station_lat=None, station_alt=Non
self.header = self._parse_BaseDataHeader()
self.radial = self._parse_radial()
self.nrays = len(self.radial)
status = np.array([istatus['RadialState'] for istatus in self.radial[:]])
self.sweep_start_ray_index = np.where((status == 0) | (status == 3))[0]
self.sweep_end_ray_index = np.where((status == 2) | (status == 4))[0]
self.nsweeps = len(self.sweep_start_ray_index)
self.nsweeps = self.header['TaskConfig']['CutNumber']
self.sweep_start_ray_index = np.arange(0, self.nrays, self.nrays // self.nsweeps)
self.sweep_end_ray_index = self.sweep_start_ray_index + self.nrays // self.nsweeps - 1
self.fid.close()

def _check_standard_basedata(self):
Expand All @@ -58,24 +57,20 @@ def _parse_BaseDataHeader(self):
BaseDataHeader['TaskConfig'], _ = _unpack_from_buf(fixed_buf,
dtype_PA.TaskConfigurationBlockPos,
dtype_PA.BaseDataHeader['TaskConfigurationBlock'])
# print(BaseDataHeader)

beam_buf = self.fid.read(dtype_PA.BeamConfigurationBlockSize * \
BaseDataHeader['TaskConfig']['BeamNumber'])
cut_buf = self.fid.read(dtype_PA.CutConfigurationBlockSize * \
BaseDataHeader['TaskConfig']['CutNumber'])
BaseDataHeader["BeamConfig"] = np.frombuffer(beam_buf, dtype_PA.BaseDataHeader['BeamConfigurationBlock'])
BaseDataHeader['CutConfig'] = np.frombuffer(cut_buf, dtype_PA.BaseDataHeader['CutConfigurationBlock'])
# print(BaseDataHeader["BeamConfig"])
# print(BaseDataHeader['CutConfig'])
#print(BaseDataHeader)
return BaseDataHeader

def _parse_radial(self):
radial = []
buf = self.fid.read(dtype_PA.RadialHeaderBlockSize)
while len(buf) == dtype_PA.RadialHeaderBlockSize: ##read until EOF
RadialDict, _ = _unpack_from_buf(buf, 0, dtype_PA.RadialHeader())
#print(RadialDict)
self.MomentNum = RadialDict['MomentNumber']
self.LengthOfData = RadialDict['LengthOfData']
RadialDict['fields'] = self._parse_radial_single()
Expand All @@ -88,7 +83,6 @@ def _parse_radial_single(self):
for _ in range(self.MomentNum):
Mom_buf = self.fid.read(dtype_PA.MomentHeaderBlockSize)
Momheader, _ = _unpack_from_buf(Mom_buf, 0, dtype_PA.RadialData())
#print(Momheader)
Data_buf = self.fid.read(Momheader['Length'])
assert (Momheader['BinLength'] == 1) | (Momheader['BinLength'] == 2), "Bin Length has problem!"
if Momheader['BinLength'] == 1:
Expand Down Expand Up @@ -210,8 +204,8 @@ def __init__(self, WSR98D):
self.fields = self._get_fields()
self.rays_per_sweep = self.nrays // self.nsweeps
self.sitename = self.WSR98D.get_sitename()
self.sweep_start_ray_index = np.cumsum(self.bins_per_sweep) - self.bins_per_sweep
self.sweep_end_ray_index = np.cumsum(self.bins_per_sweep) - 1
self.sweep_start_ray_index = self.WSR98D.sweep_start_ray_index
self.sweep_end_ray_index = self.WSR98D.sweep_end_ray_index

def get_nbins_per_sweep(self):
"""
Expand Down

0 comments on commit 1921e65

Please sign in to comment.