Skip to content

Commit

Permalink
新增pup产品cappi,vwp,swp,uam,sti解析
Browse files Browse the repository at this point in the history
  • Loading branch information
pysoer committed Nov 29, 2023
1 parent 6d59bc4 commit 8536ec3
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions cinrad/io/level3.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,26 @@ def _ppi(buf):
def _rhi(buf):
params = {}
azi = np.frombuffer(buf.read(4), "f4")[0]
top = np.frombuffer(buf.read(4), "f4")[0]
bot = np.frombuffer(buf.read(4), "f4")[0]
top = np.frombuffer(buf.read(4), "i4")[0]
bot = np.frombuffer(buf.read(4), "i4")[0]
params["azimuth"] = azi
params["top"] = top
params["bottom"] = bot
return params

@staticmethod
def _cappi(buf):
params = {}
layers_count = np.frombuffer(buf.read(4), "i4")[0]
top = np.frombuffer(buf.read(4), "i4")[0]
bot = np.frombuffer(buf.read(4), "i4")[0]
filled = np.frombuffer(buf.read(4), "i4")[0]
params["layers_count"] = layers_count
params["top"] = top
params["bottom"] = bot
params["filled"] = filled
return params

@staticmethod
def _empty(buf):
pass
Expand All @@ -433,6 +446,7 @@ def parse(cls, product_type, param_bytes):
map_func = {
1: cls._ppi,
2: cls._rhi,
3: cls._cappi,
51: cls._ppi,
52: cls._ppi,
18: cls._empty,
Expand Down Expand Up @@ -622,6 +636,10 @@ def _parse_raster_fmt(self):

def _parse_cappi_fmt(self):
ds = []
height = self.params["bottom"]
height_step = (self.params["top"] - self.params["bottom"]) / (
self.params["layers_count"] - 1
)
while 1:
try:
radial_header = np.frombuffer(self.f.read(64), L3_radial)
Expand Down Expand Up @@ -661,7 +679,7 @@ def _parse_cappi_fmt(self):
data = Dataset(
{"CAPPI": da},
attrs={
"elevation": 0,
"height": height,
"range": end_range,
"scan_time": self.scantime.strftime("%Y-%m-%d %H:%M:%S"),
"site_code": self.code,
Expand All @@ -672,6 +690,7 @@ def _parse_cappi_fmt(self):
},
)
ds.append(data)
height += height_step
except:
# Decode broken files as much as possible
warnings.warn("Broken compressed file detected.", RuntimeWarning)
Expand Down

0 comments on commit 8536ec3

Please sign in to comment.