Skip to content

Commit

Permalink
fixing standard
Browse files Browse the repository at this point in the history
  • Loading branch information
fedhere committed May 23, 2015
1 parent ed8218b commit 53c33f4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
28 changes: 15 additions & 13 deletions coaddim.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
if not myexposure:
try:
print header0[value]
except:
except KeyError:
print "missing required keyword:",k,value
sys.exit()
myexposure = float(header0[value])
Expand All @@ -163,7 +163,7 @@
try:
print header0[value]
mysaturate = header0[value]
except:
except KeyError:
print "missing required keyword ",k,value
sys.exit()
print "saturate :",mysaturate
Expand All @@ -173,7 +173,7 @@
try:
print header0[value]
mygain = header0[value]
except:
except KeyError:
print "missing required keyword ",k,value
sys.exit()
print "gain :",mygain
Expand All @@ -183,7 +183,7 @@
try:
print header0[value]
myrdnoise = header0[value]
except:
except KeyError:
print "missing required keyword ",k,value
sys.exit()
print "read noise :",myrdnoise
Expand All @@ -193,7 +193,7 @@
try:
print header0[value]
myobject = header0[value]
except:
except KeyError:
print "missing required keyword ",k,value
myobject='MYSTERYOBJECT'
print "object:",myobject
Expand All @@ -203,7 +203,7 @@
try:
print header0[value]
mymjd = header0[value]
except:
except KeyError:
print "missing keyword ",k,value
mymjd=0.0
print "mjd :",mymjd
Expand All @@ -213,7 +213,7 @@
try:
print header0[value]
mydate = header0[value]
except:
except KeyError:
print "missing keyword ",k,value
import datetime
mydate=str(datetime.date.today())
Expand All @@ -224,7 +224,7 @@
try:
print header0[value]
myscope=header0[value]
except:
except KeyError:
print "missing keyword ",k,value
myscope='SOMESCOPE'
print "telescope: ",myscope
Expand All @@ -234,7 +234,7 @@
try:
print header0[value]
myfilter = header0[value]
except:
except KeyError:
print "missing keyword ",k,value
myfilter='UNKNOWN'
print "filter: ",myfilter
Expand Down Expand Up @@ -360,7 +360,7 @@
acceptedlist.append(allimgs[i].split("/")[-1])
try:
myexposure += float(header[keys['exposure']])
except:
except KeyError:
myexposure+=exposure
nimgs+=1
else:
Expand All @@ -372,7 +372,7 @@
acceptedlist.append(allimgs[i].split("/")[-1])
try:
myexposure += float(header[keys['exposure']])
except:
except KeyError:
myexposure+=exposure
nimgs+=1

Expand All @@ -385,7 +385,7 @@
tmp+=PF.getdata(allimgs[i])
try:
myexposure += float(header[keys['exposure']])
except:
except KeyError:
myexposure=exposure
nimgs+=1
acceptedlist.append(allimgs[i].split("/")[-1])
Expand Down Expand Up @@ -448,7 +448,9 @@
else :
existing=sorted([f for f in os.listdir(impath) if base in f and f.endswith('.fits')])
try: int(existing.split('_')[-1].split('.')[0])
except: existing=existing[1:]
except:
existing=existing[1:]
pass
outfile = base+'_' + str(np.max([int(ii.split('_')[-1].split('.')[0]) for ii in existing]) + 1) + '.fits'


Expand Down
28 changes: 14 additions & 14 deletions coaddutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import numpy as np
from scipy import *
from scipy import cluster
from scipy.stats import mode
from scipy.interpolate import interp1d
#from scipy.stats import mode
from pylab import imshow,title,figure,show,clf,draw


Expand Down Expand Up @@ -103,16 +102,16 @@ def dist(pair):


def sigclippedstd(arr):
iter = 0
oldarr=np.zeros(len(arr.flatten())+1,float)
while (iter < 20 and np.mean(arr)>np.median(arr)):
#len(arr.flatten())<len(oldarr.flatten())):
oldarr=arr
iterator = 0
#oldarr=np.zeros(len(arr.flatten())+1,float)
while (iterator < 20 and np.mean(arr)>np.median(arr)):
#len(arr.flatten())<len(oldarr.flatten())):
#oldarr=arr
m=np.mean(arr)
s=np.std(arr)
# print s, m
arr=arr.clip(min=m-1*s,max=m+1*s)
iter+=1
iterator+=1
return(s)


Expand All @@ -137,8 +136,8 @@ def masksaturated(data, header0, saturation):
# low in some telescopes. that must be fixed
#since saturated pixels really mess up the correlation and
#someetime saturation occurs BELOW the saturation limit
n1=data.shape[0]
n2=data.shape[1]
#n1=data.shape[0]
#n2=data.shape[1]
index = np.array(range(data.shape[0]*data.shape[1]))
print index
index1=index % data.shape[1]
Expand Down Expand Up @@ -239,8 +238,8 @@ def masksaturated(data, header0, saturation):
return data


def correlate(fits,saturation,showme=False):

def correlate(fits,saturation, showme=False):
print saturation
if fits[0].shape[0] >= fits[1].shape[0]:
larger = 0
smaller = 1
Expand Down Expand Up @@ -309,7 +308,7 @@ def correlate(fits,saturation,showme=False):
axis2_shift,axis1_shift = phase[0],phase[1]
if phase[1] :
if phase[1] == naxis2:
axis1_shift ==[0,naxis2,0,naxis2]
axis1_shift =[0,naxis2,0,naxis2]
elif phase[1] > naxis2/2:
print "phase1>naxis2/2"
axis1_shift =[naxis2-phase[1],naxis2,0,-(naxis2-phase[1])]
Expand Down Expand Up @@ -408,7 +407,7 @@ def correlate(fits,saturation,showme=False):
fits[smaller][abs(axis2_shift):,abs(axis1_shift):])
# stack[:-abs(axis2_shift),:-abs(axis1_shift)] += w*fitspad[abs(axis2_shift):,abs(axis1_shift):]
'''
else:
return(fits[larger],fits[smaller])
Expand All @@ -427,3 +426,4 @@ def correlate(fits,saturation,showme=False):
#coadded=
#return (fits[larger][int(slicex1[0]):int(slicex1[1]), int(slicey1[0]):int(slicey1[1])],fits[smaller][int(slicex2[0]):int(slicex2[1]), int(slicey2[0]):int(slicey2[1])])
'''

0 comments on commit 53c33f4

Please sign in to comment.