# IPython log file

get_ipython().system(u'ls -F --color ')
get_ipython().system(u'ls -F --color ../')
get_ipython().system(u'ls -F --color ../..')
get_ipython().system(u'ls -F --color ../../logs/')
from scipy.io import loadmat
raw = loadmat('../../logs/rowe_b.ENS.mat')
raw['E00001']
raw['E000001']
u_e = raw['E000003']
plot(u_e[:,1])
clf()
u_e.shape
raw['E000012'][0]
raw['E000013'][0]
raw['E000013']
raw.keys()
raw['E000014']
raw.keys()
raw[__header__]
raw['__header__']
raw['E000008']
raw['E000008'][1]
raw['E000008'][1].shape
raw['E000008'][1][0]
raw['E000008'][0][0]
raw['E000008'][0][1]
raw['E000008'][0][2]
raw['E000008'][0][21]
np.astype(raw['E000008'][0][21])
np.astype(raw['E000008'][:][21])
plot(raw['E000008'][:][21])
raw['E000008'].shape
plot(raw['E000008'][:,21])
clf()
plot(raw['E000008'][:,21])
stfv = raw['E000008'][:,21]
stfw
get_ipython().magic(u'pinfo stfv.astype')
stfv.view(np.dtype(str))
stfv.view(np.dtype('a4'))
stfv.view(np.dtype('a3'))
stfv.view(np.dtype('a5'))
stfv.view(np.dtype('a4'))
raw['E000008']
ensemble_data = raw['E000008']
ensemble_data[13]
ensemble_data[:,13]
bt = raw['E000010']
clf()
plot(bt[:,14:18])
bt.shape
plot(bt[:,14:18,0])
clf()
plot(bt[:,14:18,0])
ax = gca()
ax.invert_yaxis()
legend(['beam 0','beam 1','beam 2','beam 3'])
title('rowe_b.ENS.mat')
ylabel('range [m] (to bottom detection)')
ylabel('range [m] (to detected bottom)')
xlabel('ensemble')
u_ie_e = bt[:,46:49,:]
u_ie_e.shape
u_ie_e = bt[:,46:49,:].squeeze()
u_ie_e.shape
t = bt[:,1,:].squeeze()
t.shape
plot(t)
plot(diff(t))
clf()
plot(diff(t))
ylim([-1,1])
ylim([-1,4])
# looks like dt = 1 sec, with a few that register as 0 or 2
u_e, u_n, u_u = u_ie_e.T
x_e = np.trapz(u_e)
x_n = np.trapz(u_n)
x_u = np.trapz(u_u)
clf()
plot(u_e, u_n)
figure()
plot(u_e)
plot(u_e[u_e < 4])
max(u_e)
median(u_e)
mask_e = (u_e > 88)
mask_n = (u_n > 88)
mask_u = (u_u > 88)
mask = np.logical_and(np.logical_and(mask_e,mask_n), mask_u)
plot(mask)
clf()
plot(mask)
mu_e, mu_n, mu_u = u_ie_e.T[~mask]
mu_e, mu_n, mu_u = u_ie_e.transpose()[~mask]
mask
mu_e, mu_n, mu_u = u_ie_e[~mask].T
plot(mu_e)
clf()
mt = t[~mask]
x_e = np.trapz(u_e, t)
x_n = np.trapz(u_n, t)
x_u = np.trapz(u_u, t)
plot(x_e, x_n)
x_e = np.trapz(mu_e, t)
x_u = np.trapz(u_u, t)
x_e = np.trapz(mu_e, mt)
x_n = np.trapz(mu_n, mt)
plot(x_e, x_n)
clf()
plot(x_e, x_n)
x_e
from scipy import integrate
x = np.linspace(-2, 2, num=20)
y = x
y_int = integrate.cumtrapz(y, x, initial=0)
plt.plot(x, y_int, 'ro', x, y[0] + 0.5 * x**2, 'b-')
plt.show()
x_e = np.cumtrapz(mu_e, mt)
x_e = scipy.integrate.cumtrapz(mu_e, mt)
import scipy
import scipy.integrate
x_e = scipy.integrate.cumtrapz(mu_e, mt)
x_n = scipy.integrate.cumtrapz(mu_n, mt)
clf()
plot(x_e, x_n)
clf()
plot(u_e)
plot(mu_e)
clf()
plot(np.diff(mt))
ylim([-1,4])
mask_t = (t < 0.1)
mask = np.logical_and(mask_t, np.logical_and(np.logical_and(mask_e,mask_n), mask_u))
mask_t = np.logical_and(np.diff(t) < 0.1, np.diff(t) > 10)
mask = np.logical_and(mask_t, np.logical_and(np.logical_and(mask_e,mask_n), mask_u))
mask_t = np.logical_and(np.diff(t) < 0.1, np.diff(t) > 10)
mask = np.logical_and(mask_t, np.logical_and(np.logical_and(mask_e[:-1], mask_n[:-1]), mask_u[:-1]))
mu_e, mu_n, mu_u = (u_ie_e[:-1])[~mask].T
x_e = scipy.integrate.cumtrapz(mu_e, mt)
mt = (t[:-1])[~mask]
x_e = scipy.integrate.cumtrapz(mu_e, mt)
x_n = scipy.integrate.cumtrapz(mu_n, mt)
clf()
plot(x_e, x_n)
plot(mask)
clf()
plot(mask)
mask_t = np.logical_and(np.diff(t) < 0.1, np.diff(t) > 10)
plot(mask_t)
mask_t = np.logical_or(np.diff(t) < 0.1, np.diff(t) > 10)
plot(mask_t)
mask = np.logical_and(mask_t, np.logical_and(np.logical_and(mask_e[:-1], mask_n[:-1]), mask_u[:-1]))
u_e, u_n, u_u = u_ie_e.T
mu_e, mu_n, mu_u = (u_ie_e[:-1])[~mask].T
mt = (t[:-1])[~mask]
x_e = scipy.integrate.cumtrapz(mu_e, mt)
x_n = scipy.integrate.cumtrapz(mu_n, mt)
cl;f()
clf()
plot(x_e, x_n)
clf()
plot(mask)
mask = np.logical_or(mask_t, np.logical_or(np.logical_or(mask_e[:-1], mask_n[:-1]), mask_u[:-1]))
plot(mask)
clf()
mu_e, mu_n, mu_u = (u_ie_e[:-1])[~mask].T
mt = (t[:-1])[~mask]
x_n = scipy.integrate.cumtrapz(mu_n, mt)
x_e = scipy.integrate.cumtrapz(mu_e, mt)
plot(x_e, x_n)
# TODO: formalize this in a script and save it out as a HDF5 file
get_ipython().magic(u'logstart ~/rti.py')
get_ipython().system(u'ls -F --color ')
get_ipython().system(u'ls -F --color ..')
get_ipython().system(u'ls -F --color ../..')
get_ipython().system(u'ls -F --color ../../logs/')
get_ipython().magic(u'pwd ')
get_ipython().magic(u'run ../example/readGPGGA.py')
load_gpgga_file('../../logs/GPS_b.log')
dtime, latitude, longitude, raw_gps = load_gpgga_file('../../logs/GPS_b.log', startdate=datetime(2013,04,23))
mbm = oa.maps.MontereyBay(resolution='l')
import okeanidanalysis as oa
mbm = oa.maps.MontereyBay(resolution='l')
mbm.plot(longitude, latitude, latlon=True)
mbm.plot(longitude, latitude, latlon=True, marker='o')
import scipy.io.savemat
from scipy.io import savemat
get_ipython().magic(u'pinfo2 savemat')
get_ipython().magic(u'pinfo2 savemat')
get_ipython().magic(u'pinfo2 savemat')
foo = loadmat('../../logs/GPS_b.log.mat')
foo
bar = loadmat('../../logs/GPS_b.log.mat')
plot(foo['dn'])
plot(bar['dn'])
clf()
plot(foo['dn'] - bar['dn'])
baz = loadmat('../../logs/GPS_b.log.mat')
plot(foo['dn'] - baz['dn'])
np.allclose(foo['dn'],baz['dn'])
from matplotlib.dates import date2num
date2num(datetime(2013,12,12))
date2num(datetime(2013,12,12)) + 366
from matplotlib.dates import num2date
dto = num2date(baz['dn'] - 366)
dto
dtime
dto
get_ipython().magic(u'pinfo2 oa.maps.MontereyBay')
