Skip to content

Commit

Permalink
Test fitting on SDSS data classified by Galaxy Zoo participants
Browse files Browse the repository at this point in the history
  • Loading branch information
ricktjwong committed Dec 3, 2018
1 parent e95f3ee commit 5981e4a
Show file tree
Hide file tree
Showing 14 changed files with 4,682 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
modules/__pycache__/

Binary file added data/fpAtlas-001740-5-0022.fit
Binary file not shown.
4,267 changes: 4,267 additions & 0 deletions data/fpObjc-001740-5-0022.fit

Large diffs are not rendered by default.

Binary file added data/galaxyzoo1.fits
Binary file not shown.
319 changes: 319 additions & 0 deletions data/psField-001740-5-0022.fit

Large diffs are not rendered by default.

Binary file added data/spiral.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/spiral.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/spiral2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions data/tsField-001740-5-40-0022.fit

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions modules/galaxy_zoo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 3 10:40:45 2018
@author: ricktjwong
"""

from astropy.io import fits
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from PIL import Image

import sersic_profile as sp
import mask as mk
import process as ps
import peak_detection as pk

def rgb2gray(rgb):
r, g, b = rgb[:,:,0], rgb[:,:,1], rgb[:,:,2]
gray = 0.2989 * r + 0.5870 * g + 0.1140 * b
return gray

#hdulist = fits.open("../data/galaxyzoo1.fits")
hdulist = fits.open("../data/psField-001740-5-0022.fit")
data = hdulist[1].data
print(data.dtype)
print(len(data))
print("Uncertain galaxy:")
print(data[0])
print("Spiral galaxy:")
print(data[1])
print("Elliptical galaxy:")
print(data[3])

#img = mpimg.imread("../data/spiral2.jpeg")
#img = rgb2gray(img)
#
#plt.imshow(img)
#
#peaks = pk.find_peaks(img)
#
#total_intensity = sp.circle_intensity(img, (50, 51), 24)
#raw, r_h = sp.half_light_radius(img, (50, 51), 24, total_intensity)
#
#print("Half-radius:" + str(r_h))
#
#y = [sp.surface_intensity(img, (50, 51), i) for i in range(1, 10)]
#print(y)
#x = [i for i in range(1, len(y) + 1)]
#plt.figure()
#plt.plot(x, y, c='b')
#
#I_e = sp.surface_intensity(img, (50, 51), int(r_h))
#print(I_e)


25 changes: 8 additions & 17 deletions modules/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import sersic_profile as sp
import mask as mk
import process as ps
import peak_detection as pk

hdulist = fits.open("../data/mosaic.fits")
data = hdulist[0].data
Expand All @@ -30,30 +31,20 @@

data = data - 3421
y = [sp.surface_intensity(data, (2459, 3215), i) for i in range(1, 13)]
print(y)
x = [i for i in range(1, len(y) + 1)]
plt.figure()
plt.plot(x, y)
plt.plot(x, y, c='b')

I_e = sp.surface_intensity(data, (2459, 3215), int(r_h))
print(I_e)
print(r_h)

I = [sp.I(i, I_e, int(r_h), 0.60) for i in x]
plt.plot(x, I)
plt.plot(x, I, "--")

for j in range(1,10):
I = [sp.I(i, I_e, int(r_h), j) for i in x]
plt.plot(x, I)
plt.plot(x, I, "--")

plt.figure()
total_intensity = sp.circle_intensity(data, (518, 3539), 3)
raw, r_h = sp.half_light_radius(data, (518, 3539), 3, total_intensity)

y = [sp.surface_intensity(data, (518, 3539), i) for i in range(1, 4)]
x = [i for i in range(1, len(y) + 1)]
plt.figure()
plt.plot(x, y)

I_e = sp.surface_intensity(data, (518, 3539), int(r_h))

for j in range(1,10):
I = [sp.I(i, I_e, int(r_h), j) for i in x]
plt.plot(x, I)
peaks = pk.find_peaks(data[0:1000])
35 changes: 18 additions & 17 deletions modules/peak_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,26 @@

from math import sqrt
from skimage.feature import blob_dog, blob_log, blob_doh
from astropy.io import fits
import matplotlib.pyplot as plt

hdulist = fits.open("../data/mosaic.fits")
img = hdulist[0].data

blobs_log = blob_log(img, max_sigma=30, num_sigma=10, threshold=.01)
# Compute radii in the 3rd column.
blobs_log[:, 2] = blobs_log[:, 2] * sqrt(2)
def find_peaks(data):
blobs_log = blob_log(data, min_sigma=5, max_sigma=30, num_sigma=10, threshold=.01)
# Compute radii in the 3rd column.
blobs_log[:, 2] = blobs_log[:, 2] * sqrt(2)
return blobs_log

fig, ax = plt.subplots()
#coords_radius = []
#
for blob in blobs_log:
ax.set_title("LOG")
ax.imshow(img, interpolation='nearest')
y, x, r = blob
# coords_radius.append([x, y, r])
c = plt.Circle((x, y), r, color='red', linewidth=2, fill=False)
ax.add_patch(c)

plt.show()
def plot_blobs(data, blobs):
fig, ax = plt.subplots()
#coords_radius = []
#
for blob in blobs:
ax.set_title("LOG")
ax.imshow(data, interpolation='nearest')
y, x, r = blob
# coords_radius.append([x, y, r])
c = plt.Circle((x, y), r, color='red', linewidth=2, fill=False)
ax.add_patch(c)

plt.show()
Binary file added papers/0105545.pdf
Binary file not shown.
Binary file added papers/05648062.pdf
Binary file not shown.

0 comments on commit 5981e4a

Please sign in to comment.