tascpy
tascpy は、計測アプリケーション「tasc」などから出力される計測データの分析・可視化を効率的に行うための Python ライブラリです。直感的なインターフェースと強力なデータ処理機能を備え、メソッドチェーン形式で複雑な操作を簡潔に記述できます。
主な特徴
- メソッドチェーンによる流れるような操作:複数のデータ処理ステップを連続して記述できます
- イミュータブルなデータ操作:元のデータを変更せず、常に新しいデータセットを生成します
- ドメイン特化機能:荷重-変位データや座標データなど、特定の分析領域に特化した機能を提供します
- 柔軟なデータ選択:列名、行インデックス、ステップ値などによる多彩な選択操作をサポートします
- 高度な数学的処理:数値演算、補間、正規化など様々な数学的操作を提供します
- 直感的な可視化:Matplotlib と連携した簡単かつ高度なデータ可視化機能があります
- 型ヒントと自動補完:VSCode などの IDE で自動補完や型チェックを完全サポートします
インストール方法
pip からのインストール
pip install tascpy
ソースからのインストール
git clone https://github.com/toruinaba/tascpy.git
cd tascpy
pip install -e .
使用例
基本的な使い方
import tascpy
# ファイルからデータを読み込む(format_name: "tasc_txt" または "csv")
collection = tascpy.load("data.csv", format_name="csv")
# メソッドチェーンでデータを処理
result = (
collection.ops
.select(columns=["Force", "Displacement"]) # 必要な列を選択
.filter_by_condition("Force", lambda x: x > 0) # 正の荷重のみ抽出
.add("Force", 10, result_column="AdjustedForce") # 新しい列を作成
.divide("AdjustedForce", "Displacement", result_column="Ratio")
.end() # チェーンを終了して結果を取得
)
print(f"処理後のデータ: {len(result)} 行 × {len(result.columns)} 列")
print(f"最大値: {result['Ratio'].max():.2f}")
単位の確認
各列は単位(unit)とチャンネル名(ch)を持ちます。単位は記録・確認のためのもので、自動変換はしません。
演算結果の単位は演算の種類から決まり、自明でない場合は None(不明)になります。unit= で明示することもできます。
collection.units # {"Force": "kN", "Displacement": "mm", ...}
result["AdjustedForce"].unit # "kN"(加算は元の列の単位を引き継ぐ)
result["Ratio"].unit # None(列どうしの除算の単位は自明でない)
collection[0] # <Row step=1, Force=0.0 kN, Displacement=0.0 mm, ...>
# polars の DataFrame との相互変換
df = collection.df
again = tascpy.ColumnCollection.from_frame(df, units=collection.units)
# 保存
collection.io.save("out.txt") # TASC 形式(列名・ch・単位を保持)
collection.io.to_parquet("out.parquet") # 単位・属性・解析結果まで保持
restored = tascpy.load_parquet("out.parquet")
荷重-変位ドメインの分析
# 荷重-変位ドメインへ変換し、剛性と降伏点を計算
ld = (
collection.ops
.as_domain(tascpy.as_load_displacement, load_column="Force", displacement_column="Displacement")
.remove_consecutive_duplicates_across()
.calculate_stiffness(range_start=0.1, range_end=0.5)
.find_yield_point(method="offset", offset_value=0.002) # 0.2%オフセット法
.end()
)
stiffness = ld.results["stiffness"]
print(f"初期剛性: {stiffness.value:.2f} {stiffness.unit}") # 例: kN/mm
yield_pt = ld.results["yield_point"]
print(f"降伏荷重: {yield_pt.y:.2f} {yield_pt.y_unit}")
print(f"降伏変位: {yield_pt.x:.2f} {yield_pt.x_unit}")
collection.ops が返す操作オブジェクトは通常のクラスなので、IDE の自動補完と型チェックがそのまま効きます。as_domain に変換関数(tascpy.as_load_displacement など)を渡してドメインに変換すると、変換の引数とドメイン固有の操作(find_yield_point など)も補完されます。
可視化の例
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(10, 6))
collection.plot.plot(y_column="Force", x_column="Displacement", ax=ax, marker="o", alpha=0.7)
ax.set_title("荷重-変位関係")
ax.grid(True)
plt.tight_layout()
plt.show()
ドキュメント
より詳細なドキュメントとサンプルについては、以下を参照してください:
-
チュートリアル - 繰り返し載荷試験のデータを読み込み、スケルトン曲線・降伏点・履歴エネルギーを求めて保存するまで(コードは CI で実行・検査しています)
-
基本サンプル集 - 基本的な操作と使用例
-
高度なサンプル - 異常値分析など高度な分析テクニック
-
ドメイン特化機能 - 荷重-変位分析や座標データ処理の例
-
開発者ガイド - tascpy の拡張や独自ドメインの開発方法
-
コアデータモデル設計 - データ保持・単位・欠損の規則
動作環境
- Python 3.11 以上
- 依存ライブラリ:
- numpy
- polars
- matplotlib
- japanize-matplotlib(日本語フォントサポート用)
プロジェクト構造
tascpy/
├── src/
│ └── tascpy/
│ ├── numeric/ # numpy 配列に直接使える解析関数
│ ├── core/ # データモデル(ColumnCollection など)と汎用の操作・入出力・描画
│ └── domains/ # ドメイン(荷重-変位・座標・ひずみ)。ドメインごとに collection / ops / plotter / draw
├── tests/ # テストコード(tests/manual/examples にサンプル)
└── docs/ # ドキュメント
ライセンス
MIT ライセンスの下で公開されています。詳細は LICENSE ファイルを参照してください。
開発について
個人で開発・保守しているライブラリです。不具合は GitHub Issue で知らせていただければ確認しますが、対応の時期はお約束できません。開発時の規約と手順は CONTRIBUTING.md にまとめています。
著者
- Toru Inaba (@toruinaba)
Metadata
Release files for tascpy 0.7.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 | |
|---|---|---|---|---|
| tascpy-0.7.1.tar.gz | 77.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tascpy-0.7.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 170.3 kB
Release files / tascpy-0.7.1.tar.gz
| Download URL | tascpy-0.7.1.tar.gz |
|---|---|
| Size | 77.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eab6185086fc1fcc070e3726da4f5eb957dad2a877d970e27831ed1f8681939f
|
|
BLAKE2b-256 checksum How to use checksums |
b4c1b9ca458f7db20c631c51681474e1f95eabd5448f597edfecead0e3da3580
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logRelease files / tascpy-0.7.1-py3-none-any.whl
| Download URL | tascpy-0.7.1-py3-none-any.whl |
|---|---|
| Size | 93.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f7612b35e6455895b99f855c029f40cd41d4db39d52bbde2fd9ca791017e300c
|
|
BLAKE2b-256 checksum How to use checksums |
a53c916c20ea7096340a2f9405ded151b1b99fb21df32972cc2ce1ba8d1e0ba6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logSecurity for tascpy 0.7.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for tascpy-0.7.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logA 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.