Commit 14aba26f authored by Monica Rainer's avatar Monica Rainer
Browse files

Merge branch 'master' into develop

parents daa2623c 3f56a65f
__version__ = '1.5.2'
__version__ = '1.6.0'
......@@ -237,6 +237,34 @@ class GBFlats():
red_nor = os.path.join(CONFIG['RED_CALIB'],os.path.basename(nor))
shutil.copyfile(nor,red_nor)
mflat = ccdproc.CCDData.read(red_straight, unit=u.adu)
data = mflat.data
# create extraction mask
maskC = np.ones((CONFIG['YCCD'],CONFIG['XCCD']), dtype='int')
xvalues = np.arange(CONFIG['XCCD'])
for x in xrange(CONFIG['N_ORD']):
# order limits
start = x*CONFIG['W_ORD']
end = min(start+CONFIG['W_ORD'],CONFIG['YCCD'])
# evaluate average background value for each order
background = np.sort(fdata,axis=None)[0:CONFIG['YCCD']*3]
back = np.median(background)
# create mask for extraction
for row in xrange(3,38,1):
rrow = start + row
if np.median(fdata[rrow]) > back*2:
maskC[rrow] = 0
cmask = np.asarray(maskC, dtype='int')
hdu = fits.PrimaryHDU(data=cmask)
cm = fits.HDUList([hdu])
cm.writeto(CONFIG['MASK_C'],clobber=True)
return
......@@ -281,6 +309,10 @@ class GBFlats():
#print args
subprocess.call(args)
with fits.open(straight, 'update') as s:
s[0].header[CONFIG['KEYS']['FILENAME']] = os.path.basename(straight)
s[0].header = metadata.add_metadata(s[0].header)
self.messages.append('Orders straightened.')
db.insert_dbfile(self.dbconn,'flatstr',straight)
......@@ -288,12 +320,12 @@ class GBFlats():
# Update FILENAME in header then
# add metadata to header and save straight file
mflat.header[CONFIG['KEYS']['FILENAME']] = os.path.basename(straight)
mflat.header = metadata.add_metadata(mflat.header)
#mflat.header[CONFIG['KEYS']['FILENAME']] = os.path.basename(straight)
#mflat.header = metadata.add_metadata(mflat.header)
hdu = fits.PrimaryHDU(data=mflat.data, header=mflat.header)
str_fits = fits.HDUList([hdu])
str_fits.writeto(straight, overwrite=True)
#hdu = fits.PrimaryHDU(data=mflat.data, header=mflat.header)
#str_fits = fits.HDUList([hdu])
#str_fits.writeto(straight, overwrite=True)
......
......@@ -253,16 +253,28 @@ class GBNodding():
subprocess.call(args)
# Read straight file
imstr = ccdproc.CCDData.read(straight, unit=u.adu)
#imstr = ccdproc.CCDData.read(straight, unit=u.adu)
# Update FILENAME in header then
# add metadata to header and save straight file
imstr.header[CONFIG['KEYS']['FILENAME']] = os.path.basename(straight)
imstr.header = metadata.add_metadata(imstr.header)
hdu = fits.PrimaryHDU(data=imstr.data, header=imstr.header)
str_fits = fits.HDUList([hdu])
str_fits.writeto(straight, overwrite=True)
with fits.open(straight, 'update') as s:
s[0].header[CONFIG['KEYS']['FILENAME']] = os.path.basename(straight)
s[0].header = metadata.add_metadata(s[0].header)
s.flush()
#imstr.header[CONFIG['KEYS']['FILENAME']] = os.path.basename(straight)
#imstr.header = metadata.add_metadata(imstr.header)
#hdu = fits.PrimaryHDU(data=imstr.data, header=imstr.header)
#str_fits = fits.HDUList([hdu])
#str_fits.writeto(straight, overwrite=True)
imstr = ccdproc.CCDData.read(straight, unit=u.adu)
str_file = os.path.join(CONFIG['RED_STR'],os.path.basename(straight))
try: shutil.copyfile(straight,str_file)
......
......@@ -388,17 +388,22 @@ class GBStare():
subprocess.call(args)
# Read straight file
imstr = ccdproc.CCDData.read(straight, unit=u.adu)
#imstr = ccdproc.CCDData.read(straight, unit=u.adu)
# Update FILENAME in header then
# add metadata to header and save straight file
imstr.header[CONFIG['KEYS']['FILENAME']] = os.path.basename(straight)
imstr.header = metadata.add_metadata(imstr.header)
with fits.open(straight, 'update') as s:
s[0].header[CONFIG['KEYS']['FILENAME']] = os.path.basename(straight)
s[0].header = metadata.add_metadata(s[0].header)
#hdu = fits.PrimaryHDU(data=imstr.data, header=imstr.header)
#str_fits = fits.HDUList([hdu])
#str_fits.writeto(straight, overwrite=True)
hdu = fits.PrimaryHDU(data=imstr.data, header=imstr.header)
str_fits = fits.HDUList([hdu])
str_fits.writeto(straight, overwrite=True)
# Read straight file
imstr = ccdproc.CCDData.read(straight, unit=u.adu)
imflat = imstr.data.copy()
str_file = os.path.join(CONFIG['RED_STR'],os.path.basename(straight))
try: shutil.copyfile(straight,str_file)
......
Markdown is supported
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