GitLab system status is available here and here

Commit 9c2b5a78 authored by Ethan Yeung's avatar Ethan Yeung
Browse files

touched up first part of the project

parent 361c17fb
%% Cell type:code id:6fad088d tags:
``` python
# preliminary import statements
import numpy as np
import sep
```
%% 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:code id:ed382cbb tags:
``` python
# read in the data
hdu = fits.open("/home/eyeun/Documents/astr-19/final/image.fits")
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: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:code id:c6cc10c3 tags:
``` python
# measure a spatially varying background on the image
bkg = sep.Background(data)
```
%% 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:code id:4dd96f7a tags:
``` python
# evaluate background as 2-d array, same size as original image
bkg_image = bkg.back()
```
%% 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:code id:2bd419be tags:
``` python
# evaluate the background noise as 2-d array, same size as original image
bkg_rms = bkg.rms()
```
%% 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: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:code id:40cc6728 tags:
``` python
# how many objects were detected
len(objects)
```
%% Output
69
%% 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
%% Cell type:code id:fe5a8c38 tags:
``` python
# available fields
objects.dtype.names
```
%% Output
('thresh',
'npix',
'tnpix',
'xmin',
'xmax',
'ymin',
'ymax',
'x',
'y',
'x2',
'y2',
'xy',
'errx2',
'erry2',
'errxy',
'a',
'b',
'theta',
'cxx',
'cyy',
'cxy',
'cflux',
'flux',
'cpeak',
'peak',
'xcpeak',
'ycpeak',
'xpeak',
'ypeak',
'flag')
%% Cell type:code id:70a6c0cd tags:
``` python
flux, fluxerr, flag = sep.sum_circle(data_sub, objects['x'], objects['y'], 3.0, err=bkg.globalrms, gain=1.0)
```
%% Cell type:code id:19e03169 tags:
``` python
# show the first 10 objects results
for i in range(10):
print("object {:d}: flux = {:f} +/- {:f}".format(i, flux[i], fluxerr[i]))
```
%% Output
object 0: flux = 2249.159297 +/- 291.027802
object 1: flux = 3092.220430 +/- 291.592204
object 2: flux = 5949.868379 +/- 356.562003
object 3: flux = 1851.426582 +/- 295.028816
object 4: flux = 72736.386914 +/- 440.172206
object 5: flux = 3860.756152 +/- 352.163162
object 6: flux = 6418.913789 +/- 357.458973
object 7: flux = 2210.707656 +/- 350.791223
object 8: flux = 2741.607227 +/- 352.277746
object 9: flux = 20916.875566 +/- 376.966138
%% Cell type:code id:00a52930 tags:
``` python
```
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment