Skip to content

Commit

Permalink
Merge branch 'CyanideCN:master' into fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pysoer authored Apr 25, 2024
2 parents 8fda5b2 + e75630a commit 6081556
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
37 changes: 37 additions & 0 deletions cinrad/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,40 @@ def read_level2(filename: str) -> RadarBase:
return StandardData(filename)
else:
return CinradReader(filename)


def read_auto(filename: str) -> RadarBase:
"""Read radar data, auto detected type of file .
Args:
filename: file name of radar data.
Radar types:
1. StandardData, standard format based data.
2. StandardPUP, standard PUP format data.
3. MocMosaic, mosaic format data v3.0.
4. SWAN, SWAN format data.
5. CinradReader, cinrad format based data.
6. PhasedArrayData, standard format phased array radar data(XAD-2023).
TODO:PUP & CinradReader(fix later)
"""
with prepare_file(filename) as file:
flag = file.read(125)
if flag[0:4] == b"RSTM":
if flag[8:12] == b"\x01\x00\x00\x00":
return StandardData(filename)
elif flag[8:12] == b"\x02\x00\x00\x00":
return StandardPUP(filename)
elif flag[8:12] == b"\x10\x00\x00\x00":
return PhasedArrayData(filename)
else:
raise Exception("Unknown standard radar type")
elif flag[0:3] == b"MOC":
return MocMosaic(filename)
if flag[50:54] == b"SWAN":
return SWAN(filename)
sc_flag = flag[100:106]
cc_flag = flag[116:122]
if flag[14:16] == b"\x01\x00" or sc_flag == b"CINRAD" or cc_flag == b"CINRAD":
return CinradReader(filename)
raise Exception("Unknown radar type")
4 changes: 4 additions & 0 deletions cinrad/visualize/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ def __init__(self, filename: str, encoding: str = "gbk"):
pass
self._fields = self._reader.fields

from cartopy import __version__

if __version__ >= "0.23.0":
ShpReader = shapereader.BasicReader

def setup_plot(dpi: Number_T, figsize: tuple = FIG_SIZE, style: str = "black") -> Any:
if style == "transparent":
Expand Down

0 comments on commit 6081556

Please sign in to comment.