この質問を書くのに苦労しました。複数の CTD データ ファイル (深さのある海洋温度値を含むファイル) があります。深さによって温度がどのように変化するかを確認するために、それらを 1 つの図にプロットしました。私が今やりたいことは、平均温度 (すべてのファイルの中で) の平均プロファイル (1 行のみ) を深さでプロットすることです。つまり、複数のデータ ファイルからの各変数の行ごとの平均のようなものです。
私のデータは、温度値の列と深さ値の別の列である cnv 形式です。各データ セットの深さと温度の値の数は同じではありません (つまり、同じ行数ではありません)。
これは、各ファイルをロットするためだけに私のコードがどのように見えるかであり、それが生成する図を添付しました:
from seabird.cnv import fCNV
import numpy as np
import matplotlib.pyplot as plt
from seabird.cnv import fCNV
import glob
filenames = sorted(glob.glob('dSBE19plus*.cnv')) #load multiple files
filenames = filenames[0:8]
fig1 = plt.figure()
ax1 = fig1.add_subplot(111)
for f in filenames:
print(f)
data = fCNV(f)
# Assign variable names
depth = data['prdM']
temp = data['tv290C']
salt = data['PSAL']
fluo = data['flECO-AFL']
turbidity = data['turbWETntu0']
ax1.plot(temp,depth)
# Draw x label
ax1.set_xlabel('Temperature (C)')
ax1.xaxis.set_label_position('top') # this moves the label to the top
ax1.xaxis.set_ticks_position('top') # this moves the ticks to the top
# Draw y label
ax1.set_ylim([0, 100])
ax1.set_ylabel('Depth (m)')
ax1.set_ylim(ax1.get_ylim()[::-1])
ax1.set_xlim([15, 26])
fig1.savefig('ctd_plot.png')
私の質問が理にかなっていることを願っています。
どうもありがとう