flkit
一个功能强大的 Python 工具包,提供空间分析、数据插值、数据库操作、命令行工具等多种功能。
功能特性
空间分析算法 (flkit.alg)
- 三角剖分: Delaunay 三角剖分算法
- 点与几何体关系: 点在三角形内、点在多边形内、点在体积内等判断
- 距离计算: 有限平面距离、点到三角形距离等
- 追踪算法: 曲线追踪和方向计算
- 索引构建: 空间索引构建和查询
数据插值方法 (flkit.alg.inter)
- IDW: 反距离加权插值(2D/3D)
- Kriging: 克里金插值(普通克里金、泛克里金)
- RBF: 径向基函数插值
- 最近邻: 最近邻插值
- 三线性: 三线性插值
- MIDW: 改进的 IDW 插值方法
数据库操作 (flkit.db)
- MongoDB: MongoDB 数据库连接和操作
- DuckDB: DuckDB 嵌入式数据库支持
- 文件数据库: 文件对象数据库管理
- 路径工具: 路径处理和压缩工具
命令行工具 (flkit.mtcli)
- 命令解析: 灵活的命令行参数解析
- 命令组: 支持命令分组和嵌套
- 上下文管理: 命令执行上下文管理
实用工具 (flkit.tools)
- MongoDB 管理: MongoDB 进程管理
- 区域查询: 地理区域查询
- 数据转换: 字典与列表转换
- MongoDB 客户端: 命令行 MongoDB 客户端
类型系统 (flkit.typr)
- 结果处理: 统一的结果处理和错误管理
- 控制台: 控制台命令执行
- 网格系统: 2D/3D 网格管理
- Web 视图: 桌面应用 Web 视图
- 环境变量: 环境变量管理
- 验证: 数据验证工具
- WebSocket: WebSocket 任务处理
安装
环境要求
- Python >= 3.13
安装依赖
pip install numpy scipy pandas pykrige triangle pymongo duckdb pyvista pyvistaqt matplotlib opencv-python fastapi requests pywebview click pexpect pydantic python-dotenv scikit-learn
或使用版本约束:
pip install "numpy>=1.24.0" "scipy>=1.10.0" "pandas>=2.0.0" "pykrige>=1.7.0" "triangle>=20230923" "pymongo>=4.0.0" "duckdb>=0.9.0" "pyvista>=0.40.0" "pyvistaqt>=0.10.0" "matplotlib>=3.7.0" "opencv-python>=4.8.0" "fastapi>=0.100.0" "requests>=2.31.0" "pywebview>=4.0.0" "click>=8.1.0" "pexpect>=4.8.0" "pydantic>=2.0.0" "python-dotenv>=1.0.0" "scikit-learn>=1.3.0"
安装 flkit
pip install -e .
快速开始
空间插值示例
import numpy as np
from flkit.alg.inter import Kriging2D, IDW2D
# 创建已知点数据
points = np.array([
[0, 0, 10],
[1, 0, 15],
[0, 1, 12],
[1, 1, 18]
])
# 使用克里金插值
kriging = Kriging2D(variogram_model="spherical")
kriging.fit(points)
# 预测新点的值
new_point = np.array([0.5, 0.5])
predicted_value = kriging.predict(new_point)
print(f"预测值: {predicted_value}")
数据库操作示例
from flkit.db import MongoDBConnector
# 连接 MongoDB
connector = MongoDBConnector("mongodb://localhost:27017", "mydb")
# 插入数据
collection = connector.get_collection("users")
collection.insert_one({"name": "张三", "age": 25})
命令行工具示例
from flkit.typr import command, run_cmd
from typing import Optional
@command
def greet(name: str, count: int = 1):
"""问候命令"""
for _ in range(count):
print(f"你好, {name}!")
if __name__ == "__main__":
run_cmd(greet)
项目结构
flkit/
├── alg/ # 空间分析算法
│ ├── inter/ # 插值方法
│ └── ...
├── db/ # 数据库操作
├── mtcli/ # 命令行工具
├── tools/ # 实用工具
└── typr/ # 类型系统和工具
依赖库
核心依赖
- numpy, scipy, pandas - 数据科学基础
- pykrige - 克里金插值
- triangle - 三角剖分
- pymongo, duckdb - 数据库
- pyvista, pyvistaqt - 3D 可视化
- matplotlib - 2D 绘图
- opencv-python - 图像处理
- fastapi, requests, pywebview - Web 和网络
- click, pexpect - 命令行工具
- pydantic, python-dotenv - 数据验证和配置
- scikit-learn - 机器学习
许可证
请查看项目许可证文件。
贡献
欢迎提交 Issue 和 Pull Request!
Metadata
Release files for flkit 0.1.2
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 | Actions |
|---|---|---|---|---|
| flkit-0.1.2.tar.gz | 965.4 kB | Without provenance | Details for flkit-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flkit-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for flkit-0.1.2-py3-none-any.whl |
Total release size: 1.9 MB
Release files / flkit-0.1.2.tar.gz
| Download URL | flkit-0.1.2.tar.gz |
|---|---|
| Size | 965.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04b0935c18828b8766fb1b611737d4ed1fca4f5234cab2b42f086377995bb7f0
|
|
BLAKE2b-256 checksum How to use checksums |
e969b7eea52336084b07475371cbd14cde17e51bff9a5b1291d9ea9bc8794d1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.11
|
Release files / flkit-0.1.2-py3-none-any.whl
| Download URL | flkit-0.1.2-py3-none-any.whl |
|---|---|
| Size | 935.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78e7491b3eea7ac4303f5a31de1648706c1d6d7803e2fa49fbaaed794dc493ac
|
|
BLAKE2b-256 checksum How to use checksums |
2e0ce26f326c7521151b56c839d337e9dcf27a5afc95d7d368e4881b3f17e438
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.11
|
Security for flkit 0.1.2
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.