In [14]:
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline
In [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)

In [16]:
from PIL import Image
In [17]:
im = Image.open('2d.png')
width, height = im.size

Initialize an intensity array.

In [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)_

In [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.

In [20]:
intensity = intensity[::-1]
In [21]:
np.savetxt('intensity.txt', intensity)