def bathy_along_track(Float, hpids, bathy_file=None): """TODO: Docstring...""" __, idxs = Float.get_profiles(hpids, ret_idxs=True) lons = Float.lon_start[idxs] lats = Float.lat_start[idxs] dist = Float.dist[idxs] bathy = sandwell.interp_track(lons, lats, bathy_file) plt.figure() plt.plot(dist, bathy) plt.xlabel('Distance (km)') plt.ylabel('Depth (m)')
plt.figure(figsize=(5, 7)) plt.scatter(d, z, s=50, c=V*100., edgecolor='none', cmap=bwr) cbar = plt.colorbar(orientation='horizontal', extend='both') cbar.set_label(texvar+' (cm s$^{-1}$)') plt.clim(*clim) plt.xlim(np.nanmin(d), np.nanmax(d)) plt.xlabel('Distance (km)') plt.ylabel('Depth (m)') title_str = ("Float {}").format(Float.floatID) plt.title(title_str) lons = Float.lon_start[idxs] lats = Float.lat_start[idxs] dist = Float.dist[idxs] bathy = sandwell.interp_track(lons, lats, bathy_file) plt.plot(dist, bathy, 'k', linewidth=3) plt.ylim(np.nanmin(bathy), np.nanmax(z)) my_savefig(Float.floatID, var + '_mountain') pf.track_on_bathy(Float, hpids, bathy_file=bathy_file) my_savefig(Float.floatID, 'mountain_area_track') # %% Fitting in only one direction. Vertical wavenumber. def plane_wave(x, A, k, phase): return A*np.cos((k*x + phase))
V = getattr(Float, var)[:, idxs].flatten(order='F') z = getattr(Float, zvar)[:, idxs].flatten(order='F') d = getattr(Float, dvar)[:, idxs].flatten(order='F') zs.append(z.copy()) tgps = getattr(Float, 'UTC_start')[idxs] lon = getattr(Float, 'lon_start')[idxs] lat = getattr(Float, 'lat_start')[idxs] tctd = getattr(Float, 'UTC')[:, idxs].flatten(order='F') nans = np.isnan(d) | np.isnan(tctd) tctd = tctd[~nans] dctd = d[~nans] lonctd = np.interp(tctd, tgps, lon) latctd = np.interp(tctd, tgps, lat) bathy = sandwell.interp_track(lonctd, latctd, bf) d -= dctd[bathy.argmax()] ds.append(d.copy()) nans = np.isnan(d) | np.isnan(z) | np.isnan(V) # Wg = griddata((d[~nans], z[~nans]), V[~nans], (Xg, Zg), method='linear') # Wgs.append(Wg.copy()) dctd -= dctd[bathy.argmax()] points = np.array([d, z]).transpose().reshape(-1, 1, 2) segs = np.concatenate([points[:-1], points[1:]], axis=1) lc = LineCollection(segs, cmap=bwr2,
LOG_KAP = (np.log10(kappa)).flatten(order='F')[use] # Plotting # # Epsilon d = getattr(Float, 'dist_ctd')[:, idxs].flatten(order='F') tgps = getattr(Float, 'UTC_start')[idxs] lon = getattr(Float, 'lon_start')[idxs] lat = getattr(Float, 'lat_start')[idxs] tctd = getattr(Float, 'UTC')[:, idxs].flatten(order='F') nans = np.isnan(d) | np.isnan(tctd) tctd = tctd[~nans] dctd = d[~nans] lonctd = np.interp(tctd, tgps, lon) latctd = np.interp(tctd, tgps, lat) bathy = sandwell.interp_track(lonctd, latctd, bf) dbathymax = dctd[bathy.argmax()] dctd -= dbathymax X -= dbathymax ax1.plot(Float.dist[idxs] - dbathymax, 1000.*ieps, label=Float.floatID) LOG_EPS[noise] = np.NaN step = 10 sc = ax0.scatter(X[::step], Z[::step], s=5, c=LOG_EPS[::step], edgecolor='none', cmap=plt.get_cmap('YlOrRd'), vmin=-10., vmax=-7, alpha=.5)
z = getattr(Float, 'z')[:, idxs].flatten(order='F') d = getattr(Float, 'dist_ctd')[:, idxs].flatten(order='F') t = getattr(Float, 'UTC')[:, idxs].flatten(order='F') # This block gets the bathymetry at the estimated position of each CTD measurement. # NaNs removed so array size is different to the above block. tgps = getattr(Float, 'UTC_start')[idxs] lon = getattr(Float, 'lon_start')[idxs] lat = getattr(Float, 'lat_start')[idxs] tctd = getattr(Float, 'UTC')[:, idxs].flatten(order='F') nans = np.isnan(d) | np.isnan(tctd) tctd = tctd[~nans] dctd = d[~nans] lonctd = np.interp(tctd, tgps, lon) latctd = np.interp(tctd, tgps, lat) bathy = sandwell.interp_track(lonctd, latctd, bf) # Zero the distances at the top of the sea mount. d -= dctd[bathy.argmax()] for ax, dmin, dmax in zip(axs, depth_mins, depth_maxs): in_range = (z > dmin) & (z < dmax) C = ax.scatter(d[in_range], utils.datenum_to_datetime(t[in_range]), c=Ww[in_range], s=30, cmap=bwr, vmin=-0.08, vmax=0.08) ax.set_ylim(datetime.datetime(2011, 1, 2, 12), datetime.datetime(2011, 1, 4, 6)) ax.set_xlim(-20, 40) ax.set_xlabel('Distance (km)') ax.set_title("{} to {} m".format(dmin, dmax))
# title_str = ("Float {}").format(Float.floatID) # ax.set_title(title_str) cbp = plt.colorbar(C, cax=cax, orientation='horizontal', extend='both') cbp.set_label('$w$ (m s$^{-1}$)') cbp.set_ticks([-0.05, 0, 0.05]) cbp.set_ticklabels(['-0.05', '0', '0.05']) if save_figs: filename = os.path.join(fsd, '{}_w_section.pdf'.format(Float.floatID)) fig.savefig(filename, bbox_inches='tight', pad_inches=0) # %% Float 4596 topo section Float = E4596 b = sandwell.interp_track(Float.lon_start, Float.lat_start, bf) __, z = Float.get_timeseries(Float.hpid, 'z') t, Ww = Float.get_timeseries(Float.hpid, 'Ww') __, Wf = Float.get_timeseries(Float.hpid, 'Wz') __, d = Float.get_timeseries(Float.hpid, 'dist_ctd') use = t > 7000. z = z[use] Ww = Ww[use] Wf = Wf[use] d = d[use] Ww[np.abs(Wf) < 0.08] = np.nan fig, ax = plt.subplots(1, 1, figsize=(6.5, 3))