Skip to content

Instantly share code, notes, and snippets.

@stggh
Created April 13, 2016 01:49
Show Gist options
  • Save stggh/c4c44c8f29c377a9f8c1ce450d75088e to your computer and use it in GitHub Desktop.
Save stggh/c4c44c8f29c377a9f8c1ce450d75088e to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import numpy as np
import abel
import matplotlib.pyplot as plt
# sample image O- PES
n=1001
IM = abel.tools.analytical.sample_image(n, name="Ominus")
# quadrants
Q = abel.tools.symmetry.get_image_quadrants(IM)
Q0 = Q[0]
dr = 0.1
# forward transform = projected image
fQ0 = abel.hansenlaw.hansenlaw_transform(Q0, direction="forward", dr=dr)
# inverse transform = original image
HfQ0 = abel.hansenlaw.hansenlaw_transform(fQ0, dr=dr)
# cf with three_point
TfQ0 = abel.dasch.three_point_transform(fQ0, dr=dr)
# speed distributions
orig_speed = abel.tools.vmi.angular_integration(Q0, origin=(0, 0), dr=dr, average=True)
hl_speed = abel.tools.vmi.angular_integration(HfQ0, origin=(0, 0), dr=dr, average=True)
tp_speed = abel.tools.vmi.angular_integration(TfQ0, origin=(0, 0), dr=dr, average=True)
ax0 = plt.subplot2grid((1, 2), (0, 0))
ax1 = plt.subplot2grid((1, 2), (0, 1))
ax0.plot(*orig_speed, color='r', linestyle='--', alpha=1, label="orig.")
ax0.plot(*hl_speed, color='b', alpha=1, label="hansenlaw")
ax0.plot(*tp_speed, color='g', alpha=1, label="3pt")
ax0.axis(xmin=230, xmax=410)
ax0.set_title("sample image Ominus $n={}$".format(n))
ax1.plot(*orig_speed, color='r', linestyle='--', alpha=1, label="orig.")
ax1.plot(*hl_speed, color='b', alpha=1, label="hansenlaw")
ax1.plot(*tp_speed, color='g', alpha=1, label="3pt")
ax1.axis(xmin=335, xmax=345)
ax1.legend(loc=0, labelspacing=0.1, fontsize=10, frameon=False)
ax1.set_title("zoomed")
plt.savefig("O-.png", dpi=100)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment