Commit b0437988 authored by amichaut's avatar amichaut
Browse files

saving MSD plots in main directory (except for individual plots)

parent 8d560731
......@@ -568,10 +568,6 @@ def plot_MSD(data_dir, track, track_groups=None, df=None, df_out=None, fit_model
plot_config = make_plot_config() if plot_config is None else plot_config
color_list = plot_config['color_list']
if plot_dir is None:
plot_dir = osp.join(data_dir, 'MSD')
tpr.safe_mkdir(plot_dir)
data = tpr.get_data(data_dir)
timescale = data['timescale']
if df is None:
......@@ -601,6 +597,12 @@ def plot_MSD(data_dir, track, track_groups=None, df=None, df_out=None, fit_model
df_out.loc[ind, 'redchi'] = results['redchi']
if save_plot:
if plot_dir is None:
plot_dir = osp.join(data_dir, 'MSD')
else:
plot_dir = osp.join(plot_dir, 'MSD') # save in a separate folder
tpr.safe_mkdir(plot_dir)
info = tpr.get_info(data_dir)
D_unit = tpr.make_param_label('D', l_unit=info['length_unit'], t_unit=info['time_unit'], only_unit=True)
......@@ -1209,8 +1211,7 @@ def plot_all_MSD(data_dir, df=None, df_out=None, fit_model="biased_diff", msd_al
# plotting directory
if plot_dir is None:
plot_dir = osp.join(data_dir, 'MSD')
tpr.safe_mkdir(plot_dir)
plot_dir = data_dir
# save config
config_dir = osp.join(plot_dir, 'config')
......@@ -1259,7 +1260,7 @@ def plot_all_MSD(data_dir, df=None, df_out=None, fit_model="biased_diff", msd_al
info = tpr.get_info(data_dir)
D_unit = tpr.make_param_label('D', l_unit=info['length_unit'], t_unit=info['time_unit'], only_unit=True)
fig, ax = plt.subplots(1, 1, figsize=plot_config['figsize'])
fig, ax = plt.subplots(figsize=plot_config['figsize'])
if hue is not None:
if hue_order is None:
......
......@@ -166,9 +166,8 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
# MSD analysis
if MSD_config['run']:
print("MSD analysis...")
MSD_dir = tpr.safe_mkdir(osp.join(sub_dir, 'MSD'))
df_prop = tpl.plot_all_MSD(data_dir, df, df_out=df_prop, fit_model=MSD_config['MSD_model'],
MSD_parameters=MSD_config, plot_config=plot_config, plot_dir=MSD_dir, hue=hue,
MSD_parameters=MSD_config, plot_config=plot_config, plot_dir=sub_dir, hue=hue,
hue_order=hue_order)
df_prop.to_csv(mean_fn)
......
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