From 2ca1fe19e4edaecd9bb6d3ee0c8589a102cc2ed2 Mon Sep 17 00:00:00 2001 From: Peter Swain <peter.swain@ed.ac.uk> Date: Wed, 19 Jul 2023 12:30:00 +0100 Subject: [PATCH] added function to add gr data to dl.df --- growth_rate.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/growth_rate.py b/growth_rate.py index b49a8d3..685dccd 100644 --- a/growth_rate.py +++ b/growth_rate.py @@ -13,8 +13,8 @@ from wela.figs2pdf import figs2pdf def find_all_grs( dataname, max_no_cells=None, - indir=None, - outdir=".", + h5dir=None, + wdir=".", use_tsv=True, ): """ @@ -26,9 +26,9 @@ def find_all_grs( Name of experiment, passed to dataloader. max_no_cells: None or int The maximum number of cells to process. - indir: str (optional) + h5dir: str (optional) The directory containing the h5 files. - outdir: str (optional) + wdir: str (optional) The directory containing any tsv files to load and where tsv files will be saved. use_tsv: boolean (optional) @@ -37,7 +37,7 @@ def find_all_grs( Example ------- >>> from wela.growth_rate import find_all_grs - >>> find_all_grs("Pdr5", max_no_cells=2, outdir="tsv_files") + >>> find_all_grs("Pdr5", max_no_cells=2, wdir="tsv_data") """ # only save if all cells are processed if max_no_cells is None: @@ -45,7 +45,7 @@ def find_all_grs( else: save = False # get data - dl = dataloader(indir=indir, outdir=outdir) + dl = dataloader(h5dir=h5dir, wdir=wdir) dl.load(dataname, use_tsv=use_tsv) b_vol = dl.wide_df("bud_volume") m_vol = dl.wide_df("volume") @@ -67,10 +67,12 @@ def find_all_grs( pickle.dump(res_m, open(dataname + "_res_m.pkl", "wb")) figs2pdf(dataname + "_m.pdf") plt.close("all") - # add to dataframe and save - if save: - addgrfrompkl(dl, ".") - dl.save(dataname) + + +def add_to_dataframe(dl, pkl_dir="."): + """Add data from pkl files to a dataloader's data frame.""" + addgrfrompkl(dl, pkl_dir) + dl.save(dl.dataname) def find_gr( @@ -209,7 +211,7 @@ def runGP(x, y, bounds, noruns, signals, verbose, title, maxnofigs=70): mg.sketch(".", derivs=1) plt.ylabel("d/dt volume") plt.xlabel("time") - plt.show() + plt.show(block=False) res = dict( zip( signals, -- GitLab