Commit 7ca8f1ac authored by amichaut's avatar amichaut
Browse files

minor bug fix in compare module + bug fix in plot_on maps computed even if not...

minor bug fix in compare module + bug fix in plot_on maps computed even if not computed in scalar maps
parent babd627c
This diff is collapsed.
This diff is collapsed.
......@@ -737,8 +737,9 @@ def plot_param_hist(data_dir, param, df=None, hue=None, hue_order=None, hist=Tru
df = df[np.isfinite(df[param])]
kind = "hist" if hist else "kde"
g = sns.displot(data=df, x=param, hue=hue, kind=kind, kde=kde)
fig = g.fig
g = sns.displot(data=df, x=param, hue=hue, kind=kind, kde=kde,facet_kws={'legend_out':False})
sns.move_legend(g, "upper right", frameon=False)
fig = g.figure
ax = g.ax
fig.set_size_inches(figsize[0], figsize[1])
ax.set_xlabel(param_label)
......
......@@ -26,7 +26,6 @@
import os
import os.path as osp
import csv
import time
import matplotlib.pyplot as plt
from matplotlib import cm
......@@ -510,7 +509,7 @@ def pool_datasets(df_list, name_list):
if df is None:
continue
df['dataset'] = name_list[i]
df_out = pd.concat([df_out, df])
df_out = pd.concat([df_out, df], ignore_index=True)
return df_out
......
......@@ -130,6 +130,7 @@ def map_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fal
plot_grid=grid_param['plot_grid'],
save_plot_fn=osp.join(map_dir, 'grids{}'.format(plot_config['format'])))
special_fields = ['div', 'curl', 'v_mean', 'a_mean'] # special scalar fields that need to be calculated and not interpolated
# Compute fields
for i, df in enumerate(df_list):
# name subset directory
......@@ -157,7 +158,7 @@ def map_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fal
# list required fields to interpolate
all_fields = list(set(list(scalar_fields.keys()) + list(vector_fields.keys()) + list(vector_mean.keys())))
interp_fields = [f for f in all_fields if f not in ['div', 'curl', 'v_mean', 'a_mean']] # fields to interpolate
interp_fields = [f for f in all_fields if f not in special_fields] # fields to interpolate
vel_fields = ['v' + d for d in dimensions]
acc_fields = ['a' + d for d in dimensions]
......@@ -177,11 +178,19 @@ def map_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fal
if af not in interp_fields:
interp_fields.append(af)
# add plot_on fields to fields to compute
plot_on_fields = []
for k in vector_fields.keys():
plot_on_f = vector_fields[k]['plot_on']
plot_on_fields.append(plot_on_f)
if plot_on_f not in interp_fields and plot_on_f not in special_fields:
interp_fields.append(plot_on_f)
# compute data
field_data = tca.interpolate_all_fields(data_dir, df, grids, field_values=interp_fields,
temporal_average=map_param['temporal_average'],
export_field=map_param['export_field'], outdir=sub_dir)
if 'div' in all_fields or 'curl' in all_fields:
if 'div' in all_fields or 'curl' in all_fields or 'div' in plot_on_fields or 'curl' in plot_on_fields:
field_data = tca.compute_all_div_curl(data_dir, df, field_data, lengthscale,
export_field=map_param['export_field'], outdir=sub_dir)
for mf in ['v_mean', 'a_mean']:
......
......@@ -73,7 +73,7 @@ def compare_datasets(data_dir, df_list=[], track_df_list=[], MSD_df_list=[], dat
if param_couples is not None:
if len(param_couples['couples']) > 0:
print("plotting scatter plots")
print("Plotting couples of parameters...")
for param_couple in param_couples['couples']:
tpl.plot_param_vs_param(data_dir, param_couple[0], param_couple[1], df=pooled_all_df, hue=hue,
hue_order=hue_order, set_axis_lim=param_couples['axis_lim'], plot_config=plot_config,
......@@ -81,15 +81,15 @@ def compare_datasets(data_dir, df_list=[], track_df_list=[], MSD_df_list=[], dat
if param_track_couples is not None:
if len(param_track_couples['couples']) > 0:
print("plotting scatter plots")
print("Plotting couples of whole-track parameters...")
for param_couple in param_track_couples['couples']:
tpl.plot_param_vs_param(data_dir, param_couple[0], param_couple[1], df=pooled_track_df, hue=hue,
hue_order=hue_order, set_axis_lim=param_track_couples['axis_lim'],
plot_config=plot_config, plot_dir=plot_dir, suffix='_' + names_str)
plot_config=plot_config, plot_dir=plot_dir, suffix='_' + names_str, prefix='track_')
if param_hist is not None:
if len(param_hist['param']) > 0:
print("plotting histograms")
print("Plotting parameters histograms...")
for param in param_hist['param']:
tpl.plot_param_hist(data_dir, param, df=pooled_all_df, hue=hue, hue_order=hue_order,
hist=param_hist['hist'], kde=param_hist['kde'],
......@@ -97,15 +97,15 @@ def compare_datasets(data_dir, df_list=[], track_df_list=[], MSD_df_list=[], dat
if param_track_hist is not None:
if len(param_track_hist['param']) > 0:
print("plotting histograms")
print("Plotting whole-track parameters histograms...")
for param in param_track_hist['param']:
tpl.plot_param_hist(data_dir, param, df=pooled_track_df, hue=hue, hue_order=hue_order,
hist=param_track_hist['hist'], kde=param_track_hist['kde'],
plot_config=plot_config, plot_dir=plot_dir, suffix='_' + names_str)
plot_config=plot_config, plot_dir=plot_dir, suffix='_' + names_str, prefix='track_')
if param_boxplot is not None:
if len(param_boxplot['param']) > 0:
print("plotting boxplots")
print("Plotting parameters boxplots...")
for param in param_boxplot['param']:
tpl.plot_param_boxplot(data_dir, df=pooled_all_df, x_param=x_param, param=param, order=order,
save_stat=param_boxplot['save_stat'], boxplot=param_boxplot['boxplot'],
......@@ -114,12 +114,12 @@ def compare_datasets(data_dir, df_list=[], track_df_list=[], MSD_df_list=[], dat
if param_track_boxplot is not None:
if len(param_track_boxplot['param']) > 0:
print("plotting boxplots")
print("Plotting whole-track parameters boxplots...")
for param in param_track_boxplot['param']:
tpl.plot_param_boxplot(data_dir, df=pooled_track_df, x_param=x_param, param=param, order=order,
save_stat=param_track_boxplot['save_stat'], boxplot=param_track_boxplot['boxplot'],
swarmplot=param_track_boxplot['swarmplot'], plot_config=plot_config, plot_dir=plot_dir,
suffix='_' + names_str)
suffix='_' + names_str, prefix='track_')
if MSD_plot_param is not None:
# add parameters
......
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