<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Compare $A_{sym}$ vs. $E_{min}$
I'm going to create a figure that compares the magnitude of anisotropy vs. energy threshold for the four data sets.
Measured
ipol
cgmf
freya
Each of the datap/Asym.csv spreadsheets were calculated using the script scripts/plot_Asym_energy_space.py. 
Enable interactive plots
Step1:  Move up a directory for easier access
Step2:  Find the other data
Step3:  Which do I want to plot on the same distribution?
Step4:  General plot settings
Step5:  Plot as-is
These will be for Figure 7 in the paper.
Step6:  Compare simulation to experiment
Step7:  Try $A_{sym} = W(180)/W_{min}$
Should we be comparing to the data at 90 degrees, or the minimum W values?
Step8:  Try plotting everything together
<ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import (MultipleLocator, FormatStrFormatter, AutoMinorLocator)
import pandas as pd
Explanation: Compare $A_{sym}$ vs. $E_{min}$
I'm going to create a figure that compares the magnitude of anisotropy vs. energy threshold for the four data sets.
Measured
ipol
cgmf
freya
Each of the datap/Asym.csv spreadsheets were calculated using the script scripts/plot_Asym_energy_space.py. 
Enable interactive plots
End of explanation
os.getcwd()
os.chdir('..')
os.getcwd()
sys.path.append('../scripts')
import bicorr_plot as bicorr_plot
import bicorr_math as bicorr_math
angle_bin_edges = np.arange(10.01,181,10)
angle_bin_centers = bicorr_math.calc_centers(angle_bin_edges)
angle_bin_edges.shape
Explanation: Move up a directory for easier access
End of explanation
os.listdir('cgmf/datap')
Asym_df_meas = pd.read_csv(r'Cf072115_to_Cf072215b/datap/Asym_df.csv', index_col=0)
Asym_df_cgmf = pd.read_csv(r'cgmf/datap/Asym_df.csv', index_col=0)
Asym_df_freya = pd.read_csv(r'freya/datap/Asym_df.csv', index_col=0)
Asym_df_ipol = pd.read_csv(r'ipol/datap/Asym_df.csv', index_col=0)
Asym_df_ipol_noct = pd.read_csv(r'ipol_noct/datap/Asym_df.csv', index_col=0)
Explanation: Find the other data
End of explanation
Asym_dfs=[Asym_df_meas,Asym_df_cgmf,Asym_df_freya,Asym_df_ipol,Asym_df_ipol_noct]
legends =['Experiment', 'CGMF',      'FREYA',      'PoliMi',    'PoliMi-No CT']
fmts   = ['x',          's',         'D',          'o',         '^']
colors = ['#5d269b',    '#dd673b',   '#80bc31',    '#3cbfe0',   '#4242f4']
to_plot = [0,1,2,3]
Explanation: Which do I want to plot on the same distribution?
End of explanation
line_thickness = 1
ebar_width     = 3
Explanation: General plot settings
End of explanation
Asym_df_cgmf.head()
fig = plt.figure(figsize=(4,4))
ax = plt.gca()
for i in to_plot:
    Asym_df = Asym_dfs[i]
    ax.errorbar(Asym_df['emin'],
                 Asym_df['Asym'],
                 yerr=Asym_df['Asym_err'],
                 fmt=fmts[i],
                 markeredgewidth=1,
                 markerfacecolor='none',
                 elinewidth=line_thickness,
                 capthick = line_thickness,
                 capsize = ebar_width,
                 c=colors[i])
ax.set_xlim([0.8,4])
ax.set_ylim([.5,4.5])
ax.set_xlabel('$E_{min}$ (MeV)')
ax.set_ylabel('$A_{sym}$')
# Set up ticks
ax.tick_params(axis='both',
               which='major',
               direction='inout',
               length=6,
               color='k',
               bottom=True, right=True, top=True, left=True)
ax.tick_params(axis='both',
               which='minor',
               direction='in',
               length=3,
               bottom=True, right=True, top=True, left=True)
# Major
ax.xaxis.set_major_locator(MultipleLocator(1))
ax.yaxis.set_major_locator(MultipleLocator(1))
# Minor
ax.xaxis.set_minor_locator(MultipleLocator(.2))
ax.yaxis.set_minor_locator(MultipleLocator(0.2))
ax.text(1,4,'(a)', size=15, backgroundcolor='white')
leg = plt.legend([legends[i] for i in to_plot],bbox_to_anchor=(.46,.53))
leg.get_frame().set_edgecolor('w')
plt.tight_layout()
bicorr_plot.save_fig_to_folder('Asym_vs_Emin_compare',r'compare\fig')
Explanation: Plot as-is
These will be for Figure 7 in the paper.
End of explanation
def plot_calcs(Asym_df):
    x = Asym_df['emin']
    y = Asym_df['Asym']
    yerr = Asym_df['Asym_err']
    return x, y, yerr
Asym_df_exp = Asym_dfs[0]
to_plot = [1,2,3]
fig = plt.figure(figsize=(4,4))
ax = plt.gca()
x, y_exp, yerr_exp = plot_calcs(Asym_df_exp)
for i in to_plot:
    Asym_df = Asym_dfs[i]
    x_sim, y_sim, yerr_sim = plot_calcs(Asym_df)
    y,yerr = bicorr_math.prop_err_division(y_sim,yerr_sim,y_exp,yerr_exp)    
    
    ax.errorbar(x, y, yerr=yerr,
                 fmt=fmts[i],
                 markeredgewidth=1,
                 markerfacecolor='none',
                 elinewidth=line_thickness,
                 capthick = line_thickness,
                 capsize = ebar_width,
                 c=colors[i])
