In [29]:
import numpy as np
# Set up matplotlib and use a nicer set of plot parameters
%config InlineBackend.rc = {}
import matplotlib
matplotlib.rc_file("../templates/matplotlibrc")
import matplotlib.pyplot as plt
%matplotlib inline


/software/csg/anaconda/anaconda3/lib/python3.5/site-packages/matplotlib/__init__.py:872: UserWarning: axes.color_cycle is deprecated and replaced with axes.prop_cycle; please use the latter.
  warnings.warn(self.msg_depr % (key, alt_key))

In [30]:
from astropy.utils.data import download_file

In [31]:
from astropy.io import fits

In [32]:
image_file = '../datasets/bam/example.fits'

In [33]:
hdu_list = fits.open(image_file)
hdu_list.info()
# Gaia SM images are binned by 2 in AC direction( hence AC dim = 990 )
# Gaia SM images are binned by 2 in AL direction( hence AL dim = 2543 )


Filename: ../datasets/bam/CR_000027056802448195100_2014-09-07.fits
No.    Name         Type      Cards   Dimensions   Format
0    PRE_PROCESSED  PrimaryHDU      30   (141, 721)   int16 (rescales to uint16)   

In [6]:
image_data = hdu_list[0].data

In [7]:
print(type(image_data))
print(image_data.shape)


<class 'numpy.ndarray'>
(721, 141)

In [8]:
hdu_list.close()

In [25]:
from matplotlib.colors import LogNorm
plt.imshow(image_data, cmap='gray')
plt.colorbar()
# To see more color maps
# http://wiki.scipy.org/Cookbook/Matplotlib/Show_colormaps


Out[25]:
<matplotlib.colorbar.Colorbar at 0x2b62244e62e8>

In [26]:
print('Min:', np.min(image_data))
print('Max:', np.max(image_data))
print('Mean:', np.mean(image_data))
print('Stdev:', np.std(image_data))


Min: 2
Max: 21269
Mean: 1504.59683654
Stdev: 154.84352282

In [27]:
# Rotate and Strech color
import scipy
from scipy import ndimage
rotated_img = scipy.ndimage.rotate(image_data, 90)
plt.xlabel('Time [TDI units]')
plt.ylabel('AC')
plt.imshow(rotated_img, cmap='gray', vmin=512, vmax=3000)


Out[27]:
<matplotlib.image.AxesImage at 0x2b62245000f0>

In [28]:
# Interactive Plot
plt.ion()
ax=plt.gca()
ax.imshow(rotated_img, cmap='gray', vmin=512, vmax=3000)
plt.xlabel('Time [TDI units]')
plt.ylabel('AC')
plt.draw()



In [ ]: