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

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

Initialize an intensity array.

[5]:
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)_

[6]:
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.

[7]:
intensity = intensity[::-1]
[8]:
np.savetxt('intensity.txt', intensity)