[14]:

import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline

[15]:

from stingray.simulator.transfer import TransferFunction


# Setting Up Data¶

We use Image module from Python Imaging library to digitize 2-d plot from Uttley et al. (2014)

[16]:

from PIL import Image

[17]:

im = Image.open('2d.png')
width, height = im.size


Initialize an intensity array.

[18]:

intensity = np.array([[1 for j in range(width)] for i in range(height)])


Below, we retrieve each pixel and then calculate darkness value. The perceived brightness is given by:

_0.2126R + 0.7152G + 0.0722*B_

To get darkness, the formula is corrected as follows:

_0.2126(255-R) + 0.7152(255-G) + 0.0722*(255-B)_

[19]:

for x in range(0, height):
for y in range(0, width):
RGB = im.getpixel((y, x))
intensity[x][y] = (0.2126 * (255-RGB[0]) + 0.7152 * (255-RGB[1]) + 0.0722 * (255-RGB[2]))


Invert along Y-axis to account for some conventions.

[20]:

intensity = intensity[::-1]

[21]:

np.savetxt('intensity.txt', intensity)