我很难写出这个问题。我有多个 CTD 数据文件(包含海洋温度值和深度的文件)。我将它们绘制在一个图形上,以查看温度如何随深度变化。我现在想做的是绘制平均温度(在所有文件中)与深度的平均分布(仅一行)。因此,就像来自多个数据文件的每个变量的逐行平均值一样。
我的数据是 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')
我希望我的问题是有道理的。
非常感谢