Open main menu

Changes

Matplotlib DPL94 R1rho R2eff

2,675 bytes added, 16:33, 14 March 2014
### plotting facility.
import matplotlib.pyplot as plt
 
# Ordered dictionary
import collections
### relax modules
# Import some tools to loop over the spins.
from pipe_control.mol_res_spin import return_spin, spin_loop
# Import method to calculate the R1rho R1_rho offset data
from specific_analyses.relax_disp.disp_data import calc_rotating_frame_params, generate_r20_key, loop_exp_frq
x_disp_point = []
y = []
y_R1_rho = []
 
cdp.mydic = collections.OrderedDict()
for dic_key in cdp.myspin.dic_key_list:
R1 = cdp.myspin.ri_data['R1']
R1_rho = cdp.myspin.r2eff[dic_key]
  print# Store the R1_rho value y_R1_rho.append(R1_rho)  exp_type, frq_1e6, offset, point = dic_key.split("_"))
# Get disp_point, the Spin-lock field strength
x_disp_point.append(float(dic_key.split("_")[-1]point))
# Get w_eff
theta = cdp.myspin.theta_spin_dic[dic_key]
x_theta.append(theta)
# Get Domega
Domega = Domega_spin_dic[dic_key]
# Calculate y value
R1rho_R2eff R1_rho_R2eff = (R1_rho - R1*cos(theta)*cos(theta)) / (sin(theta) * sin(theta)) y.append(R1rho_R2effR1_rho_R2eff # Add to dic if exp_type not in cdp.mydic: cdp.mydic[exp_type] = collections.OrderedDict() if frq_1e6 not in cdp.mydic[exp_type]: cdp.mydic[exp_type][frq_1e6] = collections.OrderedDict() if offset not in cdp.mydic[exp_type][frq_1e6]: cdp.mydic[exp_type][frq_1e6][offset] = collections.OrderedDict() cdp.mydic[exp_type][frq_1e6][offset]['point'] = [] cdp.mydic[exp_type][frq_1e6][offset]['theta'] = [] cdp.mydic[exp_type][frq_1e6][offset]['w_eff'] = [] cdp.mydic[exp_type][frq_1e6][offset]['R1_rho'] = [] cdp.mydic[exp_type][frq_1e6][offset]['R1_rho_R2eff'] = [] cdp.mydic[exp_type][frq_1e6][offset]['point'].append(float(point)) cdp.mydic[exp_type][frq_1e6][offset]['theta'].append(float(theta)) cdp.mydic[exp_type][frq_1e6][offset]['w_eff'].append(float(w_eff)) cdp.mydic[exp_type][frq_1e6][offset]['R1_rho'].append(float(R1_rho)) cdp.mydic[exp_type][frq_1e6][offset]['R1_rho_R2eff'].append(float(R1_rho_R2eff)) print cdp.mydic[exp_type][frq_1e6][offset]['R1_rho']
# Print values in dicfor exptype, frq_dic in cdp.mydic.items(): for frq, offset_dic in frq_dic.items(): for offset, val_dics in offset_dic.items(): print x_disp_pointexptype, frq, offset, val_dics['R1_rho'], val_dics['theta']
# Modify data
y_mod = y[:-rem_points]
# Define labels for plotting
plotlabel_R1_rho_R2eff = 'R1_rho_R2eff'
plotlabel_R1_rho = 'R1_rho'
xlabel_w_eff = 'Effective field in rotating frame [%s rad.s^-1]'%(str(w_eff_div))
xlabel_theta = 'Rotating frame tilt angle [rad]'
xlabel_lock = 'Spin-lock field strength [Hz]'
ylabel_R1_rho_R2eff = 'R1_rho_R2eff [rad.s^-1]'
ylabel_R1_rho = 'R1_rho [rad.s^-1]'
# Plot R1rho_R2eff R1_rho_R2eff as function of w_eff
plt.figure()
plotlabel = 'R1rho_R2eff'plt.plot(x_w_eff_mod, y_mod, 'o', label='R1rho_R2eff')xlabel = 'Effective field in rotating frame [%s rad.s^-1]'%(str(w_eff_div)plotlabel_R1_rho_R2eff)plt.xlabel(xlabelxlabel_w_eff)ylabel = 'R1rho_R2eff [rad.s^-1]'plt.ylabel(ylabelylabel_R1_rho_R2eff)
plt.legend(loc='best')
plt.grid(True)
plt.ylim([0,16])
plt.title("%s \n %s as function of %s"%(spin_inte,ylabelylabel_R1_rho_R2eff, xlabelxlabel_w_eff))#plt.savefig("matplotlib_%s_%s_w_eff.png"%(spin_inte_rep, plotlabelplotlabel_R1_rho_R2eff) )
# Plot R1rho_R2eff R1_rho_R2eff as function of w_efftheta
plt.figure()
plotlabel = 'R1rho_R2eff'plt.plot(x_theta, y, 'o', label='R1rho_R2eff'plotlabel_R1_rho_R2eff)xlabel = 'Rotating frame tilt angle [rad]'plt.xlabel(xlabelxlabel_theta)ylabel = 'R1rho_R2eff [rad.s^-1]'plt.ylabel(ylabelylabel_R1_rho_R2eff)
plt.legend(loc='best')
plt.grid(True)
plt.ylim([0,16])
plt.title("%s \n %s as function of %s"%(spin_inte,ylabelylabel_R1_rho_R2eff, xlabelxlabel_theta))#plt.savefig("matplotlib_%s_%s_theta.png"%(spin_inte_rep, plotlabelplotlabel_R1_rho_R2eff) )
# Plot R1rho_R2eff R1_rho_R2eff as function of disp_point, the Spin-lock field strength
plt.figure()
plotlabel = 'R1rho_R2eff'plt.plot(x_disp_point, y, 'o', label='R1rho_R2eff'plotlabel_R1_rho_R2eff)xlabel = 'Spin-lock field strength [Hz]'plt.xlabel(xlabelxlabel_lock)ylabel = 'R1rho_R2eff [rad.s^-1]'plt.ylabel(ylabelylabel_R1_rho_R2eff)
plt.legend(loc='best')
plt.grid(True)
#plt.ylim([0,16])plt.title("%s \n %s as function of %s"%(spin_inte,ylabelylabel_R1_rho_R2eff, xlabelxlabel_lock))plt.savefig("matplotlib_%s_%s_disp.png"%(spin_inte_rep, plotlabelplotlabel_R1_rho_R2eff) )
# Plot R1_rho as function of theta.
plt.figure()
plt.plot(x_theta, y_R1_rho, 'o', label=plotlabel_R1_rho)
plt.xlabel(xlabel_theta)
plt.ylabel(ylabel_R1_rho)
plt.legend(loc='best')
plt.grid(True)
plt.ylim([0,16])
plt.title("%s \n %s as function of %s"%(spin_inte, ylabel_R1_rho, xlabel_theta))
plt.savefig("matplotlib_%s_%s_theta.png"%(spin_inte_rep, plotlabel_R1_rho) )
 
# Plot R1_rho as function of theta.
plt.figure()
for exptype, frq_dic in cdp.mydic.items():
for frq, offset_dic in frq_dic.items():
for offset, val_dics in offset_dic.items():
graphlabel = "%s_%s"%(frq, offset)
plt.plot(val_dics['theta'], val_dics['R1_rho'], '-o', label=graphlabel)
plt.ylabel(ylabel_R1_rho)
plt.xlabel(xlabel_theta)
plt.legend(loc='best')
plt.grid(True)
plt.ylim([0,16])
plt.title("%s \n %s as function of %s"%(spin_inte, ylabel_R1_rho, xlabel_theta))
plt.savefig("matplotlib_%s_%s_theta_sep.png"%(spin_inte_rep, plotlabel_R1_rho) )
plt.show()