tadd custom colormap - sphere - GPU-based 3D discrete element method algorithm … | |
git clone git://src.adamsgaard.dk/sphere | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 268c33e3139401cd0432a47be85c7c32f52b4e81 | |
parent e2aa72ce826ba4d17883d2870b6a68acf5d6c613 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Tue, 14 Apr 2015 11:34:42 +0200 | |
add custom colormap | |
Diffstat: | |
A python/bird.py | 54 +++++++++++++++++++++++++++++… | |
M python/halfshear-darcy-strain.py | 20 +++++++++++++------- | |
M python/halfshear-darcy-strength-di… | 18 +++++++++--------- | |
3 files changed, 76 insertions(+), 16 deletions(-) | |
--- | |
diff --git a/python/bird.py b/python/bird.py | |
t@@ -0,0 +1,54 @@ | |
+''' | |
+A sequential colormap named after a colorful blue-yellow bird. | |
+''' | |
+ | |
+import matplotlib | |
+test=True | |
+ | |
+cmdict_bird = {\ | |
+ 'red': ( | |
+ (0.0, 0.20784313725490197, 0.20784313725490197), | |
+ (0.125, 0.027450980392156862, 0.027450980392156862), | |
+ (0.25, 0.07450980392156863, 0.07450980392156863), | |
+ (0.375, 0.0196078431372549, 0.0196078431372549), | |
+ (0.5, 0.16470588235294117, 0.16470588235294117), | |
+ (0.625, 0.4980392156862745, 0.4980392156862745), | |
+ (0.75, 0.7843137254901961, 0.7843137254901961), | |
+ (0.875, 0.996078431372549, 0.996078431372549), | |
+ (1.0, 0.9725490196078431, 0.9725490196078431)), | |
+ | |
+ 'green': ( | |
+ (0.0, 0.1647058823529412, 0.1647058823529412), | |
+ (0.125, 0.3764705882352941, 0.3764705882352941), | |
+ (0.25, 0.5058823529411764, 0.5058823529411764), | |
+ (0.375, 0.6392156862745098, 0.6392156862745098), | |
+ (0.5, 0.7137254901960784, 0.7137254901960784), | |
+ (0.625, 0.7490196078431373, 0.7490196078431373), | |
+ (0.75, 0.7333333333333333, 0.7333333333333333), | |
+ (0.875, 0.7568627450980392, 0.7568627450980392), | |
+ (1.0, 0.9803921568627451, 0.9803921568627451)), | |
+ | |
+ 'blue': ( | |
+ (0.0, 0.5254901960784314, 0.5254901960784314), | |
+ (0.125, 0.8745098039215686, 0.8745098039215686), | |
+ (0.25, 0.8313725490196079, 0.8313725490196079), | |
+ (0.375, 0.7882352941176470, 0.7882352941176470), | |
+ (0.5, 0.6470588235294118, 0.6470588235294118), | |
+ (0.625, 0.4784313725490196, 0.4784313725490196), | |
+ (0.75, 0.3607843137254902, 0.3607843137254902), | |
+ (0.875, 0.2235294117647059, 0.2235294117647059), | |
+ (1.0, 0.0509803921568627, 0.0509803921568627))} | |
+ | |
+cm_bird = matplotlib.colors.LinearSegmentedColormap('bird', cmdict_bird) | |
+matplotlib.pyplot.register_cmap(cmap=cm_bird) | |
+ | |
+# e.g.: | |
+# plt.imshow(..., cmap='bird') | |
+if test: | |
+ import numpy | |
+ x = numpy.linspace(0, 1) | |
+ y = numpy.linspace(0, 1) | |
+ X,Y = numpy.meshgrid(x,y) | |
+ Z = X | |
+ matplotlib.pyplot.imshow(Z, cmap='bird') | |
+ matplotlib.pyplot.show() | |
diff --git a/python/halfshear-darcy-strain.py b/python/halfshear-darcy-strain.py | |
t@@ -15,7 +15,8 @@ from matplotlib.ticker import MaxNLocator | |
sigma0 = 20000.0 | |
#cvals = ['dry', 1.0, 0.1, 0.01] | |
-cvals = ['dry', 3.5e-13, 3.5e-15] | |
+#cvals = ['dry', 3.5e-13, 3.5e-15] | |
+cvals = ['dry', 3.5e-13, 3.5e-14, 3.5e-15] | |
#cvals = ['dry', 1.0] | |
#step = 1999 | |
t@@ -24,14 +25,14 @@ sim.readfirst(verbose=False) | |
# particle z positions | |
-zpos_p = [[], [], []] | |
+zpos_p = [[], [], [], []] | |
# cell midpoint cell positions | |
-zpos_c = [[], [], []] | |
+zpos_c = [[], [], [], []] | |
# particle x displacements | |
-xdisp = [[], [], []] | |
-xdisp_mean = [[], [], []] | |
+xdisp = [[], [], [], []] | |
+xdisp_mean = [[], [], [], []] | |
s = 0 | |
for c in cvals: | |
t@@ -103,6 +104,8 @@ for s in numpy.arange(len(cvals)): | |
legend = 'dry' | |
elif cvals[s] == 3.5e-13: | |
legend = 'wet, relatively permeable' | |
+ elif cvals[s] == 3.5e-14: | |
+ legend = 'wet, intermediate permeability' | |
elif cvals[s] == 3.5e-15: | |
legend = 'wet, relatively impermeable' | |
else: | |
t@@ -148,14 +151,17 @@ for s in numpy.arange(len(cvals)): | |
legend_alpha=0.5 | |
ax[0].legend(loc='lower right', prop={'size':18}, fancybox=True, framealpha=le… | |
ax[0].grid() | |
-ax[0].set_xlim([-0.1,1.1]) | |
+ax[0].set_xlim([-0.05, 1.01]) | |
+#ax[0].set_ylim([0.0, 0.47]) | |
+ax[0].set_ylim([0.20, 0.47]) | |
plt.tight_layout() | |
plt.subplots_adjust(wspace = .05) | |
plt.MaxNLocator(nbins=4) | |
filename = 'halfshear-darcy-strain.pdf' | |
plt.savefig(filename) | |
-shutil.copyfile(filename, '/Users/adc/articles/own/2/graphics/' + filename) | |
+#shutil.copyfile(filename, '/Users/adc/articles/own/2/graphics/' + filename) | |
+shutil.copyfile(filename, '/home/adc/articles/own/2/graphics/' + filename) | |
print(filename) | |
diff --git a/python/halfshear-darcy-strength-dilation-rate.py b/python/halfshea… | |
t@@ -154,14 +154,14 @@ for c, mu_f in enumerate(mu_f_vals): | |
label=label, linewidth=1) | |
if pressures: | |
- #ax3.plot(shear_strain[c][1:], p_max[c][1:], '-' + color[c], alpha=0.5) | |
- ax3.plot(shear_strain[c][1:], p_mean[c][1:], '-' + color[c], \ | |
- label=label, linewidth=1) | |
- #ax3.plot(shear_strain[c][1:], p_min[c][1:], '-' + color[c], alpha=0.5) | |
+ ax3.plot(shear_strain[c][1:], p_max[c][1:], '-' + color[c], alpha=0.5) | |
+ #ax3.plot(shear_strain[c][1:], p_mean[c][1:], '-' + color[c], \ | |
+ #label=label, linewidth=1) | |
+ ax3.plot(shear_strain[c][1:], p_min[c][1:], '-' + color[c], alpha=0.5) | |
- #ax3.fill_between(shear_strain[c][1:], p_min[c][1:], p_max[c][1:], | |
- #where=p_min[c][1:]<=p_max[c][1:], facecolor=color[c], | |
- #interpolate=True, alpha=0.5) | |
+ ax3.fill_between(shear_strain[c][1:], p_min[c][1:], p_max[c][1:], | |
+ where=p_min[c][1:]<=p_max[c][1:], facecolor=color[c], | |
+ interpolate=True, alpha=0.5) | |
#ax4.plot(shear_strain[c][1:], f_n_mean[c][1:], '-' + color[c], | |
#label='$c$ = %.2f' % (cvals[c-1]), linewidth=2) | |
t@@ -218,8 +218,8 @@ ax2.set_ylim([0.0, 0.8]) | |
#ax1.set_ylim([0.0, 1.0]) | |
if pressures: | |
#ax3.set_ylim([-1400, 900]) | |
- ax3.set_ylim([-490, 490]) | |
- ax3.set_xlim([0.0, 0.09]) | |
+ ax3.set_ylim([-200, 200]) | |
+ #ax3.set_xlim([0.0, 0.09]) | |
plt.tight_layout() | |
plt.subplots_adjust(hspace=0.05) |