I have had a difficult time trying to write this question. I have multiple CTD data files (files that contain ocean temperature values with depth). I have plotted them onto one figure to see how temperature changes with depth. What I would like to do now is plot a mean profile (just one line) of the average temperature (amongst all the files) with depth. So like a row-wise average for each variable from the multiple data files.
My data is in cnv format which is just a column of temperature values and another column of depth values. Each data set does not have the same number of depth and temperature values (i.e. not the same number of rows).
This is what my code looks like just for lotting each file and I have attached the figure it produces:
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')
Figure of each CTD data set plotted
I hope my question makes sense.
Many thanks