GitLab system status is available here and here

Commit d1c15613 authored by Ethan Yeung's avatar Ethan Yeung
Browse files

added comments in Markdown

parent 9c2b5a78
%% Cell type:markdown id:c1bde056 tags:
preliminary import statements
%% Cell type:code id:6fad088d tags:
``` python
# preliminary import statements
import numpy as np
import sep
```
%% Cell type:markdown id:cad8ab47 tags:
additional setup for reading the test image and displaying plots
%% Cell type:code id:11230211 tags:
``` python
# additional setup for reading the test image and displaying plots
from astropy.io import fits
import matplotlib.pyplot as plt
from matplotlib import rcParams
%matplotlib inline
rcParams['figure.figsize'] = [10., 8.]
```
%% Cell type:markdown id:c0b3fb2c tags:
read in the data and then get the image data
%% Cell type:code id:ed382cbb tags:
``` python
# read in the data
hdu = fits.open("../final/image.fits")
# get the image data
data = hdu[0].data
```
%% Output
WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:
ESO-LOG 00:00:00> DATE = '1992-10-26' / Mon Oct 26, 1992 [astropy.io.fits.card]
WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:
ESO-LOG 03:04:08>-START EXPO EMMI RED / Start exp. on EMMI Red CC [astropy.io.fits.card]
WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:
ESO-LOG 03:04:09> EXPO EMMI RED NO = 24887 / Exp. num. on EMMI Red CCD [astropy.io.fits.card]
WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:
ESO-LOG 03:10:52>-STOP EXPO EMMI RED / Stop exp. on EMMI Red CCD [astropy.io.fits.card]
%% Cell type:markdown id:63913248 tags:
show the image
%% Cell type:code id:6c7086d0 tags:
``` python
# show the image
m, s = np.mean(data), np.std(data)
plt.imshow(data, interpolation='nearest', cmap='gray', vmin=m-s, vmax=m+s, origin='lower')
plt.colorbar();
plt.savefig("image1.png")
```
%% Output
%% Cell type:markdown id:5a8fcfe4 tags:
measure a spatially varying background on the image
%% Cell type:code id:c6cc10c3 tags:
``` python
# measure a spatially varying background on the image
bkg = sep.Background(data)
```
%% Cell type:markdown id:310b287a tags:
get a "global" mean and noise of the image background
%% Cell type:code id:72e0ec9f tags:
``` python
# get a "global" mean and noise of the image background
print(bkg.globalback)
print(bkg.globalrms)
```
%% Output
6852.04931640625
65.46174621582031
%% Cell type:markdown id:7b875d85 tags:
evaluate background as 2-d array, same size as original image
%% Cell type:code id:4dd96f7a tags:
``` python
# evaluate background as 2-d array, same size as original image
bkg_image = bkg.back()
```
%% Cell type:markdown id:1717c4d9 tags:
show the background
%% Cell type:code id:32252553 tags:
``` python
# show the background
plt.imshow(bkg_image, interpolation='nearest', cmap='gray', origin='lower')
plt.colorbar();
plt.savefig("image2.png")
```
%% Output
%% Cell type:markdown id:666740da tags:
evaluate the background noise as 2-d array, same size as original image
%% Cell type:code id:2bd419be tags:
``` python
# evaluate the background noise as 2-d array, same size as original image
bkg_rms = bkg.rms()
```
%% Cell type:markdown id:83e52b83 tags:
show the background noise
%% Cell type:code id:cd80115f tags:
``` python
# show the background noise
plt.imshow(bkg_rms, interpolation='nearest', cmap='gray', origin='lower')
plt.colorbar();
plt.savefig("image3.png")
```
%% Output
%% Cell type:markdown id:2c9ef006 tags:
subtract the background
%% Cell type:code id:dcee000e tags:
``` python
# subtract the background
data_sub = data - bkg
```
%% Cell type:code id:b6554292 tags:
``` python
objects = sep.extract(data_sub, 1.5, err=bkg.globalrms)
```
%% Cell type:markdown id:f2d1183f tags:
how many objects were detected
%% Cell type:code id:40cc6728 tags:
``` python
# how many objects were detected
len(objects)
```
%% Output
69
%% Cell type:markdown id:b8b642c5 tags:
circle each object in red
%% Cell type:code id:b086d8be tags:
``` python
from matplotlib.patches import Ellipse
# plot background-subtracted image
fig, ax = plt.subplots()
m, s = np.mean(data_sub), np.std(data_sub)
im = ax.imshow(data_sub, interpolation='nearest', cmap='gray',
vmin=m-s, vmax=m+s, origin='lower')
# plot an ellipse for each object
for i in range(len(objects)):
e = Ellipse(xy=(objects['x'][i], objects['y'][i]),
width=6*objects['a'][i],
height=6*objects['b'][i],
angle=objects['theta'][i] * 180. / np.pi)
e.set_facecolor('none')
e.set_edgecolor('red')
ax.add_artist(e)
plt.savefig("image4.png")
```
%% Output