def plot_gvel(per, relative=False): key = period2key(per) gvel_filename = "iso_gvel_fin_%s.dat"%key figname = "iso_gvel_fin_%s.png"%key # read the data (this method only works for 1x1 degree grid as loadtxt only # works whern there are the same number of points in each row) print gvel_filename rawdata = np.loadtxt(gvel_filename, skiprows=1) data = rawdata.ravel().reshape(180, 360) # project the data from the global grid to the projected one data_proj = m.transform_scalar(data[::-1, :], lons, lats, nx, ny) if relative: average = np.average(data_proj) data_proj = (data_proj/average - 1.0) * 100.0 # do the plot plt.figure() m.drawcoastlines() m.drawcountries() m.drawparallels(parallels, labels=[1, 0, 0, 0]) m.drawmeridians(meridians, labels=[0, 0, 0, 1]) im = m.imshow(data_proj, cmap='jet_r') if relative: m.colorbar(location='right', label='%') plt.title('Group velocity anomaly at T=%.1f s (wrt U = %.2f km/s)' % (per, average)) else: m.colorbar(location='right', label='U (km/s)') plt.title('Group velocity anomaly at T=%.1f s'% per) plt.savefig(figname) plt.close() print figname
def plot_gvel(per, relative=False): key = period2key(per) gvel_filename = "iso_gvel_fin_%s.dat" % key figname = "iso_gvel_fin_%s.png" % key # read the data (this method only works for 1x1 degree grid as loadtxt only # works whern there are the same number of points in each row) print gvel_filename rawdata = np.loadtxt(gvel_filename, skiprows=1) data = rawdata.ravel().reshape(180, 360) # project the data from the global grid to the projected one data_proj = m.transform_scalar(data[::-1, :], lons, lats, nx, ny) if relative: average = np.average(data_proj) data_proj = (data_proj / average - 1.0) * 100.0 # do the plot plt.figure() m.drawcoastlines() m.drawcountries() m.drawparallels(parallels, labels=[1, 0, 0, 0]) m.drawmeridians(meridians, labels=[0, 0, 0, 1]) im = m.imshow(data_proj, cmap='jet_r') if relative: m.colorbar(location='right', label='%') plt.title('Group velocity anomaly at T=%.1f s (wrt U = %.2f km/s)' % (per, average)) else: m.colorbar(location='right', label='U (km/s)') plt.title('Group velocity anomaly at T=%.1f s' % per) plt.savefig(figname) plt.close() print figname
#!/usr/bin/env python # encoding: utf-8 from os import system from dsp2intomodes import period2key periods = [20, 50, 100, 150] for per in periods: key = period2key(per) fname = "input_%s.txt" % key system("xregiostack6 < %s" % fname)