Difference: StewartBoogertPhotometryStarFinder (1 vs. 2)

Revision 209 Nov 2017 - LunaMarieBorella1

Line: 1 to 1
 
META TOPICPARENT name="StewartBoogertPhotometry2017"
Deleted:
<
<
from astropy.io import fits import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit import glob import ntpath import math as m from scipy import stats import operator
 BLACK = 0
Changed:
<
<
WHITE=2**16
>
>
WHITE=5000
 def OpenImage(FileName): """Opens a FIT image and puts pixel ADU values into an array""" image = fits.getdata(FileName)
Line: 26 to 17
 def count(pic): xsize, ysize = np.shape(pic) temp = pic
Changed:
<
<
result = 0
>
>
clust = []
  for x in range(xsize): for y in range(ysize):
Changed:
<
<
if temp[x,y] >= Threshold: result += 1 fill(temp, xsize, ysize, x, y) plt.imshow(temp, cmap=plt.cm.binary) return result
>
>
if temp[x,y] >= Threshold and temp[x,y] = WHITE:

clust.append((fill(temp, xsize, ysize, x, y)))

plt.imshow(temp, cmap='gray_r', origin='lower',interpolation='none', vmin=WHITE - 1,vmax=WHITE)

return clust

  def fill(pic, xsize, ysize, x, y):
Changed:
<
<
if pic[x, y] = Threshold: pic[x,y] = WHITE
>
>
if pic[x, y] < Threshold:
  return
Deleted:
<
<
pic[x,y] = BLACK if x>0: fill(pic, xsize, ysize, x-1, y) if x < (xsize-1): fill(pic, xsize, ysize, x+1, y) if y > 0: fill(pic, xsize, ysize, x, y-1) if y < (ysize-1): fill(pic, xsize, ysize, x, y+1)
 
Added:
>
>
thisClustList = []

queue = [(x, y)] while len(queue) = 0: next = queue.pop() if pic[next[0], next[1]] >= Threshold and pic[next[0], next[1]] = WHITE: pic[next[0], next[1]] = WHITE thisClustList.append((next[0], next[1])) if x > 0: queue.append((x-1, y)) if x < (xsize-1): queue.append((x+1, y)) if y > 0: queue.append((x, y-1)) if y < (ysize-1): queue.append((x, y+1)) return thisClustList

 
Added:
>
>
pic = OpenImage("C:\\Users\\Blake\\Dropbox\\Msci_project\\Alpha\\alpha_persei_10.fit")
 
Added:
>
>
Threshold = pic.mean()+(np.std(pic))
 
Deleted:
<
<
pic = OpenImage("C:\\Users\\Blake\\Dropbox\\Msci_project\\Alpha\\alpha_persei.fit") Threshold = pic.mean()+(np.std(pic)/20)
 plt.figure(1)
Changed:
<
<
plt.imshow(pic)
>
>
plt.imshow(pic, cmap='gray', origin='lower',interpolation='none', vmin=np.median(pic),vmax=np.median(pic)*2.2) plt.colorbar()
 plt.figure(2)
Changed:
<
<
print count(pic)
>
>
stars = count(pic) print stars print len(stars) count(pic) plt.colorbar()
 
Deleted:
<
<
plt.show()
 
Added:
>
>
plt.show()
 

<\verbatim>

Revision 127 Oct 2017 - LunaMarieBorella1

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="StewartBoogertPhotometry2017"
from astropy.io import fits
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
import glob
import ntpath
import math as m
from scipy import stats
import operator

BLACK = 0
WHITE=2**16
def OpenImage(FileName):
    """Opens a FIT image and puts pixel ADU values into an array"""
    image = fits.getdata(FileName)
    return image

def OpenDirectory(Directory):
    filenames = glob.glob(Directory+"*.fit")
    return filenames


def count(pic):
   xsize, ysize = np.shape(pic)
   temp = pic
   result = 0
   for x in range(xsize):
      for y in range(ysize):
         if temp[x,y] >= Threshold:
            result += 1
            fill(temp, xsize, ysize, x, y)
   plt.imshow(temp, cmap=plt.cm.binary)         
   return result

def fill(pic, xsize, ysize, x, y):
   if pic[x, y] != Threshold:
      pic[x,y] = WHITE
      return 
   pic[x,y] = BLACK
   if x>0: fill(pic, xsize, ysize, x-1, y)
   if x < (xsize-1): fill(pic, xsize, ysize, x+1, y)
   if y > 0: fill(pic, xsize, ysize, x, y-1)
   if y < (ysize-1): fill(pic, xsize, ysize, x, y+1)




pic = OpenImage("C:\\Users\\Blake\\Dropbox\\Msci_project\\Alpha\\alpha_persei.fit")
Threshold = pic.mean()+(np.std(pic)/20)
plt.figure(1)
plt.imshow(pic)
plt.figure(2)
print count(pic)

plt.show()



<\verbatim>



-- Public.LunaBorella - 27 Oct 2017
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding RHUL Physics Department TWiki? Send feedback