雷达系列:必须更新!测试cinrad最新更新的read_auto
前言
最近pycinrad更新1.9.0版本,更新内容如下
我们来试试新鲜出炉的read_auto函数吧
温馨提示
本文镜像 :气象分析3.9
由于可视化代码过长隐藏,可点击运行Fork查看
🔜🔜若没有成功加载可视化图,点击运行可以查看
ps:隐藏代码在【代码已被隐藏】所在行,点击所在行,可以看到该行的最右角,会出现个三角形,点击查看即可
!pip install --upgrade --index-url=https://pypi.mirrors.ustc.edu.cn/simple cinrad --user
Looking in indexes: https://pypi.mirrors.ustc.edu.cn/simple
Requirement already satisfied: cinrad in /opt/conda/lib/python3.9/site-packages (1.8.0)
Collecting cinrad
Downloading https://mirrors.bfsu.edu.cn/pypi/web/packages/28/56/d0e16fc19e471cd61d06de5d21d32600c23908247d90c00fa573161f327c/cinrad-1.9.0.tar.gz (392 kB)
[2K [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m392.7/392.7 kB[0m [31m2.9 MB/s[0m eta [36m0:00:00[0ma [36m0:00:01[0m
[?25h Preparing metadata (setup.py) ... [?25ldone
[?25hRequirement already satisfied: metpy>=0.8 in /opt/conda/lib/python3.9/site-packages (from cinrad) (1.6.1)
Requirement already satisfied: cartopy>=0.15 in /opt/conda/lib/python3.9/site-packages (from cinrad) (0.22.0)
Requirement already satisfied: pyshp!=2.0.0,!=2.0.1 in /opt/conda/lib/python3.9/site-packages (from cinrad) (2.3.1)
Requirement already satisfied: matplotlib>=2.2 in /opt/conda/lib/python3.9/site-packages (from cinrad) (3.8.3)
Requirement already satisfied: vanadis in /opt/conda/lib/python3.9/site-packages (from cinrad) (0.0.2)
Requirement already satisfied: cinrad_data>=0.1 in /opt/conda/lib/python3.9/site-packages (from cinrad) (0.1)
Requirement already satisfied: packaging>=20 in /opt/conda/lib/python3.9/site-packages (from cartopy>=0.15->cinrad) (23.2)
Requirement already satisfied: numpy>=1.21 in /opt/conda/lib/python3.9/site-packages (from cartopy>=0.15->cinrad) (1.26.4)
Requirement already satisfied: pyproj>=3.1.0 in /opt/conda/lib/python3.9/site-packages (from cartopy>=0.15->cinrad) (3.4.1)
Requirement already satisfied: shapely>=1.7 in /opt/conda/lib/python3.9/site-packages (from cartopy>=0.15->cinrad) (1.8.5.post1)
Requirement already satisfied: kiwisolver>=1.3.1 in /opt/conda/lib/python3.9/site-packages (from matplotlib>=2.2->cinrad) (1.4.2)
Requirement already satisfied: importlib-resources>=3.2.0 in /opt/conda/lib/python3.9/site-packages (from matplotlib>=2.2->cinrad) (5.7.1)
Requirement already satisfied: cycler>=0.10 in /opt/conda/lib/python3.9/site-packages (from matplotlib>=2.2->cinrad) (0.11.0)
Requirement already satisfied: contourpy>=1.0.1 in /opt/conda/lib/python3.9/site-packages (from matplotlib>=2.2->cinrad) (1.2.0)
Requirement already satisfied: pyparsing>=2.3.1 in /opt/conda/lib/python3.9/site-packages (from matplotlib>=2.2->cinrad) (3.0.9)
Requirement already satisfied: fonttools>=4.22.0 in /opt/conda/lib/python3.9/site-packages (from matplotlib>=2.2->cinrad) (4.33.3)
Requirement already satisfied: pillow>=8 in /opt/conda/lib/python3.9/site-packages (from matplotlib>=2.2->cinrad) (9.4.0)
Requirement already satisfied: python-dateutil>=2.7 in /opt/conda/lib/python3.9/site-packages (from matplotlib>=2.2->cinrad) (2.8.2)
Requirement already satisfied: traitlets>=5.0.5 in /opt/conda/lib/python3.9/site-packages (from metpy>=0.8->cinrad) (5.2.0)
Requirement already satisfied: pandas>=1.4.0 in /opt/conda/lib/python3.9/site-packages (from metpy>=0.8->cinrad) (2.0.3)
Requirement already satisfied: pooch>=1.2.0 in /opt/conda/lib/python3.9/site-packages (from metpy>=0.8->cinrad) (1.8.1)
Requirement already satisfied: pint>=0.17 in /opt/conda/lib/python3.9/site-packages (from metpy>=0.8->cinrad) (0.23)
Requirement already satisfied: xarray>=0.21.0 in /opt/conda/lib/python3.9/site-packages (from metpy>=0.8->cinrad) (2024.2.0)
Requirement already satisfied: scipy>=1.8.0 in /opt/conda/lib/python3.9/site-packages (from metpy>=0.8->cinrad) (1.11.4)
Requirement already satisfied: zipp>=3.1.0 in /opt/conda/lib/python3.9/site-packages (from importlib-resources>=3.2.0->matplotlib>=2.2->cinrad) (3.8.0)
Requirement already satisfied: pytz>=2020.1 in /opt/conda/lib/python3.9/site-packages (from pandas>=1.4.0->metpy>=0.8->cinrad) (2022.1)
Requirement already satisfied: tzdata>=2022.1 in /opt/conda/lib/python3.9/site-packages (from pandas>=1.4.0->metpy>=0.8->cinrad) (2024.1)
Requirement already satisfied: typing-extensions in /opt/conda/lib/python3.9/site-packages (from pint>=0.17->metpy>=0.8->cinrad) (4.7.1)
Requirement already satisfied: requests>=2.19.0 in /opt/conda/lib/python3.9/site-packages (from pooch>=1.2.0->metpy>=0.8->cinrad) (2.27.1)
Requirement already satisfied: platformdirs>=2.5.0 in /opt/conda/lib/python3.9/site-packages (from pooch>=1.2.0->metpy>=0.8->cinrad) (4.2.0)
Requirement already satisfied: certifi in /opt/conda/lib/python3.9/site-packages (from pyproj>=3.1.0->cartopy>=0.15->cinrad) (2024.2.2)
Requirement already satisfied: six>=1.5 in /opt/conda/lib/python3.9/site-packages (from python-dateutil>=2.7->matplotlib>=2.2->cinrad) (1.16.0)
Requirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.9/site-packages (from requests>=2.19.0->pooch>=1.2.0->metpy>=0.8->cinrad) (3.3)
Requirement already satisfied: charset-normalizer~=2.0.0 in /opt/conda/lib/python3.9/site-packages (from requests>=2.19.0->pooch>=1.2.0->metpy>=0.8->cinrad) (2.0.12)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/conda/lib/python3.9/site-packages (from requests>=2.19.0->pooch>=1.2.0->metpy>=0.8->cinrad) (1.26.9)
Building wheels for collected packages: cinrad
Building wheel for cinrad (setup.py) ... [?25ldone
[?25h Created wheel for cinrad: filename=cinrad-1.9.0-cp39-cp39-linux_x86_64.whl size=642314 sha256=40ece76952768a0faff6942d3b102836ae82c9216a9b233e5e16fb64dd3aca49
Stored in directory: /home/mw/.cache/pip/wheels/6e/08/49/d0688c1740d9d867a940e78bfd270d9f9f141e32b106ba50ef
Successfully built cinrad
Installing collected packages: cinrad
Successfully installed cinrad-1.9.0
型号:CC/CCJ
import cinrad
ds1 = cinrad.io.read_auto('/home/mw/input/pycwr5461/2016070817 (1).48V.gz')
ds1.available_product(0)
['REF', 'VEL', 'SW', 'azimuth']
型号:SC
import cinrad
ds1 = cinrad.io.read_auto('/home/mw/input/pycwr5461/Z_RADR_I_Z9240_20190703101340_O_DOR_SC_CAP.bin.bz2')
ds1.available_product(0)
['REF', 'VEL', 'SW', 'azimuth', 'RF']
型号:SAD
import cinrad
ds1 = cinrad.io.read_auto('/home/mw/input/pycwr5461/Z_RADR_I_Z9898_20190828181529_O_DOR_SAD_CAP_FMT (1).bin.bz2')
ds1.available_product(0)
['TREF', 'REF', 'SQI', 'ZDR', 'RHO', 'PHI', 'KDP', 'SNRH']
型号:SB
没骂人
import cinrad
ds1 = cinrad.io.read_auto('/home/mw/input/pycwr5461/Z9396_BASE_SB_20180724_055400 (1).bin.bz2')
ds1.available_product(0)
---------------------------------------------------------------------------
RadarDecodeError Traceback (most recent call last)
Input In [1], in <cell line: 2>()
1 import cinrad
----> 2 ds1 = cinrad.io.read_auto('/home/mw/input/pycwr5461/Z9396_BASE_SB_20180724_055400 (1).bin.bz2')
3 ds1.available_product(0)
File ~/.local/lib/python3.9/site-packages/cinrad/io/__init__.py:52, in read_auto(filename)
50 cc_flag = flag[116:122]
51 if flag[14:16] == b"\x01\x00" or sc_flag == b"CINRAD" or cc_flag == b"CINRAD":
---> 52 return CinradReader(filename)
53 raise Exception("Unknown radar type")
File ~/.local/lib/python3.9/site-packages/cinrad/io/level2.py:116, in CinradReader.__init__(self, file, radar_type)
114 else:
115 if not t_infer:
--> 116 raise RadarDecodeError(
117 "Unable to determine the file type. Use `radar_type` keyword"
118 "to specify the radar type."
119 )
120 self.radartype = t_infer
121 self.site_info = {}
RadarDecodeError: Unable to determine the file type. Use `radar_type` keywordto specify the radar type.
from cinrad.io import CinradReader, StandardData
SB = CinradReader('/home/mw/input/pycwr5461/Z9396_BASE_SB_20180724_055400 (1).bin.bz2',radar_type='SB')
SB.available_product(0)
/home/mw/.local/lib/python3.9/site-packages/cinrad/io/level2.py:109: UserWarning: Contradictory information from input radar type andradar type detected from input file.
warnings.warn(
['REF', 'VEL', 'SW', 'azimuth', 'RF']
read_auto不支持直接读取SB,当然我们可以像上面一样读取
相控阵
import cinrad
ds1 = cinrad.io.read_auto('/home/mw/input/pycwr5461/Z_RADR_I_ZGZ01_20200820220246_O_DOR_DXK_CAR.bin.bz2')
ds1.available_product(0)
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
Input In [10], in <cell line: 3>()
1 import cinrad
----> 3 ds1 = cinrad.io.read_auto('/home/mw/input/pycwr5461/Z_RADR_I_ZGZ01_20200820220246_O_DOR_DXK_CAR.bin.bz2')
4 ds1.available_product(0)
File ~/.local/lib/python3.9/site-packages/cinrad/io/__init__.py:53, in read_auto(filename)
51 if flag[14:16] == b"\x01\x00" or sc_flag == b"CINRAD" or cc_flag == b"CINRAD":
52 return CinradReader(filename)
---> 53 raise Exception("Unknown radar type")
Exception: Unknown radar type
当然对于多变的相控阵格式是不支持的,相信应该可以读取最新格式的相控阵雷达数据
小结
谢谢开发者们对于pycinrad的不断维护,read_auto函数应该能满足大多数用户的需求了
pycinrad对于业务人员的使用是越来越友好了
相信随着使用难度的降低,会有越来越多的用户加入