leg = plt.legend([legends[i] for i in to_plot],bbox_to_anchor=(.4,.6))    
leg.get_frame().set_edgecolor('w')
plt.axhline(1.0,color='gray', linewidth=1,linestyle='--')
    
ax.set_xlim([0.8,4])
ax.set_ylim([.5,2])
ax.set_xlabel('$E_{min}$ (MeV)')
ax.set_ylabel(r'$\left[A_{sym}\right]_{SIM} / \left[A_{sym}\right]_{EXP}$')
# Set up ticks
ax.tick_params(axis='both',
               which='major',
               direction='inout',
               length=6,
               color='k',
               bottom=True, right=True, top=True, left=True)
ax.tick_params(axis='both',
               which='minor',
               direction='in',
               length=3,
               bottom=True, right=True, top=True, left=True)
# Major
ax.xaxis.set_major_locator(MultipleLocator(1))
ax.yaxis.set_major_locator(MultipleLocator(.5))
# Minor
ax.xaxis.set_minor_locator(MultipleLocator(.2))
ax.yaxis.set_minor_locator(MultipleLocator(0.1))
ax.text(1,1.83,'(b)', size=15, backgroundcolor='white')
plt.tight_layout()
bicorr_plot.save_fig_to_folder('Asym_vs_Emin_diff',r'compare\fig')
os.getcwd()
Explanation: Compare simulation to experiment
End of explanation
Asym_df
fig = plt.figure(figsize=(4,4))
ax = plt.gca()
for i in to_plot:
    Asym_df = Asym_dfs[i]
    ax.errorbar(Asym_df['emin'],
                 Asym_df['Asym_min'],
                 yerr=Asym_df['Asym_min_err'],
                 fmt=fmts[i],
                 markeredgewidth=1,
                 markerfacecolor='none',
                 elinewidth=line_thickness,
                 capthick = line_thickness,
                 capsize = ebar_width,
                 c=colors[i])
ax.set_xlim([0,4])
ax.set_ylim([.5,4.5])
ax.set_xlabel('$E_{min}$')
ax.set_ylabel('$A_{sym}$')
# Set up ticks
ax.tick_params(axis='both',
               which='major',
               direction='inout',
               length=6,
               color='k',
               bottom=True, right=True, top=True, left=True)
ax.tick_params(axis='both',
               which='minor',
               direction='in',
               length=3,
               bottom=True, right=True, top=True, left=True)
# Major
ax.xaxis.set_major_locator(MultipleLocator(1))
ax.yaxis.set_major_locator(MultipleLocator(1))
# Minor
ax.xaxis.set_minor_locator(MultipleLocator(.2))
ax.yaxis.set_minor_locator(MultipleLocator(0.2))
plt.legend([legends[i] for i in to_plot])
plt.tight_layout()
bicorr_plot.save_fig_to_folder('Asym_min_vs_Emin_compare',r'compare\fig')
Explanation: Try $A_{sym} = W(180)/W_{min}$
Should we be comparing to the data at 90 degrees, or the minimum W values?
End of explanation
fig = plt.figure(figsize=(6,6))
ax = plt.gca()
for i in to_plot:
    Asym_df = Asym_dfs[i]
    ax.errorbar(Asym_df['emin'],
                 Asym_df['Asym'],
                 yerr=Asym_df['Asym_err'],
                 fmt=fmts[i],
                 markeredgewidth=1,
                 markerfacecolor='k',
                 elinewidth=line_thickness,
                 capthick = line_thickness,
                 capsize = ebar_width,
                 c=colors[i])
    ax.errorbar(Asym_df['emin'],
                 Asym_df['Asym_min'],
                 yerr=Asym_df['Asym_min_err'],
                 fmt=fmts[i],
                 markeredgewidth=1,
                 markerfacecolor='none',
                 elinewidth=line_thickness,
                 capthick = line_thickness,
                 capsize = ebar_width,
                 c=colors[i])
ax.set_xlim([0,4])
ax.set_ylim([1,4])
ax.set_xlabel('$E_{min}$')
ax.set_ylabel('$A_{sym}$')
# Set up ticks
ax.tick_params(axis='both',
               which='major',
               direction='inout',
               length=6,
               color='k',
               bottom=True, right=True, top=True, left=True)
ax.tick_params(axis='both',
               which='minor',
               direction='in',
               length=3,
               bottom=True, right=True, top=True, left=True)
# Major
ax.xaxis.set_major_locator(MultipleLocator(1))
ax.yaxis.set_major_locator(MultipleLocator(1))
# Minor
ax.xaxis.set_minor_locator(MultipleLocator(.2))
ax.yaxis.set_minor_locator(MultipleLocator(0.2))
plt.legend([legends[i] for i in np.repeat(to_plot,2).tolist()])
plt.tight_layout()
np.repeat(to_plot,2).tolist()
Explanation: Try plotting everything together
End of explanation
<END_TASK>