气象数据读写及访问程序库
提供对MICAPS文件, 卫星云图, 天气雷达等数据的读写程序, 并访问CMADaaS, CIMISS和MICAPS CASSANDRA数据库文件等.
Only Python 3 is supported. 建议安装Anaconda数据科学工具库, 已包括scipy, numpy, matplotlib等大多数常用科学程序库.
开发环境(uv)
项目使用 uv 管理依赖和开发环境,开发解释器固定为 Python 3.12,包的最低 Python 要求保持为 3.9。
在仓库根目录执行:
uv sync --locked
uv run pytest
uv run pytest tests\test_read_micaps.py::test_pressure_is_decoded_once
uv run ruff format .
uv run ruff check --fix .
uv build
uv sync --locked 按 uv.lock 创建 .venv,以可编辑模式安装本项目,并安装 pytest、Ruff。VS Code 请选择 .venv\Scripts\python.exe 作为解释器;运行命令使用 uv run,无需手动激活环境。
包元数据和运行依赖统一维护在 pyproject.toml,setup.py 仅保留兼容入口。添加运行依赖使用 uv add <package>,添加开发依赖使用 uv add --dev <package>,移除依赖使用 uv remove <package>;同时保留更新后的 uv.lock。Ruff 使用默认 Python 检查规则、兼容 Python 3.9,并排除自动生成的 Protobuf 文件及包含非 Python 单元的示例笔记本;历史代码可能仍有 lint 问题,避免为环境配置任务批量改写源代码。
访问在线数据服务还需要按下文配置用户目录中的 config.ini;离线读取测试不需要服务账号。GRIB、Py-ART、Cassandra 等可选功能依赖不包含在基础开发环境中。
Install
Using the fellowing command to install packages:
- 使用pypi安装源安装(https://pypi.org/project/nmc-met-io/)
pip install nmc-met-io
- 若要安装Github上的开发版(请先安装Git软件):
pip install git+git://github.com/nmcdev/nmc_met_io.git
- 或者下载软件包进行安装:
git clone --recursive https://github.com/nmcdev/nmc_met_io.git
cd nmc_met_io
python setup.py install
可选支持库:
-
若需要实现对grib格式数据的读取, 请用conda安装:
-
若需要使用将标准雷达格式转化为pyart格式程序
standard_data_to_pyart, 请安装:- arm_pyart,
conda install -c conda-forge arm_pyart
- arm_pyart,
-
若需要对Cassandra集群数据库进行访问, 请安装:
- cassandra-driver, 'pip install cassandra-driver'
设置配置文件
若要访问CMADaaS(大数据云), MICAPS服务器等, 需在配置文件中设置地址和用户信息(若不需要, 则相应项无需配置).
- 在系统用户目录下("C:\Users\用户名"(windows)或"/home/用户名/"(Linux)), 建立文件夹".nmcdev"(若Windows下无法直接创建, 在命令窗口中输入
mkdir .nmcdev创建) - 在".nmcdev"中创建文本文件"config.ini", 内容模板为:
# 用于nmc_met_io读取大数据云, MICAPS服务器等的配置文件.
# 若用不到某个服务器, 则不设置或删除改段落即可.
# 注意设置IP地址时, 不要加http等前缀信息.
# 当读取CMADaas, MICAPS Cassandra等数据时, 采取了本地文件缓存机制, 以便加快
# 文件的读取速度和减少数据库访问次数(设置函数参数cache=False可以不用缓存机制).
# CACHE_DIR, 缓存目录, 若没有设置, 默认为 /user_home/.nmcdev/cache
# CACHE_DAYS, 缓存天数, 若没有设置, 默认为7, 即7天之前的缓存数据将被删除
[CACHE]
# CACHE_DIR = ~
CACHE_DAYS = 7
# CMADaaS大数据云平台配置:
# DNS为IP地址, PORT为端口
# USER_ID和PASSWORD分别为用户名和密码
# serviceNodeId为服务节点名称(一般为 NMIC_MUSIC_CMADAAS)
[CMADaaS]
DNS = xx.xx.xx.xx
PORT = xx
USER_ID = xxxxxxxx
PASSWORD = xxxxxxxx
serviceNodeId = NMIC_MUSIC_CMADAAS
# MICAPS Cassandra服务器配置(一般需要联系运维开通访问权限)
# GDS_IP为IP地址, GDS_PORT为端口
# 可以人为设置本地数据缓存的地址CACHE_DIR, 默认为配置文件夹目录下的cache文件夹
[MICAPS]
GDS_IP = xx.xx.xx.xx
GDS_PORT = 8080
# CIMISS网址及用户ID和PASSWORD, 2021年年底CIMISS停止提供服务
# DNS为IP地址, PORT为端口
# USER_ID和PASSWORD分别为用户名和密码
[CIMISS]
DNS = xx.xx.xx.xx
USER_ID = xxxxxxxxx
PASSWORD = xxxxxxxx
# 彩云天气API的访问口令
[CAIY]
token = xxxxxxxxxxxxxx
# MAPBOX地图数据的访问口令(nmc_met_graphics绘图可以用)
# https://docs.mapbox.com/help/glossary/access-token 申请
[MAPBOX]
token = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# 天地地图数据的访问口令(nmc_met_graphics绘图可以用)
# http://lbs.tianditu.gov.cn/server/MapService.html 申请
[TIANDITU]
token = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# 配置Cassandra集群访问接口
[Cassandra]
ClusterIPAddresses=Cassandra集群IP地址以“,”分隔,可以参考MICAPS4的配置文件配置
ClusterPort=Cassandra集群服务端口
KeySpace=Cassandra上数据存储的主键名
Metadata
Release files for nmc_met_io 0.1.17.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nmc_met_io-0.1.17.1.tar.gz | 21.0 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nmc_met_io-0.1.17.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.2 MB
Release files / nmc_met_io-0.1.17.1.tar.gz
| Download URL | nmc_met_io-0.1.17.1.tar.gz |
|---|---|
| Size | 21.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
994b0bfc924b2a77f584695307e2843d8d769d1ca3c0a15969e4eecab475e027
|
|
BLAKE2b-256 checksum How to use checksums |
cfc4b14a5e25704e5a0ab52102dc010af32acf116eff12fc41cd07087ff42ec5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / nmc_met_io-0.1.17.1-py3-none-any.whl
| Download URL | nmc_met_io-0.1.17.1-py3-none-any.whl |
|---|---|
| Size | 254.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
045d9602775a0d03e3ed06e80126acee92cb6edb736e70ff3f1d170c8279f545
|
|
BLAKE2b-256 checksum How to use checksums |
fc2839e6e457d3d50839858fadc53b97ad1b0ca901472aa16a59a2bd07d21010
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for nmc_met_io 0.1.17.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.