Commit 2e6f94ff authored by Marius Isken's avatar Marius Isken
Browse files

Update plot

parent bbcc64f0
......@@ -933,7 +933,7 @@ def draw_fits_figures_statics(ds, model, plt):
gms = gms[isort]
xs = model.xs[isort, :]
xbest = xs[0, :]
source = problem.get_source(xbest)
ms, ns, results = problem.evaluate(xbest, result_mode='full')
......@@ -941,66 +941,73 @@ def draw_fits_figures_statics(ds, model, plt):
figures = []
tick_locator = ticker.MaxNLocator(nbins=5)
for sat_target,result in zip (problem.satellite_targets,results):
def decorateAxes(ax, title):
ax.set_title(title)
ax.set_ylabel('[m]')
ax.set_xlabel('[m]')
ax.set_aspect('equal')
def drawRectangularOutline(ax):
source.regularize()
print source
fn, fe = source.outline(cs='xy').T
offset_n, offset_e = latlon_to_ne_numpy(
sat_target.lats[0], sat_target.lons[0],
source.lat, source.lon)
print 'fn', fn
print 'fe', fe
fn += offset_n
fe += offset_e
print 'fn_off', fn
print 'fe_off', fe
print sat_target.lats[0], sat_target.lons[0], source.lat, source.lon,\
offset_e, offset_n
ax.plot(offset_e, offset_n, marker='o')
ax.plot(fe, fn, marker='o')
# ax.fill(fe, fn, color=(0.5, 0.5, 0.5), alpha=0.5)
# ax.plot(fe[:2], fn[:2], linewidth=2., color='black', alpha=0.5)
for sat_target, result in zip(problem.satellite_targets, results):
fig = plt.figure(figsize=(16, 4))
cmap = plt.cm.get_cmap('coolwarm')
qt = ds.get_kite_scene(sat_target.scene_id).quadtree
E = sat_target.east_shifts
N = sat_target.north_shifts
fig = plt.figure(figsize=(16,4))
cmap = plt.cm.get_cmap('coolwarm')
stat_obs = qt.leaf_medians
stat_syn = result.statics_syn['displacement.los']
res = (stat_obs - stat_syn)
lmax = num.abs([num.min(stat_obs), num.max(stat_obs)]).max()
levels = num.linspace(-lmax, lmax, 50)
flat = stat_obs .flatten('F')
lmax = num.abs(stat_obs).max()
levels = num.linspace(-lmax, lmax, 50)
flat = stat_obs.flatten('F')
ax = fig.add_subplot(131)
obs_plot = ax.tricontourf(E, N, flat, levels= levels, cmap=cmap)
cb = fig.colorbar(obs_plot, ax=ax, orientation='horizontal', aspect=10)
cb.locator = tick_locator
cb.update_ticks()
fn, fe = source.outline(cs='xy').T
offset_n, offset_e = latlon_to_ne_numpy(sat_target.lats[0], sat_target.lons[0], source.lat, source.lon)
fn = fn+offset_n
fe = fe+offset_e
ax.fill(fe, fn, color=(0.5, 0.5, 0.5), alpha=0.5)
ax.plot(fe[:2], fn[:2],linewidth=2., color='black', alpha=0.5)
plt.title('Data')
ax.set_ylabel('[m]')
ax.set_xlabel('[m]')
ax.set_aspect('equal')
obs_plot = ax.tricontourf(E, N, flat, levels=levels, cmap=cmap)
fig.colorbar(obs_plot, ax=ax, orientation='horizontal', aspect=10,
ticks=tick_locator)
drawRectangularOutline(ax)
decorateAxes(ax, 'Data')
ax = fig.add_subplot(132)
ax.tricontourf(E, N, stat_syn, levels= levels, cmap=cmap)
cb = fig.colorbar(obs_plot, ax=ax, orientation='horizontal' ,aspect=10)
cb.locator = tick_locator
cb.update_ticks()
ax.fill(fe, fn, color=(0.5, 0.5, 0.5), alpha=0.5)
ax.plot(fe[:2],fn[:2],linewidth=2.,color='black',alpha=0.5)
plt.title('Model')
ax.set_ylabel('[m]')
ax.set_xlabel('[m]')
ax.set_aspect('equal')
ax = fig.add_subplot(133)
ax.tricontourf(E, N, res, levels= levels, cmap=cmap)
cb = fig.colorbar(obs_plot,ax=ax, orientation='horizontal', aspect=10)
cb.locator = tick_locator
cb.update_ticks()
ax.fill(fe, fn, color=(0.5, 0.5, 0.5), alpha=0.5)
ax.plot(fe[:2],fn[:2],linewidth=2.,color='black',alpha=0.5)
plt.title('Residual')
ax.set_ylabel('[km]')
ax.set_xlabel('[km]')
ax.set_aspect('equal')
ax.tricontourf(E, N, stat_syn, levels=levels, cmap=cmap)
fig.colorbar(obs_plot, ax=ax, orientation='horizontal', aspect=10,
ticks=tick_locator)
drawRectangularOutline(ax)
decorateAxes(ax, 'Model')
ax = fig.add_subplot(133)
ax.tricontourf(E, N, res, levels=levels, cmap=cmap)
fig.colorbar(obs_plot, ax=ax, orientation='horizontal', aspect=10,
ticks=tick_locator)
drawRectangularOutline(ax)
decorateAxes(ax, 'Residual')
figures.append(fig)
return figures
def draw_fits_figures(ds, model, plt):
fontsize = 8
fontsize_title = 10
......@@ -1522,7 +1529,7 @@ plot_dispatch = {
'jointpar': draw_jointpar_figures,
'hudson': draw_hudson_figure,
'fits': draw_fits_figures,
'fits_statics' : draw_fits_figures_statics,
'fits_statics': draw_fits_figures_statics,
'solution': draw_solution_figure}
......@@ -1593,7 +1600,8 @@ def plot_result(dirname, plotnames_want,
fns.extend(
save_figs(figs, plot_dirname, plotname, formats, dpi))
if 5 != len({'fits','fits_statics', 'jointpar', 'hudson', 'solution'} - plotnames_want):
if 5 != len({'fits', 'fits_statics', 'jointpar', 'hudson', 'solution'}
- plotnames_want):
problem, xs, misfits = core.load_problem_info_and_data(
dirname, subset='harvest')
......@@ -1612,7 +1620,7 @@ def plot_result(dirname, plotnames_want,
if save:
fns.extend(
save_figs(figs, plot_dirname, plotname, formats, dpi))
for plotname in ['fits_statics']:
if plotname in plotnames_want:
config = guts.load(filename=op.join(dirname, 'config.yaml'))
......@@ -1625,7 +1633,6 @@ def plot_result(dirname, plotnames_want,
fns.extend(
save_figs(figs, plot_dirname, plotname, formats, dpi))
for plotname in ['jointpar', 'hudson', 'solution']:
if plotname in plotnames_want:
figs = plot_dispatch[plotname](model, plt)
......@@ -1635,4 +1642,3 @@ def plot_result(dirname, plotnames_want,
if not save:
plt.show()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment