From 967e1392cd76eeab0dd7c59949ce072ab59f4ac1 Mon Sep 17 00:00:00 2001 From: Rainer Wittmaack Date: Thu, 22 Oct 2009 00:56:48 +0200 Subject: [PATCH] some minor tweaks to some mpl files and color filter updates --- bifandvel.py | 28 ++++++-- converge.py | 20 +++--- defangle.py | 16 +++-- map.py | 210 +++++++++++++++++++++++++++++++++++++++++++++++++---------- pinv2.py | 81 ++++++++++++----------- 5 files changed, 256 insertions(+), 99 deletions(-) diff --git a/bifandvel.py b/bifandvel.py index 868e6b4..1f403bb 100644 --- a/bifandvel.py +++ b/bifandvel.py @@ -7,14 +7,15 @@ import matplotlib.mlab as mlab import matplotlib.axes as axe import matplotlib.text as txt -DATAX = '../rk_bifurcate.dat' -DATAV = '../rk_bif_avg_velo.dat' +DATAX = '../data/rk_bifurcate_l_f001.dat' +DATAV = '../data/rk_bif_avg_velo_l_f001.dat' DATAEU = [] -DATAEU.append("../eu_bif_avg_velo_t6.dat") -DATAEU.append("../eu_bif_avg_velo_t5.dat") +DATAEU.append("/home/raw/eu_bif_avg_velo_t5.dat") +DATAEU.append("/home/raw/eu_bif_avg_velo_t4.dat") +DATAEU.append("/home/raw/eu_bif_avg_velo_t3.dat") -FOUT = '../test.png' +FOUT = '../latex2/images/bifurcation_l_f001.png' # some macros PI = math.pi @@ -24,8 +25,8 @@ L = 2*PI xpad = 0.000002 ypad = 0.1 max = 0.875 -tsize = 24 -ticksize = 16 +tsize = 34 +ticksize = 26 has_temp = False # default values @@ -52,8 +53,13 @@ rect2 = [left, 0.1, width, c] title = "a = 1.15, w = 0.1, l = 3.0, eta1 = 1.0, eta2 = 1.5, theta = 0, alpha = 83" # import data +print "reading bifurcation data..." r = mlab.csv2rec(DATAX, delimiter='\t', comments='#') +print "done." +print "reading velocity data..." s = mlab.csv2rec(DATAV, delimiter='\t', comments='#') +print "done." + xmin = r.r.min() xmax = r.r.max() @@ -74,6 +80,7 @@ ax1 = fig.add_axes(rect1) ax2 = fig.add_axes(rect2) # put x into the plot +print "plotting bifurcation..." ax1.plot(r.r, r.x, c='r', marker=',', ms=0.1, ls='') ax1.set_xlim(xlim1) ax1.set_ylim(ylim1) @@ -81,8 +88,11 @@ ax1.set_yticks(ytks1) ax1.set_ylabel(ylbl1, size=tsize) ax1.set_xticklabels(xtkl1, size=ticksize) ax1.set_yticklabels(ytkl1, size=ticksize) +ax1.axvline(1.82, color='black', ls=':', lw=4) +print "done." # put into the plot +print "plotting velocity..." ax2.plot(s.r, s.x, c='b', marker=',', ms=0.1, ls='') if has_temp is True: u = [] @@ -97,11 +107,15 @@ ax2.set_ylabel(ylbl2, size=tsize) ax2.set_xlabel(xlbl2, size=tsize) ax2.set_xticklabels(ax2.get_xticks(), size=ticksize) ax2.set_yticklabels(ax2.get_yticks(), size=ticksize) +ax2.axvline(1.82, color='black', ls=':', lw=4) +print "done." # adjust subplots plt.subplots_adjust(hspace=0) # stream the whole mess into a file +print "flushing into file..." plt.savefig(FOUT) +print "done." # EOf diff --git a/converge.py b/converge.py index fb34d2f..3a1677e 100644 --- a/converge.py +++ b/converge.py @@ -6,12 +6,13 @@ import matplotlib.mlab as mlab from matplotlib.pyplot import * from pylab import * -DATA_RK = "../rk_conv.dat" -DATA_EU = "../eu_conv.dat" +DATA_RK = "/home/raw/rk_conv.dat" +DATA_EU = "/home/raw/eu_conv.dat" FOUT = "../converge.png" xlabel = r'$h$' ylabel = r'$\delta y$' +labelsize = 24 res = (1440/80,900/80) # default dpi is 80 ###################################################################### @@ -53,7 +54,7 @@ eu_mean = mean_var(h_eu, x_eu) #print rk_mean -fig = plt.figure(figsize=res) +fig = plt.figure() #(figsize=res) #ax1 = fig.add_subplot(211) ax2 = fig.add_subplot(111) @@ -70,24 +71,23 @@ err_rk = [] err_eu = [] for i in range(len(rk_mean)): - tmp = np.abs(rk_mean[0] - rk_mean[i]) + tmp = np.abs(rk_mean[i] - rk_mean[0]) err_rk.append(tmp) for i in range(len(eu_mean)): - tmp = np.abs(rk_mean[0] - eu_mean[i]) + tmp = np.abs(eu_mean[i] - rk_mean[0]) err_eu.append(tmp) print "plotting..." -3 ax2.loglog(unique(h_rk), err_rk, marker=',', ls='', ms=0.1) ax2.loglog(unique(h_eu), err_eu, marker=',', ls='', ms=0.1) pad = h_max -ax2.set_xlabel(xlabel) -ax2.set_ylabel(ylabel) -ax2.set_xlim(h_min,h_max) -ax2.set_ylim(min(err_eu),1) +ax2.set_xlabel(xlabel, size=labelsize) +ax2.set_ylabel(ylabel, size=labelsize) +#ax2.set_xlim(h_min,h_max) +#ax2.set_ylim(min(err_eu),1) #ax1.set_xlim() #ax1.set_ylim(-3.3,-3.2) diff --git a/defangle.py b/defangle.py index 42ccc1d..48e7719 100644 --- a/defangle.py +++ b/defangle.py @@ -12,13 +12,13 @@ ANGLE = [] VELO = [] ANGLE.append("../rk_defangle.dat") ANGLE.append("../data/eu_defangle_t225.dat") -#ANGLE.append("../data/eu_defangle_t675.dat") +ANGLE.append("../data/eu_defangle_t224.dat") VELO.append("../rk_bif_avg_velo.dat") VELO.append("../data/eu_defangle_velo_t255.dat") -#VELO.append("../data/eu_defangle_velo_t675.dat") +VELO.append("../data/eu_defangle_velo_t224.dat") -FOUT = "../defangle.png" +FOUT = "../latex2/images/defangle.png" xlabel = r'$h$' ylabel = r'$\delta y$' @@ -67,6 +67,12 @@ def mean_angle(param,angle): #print len(ret_avg) return ret_avg +color_list = [ + 'black', + 'red', + 'green', + ] + marker_list = [ '.', ',', @@ -113,10 +119,10 @@ for i in range(len(angle)): for i in range(len(angle)): ax1.plot(unique_r[i], avg_angles[i], marker=marker_list[i], - ms=0, ls=ls_list[i], color='black') + ms=0, ls=ls_list[i], color=color_list[i]) for i in range(len(velo)): ax2.plot(unique_r[i], avg_velo[i], marker_list[i], ms=0, - ls=ls_list[i], color='black') + ls=ls_list[i], color=color_list[i]) xticks = np.arange(0,360+1,45) yticks1 = np.arange(0,360+1,45) diff --git a/map.py b/map.py index f681c0d..76f5576 100644 --- a/map.py +++ b/map.py @@ -8,8 +8,8 @@ import random from pylab import * from matplotlib.pyplot import * -FIN = '../data/dual_bif_alpha_l_55_65_1_4_f0005.dat' -FOUT = '../db5.png' +FIN = '../data/dual_bif_alpha_l_55_65_1_4_f001.dat' +FOUT = '../db10.png' samples = 10 ticksize = 14 @@ -18,18 +18,18 @@ title = "a = 1.15, w = 0.1, F = 0.00, eta1 = 1.0, eta2 = 1.5, theta = 0" xlabel = r'$\alpha$' ylabel = r'$l$' -xtfreq = 2 +xtfreq = 3 ytfreq = 1 xpad = 0.01 ypad = 0.01 -ms = 30 +ms = 80 ystep = 0.1 xstep = 0.1 res = (1024/80,768/80) # default dpi is 80 method = 'direct' # mean, direct has_y = False has_col = False -has_bias = False +has_legend = False ################################################################################ @@ -73,46 +73,182 @@ def assign_color2(colors,xar,yar,vel,clist): # print len(tmp), samples assert len(tmp) == samples ccount = len(unique(tmp)) - if ccount == 2 and 'green' in tmp and 'orange' in tmp: + if ccount >= 2 and 'green' in tmp and 'orange' in tmp: ret_xcolors[6].append(xar[i]) ret_ycolors[6].append(yar[i]) - elif ccount == 2 and 'blue' in tmp and 'red' in tmp: + elif ccount >= 2 and 'blue' in tmp and 'red' in tmp: ret_xcolors[7].append(xar[i]) ret_ycolors[7].append(yar[i]) elif ccount == 2 and 'blue' in tmp and 'black' in tmp: - if tmp.count('blue') >= samples/2: + if tmp.count('blue') >= samples/samples: ret_xcolors[2].append(xar[i]) ret_ycolors[2].append(yar[i]) else: ret_xcolors[0].append(xar[i]) ret_ycolors[0].append(yar[i]) elif ccount == 2 and 'red' in tmp and 'black' in tmp: - if tmp.count('red') >= samples/2: + if tmp.count('red') >= samples/samples: ret_xcolors[5].append(xar[i]) ret_ycolors[5].append(yar[i]) else: ret_xcolors[0].append(xar[i]) ret_ycolors[0].append(yar[i]) elif ccount == 2 and 'green' in tmp and 'black' in tmp: - if tmp.count('green') >= samples/2: + if tmp.count('green') >= samples/samples: ret_xcolors[3].append(xar[i]) ret_ycolors[3].append(yar[i]) else: ret_xcolors[0].append(xar[i]) ret_ycolors[0].append(yar[i]) elif ccount == 2 and 'orange' in tmp and 'black' in tmp: - if tmp.count('orange') >= samples/2: + if tmp.count('orange') >= samples/samples: + ret_xcolors[4].append(xar[i]) + ret_ycolors[4].append(yar[i]) + else: + ret_xcolors[0].append(xar[i]) + ret_ycolors[0].append(yar[i]) + elif ccount == 2 and 'blue' in tmp and 'grey' in tmp: + if tmp.count('blue') >= samples/samples: + ret_xcolors[2].append(xar[i]) + ret_ycolors[2].append(yar[i]) + else: + ret_xcolors[1].append(xar[i]) + ret_ycolors[1].append(yar[i]) + elif ccount == 2 and 'red' in tmp and 'grey' in tmp: + if tmp.count('red') >= samples/samples: + ret_xcolors[5].append(xar[i]) + ret_ycolors[5].append(yar[i]) + else: + ret_xcolors[1].append(xar[i]) + ret_ycolors[1].append(yar[i]) + elif ccount == 2 and 'green' in tmp and 'grey' in tmp: + if tmp.count('green') >= samples/samples: + ret_xcolors[3].append(xar[i]) + ret_ycolors[3].append(yar[i]) + else: + ret_xcolors[1].append(xar[i]) + ret_ycolors[1].append(yar[i]) + elif ccount == 2 and 'orange' in tmp and 'grey' in tmp: + if tmp.count('orange') >= samples/samples: + ret_xcolors[4].append(xar[i]) + ret_ycolors[4].append(yar[i]) + else: + ret_xcolors[1].append(xar[i]) + ret_ycolors[1].append(yar[i]) + elif ccount == 2 and 'grey' in tmp and 'black' in tmp: + if tmp.count('grey') >= samples/2: + ret_xcolors[1].append(xar[i]) + ret_ycolors[1].append(yar[i]) + else: + ret_xcolors[0].append(xar[i]) + ret_ycolors[0].append(yar[i]) + + elif ccount == 2 and 'blue' in tmp and ('orange' in tmp or 'green' in tmp): + if tmp.count('blue') >= samples/2: + ret_xcolors[1].append(xar[i]) + ret_ycolors[1].append(yar[i]) + elif tmp.count('green') >= samples/2: + ret_xcolors[3].append(xar[i]) + ret_ycolors[3].append(yar[i]) + elif tmp.count('orange') >= samples/2: + ret_xcolors[4].append(xar[i]) + ret_ycolors[4].append(yar[i]) + else: + ret_xcolors[0].append(xar[i]) + ret_ycolors[0].append(yar[i]) + elif ccount == 2 and 'red' in tmp and ('orange' in tmp or 'green' in tmp): + if tmp.count('red') >= samples/2: + ret_xcolors[5].append(xar[i]) + ret_ycolors[5].append(yar[i]) + elif tmp.count('green') >= samples/2: + ret_xcolors[3].append(xar[i]) + ret_ycolors[3].append(yar[i]) + elif tmp.count('orange') >= samples/2: ret_xcolors[4].append(xar[i]) ret_ycolors[4].append(yar[i]) else: ret_xcolors[0].append(xar[i]) ret_ycolors[0].append(yar[i]) + + + elif ccount == 3 and 'green' in tmp and 'orange' in tmp and 'grey': ret_xcolors[6].append(xar[i]) ret_ycolors[6].append(yar[i]) elif ccount == 3 and 'blue' in tmp and 'red' in tmp and 'grey': ret_xcolors[7].append(xar[i]) ret_ycolors[7].append(yar[i]) + + elif ccount == 3 and 'blue' in tmp and ('grey' in tmp or 'black' in tmp): + if tmp.count('blue') >= samples/2: + ret_xcolors[6].append(xar[i]) + ret_ycolors[6].append(yar[i]) + else: + ret_xcolors[0].append(xar[i]) + ret_ycolors[0].append(yar[i]) + elif ccount == 3 and 'red' in tmp and ('grey' in tmp or 'black' in tmp): + if tmp.count('red') >= samples/2: + ret_xcolors[6].append(xar[i]) + ret_ycolors[6].append(yar[i]) + else: + ret_xcolors[0].append(xar[i]) + ret_ycolors[0].append(yar[i]) + elif ccount == 3 and 'green' in tmp and ('grey' in tmp or 'black' in tmp): + if tmp.count('green') >= samples/2: + ret_xcolors[7].append(xar[i]) + ret_ycolors[7].append(yar[i]) + else: + ret_xcolors[0].append(xar[i]) + ret_ycolors[0].append(yar[i]) + elif ccount == 3 and 'orange' in tmp and ('grey' in tmp or 'black' in tmp): + if tmp.count('orange') >= samples/2: + ret_xcolors[7].append(xar[i]) + ret_ycolors[7].append(yar[i]) + else: + ret_xcolors[0].append(xar[i]) + ret_ycolors[0].append(yar[i]) + + elif ccount == 4 and 'blue' and ('green' in tmp or 'orange') in tmp and 'grey' and 'black' in tmp: + if tmp.count('blue') >= samples/2: + ret_xcolors[2].append(xar[i]) + ret_ycolors[2].append(yar[i]) + elif tmp.count('green') >= samples/2: + ret_xcolors[3].append(xar[i]) + ret_ycolors[3].append(yar[i]) + elif tmp.count('orange') >= samples/2: + ret_xcolors[4].append(xar[i]) + ret_ycolors[4].append(yar[i]) + else: + ret_xcolors[0].append(xar[i]) + ret_ycolors[0].append(yar[i]) + elif ccount == 4 and 'red' and ('green' in tmp or 'orange' in tmp) and 'grey' and 'black' in tmp: + if tmp.count('red') >= samples/2: + ret_xcolors[5].append(xar[i]) + ret_ycolors[5].append(yar[i]) + elif tmp.count('green') >= samples/2: + ret_xcolors[3].append(xar[i]) + ret_ycolors[3].append(yar[i]) + elif tmp.count('orange') >= samples/2: + ret_xcolors[4].append(xar[i]) + ret_ycolors[4].append(yar[i]) + else: + ret_xcolors[0].append(xar[i]) + ret_ycolors[0].append(yar[i]) + elif ccount == 4 and 'green' in tmp and 'grey' and 'black' in tmp: + if tmp.count('green') >= samples/2: + ret_xcolors[3].append(xar[i]) + ret_ycolors[3].append(yar[i]) + else: + ret_xcolors[0].append(xar[i]) + ret_ycolors[0].append(yar[i]) + elif ccount == 4 and 'orange' in tmp and 'grey' and 'black' in tmp: + if tmp.count('orange') >= samples/2: + ret_xcolors[4].append(xar[i]) + ret_ycolors[4].append(yar[i]) + else: + ret_xcolors[0].append(xar[i]) + ret_ycolors[0].append(yar[i]) + elif ccount == 4 and 'blue' in tmp and 'red' in tmp and 'green' in tmp and 'orange' in tmp: print tmp ret_xcolors[11].append(xar[i]) @@ -201,10 +337,10 @@ vy = r.vy assert len(x) == len(y) == len(vx) == len(vy) print "done." -xmin = np.min(unique(x)) -xmax = np.max(unique(x)) -ymin = np.min(unique(y)) -ymax = np.max(unique(y)) +xmin = int(np.min(unique(x))) +xmax = int(np.max(unique(x))) +ymin = int(np.min(unique(y))) +ymax = int(np.max(unique(y))) # assumes that the step distance doesn't change over the course of time rat = xstep/ystep @@ -259,19 +395,24 @@ xticks = np.arange(xmin, xmax+xpad, xtfreq) yticks = np.arange(ymin, ymax+ypad, ytfreq) -fig = plt.figure() #(figsize=res) +fig = plt.figure(figsize=res) #fig.suptitle(title, size=labelsize) max = 0.84 c = max/2 rect1 = [0.1, 0.1, c, 0.9] -rect2 = [c+0.1, 0.1, c, 0.9] +rect2 = [c+0.125, 0.1, c, 0.9] +rect = [0.1, 0.1, max, 0.9] if has_y is True: - ax1 = fig.add_subplot(121, aspect=rat) - ax2 = fig.add_subplot(122, aspect=rat) + #ax1 = fig.add_subplot(121, aspect=rat) + #ax2 = fig.add_subplot(122, aspect=rat) + ax1 = fig.add_axes(rect1, aspect=rat) + ax2 = fig.add_axes(rect2, aspect=rat) else: - ax1 = fig.add_subplot(111, aspect=rat) + #ax1 = fig.add_subplot(111, aspect=rat) + ax1 = fig.add_axes(rect, aspect=rat) + if (method == 'mean'): @@ -334,18 +475,21 @@ elif (method == 'direct'): else: print "fatal error: specify a valid method" -leg1 = ax1.legend(loc=0, shadow=True, - fancybox=True, scatterpoints=1, markerscale=1, - borderaxespad=0.) -for t in leg1.get_texts(): - t.set_fontsize('small') - -if has_y is True: - leg2 = ax2.legend(loc=2, shadow=True, +if has_legend is True: + leg1 = ax1.legend(loc=0, shadow=True, fancybox=True, scatterpoints=1, markerscale=1, borderaxespad=0.) - for t in leg2.get_texts(): + for t in leg1.get_texts(): t.set_fontsize('small') + leg1.get_frame().set_alpha(0.75) + if has_y is True: + leg2 = ax2.legend(loc=2, shadow=True, + fancybox=True, scatterpoints=1, markerscale=1, + borderaxespad=0.) + for t in leg2.get_texts(): + t.set_fontsize('small') + leg2.get_frame().set_alpha(0.75) + ax1.set_title(r'$v_x$', size=labelsize) @@ -376,13 +520,7 @@ if (has_col is True): ax1.add_collection(collection) -leg1.get_frame().set_alpha(0.75) - -if has_y is True: - leg2.get_frame().set_alpha(0.75) - - -plt.subplots_adjust(hspace=0) +#plt.subplots_adjust(hspace=0) print "flushing into a file..." plt.savefig(FOUT) print "done." diff --git a/pinv2.py b/pinv2.py index 5447714..e1f0090 100644 --- a/pinv2.py +++ b/pinv2.py @@ -1,47 +1,46 @@ -#!/usr/bin/python -# -*- coding: iso-8859-1 -*- - -import matplotlib as mpl -import numpy as np -import matplotlib.cm as cm -import matplotlib.mlab as mlab -import matplotlib.pyplot as plt -import matplotlib.patches as patch -import matplotlib.colors as col +#!/usr/bin/python +# -*- coding: iso-8859-1 -*- -FOUT = '../dimer_sympartner.png' -FCOF = '../rk_out.dat' -FP1 = '../rk_point1.dat' -FP2 = '../rk_point2.dat' -FVEL = "../rk_velo.dat" - -L = 2*np.pi -w = 0.1 -tau = L/w -evry = 1 # plot periodicity, don't set < 10 (bug) -offx = -98 # offset of (x,y) in L -offy = 94 -tfrom = 80 # from t -tto = 100 # to t -acangle = 59.1 # angle of ac drive +import matplotlib as mpl +import numpy as np +import matplotlib.cm as cm +import matplotlib.mlab as mlab +import matplotlib.pyplot as plt +import matplotlib.patches as patch +import matplotlib.colors as col + +FOUT = '../latex2/images/dimer_sympartner.png' +FCOF = '../rk_out.dat' +FP1 = '../rk_point1.dat' +FP2 = '../rk_point2.dat' +FVEL = "../rk_velo.dat" -dcangle = 0 # angle of dc bias -sperx = 4 # spacial periodicity -spery = 4 -pad = 0.01 # small padding so the ticks get drawn correctly... +L = 2*np.pi +w = 0.1 +tau = L/w +evry = 1 # plot periodicity, don't set < 10 (bug) +offx = -98 # offset of (x,y) in L +offy = 94 +tfrom = 80 # from t +tto = 100 # to t +acangle = 58 # angle of ac drive +dcangle = 0 # angle of dc bias +sperx = 4 # spacial periodicity +spery = 3 +pad = 0.01 # small padding so the ticks get drawn correctly... msize = 40 -res = (1024/80,768/80) # default dpi is 80 -cmap = cm.gray_r # colormap -shader = False # applies ultra cool shadows to the map! -show_plot = False -xlabel = r'$x$' -ylabel = r'$y$' -cblabel = r'$\cos(x)\cos(y)+\cos(x)+\cos(y)$' -fs_ticks = 16 -fs_labels = 24 -cof_only = False -has_dc = True -test = False +res = (1440/80,900/80) # default dpi is 80 +cmap = cm.gray_r # colormap +shader = False # applies ultra cool shadows to the map! +show_plot = False +xlabel = r'$x$' +ylabel = r'$y$' +cblabel = r'$\cos(x)\cos(y)+\cos(x)+\cos(y)$' +fs_ticks = 16 +fs_labels = 24 +cof_only = False +has_dc = False +test = False show_cb = False show_legend = False show_annotations = False -- 2.11.4.GIT