<commit_before><commit_msg>add an examples folder, has waterfall to start<commit_after>from abf_reader import *
import matplotlib.pyplot as plt
from abf_epoch import epoch, waterfall
import matplotlib.gridspec as gridspec
from scale_bars import *

if __name__=='__main__':
    import os
    labdir = os.environ.get("LABDIR")
    
    # change some legend plot stuff
    plt.rcParams.update(\
        {'legend.frameon':False,
         'legend.numpoints':1,
         'legend.loc':'upper left',
         'legend.fontsize':12})

    # organize info for files / conditions / plot labels into dict
    files_dict = [{'abf':abf_reader('2012_08_24_0000_cntrl.abf'),
             'color':'black',
             'label':'control'},
            {'abf':abf_reader('2012_08_24_0004_frf.abf'),
             'color':'red',
             'label':'frf'}]

    # pre plot grid
    plt.figure()
    gs = gridspec.GridSpec(2, 1, hspace = 0, wspace = 0,
                           left = 0, right = 1.)

    # plot in loop
    xlims = []
    for i, fdict in enumerate(files_dict):
        plt.subplot(gs[i,0])
        epch = epoch(fdict.pop('abf'), 1, 1)
        epch.set_pading(left = 1000, right = 2000)
        wf = waterfall(epch)
        wf.set_range() # this will change the xlim
        xlims.append(wf._xlim)
        for i, (xs,ys) in enumerate(wf):
            plt.plot(xs,ys, linewidth = 0.5, **fdict)
            if i==0:
                fdict.pop('label')
        plt.show()

    # post plotting adjust axis so grids are comparable, maybe can do
    # this with some shared axis object? Also hide axis ticks, labels
    # and spines.
    xmin = min([x[0] for x in xlims])
    xmax = max([x[1] for x in xlims])
    for ax in plt.gcf().axes:
        ax.set_xlim((xmin, xmax)) 
        ax.set_ylim((-60,30))
        ax.legend()

        # add a scale bar
        add_scalebar(ax, matchx = False, matchy = False,
                     sizex = 1, sizey = 30,
                     labelx = '1 sec', labely = '30 mV',
                     bbox_to_anchor = (0.3,0.4),
                     sep = 1, pad = 1,
                     bbox_transform = ax.transAxes, borderpad=0)
        plt.draw()


{'fraction_non_alphanumeric': 0.12476979742173112, 'fraction_numerical': 0.03038674033149171, 'mean_word_length': 1.9604904632152589, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6687969', 'n_tokens_mistral': 789, 'n_tokens_neox': 711, 'n_words': 187}