def nourishment(transect_id, dt_from=None, dt_to=None, plotproperties=None, figsize=None): transect_id = int(transect_id) if plotproperties is None: plotproperties = {} if figsize is None: figsize = (8, 9) dfs = makedfs(transect_id, dt_from, dt_to) fig = combinedplot(dfs, figsize=figsize) buf = cStringIO.StringIO() try: fig.savefig(buf, **plotproperties) except ValueError, e: logger.error("Error creating nourishment figure for %s (from %s to " "%s)" % (transect_id, dt_from, dt_to)) all_else_fails_fig = all_else_fails_plot(dfs, figsize=figsize) buf.reset() all_else_fails_fig.savefig(buf, **plotproperties) # cleanup all_else_fails_fig.clf()
set_matplotlib_defaults() try: from lizard_kml.jarkus.nc_models import makedfs except ImportError: # import locally anyway from nc_models import makedfs transects = [ 7005000, # working 7005475, # no data for ax3 and ax4 figure (returns all-else-fails) 9010047, # has very few data (should also work) 8008100, ] for transect in transects: dfs = makedfs(transect) try: fig1 = test_plot_ax1(dfs) fig1.savefig('nourishment-%s-ax1.png' % transect) except ValueError, e: print "ERROR - axis 1 for %s fails: %s" % (transect, e) try: fig2 = test_plot_ax2(dfs) fig2.savefig('nourishment-%s-ax2.png' % transect) except ValueError, e: print "ERROR - axis 2 for %s fails: %s" % (transect, e) try: fig3 = test_plot_ax3(dfs) fig3.savefig('nourishment-%s-ax3.png' % transect) except ValueError, e: print "ERROR - axis 3 for %s fails: %s" % (transect, e)