Commit 108c1070 authored by Monica Rainer's avatar Monica Rainer
Browse files

Fix bug in stare reduction

parent c7b9dec3
__version__ = '1.5.0'
__version__ = '1.5.1'
......@@ -113,12 +113,9 @@ CONFIG['UNMERGED'] = 'ms1d' # suffix for unmerged spectra
# Keywords used by the pipeline: change here if the keywords change
# If some keywords are added or removed, change varie/check_keywords accordingly.
CONFIG['KEYS'] = {'OBJECT' : 'OBJECT', 'OBSTYPE' : 'OBS-TYPE', 'OBSMODE' : 'OBSMODE' , 'IMANAME' : 'IMANAME', 'FILENAME' : 'FILENAME', 'NCOMBINE' : 'NCOMBINE', 'MJD' : 'MJD-OBS', 'EXPTIME' : 'EXPTIME', 'NODSTARE' : 'HIERARCH TNG TPL NAME' , 'GROUPN' : 'GROUP_N', 'GROUPI' : 'GROUP_I', 'SLIT' : 'SLIT_POS' , 'STARE' : 'HIERARCH TNG TPL STAREPOS' , 'GROUPID' : 'HIERARCH TNG TPL GROUPID' , 'ID' : 'HIERARCH TNG TPL OBSID' , 'PID' : 'HIERARCH TNG TPL PAIRID' , 'NPAIRS' : 'HIERARCH TNG TPL NPAIRS' ,'NREP' : 'HIERARCH TNG CAT EXP NREP' , 'EXTMODE' : 'HIERARCH TNG CAT DR SPEXTMODE' , 'RA' : 'HIERARCH TNG TEL TARG ALPHA' , 'DEC' : 'HIERARCH TNG TEL TARG DELTA' , 'PMA' : 'HIERARCH TNG TEL TARG PMA' , 'PMD' : 'HIERARCH TNG TEL TARG PMD' , 'EQUINOX' : 'HIERARCH TNG TEL TARG EQUINOX' , 'TARG_TYPE' : 'HIERARCH TNG CAT TARG TYPE' , 'AM' : 'AIRMASS' , 'RADVEL' : 'HIERARCH TNG TEL TARG RADVEL' }
#CONFIG['KEYS'] = {'OBJECT' : 'OBJECT', 'OBSTYPE' : 'OBS-TYPE', 'OBSMODE' : 'OBSMODE' , 'IMANAME' : 'IMANAME', 'FILENAME' : 'FILENAME', 'NCOMBINE' : 'NCOMBINE', 'MJD' : 'MJD-OBS', 'EXPTIME' : 'EXPTIME', 'NODSTARE' : 'HIERARCH TNG CAT ACQTEMPL' , 'GROUPN' : 'GROUP_N', 'GROUPI' : 'GROUP_I', 'SLIT' : 'SLIT_POS' , 'STARE' : 'STAREPOS' , 'GROUPID' : 'GROUPID' , 'ID' : 'OBSID' , 'PID' : 'PAIRID' , 'NPAIRS' : 'HIERARCH TNG CAT EXP NPAIRS' ,'NREP' : 'HIERARCH TNG CAT EXP NREP' , 'EXTMODE' : 'HIERARCH TNG CAT DR SPEXTMODE' , 'RA' : 'HIERARCH TNG TEL TARG ALPHA' , 'DEC' : 'HIERARCH TNG TEL TARG DELTA' , 'PMA' : 'HIERARCH TNG TEL TARG PMA' , 'PMD' : 'HIERARCH TNG TEL TARG PMD' , 'EQUINOX' : 'HIERARCH TNG TEL TARG EQUINOX' , 'TARG_TYPE' : 'HIERARCH TNG CAT TARG TYPE' , 'AM' : 'AIRMASS' , 'RADVEL' : 'HIERARCH TNG TEL TARG RADVEL' }
CONFIG['KEYS'] = {'OBJECT' : 'OBJECT', 'OBSTYPE' : 'OBS-TYPE', 'OBSMODE' : 'OBSMODE' , 'IMANAME' : 'IMANAME', 'FILENAME' : 'FILENAME', 'NCOMBINE' : 'NCOMBINE', 'MJD' : 'MJD-OBS', 'EXPTIME' : 'EXPTIME', 'NODSTARE' : 'HIERARCH TNG TPL NAME' , 'GROUPN' : 'GROUP_N', 'GROUPI' : 'GROUP_I', 'SLIT' : 'SLIT_POS' , 'STARE' : 'HIERARCH TNG TPL STAREPOS' , 'GROUPID' : 'HIERARCH TNG TPL GROUPID' , 'ID' : 'HIERARCH TNG TPL OBSID' , 'PID' : 'HIERARCH TNG TPL PAIRID' , 'NPAIRS' : 'HIERARCH TNG TPL NPAIRS' , 'IPAIRS' : 'HIERARCH TNG TPL IPAIRS' ,'NREP' : 'HIERARCH TNG CAT EXP NREP' , 'EXTMODE' : 'HIERARCH TNG CAT DR SPEXTMODE' , 'RA' : 'HIERARCH TNG TEL TARG ALPHA' , 'DEC' : 'HIERARCH TNG TEL TARG DELTA' , 'PMA' : 'HIERARCH TNG TEL TARG PMA' , 'PMD' : 'HIERARCH TNG TEL TARG PMD' , 'EQUINOX' : 'HIERARCH TNG TEL TARG EQUINOX' , 'TARG_TYPE' : 'HIERARCH TNG CAT TARG TYPE' , 'AM' : 'AIRMASS' , 'RADVEL' : 'HIERARCH TNG TEL TARG RADVEL' }
#CONFIG['KEYS'] = {'OBJECT' : 'OBJECT', 'OBSTYPE' : 'OBS-TYPE', 'OBSMODE' : 'OBSMODE' , 'IMANAME' : 'IMANAME', 'FILENAME' : 'FILENAME', 'NCOMBINE' : 'NCOMBINE', 'MJD' : 'MJD-OBS', 'EXPTIME' : 'EXPTIME', 'NODSTARE' : 'HIERARCH TNG TPL NAME' , 'GROUPN' : 'GROUP_N', 'GROUPI' : 'GROUP_I', 'SLIT' : 'SLIT_POS' , 'STARE' : 'HIERARCH TNG TPL STAREPOS' , 'GROUPID' : 'GROUPID' , 'ID' : 'OBSID' , 'PID' : 'PAIRID' , 'NPAIRS' : 'HIERARCH TNG CAT EXP NPAIRS' ,'NREP' : 'HIERARCH TNG CAT EXP NREP' , 'EXTMODE' : 'HIERARCH TNG CAT DR SPEXTMODE' , 'RA' : 'HIERARCH TNG TEL TARG ALPHA' , 'DEC' : 'HIERARCH TNG TEL TARG DELTA' , 'PMA' : 'HIERARCH TNG TEL TARG PMA' , 'PMD' : 'HIERARCH TNG TEL TARG PMD' , 'EQUINOX' : 'HIERARCH TNG TEL TARG EQUINOX' , 'TARG_TYPE' : 'HIERARCH TNG CAT TARG TYPE' , 'AM' : 'AIRMASS' , 'RADVEL' : 'HIERARCH TNG TEL TARG RADVEL' }
# Values of the keyword:
# CONFIG['OBSTYPE'] keyword values to determine the nature of the files
......@@ -138,8 +135,8 @@ CONFIG['A'] = 'A' # value of CONFIG['SLIT'] for A position
CONFIG['B'] = 'B' # value of CONFIG['SLIT'] for B position
CONFIG['C'] = 'C' # value of CONFIG['SLIT'] for C position
# CONFIG['STARE'] keyword values to determine the Obj-Sky position
CONFIG['OBJ'] = 'OBJ'
CONFIG['SKY'] = 'SKY'
CONFIG['OBJ'] = 'Obj'
CONFIG['SKY'] = 'Sky'
CONFIG['UNKNOWN'] = 'UNKNOWN'
# CONFIG['EXTMODE'] keyword values to determine to extraction mode
CONFIG['EXTPAIR'] = 'PAIR_EXT'
......
......@@ -350,6 +350,7 @@ class GBCheckRawFiles():
#print self.group
try:
groupn = int(hdr[CONFIG['KEYS']['NPAIRS']])
groupi = int(hdr[CONFIG['KEYS']['IPAIRS']])
except:
#groupn = 1
pass
......@@ -422,7 +423,8 @@ class GBCheckRawFiles():
elif nod_stare == CONFIG['STAREVALUE']:
try:
pair_id = hdr[CONFIG['KEYS']['PID']]
#pair_id = hdr[CONFIG['KEYS']['PID']]
pair_id = hdr[CONFIG['KEYS']['ID']]
except:
pair_id = obj_name
......@@ -446,8 +448,8 @@ class GBCheckRawFiles():
self.lists[CONFIG['SCIENCE']].append(self.rawfile)
#if len(self.lists[CONFIG['SCIENCE']]) == 2*groupn:
if len(self.lists[CONFIG['SCIENCE']]) == 100:
if len(self.lists[CONFIG['SCIENCE']]) == self.group['ngroup']:
#if len(self.lists[CONFIG['SCIENCE']]) == 100:
self.command[self.group['nodstare']] = 'pair'
self.working = 0
self.group.pop('pair', None)
......
......@@ -85,7 +85,7 @@ class GBStare():
continue
# check the signal in a well-defined zone
if nod.header[CONFIG['KEYS']['STARE']] == CONFIG['OBJ'] or nod.header[CONFIG['KEYS']['STARE']] == CONFIG['UNKNOWN']:
if nod.header[CONFIG['KEYS']['STARE']].lower() == CONFIG['OBJ'].lower() or nod.header[CONFIG['KEYS']['STARE']].lower() == CONFIG['UNKNOWN'].lower():
expt_obj.append(nod.header[CONFIG['KEYS']['EXPTIME']])
zone = nod.data[CONFIG['SCIENCECHECK'][0]:CONFIG['SCIENCECHECK'][1],CONFIG['SCIENCECHECK'][2]:CONFIG['SCIENCECHECK'][3]]
mean = np.mean(zone)
......@@ -113,6 +113,9 @@ class GBStare():
self.skylist.append(nod)
name_sky.append(os.path.basename(frame))
#print len(self.skylist)
#print len(self.starelist)
# Check if there is at least one Obj image.
if len(self.starelist) == 0:
......@@ -301,12 +304,15 @@ class GBStare():
Cnome = self.starelist[0].header[CONFIG['KEYS']['IMANAME']]
#print Cnome
#qui = Cnome.rindex('.')
nomebase = os.path.splitext(Cnome)[0]
#nomebase = os.path.splitext(Cnome)[0]
nomebase = '_'.join((os.path.splitext(Cnome)[0],corrected.header[CONFIG['KEYS']['SLIT']].strip()))
if grp:
#Cnome = '_'.join((Cnome[0:qui],'Cgrp.fits'))
Cnome = '_'.join((nomebase,'Cgrp.fits'))
#Cnome = '_'.join((nomebase,'Cgrp.fits'))
Cnome = '_'.join((nomebase,'grp.fits'))
else:
Cnome = '_'.join((nomebase,'C.fits'))
#Cnome = '_'.join((nomebase,'C.fits'))
Cnome = ''.join((nomebase,'.fits'))
Cnome = os.path.join(CONFIG['TMP_DIR'],Cnome)
#cor_fits = corrected.to_hdu()
......@@ -707,6 +713,8 @@ class GBStare():
#self.stare[:] = []
self.starelist[:] = []
self.skylist[:] = []
if not self.group['stares']:
self.group.clear()
return
......@@ -728,14 +736,17 @@ class GBStare():
def ingroup_process(self):
warnings.simplefilter('ignore', category=AstropyWarning)
self.pair_process()
self.stare = self.group['stares']
if self.qualitycheck():
obj = self.createObj(True)
calib, straight, dbreduced = self.reduce(obj)
if straight:
os.remove(obj)
os.remove(straight)
self.group.clear()
try:
self.stare = self.group['stares']
if self.qualitycheck():
obj = self.createObj(True)
calib, straight, dbreduced = self.reduce(obj)
if straight:
os.remove(obj)
os.remove(straight)
self.group.clear()
except:
pass
return
......
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