Commit 8aa37a4f authored by Monica Rainer's avatar Monica Rainer
Browse files

Merge branch 'merge_request' into 'master'

Merge request

See merge request monica.rainer/gofio!2
parents 4ef49468 357a2e8e
...@@ -167,6 +167,10 @@ CONFIG['MASTERFLAT'] = (' '.join((CONFIG['KEY_DRS'],'FLAT')),'Flat-field used fo ...@@ -167,6 +167,10 @@ CONFIG['MASTERFLAT'] = (' '.join((CONFIG['KEY_DRS'],'FLAT')),'Flat-field used fo
CONFIG['MASTERLAMP'] = (' '.join((CONFIG['KEY_DRS'],'LAMP')),'Calibration lamp used for the reduction') CONFIG['MASTERLAMP'] = (' '.join((CONFIG['KEY_DRS'],'LAMP')),'Calibration lamp used for the reduction')
CONFIG['KEY_WEXT'] = (' '.join((CONFIG['KEY_DRS'],'WEXT')),'Standard extraction window [pixel]') CONFIG['KEY_WEXT'] = (' '.join((CONFIG['KEY_DRS'],'WEXT')),'Standard extraction window [pixel]')
CONFIG['DRS_VERSION'] = (' '.join((CONFIG['KEY_DRS'],'VERSION')),'GOFIO version') CONFIG['DRS_VERSION'] = (' '.join((CONFIG['KEY_DRS'],'VERSION')),'GOFIO version')
CONFIG['RED'] = (' '.join((CONFIG['KEY_DRS'],'RED')),'GOFIO reduced file')
CONFIG['RED_TYPE'] = (' '.join((CONFIG['KEY_DRS'],'RED TYPE')),'GOFIO reduced file type')
CONFIG['RED_SUBTYPE'] = (' '.join((CONFIG['KEY_DRS'],'RED SUBTYPE')),'GOFIO reduced file subtype')
CONFIG['RED_SLIT'] = (' '.join((CONFIG['KEY_DRS'],'RED SLIT')),'GOFIO reduced file slit')
# Wavelength calibration # Wavelength calibration
......
...@@ -15,6 +15,7 @@ from astropy.utils.exceptions import AstropyWarning ...@@ -15,6 +15,7 @@ from astropy.utils.exceptions import AstropyWarning
from ccdproc import CCDData, Combiner from ccdproc import CCDData, Combiner
from drslib.config import CONFIG from drslib.config import CONFIG
from drslib import db from drslib import db
from drslib import metadata
import numpy as np import numpy as np
import os, shutil import os, shutil
...@@ -105,6 +106,10 @@ class GBDarks(): ...@@ -105,6 +106,10 @@ class GBDarks():
self.masterdarks[exptime].header[CONFIG['DRS_VERSION'][0]] = (CONFIG['VERSION'], CONFIG['DRS_VERSION'][1]) self.masterdarks[exptime].header[CONFIG['DRS_VERSION'][0]] = (CONFIG['VERSION'], CONFIG['DRS_VERSION'][1])
# Add metadata to header
self.masterdarks[exptime].header = metadata.add_metadata(self.masterdarks[exptime].header)
hdu = fits.PrimaryHDU(data=self.masterdarks[exptime].data,header=self.masterdarks[exptime].header) hdu = fits.PrimaryHDU(data=self.masterdarks[exptime].data,header=self.masterdarks[exptime].header)
mdark = fits.HDUList([hdu]) mdark = fits.HDUList([hdu])
......
...@@ -21,6 +21,7 @@ from astropy.utils.exceptions import AstropyWarning ...@@ -21,6 +21,7 @@ from astropy.utils.exceptions import AstropyWarning
import ccdproc import ccdproc
from drslib.config import CONFIG from drslib.config import CONFIG
from drslib import db, varie from drslib import db, varie
from drslib import metadata
import numpy as np import numpy as np
import math, os, subprocess, shutil import math, os, subprocess, shutil
...@@ -159,6 +160,9 @@ class GBFlats(): ...@@ -159,6 +160,9 @@ class GBFlats():
mflat.header[CONFIG['DRS_VERSION'][0]] = (CONFIG['VERSION'], CONFIG['DRS_VERSION'][1]) mflat.header[CONFIG['DRS_VERSION'][0]] = (CONFIG['VERSION'], CONFIG['DRS_VERSION'][1])
# Add metadata to header
mflat.header = metadata.add_metadata(mflat.header)
hdu = fits.PrimaryHDU(data=mflat.data,header=mflat.header) hdu = fits.PrimaryHDU(data=mflat.data,header=mflat.header)
masterflat = fits.HDUList([hdu]) masterflat = fits.HDUList([hdu])
masterflat.writeto(nome,clobber=True) masterflat.writeto(nome,clobber=True)
...@@ -201,9 +205,41 @@ class GBFlats(): ...@@ -201,9 +205,41 @@ class GBFlats():
shiftY = varie.shiftY(mflat.data) shiftY = varie.shiftY(mflat.data)
db.insert_dbfile(self.dbconn,'shiftY',shiftY) db.insert_dbfile(self.dbconn,'shiftY',shiftY)
# Since masterflat has been copied from calibration database
# also str and nor will be copied
self.copy_straighten()
return False
return True return True
def copy_straighten(self):
"""
The masterflat has been copied from calibration database
This function also copy str and nor file from calibration database
"""
# Get masterflat name from calibdb
# flat is a fullpath name
flat = db.extract_dbfile(self.dbconn,'flat')
# Generate str and nor fullpath name from calibdb
straight = flat.replace('.fits','_str.fits')
nor = flat.replace('.fits','_nor.fits')
# Insert str and nor in calibdb for this night
db.insert_dbfile(self.dbconn,'flatstr',straight)
db.insert_dbfile(self.dbconn,'flatnor',nor)
# Copy str and nor to RED_CALIB directory of current night
red_straight = os.path.join(CONFIG['RED_CALIB'],os.path.basename(straight))
shutil.copyfile(straight,red_straight)
red_nor = os.path.join(CONFIG['RED_CALIB'],os.path.basename(nor))
shutil.copyfile(nor,red_nor)
return
def straighten(self): def straighten(self):
""" """
Straighten the masterflat, normalize it and create the masked array Straighten the masterflat, normalize it and create the masked array
...@@ -245,13 +281,22 @@ class GBFlats(): ...@@ -245,13 +281,22 @@ class GBFlats():
#print args #print args
subprocess.call(args) subprocess.call(args)
red_straight = os.path.join(CONFIG['RED_CALIB'],os.path.basename(straight))
shutil.copyfile(straight,red_straight)
self.messages.append('Orders straightened.') self.messages.append('Orders straightened.')
db.insert_dbfile(self.dbconn,'flatstr',straight) db.insert_dbfile(self.dbconn,'flatstr',straight)
mflat = ccdproc.CCDData.read(straight, unit=u.adu) mflat = ccdproc.CCDData.read(straight, unit=u.adu)
# 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)
hdu = fits.PrimaryHDU(data=mflat.data, header=mflat.header)
str_fits = fits.HDUList([hdu])
str_fits.writeto(straight, overwrite=True)
fdata = mflat.data fdata = mflat.data
norflat = np.ones((CONFIG['YCCD'],CONFIG['XCCD']), dtype='float32') norflat = np.ones((CONFIG['YCCD'],CONFIG['XCCD']), dtype='float32')
...@@ -312,10 +357,20 @@ class GBFlats(): ...@@ -312,10 +357,20 @@ class GBFlats():
fnor = ccdproc.CCDData(norflat, unit=u.adu) fnor = ccdproc.CCDData(norflat, unit=u.adu)
fnor.header = mflat.header fnor.header = mflat.header
#fn = fnor.to_hdu() #fn = fnor.to_hdu()
hdu = fits.PrimaryHDU(data=fnor.data,header=fnor.header)
# Update FILENAME in header then
# add metadata to header and save nor file
fnor.header[CONFIG['KEYS']['FILENAME']] = os.path.basename(nor)
fnor.header = metadata.add_metadata(fnor.header)
hdu = fits.PrimaryHDU(data=fnor.data, header=fnor.header)
fn = fits.HDUList([hdu]) fn = fits.HDUList([hdu])
fn.writeto(nor,clobber=True) fn.writeto(nor, overwrite=True)
# Copy straight and nor to RED_CALIB directory
red_straight = os.path.join(CONFIG['RED_CALIB'],os.path.basename(straight))
shutil.copyfile(straight,red_straight)
red_nor = os.path.join(CONFIG['RED_CALIB'],os.path.basename(nor)) red_nor = os.path.join(CONFIG['RED_CALIB'],os.path.basename(nor))
shutil.copyfile(nor,red_nor) shutil.copyfile(nor,red_nor)
......
...@@ -5,6 +5,7 @@ Implemented in the GIANOB DRS by Monica Rainer ...@@ -5,6 +5,7 @@ Implemented in the GIANOB DRS by Monica Rainer
import logging import logging
from drslib.config import CONFIG as CFG from drslib.config import CONFIG as CFG
from sys import stdout
class DrsLogger(): class DrsLogger():
def __init__(self): def __init__(self):
...@@ -29,7 +30,7 @@ class DrsLogger(): ...@@ -29,7 +30,7 @@ class DrsLogger():
def addconsolelogger(self): def addconsolelogger(self):
"""The logger to the terminal is defined""" """The logger to the terminal is defined"""
console_handler = logging.StreamHandler() console_handler = logging.StreamHandler(stream=stdout)
formatter = logging.Formatter(fmt=self.conslogfmt) formatter = logging.Formatter(fmt=self.conslogfmt)
console_handler.setFormatter(formatter) console_handler.setFormatter(formatter)
self.logger.addHandler(console_handler) self.logger.addHandler(console_handler)
......
from drslib.config import CONFIG
def add_metadata(header):
filename = header['FILENAME']
dataDict = {'RED': True,
'RED_TYPE': None,
'RED_SUBTYPE': None,
'RED_SLIT': None}
if 'DARK' in filename:
dataDict['RED_TYPE'] = 'DARK'
if '010_DARK' in filename:
dataDict['RED_SUBTYPE'] = 'masterdark10'
elif '030_DARK' in filename:
dataDict['RED_SUBTYPE'] = 'masterdark30'
elif '060_DARK' in filename:
dataDict['RED_SUBTYPE'] = 'masterdark60'
elif '100_DARK' in filename:
dataDict['RED_SUBTYPE'] = 'masterdark100'
elif '200_DARK' in filename:
dataDict['RED_SUBTYPE'] = 'masterdark200'
elif '300_DARK' in filename:
dataDict['RED_SUBTYPE'] = 'masterdark300'
elif '600_DARK' in filename:
dataDict['RED_SUBTYPE'] = 'masterdark600'
else:
dataDict['RED_SUBTYPE'] = 'masterdark'
elif 'FLAT' in filename:
dataDict['RED_TYPE'] = 'FLAT'
if 'FLAT_nor' in filename:
dataDict['RED_SUBTYPE'] = 'masterflat_nor'
elif 'FLAT_str' in filename:
dataDict['RED_SUBTYPE'] = 'masterflat_str'
else:
dataDict['RED_SUBTYPE'] = 'masterflat'
elif 'UNE' in filename:
dataDict['RED_TYPE'] = 'UNE'
if 'UNE_ext' in filename:
dataDict['RED_SUBTYPE'] = 'wl_une_calib'
elif 'UNE_str' in filename:
dataDict['RED_SUBTYPE'] = 'wl_une_str'
else:
dataDict['RED_SUBTYPE'] = 'wl_une'
elif 'FP' in filename:
dataDict['RED_TYPE'] = 'FP'
if 'FP_ext' in filename:
dataDict['RED_SUBTYPE'] = 'wl_une_calib'
elif 'FP_str' in filename:
dataDict['RED_SUBTYPE'] = 'wl_une_str'
else:
dataDict['RED_SUBTYPE'] = 'wl_une'
elif 'str' in filename:
dataDict['RED_TYPE'] = 'INTERMEDIATE'
dataDict['RED_SUBTYPE'] = None
else:
dataDict['RED_TYPE'] = 'SCIENCE'
if 'ms1d' in filename:
dataDict['RED_SUBTYPE'] = 'ms1d'
else:
dataDict['RED_SUBTYPE'] = 's1d'
if '_AB_' in filename:
dataDict['RED_SLIT'] = 'AB'
elif '_A_' in filename:
dataDict['RED_SLIT'] = 'A'
elif '_B_' in filename:
dataDict['RED_SLIT'] = 'B'
# Insert in only keys with not None values
for key in dataDict.keys():
if dataDict[key]:
header[CONFIG[key][0]] = (dataDict[key], CONFIG[key][1])
# header[CONFIG['RED_TYPE'][0]] = (dataDict['RED_TYPE'], CONFIG['RED_TYPE'][1])
# header[CONFIG['RED_SUBTYPE'][0]] = (dataDict['RED_SUBTYPE'], CONFIG['RED_SUBTYPE'][1])
# header[CONFIG['RED_SLIT'][0]] = (dataDict['RED_SLIT'], CONFIG['RED_SLIT'][1])
return header
\ No newline at end of file
...@@ -21,6 +21,7 @@ Reduction of the nodding group: ...@@ -21,6 +21,7 @@ Reduction of the nodding group:
from drslib.config import CONFIG from drslib.config import CONFIG
from drslib import db, varie from drslib import db, varie
from drslib import metadata
from astropy import units as u from astropy import units as u
from astropy.io import ascii, fits from astropy.io import ascii, fits
...@@ -82,14 +83,10 @@ class GBNodding(): ...@@ -82,14 +83,10 @@ class GBNodding():
return True return True
def createAB(self): def create_nodcorr(self):
""" """
Create nodding images A-B and save them in temporary directory if Create nodcorr
the keyword SPEXTMODE is set to GRPAVG_EXT.
""" """
hea = self.nodlist[0].header
badpix = ccdproc.CCDData.read(CONFIG['BADPIX_MASK'], unit=u.adu) badpix = ccdproc.CCDData.read(CONFIG['BADPIX_MASK'], unit=u.adu)
bad_mask=badpix.data bad_mask=badpix.data
inverse_mask=np.logical_not(bad_mask) inverse_mask=np.logical_not(bad_mask)
...@@ -106,6 +103,46 @@ class GBNodding(): ...@@ -106,6 +103,46 @@ class GBNodding():
self.nodcorr[nod.header[CONFIG['KEYS']['SLIT']]] = nod_corr self.nodcorr[nod.header[CONFIG['KEYS']['SLIT']]] = nod_corr
nod = None nod = None
return
def check_nodcorr(self):
"""
Check if nodcorr is not corrupted
"""
try:
nodA = self.nodcorr[CONFIG['A']]
except Exception as e:
nodA = None
try:
nodB = self.nodcorr[CONFIG['B']]
except Exception as e:
nodB = None
if not nodA and not nodB:
self.messages.append('The nodding pair is corrupted. Both slits A and B are missing. Skipping pair processing.')
return False
else:
if not nodA:
self.messages.append('The nodding pair is corrupted. Slit A is missing. Skipping pair processing.')
return False
if not nodB:
self.messages.append('The nodding pair is corrupted. Slit B is missing. Skipping pair processing.')
return False
return True
def createAB(self):
"""
Create nodding images A-B and save them in temporary directory if
the keyword SPEXTMODE is set to GRPAVG_EXT.
"""
hea = self.nodlist[0].header
# Create A-B image # Create A-B image
nodA = self.nodcorr[CONFIG['A']] nodA = self.nodcorr[CONFIG['A']]
...@@ -215,13 +252,24 @@ class GBNodding(): ...@@ -215,13 +252,24 @@ class GBNodding():
subprocess.call(args) subprocess.call(args)
# Read straight file
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)
str_file = os.path.join(CONFIG['RED_STR'],os.path.basename(straight)) str_file = os.path.join(CONFIG['RED_STR'],os.path.basename(straight))
try: shutil.copyfile(straight,str_file) try: shutil.copyfile(straight,str_file)
except: pass except: pass
self.messages.append('%s: orders straightened (nodding %s).' % (str(os.path.basename(fitsfile)),slit,)) self.messages.append('%s: orders straightened (nodding %s).' % (str(os.path.basename(fitsfile)),slit,))
imstr = ccdproc.CCDData.read(straight, unit=u.adu)
hea_ima = hea hea_ima = hea
for key in CONFIG['STRAIGHT_PAR']: for key in CONFIG['STRAIGHT_PAR']:
hea_ima[CONFIG['STRAIGHT_PAR'][key]] = imstr.header[CONFIG['STRAIGHT_PAR'][key]] hea_ima[CONFIG['STRAIGHT_PAR'][key]] = imstr.header[CONFIG['STRAIGHT_PAR'][key]]
...@@ -576,6 +624,9 @@ class GBNodding(): ...@@ -576,6 +624,9 @@ class GBNodding():
heaspe[CONFIG['DRS_VERSION'][0]] = (CONFIG['VERSION'], CONFIG['DRS_VERSION'][1]) heaspe[CONFIG['DRS_VERSION'][0]] = (CONFIG['VERSION'], CONFIG['DRS_VERSION'][1])
# Add metadata to header
heaspe = metadata.add_metadata(heaspe)
#tbhdu = fits.BinTableHDU.from_columns([c1, c2, c3, c4],header=heaspe) #tbhdu = fits.BinTableHDU.from_columns([c1, c2, c3, c4],header=heaspe)
tbhdu = fits.BinTableHDU.from_columns([c1, c2, c3, c4]) tbhdu = fits.BinTableHDU.from_columns([c1, c2, c3, c4])
prihdu = fits.PrimaryHDU(data=None, header=heaspe) prihdu = fits.PrimaryHDU(data=None, header=heaspe)
...@@ -604,6 +655,9 @@ class GBNodding(): ...@@ -604,6 +655,9 @@ class GBNodding():
heaspe['CTYPE1'] = ('Nanometers','Units of coordinates') heaspe['CTYPE1'] = ('Nanometers','Units of coordinates')
heaspe['BUNIT'] = ('Relative Flux','Units of data values') heaspe['BUNIT'] = ('Relative Flux','Units of data values')
# Add metadata to header
heaspe = metadata.add_metadata(heaspe)
s1dfits = fits.PrimaryHDU(s1d,header=heaspe) s1dfits = fits.PrimaryHDU(s1d,header=heaspe)
calname1d = os.path.join(CONFIG['RED_DIR'],calname1d) calname1d = os.path.join(CONFIG['RED_DIR'],calname1d)
s1dfits.writeto(calname1d,clobber=True) s1dfits.writeto(calname1d,clobber=True)
...@@ -779,6 +833,9 @@ class GBNodding(): ...@@ -779,6 +833,9 @@ class GBNodding():
heaspe[CONFIG['DRS_VERSION'][0]] = (CONFIG['VERSION'], CONFIG['DRS_VERSION'][1]) heaspe[CONFIG['DRS_VERSION'][0]] = (CONFIG['VERSION'], CONFIG['DRS_VERSION'][1])
# Add metadata to header
heaspe = metadata.add_metadata(heaspe)
#tbhdu = fits.BinTableHDU.from_columns([c1, c2, c3, c4],header=heaspe) #tbhdu = fits.BinTableHDU.from_columns([c1, c2, c3, c4],header=heaspe)
tbhdu = fits.BinTableHDU.from_columns([c1, c2, c3, c4]) tbhdu = fits.BinTableHDU.from_columns([c1, c2, c3, c4])
prihdu = fits.PrimaryHDU(data=None, header=heaspe) prihdu = fits.PrimaryHDU(data=None, header=heaspe)
...@@ -803,6 +860,9 @@ class GBNodding(): ...@@ -803,6 +860,9 @@ class GBNodding():
heaspe['CTYPE1'] = ('Nanometers','Units of coordinates') heaspe['CTYPE1'] = ('Nanometers','Units of coordinates')
heaspe['BUNIT'] = ('Relative Flux','Units of data values') heaspe['BUNIT'] = ('Relative Flux','Units of data values')
# Add metadata to header
heaspe = metadata.add_metadata(heaspe)
s1dfits = fits.PrimaryHDU(s1d,header=heaspe) s1dfits = fits.PrimaryHDU(s1d,header=heaspe)
s1dfits.writeto(abnome1d,clobber=True) s1dfits.writeto(abnome1d,clobber=True)
...@@ -910,6 +970,10 @@ class GBNodding(): ...@@ -910,6 +970,10 @@ class GBNodding():
warnings.simplefilter('ignore', category=AstropyWarning) warnings.simplefilter('ignore', category=AstropyWarning)
if self.qualitycheck(): if self.qualitycheck():
#t1 = time.time() #t1 = time.time()
# Create and check nodcorr
self.create_nodcorr()
if not self.check_nodcorr():
return
ab, heaA, heaB = self.createAB() ab, heaA, heaB = self.createAB()
#t2 = time.time() #t2 = time.time()
#print 'Bad pixels, create nodding: %s s' % str(t2-t1) #print 'Bad pixels, create nodding: %s s' % str(t2-t1)
......
...@@ -30,6 +30,7 @@ Reduction of all the Obj-Sky group: ...@@ -30,6 +30,7 @@ Reduction of all the Obj-Sky group:
from drslib.config import CONFIG from drslib.config import CONFIG
from drslib import db, varie from drslib import db, varie
from drslib import metadata
from astropy import units as u from astropy import units as u
from astropy.io import ascii, fits from astropy.io import ascii, fits
...@@ -386,15 +387,25 @@ class GBStare(): ...@@ -386,15 +387,25 @@ class GBStare():
args.extend(shiftY) args.extend(shiftY)
subprocess.call(args) subprocess.call(args)
# Read straight file
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)
str_file = os.path.join(CONFIG['RED_STR'],os.path.basename(straight)) str_file = os.path.join(CONFIG['RED_STR'],os.path.basename(straight))
try: shutil.copyfile(straight,str_file) try: shutil.copyfile(straight,str_file)
except: pass except: pass
self.messages.append('%s: orders straightened.' % str(os.path.basename(fitsfile)),) self.messages.append('%s: orders straightened.' % str(os.path.basename(fitsfile)),)
imstr = ccdproc.CCDData.read(straight, unit=u.adu)
imflat = imstr.data.copy()
try: nspec = imstr.header[CONFIG['KEYS']['NCOMBINE']] try: nspec = imstr.header[CONFIG['KEYS']['NCOMBINE']]
except: nspec = 1 except: nspec = 1
...@@ -701,6 +712,9 @@ class GBStare(): ...@@ -701,6 +712,9 @@ class GBStare():
heaspe[CONFIG['DRS_VERSION'][0]] = (CONFIG['VERSION'], CONFIG['DRS_VERSION'][1]) heaspe[CONFIG['DRS_VERSION'][0]] = (CONFIG['VERSION'], CONFIG['DRS_VERSION'][1])
# Add metadata to header
heaspe = metadata.add_metadata(heaspe)
#tbhdu = fits.BinTableHDU.from_columns([c1, c2, c3, c4],header=heaspe) #tbhdu = fits.BinTableHDU.from_columns([c1, c2, c3, c4],header=heaspe)
tbhdu = fits.BinTableHDU.from_columns([c1, c2, c3, c4]) tbhdu = fits.BinTableHDU.from_columns([c1, c2, c3, c4])
prihdu = fits.PrimaryHDU(data=None, header=heaspe) prihdu = fits.PrimaryHDU(data=None, header=heaspe)
...@@ -726,6 +740,9 @@ class GBStare(): ...@@ -726,6 +740,9 @@ class GBStare():
heaspe['CTYPE1'] = ('Nanometers','Units of coordinates') heaspe['CTYPE1'] = ('Nanometers','Units of coordinates')
heaspe['BUNIT'] = ('Relative Flux','Units of data values') heaspe['BUNIT'] = ('Relative Flux','Units of data values')
# Add metadata to header
heaspe = metadata.add_metadata(heaspe)
s1dfits = fits.PrimaryHDU(s1d,header=heaspe) s1dfits = fits.PrimaryHDU(s1d,header=heaspe)
calname1d = os.path.join(CONFIG['RED_DIR'],calname1d) calname1d = os.path.join(CONFIG['RED_DIR'],calname1d)
s1dfits.writeto(calname1d,clobber=True) s1dfits.writeto(calname1d,clobber=True)
......
...@@ -23,6 +23,7 @@ from astropy.utils.exceptions import AstropyWarning ...@@ -23,6 +23,7 @@ from astropy.utils.exceptions import AstropyWarning
import ccdproc import ccdproc
from drslib.config import CONFIG from drslib.config import CONFIG
from drslib import db, varie from drslib import db, varie
from drslib import metadata
import numpy as np import numpy as np
import math, os, subprocess, shutil import math, os, subprocess, shutil
...@@ -141,6 +142,9 @@ class GBWls(): ...@@ -141,6 +142,9 @@ class GBWls():
mwl.header[CONFIG['DRS_VERSION'][0]] = (CONFIG['VERSION'], CONFIG['DRS_VERSION'][1]) mwl.header[CONFIG['DRS_VERSION'][0]] = (CONFIG['VERSION'], CONFIG['DRS_VERSION'][1])
# Add metadata to header
mwl.header = metadata.add_metadata(mwl.header)
hdu = fits.PrimaryHDU(data=mwl.data,header=mwl.header) hdu = fits.PrimaryHDU(data=mwl.data,header=mwl.header)
masterwl = fits.HDUList([hdu]) masterwl = fits.HDUList([hdu])
masterwl.writeto(self.mlamp,clobber=True) masterwl.writeto(self.mlamp,clobber=True)
...@@ -160,9 +164,45 @@ class GBWls(): ...@@ -160,9 +164,45 @@ class GBWls():
except: except:
self.messages.append('There are no %s lamps in the calibration database.' %(unefp)) self.messages.append('There are no %s lamps in the calibration database.' %(unefp))
return False return False
# Since masterlamp has been copied from calibration database
# also str and extr will be copied
self.copy_straighten(unefp)