def test_leading_empty(self): ss = [[None, None, 1.2, None, None], [None, None, None, None, None], [None, None, None, 1.3, 1.4]] gap_fill(*ss) self.assertEquals( ss, [[None, None, 1.2, 1.3, None], [None, None, None, None, None], [None, None, None, 1.3, 1.4]])
def test_switch(self): ss = [[100, 101, None, None, None], [None, None, 102, None, None], [None, None, None, 103, 104]] gap_fill(*ss) self.assertEquals( ss, [[100, 101, 102, None, None], [None, None, 102, 103, None], [None, None, None, 103, 104]])
def test_base_case(self): ss = [[100, 101, 102, None, None], [None, None, None, 103, 104], [None, None, None, None, None]] gap_fill(*ss) self.assertEquals( ss, [[100, 101, 102, 103, None], [None, None, None, 103, 104], [None, None, None, None, None]])
def test_empty_run(self): ss = [[100, 101, None, None, None], [None, None, None, 103, 104], [None, None, None, None, None]] gap_fill(*ss) self.assertEquals( ss, [[100, 101, None, None, None], [None, None, None, 103, 104], [None, None, None, None, None]])
def test_all_empty(self): ss = [[None, None, None, None, None], [None, None, None, None, None], [None, None, None, None, None]] gap_fill(*ss) self.assertEquals( ss, [[None, None, None, None, None], [None, None, None, None, None], [None, None, None, None, None]])
def test_all_empty(self): ss = [[None, None, None, None, None], [None, None, None, None, None], [None, None, None, None, None]] gap_fill(*ss) self.assertEquals(ss, [[None, None, None, None, None], [None, None, None, None, None], [None, None, None, None, None]] )
def test_zeros(self): ss = [[0, 0, None, None, None], [None, None, 0, None, None], [None, None, None, 0, 0]] gap_fill(*ss) self.assertEquals(ss, [[0, 0, 0, None, None], [None, None, 0, 0, None], [None, None, None, 0, 0]] )
def test_switch(self): ss = [[100, 101, None, None, None], [None, None, 102, None, None], [None, None, None, 103, 104]] gap_fill(*ss) self.assertEquals(ss, [[100, 101, 102, None, None], [None, None, 102, 103, None], [None, None, None, 103, 104]] )
def test_empty_run(self): ss = [[100, 101, None, None, None], [None, None, None, 103, 104], [None, None, None, None, None]] gap_fill(*ss) self.assertEquals(ss, [[100, 101, None, None, None], [None, None, None, 103, 104], [None, None, None, None, None]] )
def test_base_case(self): ss = [[100, 101, 102, None, None], [None, None, None, 103, 104], [None, None, None, None, None]] gap_fill(*ss) self.assertEquals(ss, [[100, 101, 102, 103, None], [None, None, None, 103, 104], [None, None, None, None, None]] )
def test_leading_empty(self): ss = [[None, None, 1.2, None, None], [None, None, None, None, None], [None, None, None, 1.3, 1.4]] gap_fill(*ss) self.assertEquals(ss, [[None, None, 1.2, 1.3, None], [None, None, None, None, None], [None, None, None, 1.3, 1.4]] )
def plot_multi(data, beginDate, endDate, show_logo=True): # data is an iterator over tuples. # each tuple has a timestamp as first column, # then 3 columns for each well: Observed, Estimated, Dry fig = figure() if show_logo: logo_im(fig) # axx = axes([0.1, 0.3, 0.5, 0.5]) # left, bottom, width, height # ax1 = subplot(2, 1, 1) # left, bottom, width, height -- 0..1 ax1 = axes([0.1, 0.3, 0.8, 0.55]) fig.suptitle("Water level elevation above NAVD88 datum, in feet", y=0.9) xlabel('Date') ylabel('Water Level (NAVD88 ft)') # xlim handles None gracefully xlim(beginDate, endDate) # axhline(y = 0.5) could be used for depicting ground elevation # labels = [ _clean_label(s) for s in keys[1:] ] # legend(labels, loc='upper left', bbox_to_anchor=(1, 1)) xticks(rotation=90) labels = data.keys() # columns is a list of lists, one for each column. columns = [ list() for _l in labels] for r in data: for i, v in enumerate(r): columns[i].append(v) for i in range(1, len(columns), 3): gap_fill(columns[i], columns[i + 1], columns[i + 2]) line_colors = ColorRange(count=(len(labels) - 1) / 3) _logger.debug("In plot_multi generation, colors = %s", list(line_colors)) lines = [] for i in range(1, len(labels)): marker = _line_styles[(i - 1) % 3] color = line_colors[(i - 1) / 3] label = "_nolegend_" if (i % 3) == 1: label = labels[i] markerprops = {'markerfacecolor':color, 'markersize':_marker_size, 'markeredgecolor':color} l = plot_date(columns[0], columns[i], fmt=marker, color=color, label=label, **markerprops) lines.append(l[0]) grid(color="0.7", linestyle="-") # float-ish color is interpreted as gray level, 1.0=white h, l = ax1.get_legend_handles_labels() # position legend in lower sub-plot, not to graphed subplot # ax2 = subplot(2, 1, 2) fig.legend(h, l, loc='lower right', ncol=1 + (len(l) / 6)) # make another legend for the dot'n'dashes, from the first 3 lines _legend_for_line_styles(fig) return len(columns[0]), fig
def plot_single(data, beginDate=None, endDate=None, dry_elevation=None, ground_elevation=None, ngvd29_correction=None, show_logo=True): f = figure() labels = data.keys() if show_logo: logo_im(f) # left, bottom, width, height ax1 = axes([0.1, 0.25, 0.8, 0.55]) f.suptitle("Water level elevation above NAVD88 datum, in feet\nGage " + labels[1], y=0.9) xlabel('Date') ylabel('Water Level (NAVD88 ft)') xlim(beginDate, endDate) # labels = [ _clean_label(s) for s in keys[1:] ] # legend(labels, loc='upper left', bbox_to_anchor=(1, 1)) xticks(rotation=90) ylabel(labels[1] + "\nWater Level (NAVD88 ft)") # data has exactly 4 columns: date, O, E, D columns = [[], [], [], []] for r in data: for i, v in enumerate(r): columns[i].append(v) gap_fill(*columns[1:3]) if dry_elevation is not None: axhline(y=dry_elevation, linewidth=4, color=gray_ish, zorder= -100) if ground_elevation is not None: axhline(y=ground_elevation, linewidth=4, color=brown_ish, zorder= -100) line_colors = ColorRange(count=1) c = line_colors[0] _logger.debug("In plot_single, color = %s", c) grid(color="0.7", linestyle="-") # float-ish color is interpreted as gray level, 1.0=white markerprops = {'markerfacecolor':c, 'markersize':_marker_size, 'markeredgecolor':c} (l1,) = plot_date(columns[0], columns[1], _line_styles[0], color=c, label="Obs", **markerprops) (l2,) = plot_date(columns[0], columns[2], _line_styles[1], color=c, label="Est", **markerprops) (l3,) = plot_date(columns[0], columns[3], _line_styles[2], color=c, label="Dry", **markerprops) # Set options to make legend horizontal, across bottom h, l = ax1.get_legend_handles_labels() f.legend(h, l, loc='lower center', bbox_to_anchor=(0.5, 0.0), ncol=3) # logo(f) # _legend_for_line_styles(f, [l1, l2, l3]) if ngvd29_correction is not None: ax1 = f.axes[0] ax2 = ax1.twinx() # new axis overlay, ticks on right, shared x axis lim = ax1.get_ylim() ax2.set_ylim([d - ngvd29_correction for d in lim]) ax2.set_ylabel("NAVD29 ft") # twinx does not preserve this, so restore it now ax2.xaxis_date() # tight_layout() draw() # tight_layout() # does not look good return len(columns[0]), f
def test_zeros(self): ss = [[0, 0, None, None, None], [None, None, 0, None, None], [None, None, None, 0, 0]] gap_fill(*ss) self.assertEquals(ss, [[0, 0, 0, None, None], [None, None, 0, 0, None], [None, None, None, 0, 0]])
def plot_multi(data, beginDate, endDate, show_logo=True): # data is an iterator over tuples. # each tuple has a timestamp as first column, # then 3 columns for each well: Observed, Estimated, Dry fig = figure() if show_logo: logo_im(fig) # axx = axes([0.1, 0.3, 0.5, 0.5]) # left, bottom, width, height # ax1 = subplot(2, 1, 1) # left, bottom, width, height -- 0..1 ax1 = axes([0.1, 0.3, 0.8, 0.55]) fig.suptitle("Water level elevation above NAVD88 datum, in feet", y=0.9) xlabel('Date') ylabel('Water Level (NAVD88 ft)') # xlim handles None gracefully xlim(beginDate, endDate) # axhline(y = 0.5) could be used for depicting ground elevation # labels = [ _clean_label(s) for s in keys[1:] ] # legend(labels, loc='upper left', bbox_to_anchor=(1, 1)) xticks(rotation=90) labels = data.keys() # columns is a list of lists, one for each column. columns = [list() for _l in labels] for r in data: for i, v in enumerate(r): columns[i].append(v) for i in range(1, len(columns), 3): gap_fill(columns[i], columns[i + 1], columns[i + 2]) line_colors = ColorRange(count=(len(labels) - 1) / 3) _logger.debug("In plot_multi generation, colors = %s", list(line_colors)) ax1.yaxis.set_major_formatter( matplotlib.ticker.FormatStrFormatter('%0.2f')) lines = [] for i in range(1, len(labels)): marker = _line_styles[(i - 1) % 3] color = line_colors[(i - 1) / 3] label = "_nolegend_" if (i % 3) == 1: label = labels[i] markerprops = { 'markerfacecolor': color, 'markersize': _marker_size, 'markeredgecolor': color } l = plot_date(columns[0], columns[i], fmt=marker, color=color, label=label, **markerprops) lines.append(l[0]) grid(color="0.7", linestyle="-" ) # float-ish color is interpreted as gray level, 1.0=white h, l = ax1.get_legend_handles_labels() # position legend in lower sub-plot, not to graphed subplot # ax2 = subplot(2, 1, 2) fig.legend(h, l, loc='lower right', ncol=1 + (len(l) / 6)) # make another legend for the dot'n'dashes, from the first 3 lines _legend_for_line_styles(fig) return len(columns[0]), fig
def plot_single(data, beginDate=None, endDate=None, dry_elevation=None, ground_elevation=None, ngvd29_correction=None, show_logo=True): f = figure() labels = data.keys() if show_logo: logo_im(f) # left, bottom, width, height ax1 = axes([0.1, 0.25, 0.8, 0.55]) f.suptitle("Water level elevation above NAVD88 datum, in feet\nGage " + labels[1], y=0.9) xlabel('Date') ylabel('Water Level (NAVD88 ft)') xlim(beginDate, endDate) # labels = [ _clean_label(s) for s in keys[1:] ] # legend(labels, loc='upper left', bbox_to_anchor=(1, 1)) xticks(rotation=90) ylabel(labels[1] + "\nWater Level (NAVD88 ft)") # data has exactly 4 columns: date, O, E, D columns = [[], [], [], []] for r in data: for i, v in enumerate(r): columns[i].append(v) gap_fill(*columns[1:3]) if dry_elevation is not None: axhline(y=dry_elevation, linewidth=4, color=gray_ish, zorder=-100) if ground_elevation is not None: axhline(y=ground_elevation, linewidth=4, color=brown_ish, zorder=-100) line_colors = ColorRange(count=1) c = line_colors[0] _logger.debug("In plot_single, color = %s", c) grid(color="0.7", linestyle="-" ) # float-ish color is interpreted as gray level, 1.0=white markerprops = { 'markerfacecolor': c, 'markersize': _marker_size, 'markeredgecolor': c } (l1, ) = plot_date(columns[0], columns[1], _line_styles[0], color=c, label="Obs", **markerprops) (l2, ) = plot_date(columns[0], columns[2], _line_styles[1], color=c, label="Est", **markerprops) (l3, ) = plot_date(columns[0], columns[3], _line_styles[2], color=c, label="Dry", **markerprops) # Set options to make legend horizontal, across bottom h, l = ax1.get_legend_handles_labels() f.legend(h, l, loc='lower center', bbox_to_anchor=(0.5, 0.0), ncol=3) # logo(f) # _legend_for_line_styles(f, [l1, l2, l3]) ax1.yaxis.set_major_formatter( matplotlib.ticker.FormatStrFormatter('%0.2f')) if ngvd29_correction is not None: # ax1 = f.axes[0] ax2 = ax1.twinx() # new axis overlay, ticks on right, shared x axis lim = ax1.get_ylim() ax2.set_ylim([d - ngvd29_correction for d in lim]) ax2.set_ylabel("NAVD29 ft") # twinx does not preserve this, so restore it now ax2.xaxis_date() ax2.yaxis.set_major_formatter( matplotlib.ticker.FormatStrFormatter('%0.2f')) # tight_layout() draw() # tight_layout() # does not look good return len(columns[0]), f