2026年5月8日金曜日

二枚貝殻偏位角分布の見える化作業

 Visualization of Bivalve Shell Deviation Angle Distribution


This document summarizes the visualization of bivalve shell deviation angle distribution in exfoliated cross-sections. Spatial distribution within each survey area (quadrat) is visualized using QGIS (pseudo-coordinate GIS analysis), while the frequency distribution across the entire survey area is visualized using a semicircular rose diagram created with a Python tool.


剥取断面における二枚貝殻偏位角分布の見える化作業をまとめました。調査区(コドラート)内部の空間分布はQGIS(疑似座標GIS解析)で、調査区全体の頻度分布はPythonツールによる半円形ローズダイヤグラムで見える化できます。

1 二枚貝殻偏位角分布の見える化作業


二枚貝殻偏位角分布の見える化作業

調査区(コドラート)内部の空間分布はQGIS(疑似座標GIS解析)で、調査区全体の頻度分布はPythonツールによる半円形ローズダイヤグラムで見える化できます。

二枚貝殻偏位角:殻と断面の成す直線(殻が断面によって仮想的に切断された際にできる接線の両端を結んだ直線)について鉛直線を基準として時計回りに測定した角度

2 参考 角度頻度分布をローズダイヤグラムに表現するPythonスクリプト

0°~20°、20°~40°という20°刻みで表現しています。

「CSV_PATH = "G:/test/aaa.csv"」のcsvファイルのパスを変更してください。

「R_MAX = 40          # 頻度表示の最高値」の数値をデータ最大数に対応して変更してください。

「R_STEP = 10         # 頻度目盛り間隔」を好みに合わせて変更してください。

csvファイルは次の例を参考に作成してください

…………………

angle,frequency

0-20,0

20-40,0

40-60,4

60-80,13

80-100,20

100-120,33

120-140,15

140-160,5

160-180,0

…………………


import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

# ===== 設定 =====
CSV_PATH = "G:/test/aaa.csv"
R_MAX = 40          # 頻度表示の最高値
R_STEP = 10         # 頻度目盛り間隔
BAR_COLOR = "indianred"   # 棒の色
EDGE_COLOR = "0.2"

# ===== CSV読み込み =====
df = pd.read_csv(CSV_PATH)

# angle列: "0-20" のような形式を想定
starts = []
ends = []

for a in df["angle"]:
    s, e = str(a).split("-")
    starts.append(float(s))
    ends.append(float(e))

df["start"] = starts
df["end"] = ends
df["center"] = (df["start"] + df["end"]) / 2
df["width"] = df["end"] - df["start"]

# matplotlibの極座標では角度をラジアンに変換
theta = np.deg2rad(df["center"])
width = np.deg2rad(df["width"])
r = df["frequency"]

# ===== 描画 =====
fig = plt.figure(figsize=(6, 8))
ax = fig.add_subplot(111, polar=True)

ax.bar(
    theta,
    r,
    width=width,
    bottom=0,
    color=BAR_COLOR,
    edgecolor=EDGE_COLOR,
    linewidth=1.5,
    align="center"
)

# 半円表示:0〜180度
ax.set_thetamin(0)
ax.set_thetamax(180)

# 角度表示
ax.set_theta_zero_location("N")   # 0度を上
ax.set_theta_direction(-1)        # 時計回り
ax.set_thetagrids([0, 30, 60, 90, 120, 150, 180])

# 頻度目盛り
ax.set_ylim(0, R_MAX)
ax.set_yticks(np.arange(R_STEP, R_MAX + 1, R_STEP))
ax.set_yticklabels([str(v) for v in np.arange(R_STEP, R_MAX + 1, R_STEP)])

# 頻度ラベルを左側に寄せる
ax.set_rlabel_position(180)

# 見た目調整
ax.grid(True, color="0.8", linewidth=1)
ax.spines["polar"].set_linewidth(1.5)

plt.tight_layout()
plt.show()

0 件のコメント:

コメントを投稿