Ipython notebook to open ADCP .mat files from VENUS and plot them
%matplotlib inline
from matplotlib import pylab
import matplotlib.pyplot as plt
import numpy as np
import scipy.io
from datetime import datetime, timedelta
Start with the east node sitting in about 170 m of water
data_east = scipy.io.loadmat('RDIADCP150WH17457_20131015T000000.378Z-53E05.mat')
for key in data_east.keys():
print key
__header__ __globals__ meta adcp units __version__ config
data_east['adcp'].dtype
dtype([('ens', 'O'), ('compassHeading', 'O'), ('pitch', 'O'), ('roll', 'O'), ('time', 'O'), ('temperature', 'O'), ('salinity', 'O'), ('pressure', 'O'), ('depth', 'O'), ('soundSpeed', 'O'), ('heading_std', 'O'), ('pitch_std', 'O'), ('roll_std', 'O'), ('intens', 'O'), ('corr', 'O'), ('velocity', 'O'), ('percentGood', 'O'), ('range', 'O'), ('u', 'O'), ('v', 'O'), ('w', 'O'), ('u_magNorth', 'O'), ('v_magNorth', 'O'), ('velocityError', 'O'), ('backscatter', 'O')])
PPe = data_east['adcp']['pressure'][0][0]
print PP[600]
vele = data_east['adcp']['velocity'][0][0]
uvele = data_east['adcp']['u'][0][0]
vvele = data_east['adcp']['v'][0][0]
erange = data_east['adcp']['range'][0][0]
etime = data_east['adcp']['time'][0][0]
speede = np.sqrt(uvele*uvele+vvele*vvele)
print uvele[100,30], erange.shape, etime.shape
print etime[100][0]
ii = 1800
print datetime.fromordinal(int(etime[ii][0])) + timedelta(days=etime[ii][0]%1) - timedelta(days = 366)
[ 168.342] 0.0518031 (85, 1) (43201, 1) 735522.002319 2013-10-15 01:00:00.320001
bins = 85
dse = np.zeros((bins,24))
# find median for each hour in each bin
for id in np.arange(bins):
for j in np.arange(24):
dse[id,j] = np.median(speede[j*ii:j*ii+ii,id])
print dse.shape
plt.plot(dse[2],'b',dse[12],'r',dse[22],'g',dse[32],'m',dse[42],'k')
plt.title('East Station')
print 170-erange[2],170-erange[12],170-erange[22],170-erange[32],170-erange[42]
(85, 24) [ 157.13] [ 137.13] [ 117.13] [ 97.13] [ 77.13]
Next the central node sitting in about 300 m of water
data_central = scipy.io.loadmat('RDIADCP150WH8497_20131015T000005.419Z-53E04.mat')
PPc = data_central['adcp']['pressure'][0][0]
print PP[600]
velc = data_central['adcp']['velocity'][0][0]
uvelc = data_central['adcp']['u'][0][0]
vvelc = data_central['adcp']['v'][0][0]
crange = data_central['adcp']['range'][0][0]
ctime = data_central['adcp']['time'][0][0]
speedc = np.sqrt(uvelc*uvelc+vvelc*vvelc)
print uvelc[100,30], crange.shape, ctime.shape
print ctime[100][0]
ii = 600
print datetime.fromordinal(int(ctime[ii][0])) + timedelta(days=ctime[ii][0]%1) - timedelta(days = 366)
[ 168.342] 0.219759 (60, 1) (14400, 1) 735522.007007 2013-10-15 01:00:05.420003
bins = 60
dsc = np.zeros((bins,24))
# find median for each hour in each bin
for id in np.arange(bins):
for j in np.arange(24):
dsc[id,j] = np.median(speedc[j*ii:j*ii+ii,id])
print dsc.shape
plt.plot(dsc[2],'b',dsc[12],'r',dsc[22],'g',dsc[32],'m',dsc[42],'k')
plt.title('Central Station')
print 300-crange[2],300-crange[12],300-crange[22],300-crange[32],300-crange[42]
(60, 24) [ 280.72] [ 230.72] [ 180.72] [ 130.72] [ 80.72]