Skip to content

Commit 7b08eed

Browse files
authored
chore: update UAM & swan & Transparent img (#134)
* 优化对风雷产品支持 * 添加UAM产品参数解析 * fix transparent img * fix:透明图投影 * fix: error to export pyart * fix: close file after read SWAN
1 parent 2195540 commit 7b08eed

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

cinrad/io/export.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def standard_data_to_pyart(f: StandardData, radius: int = 460) -> pyart.core.Rad
8888
fixed_angle["data"] = np.array(f.el)
8989

9090
fields = {}
91-
nscans = f.get_nscans()
91+
# nscans = f.get_nscans()
9292

9393
all_var = list()
9494
for lvl in f.data:
@@ -100,7 +100,7 @@ def standard_data_to_pyart(f: StandardData, radius: int = 460) -> pyart.core.Rad
100100
name = mapping[mom]
101101
dic = filemetadata(name)
102102
dic["_FillValue"] = pyart.config.get_fillvalue()
103-
raw_arr = [f.get_raw(nel, radius, mom) for nel in range(nscans)]
103+
raw_arr = [f.get_raw(nel, radius, mom) for nel in f.available_tilt(mom)]
104104
sel_arr = [i if not isinstance(i, tuple) else i[0] for i in raw_arr]
105105
moment_data = np.ma.vstack(sel_arr)
106106
dic["data"] = moment_data

cinrad/io/level3.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def __init__(self, file: Any, product: Optional[str] = None):
217217
if not product
218218
else product
219219
)
220-
for pname in ["CR", "3DREF", "反射率"]:
220+
for pname in ["CR", "REF", "反射率"]:
221221
if pname in self.product_name:
222222
self.product_name = "CR"
223223
start_lon = header["start_lon"][0]
@@ -235,6 +235,7 @@ def __init__(self, file: Any, product: Optional[str] = None):
235235
else:
236236
# Leave data unchanged because the scale and offset are unclear
237237
self.data = np.ma.masked_equal(out, 0)
238+
f.close()
238239

239240
def get_data(self) -> Dataset:
240241
r"""
@@ -421,6 +422,18 @@ def _cappi(buf):
421422
params["filled"] = filled
422423
return params
423424

425+
@staticmethod
426+
def _uam(buf):
427+
params = {}
428+
iRange = np.frombuffer(buf.read(4), "i4")[0]
429+
baseProd1 = np.frombuffer(buf.read(4), "i4")[0]
430+
dataType1 = np.frombuffer(buf.read(4), "i4")[0]
431+
params["Range"] = iRange
432+
params["baseProd1"] = baseProd1
433+
params["dataType1"] = dataType1
434+
params["elevation"] = 0
435+
return params
436+
424437
@staticmethod
425438
def _empty(buf):
426439
pass
@@ -434,6 +447,7 @@ def parse(cls, product_type, param_bytes):
434447
3: cls._cappi,
435448
51: cls._ppi,
436449
52: cls._ppi,
450+
44: cls._uam,
437451
18: cls._empty,
438452
}
439453
params = {"elevation": 0}
@@ -1019,6 +1033,7 @@ def _parse_uam_fmt(self):
10191033
"site_longitude": self.stationlon,
10201034
"site_latitude": self.stationlat,
10211035
"task": self.task_name,
1036+
**self.params,
10221037
},
10231038
)
10241039
ds["longitude"] = DataArray(lon[:, 0])

cinrad/visualize/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ def create_geoaxes(
279279
from cartopy import __version__
280280

281281
if style == "transparent":
282-
ax = fig.add_axes([0, 0, 1, 1], projection=proj)
283-
ax.set_aspect("equal")
282+
ax = fig.add_axes([0, 0, 1, 1], projection=ccrs.GOOGLE_MERCATOR)
283+
ax.set_aspect("auto")
284284
else:
285285
ax = fig.add_axes(GEOAXES_POS, projection=proj)
286286
if __version__ < "0.18":

0 commit comments

Comments
 (0)