Skip to content

Instantly share code, notes, and snippets.

@DanHickstein
Created December 28, 2017 03:11
Show Gist options
  • Save DanHickstein/affdc776c45fa72c14415fd004b88d6a to your computer and use it in GitHub Desktop.
Save DanHickstein/affdc776c45fa72c14415fd004b88d6a to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
import sys, os
import abel
transforms = [
("BASEX" , 'basex' ),
("Lin-BASEX" , 'linbasex' ),
("Direct" , 'direct' ),
("Hansen-Law" , 'hansenlaw' ),
("Onion-peeling\nBordas", 'onion_bordas' ),
("Onion-peeling\nDasch" , 'onion_peeling'),
("Three-point" , 'three_point' ),
("Two-point" , 'two_point' )]
ntrans = len(transforms) # number of transforms
data_dir = os.path.join(os.path.split(os.path.split(abel.__file__)[0])[0], 'examples','data')
IM = np.loadtxt(os.path.join(data_dir,'O2-ANU1024.txt.bz2'))
h, w = np.shape(IM)
fig, axs = plt.subplots(4, 2, figsize=(3.7,7), sharex=True, sharey=True)
fig1,axs1 = plt.subplots(2, 1, figsize=(3.7,3), tight_layout=True)
for num, (ax, (label, transFunc)) in enumerate(zip(axs.ravel(), transforms)):
print label
T = abel.Transform(IM, method=transFunc, center='convolution', center_options=dict(square=True), angular_integration=True)
r, inten = T.angular_integration
if transFunc == 'linbasex':
T.transform = T.transform * avg0 / np.mean(T.transform)
inten = inten * avg1 / np.mean(inten)
avg0 = np.mean(T.transform)
avg1 = np.mean(inten)
ax.imshow(T.transform[h/2:,w/2:], clim=(0,5), cmap='jet', origin='lower', aspect='auto')
ax.set_title(label, fontsize=10, x=0.96, y=0.90, ha='right', va='top', weight='bold', color='w')
if transFunc == 'linbasex':
T.transform = T.transform * avg / np.mean(T.transform)
avg = np.mean(T.transform)
axs1[0].plot(r, inten*1e-6, lw=1)
axs1[1].plot(r, inten*1e-6, lw=1, label=label)
# axs1[2].plot(r, inten*1e-6, lw=1)
# fig.subplots_adjust(left=0.08, bottom=0.07, right=0.98, top=0.99, hspace=0.03)
for ax in axs.ravel():
ax.set_xlim(0,512)
ax.set_ylim(0,512)
for label in ax.get_xticklabels() + ax.get_yticklabels():
label.set_fontsize(8)
fig.subplots_adjust(left=0.10, bottom=0.06, right=0.99, top=0.99, wspace=0.08, hspace=0.08)
# fig.tight_layout(pad=0.1, w_pad=0.1, h_pad=0.1)
axs[-1,0].set_xlabel('x (pixels)')
axs[-1,1].set_xlabel('x (pixels)')
axs1[0].set_xlim(0,512)
axs1[1].set_xlim(350,370)
axs1[1].legend(fontsize=6)
fig.savefig('experiment.png', dpi=200)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment