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 ...@@ -113,12 +113,9 @@ CONFIG['UNMERGED'] = 'ms1d' # suffix for unmerged spectra
# Keywords used by the pipeline: change here if the keywords change # Keywords used by the pipeline: change here if the keywords change
# If some keywords are added or removed, change varie/check_keywords accordingly. # 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 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 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' : '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: # Values of the keyword:
# CONFIG['OBSTYPE'] keyword values to determine the nature of the files # 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 ...@@ -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['B'] = 'B' # value of CONFIG['SLIT'] for B position
CONFIG['C'] = 'C' # value of CONFIG['SLIT'] for C position CONFIG['C'] = 'C' # value of CONFIG['SLIT'] for C position
# CONFIG['STARE'] keyword values to determine the Obj-Sky position # CONFIG['STARE'] keyword values to determine the Obj-Sky position
CONFIG['OBJ'] = 'OBJ' CONFIG['OBJ'] = 'Obj'
CONFIG['SKY'] = 'SKY' CONFIG['SKY'] = 'Sky'
CONFIG['UNKNOWN'] = 'UNKNOWN' CONFIG['UNKNOWN'] = 'UNKNOWN'
# CONFIG['EXTMODE'] keyword values to determine to extraction mode # CONFIG['EXTMODE'] keyword values to determine to extraction mode
CONFIG['EXTPAIR'] = 'PAIR_EXT' CONFIG['EXTPAIR'] = 'PAIR_EXT'
......
...@@ -350,6 +350,7 @@ class GBCheckRawFiles(): ...@@ -350,6 +350,7 @@ class GBCheckRawFiles():
#print self.group #print self.group
try: try:
groupn = int(hdr[CONFIG['KEYS']['NPAIRS']]) groupn = int(hdr[CONFIG['KEYS']['NPAIRS']])
groupi = int(hdr[CONFIG['KEYS']['IPAIRS']])
except: except:
#groupn = 1 #groupn = 1
pass pass
...@@ -422,7 +423,8 @@ class GBCheckRawFiles(): ...@@ -422,7 +423,8 @@ class GBCheckRawFiles():
elif nod_stare == CONFIG['STAREVALUE']: elif nod_stare == CONFIG['STAREVALUE']:
try: try:
pair_id = hdr[CONFIG['KEYS']['PID']] #pair_id = hdr[CONFIG['KEYS']['PID']]
pair_id = hdr[CONFIG['KEYS']['ID']]
except: except:
pair_id = obj_name pair_id = obj_name
...@@ -446,8 +448,8 @@ class GBCheckRawFiles(): ...@@ -446,8 +448,8 @@ class GBCheckRawFiles():
self.lists[CONFIG['SCIENCE']].append(self.rawfile) self.lists[CONFIG['SCIENCE']].append(self.rawfile)
#if len(self.lists[CONFIG['SCIENCE']]) == 2*groupn: if len(self.lists[CONFIG['SCIENCE']]) == self.group['ngroup']:
if len(self.lists[CONFIG['SCIENCE']]) == 100: #if len(self.lists[CONFIG['SCIENCE']]) == 100:
self.command[self.group['nodstare']] = 'pair' self.command[self.group['nodstare']] = 'pair'
self.working = 0 self.working = 0
self.group.pop('pair', None) self.group.pop('pair', None)
......
...@@ -85,7 +85,7 @@ class GBStare(): ...@@ -85,7 +85,7 @@ class GBStare():
continue continue
# check the signal in a well-defined zone # 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']]) expt_obj.append(nod.header[CONFIG['KEYS']['EXPTIME']])
zone = nod.data[CONFIG['SCIENCECHECK'][0]:CONFIG['SCIENCECHECK'][1],CONFIG['SCIENCECHECK'][2]:CONFIG['SCIENCECHECK'][3]] zone = nod.data[CONFIG['SCIENCECHECK'][0]:CONFIG['SCIENCECHECK'][1],CONFIG['SCIENCECHECK'][2]:CONFIG['SCIENCECHECK'][3]]
mean = np.mean(zone) mean = np.mean(zone)
...@@ -113,6 +113,9 @@ class GBStare(): ...@@ -113,6 +113,9 @@ class GBStare():
self.skylist.append(nod) self.skylist.append(nod)
name_sky.append(os.path.basename(frame)) name_sky.append(os.path.basename(frame))
#print len(self.skylist)
#print len(self.starelist)
# Check if there is at least one Obj image. # Check if there is at least one Obj image.
if len(self.starelist) == 0: if len(self.starelist) == 0:
...@@ -301,12 +304,15 @@ class GBStare(): ...@@ -301,12 +304,15 @@ class GBStare():
Cnome = self.starelist[0].header[CONFIG['KEYS']['IMANAME']] Cnome = self.starelist[0].header[CONFIG['KEYS']['IMANAME']]
#print Cnome #print Cnome
#qui = Cnome.rindex('.') #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: 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: else:
Cnome = '_'.join((nomebase,'C.fits')) #Cnome = '_'.join((nomebase,'C.fits'))
Cnome = ''.join((nomebase,'.fits'))
Cnome = os.path.join(CONFIG['TMP_DIR'],Cnome) Cnome = os.path.join(CONFIG['TMP_DIR'],Cnome)
#cor_fits = corrected.to_hdu() #cor_fits = corrected.to_hdu()
...@@ -707,6 +713,8 @@ class GBStare(): ...@@ -707,6 +713,8 @@ class GBStare():
#self.stare[:] = [] #self.stare[:] = []
self.starelist[:] = [] self.starelist[:] = []
self.skylist[:] = [] self.skylist[:] = []
if not self.group['stares']:
self.group.clear()
return return
...@@ -728,14 +736,17 @@ class GBStare(): ...@@ -728,14 +736,17 @@ class GBStare():
def ingroup_process(self): def ingroup_process(self):
warnings.simplefilter('ignore', category=AstropyWarning) warnings.simplefilter('ignore', category=AstropyWarning)
self.pair_process() self.pair_process()
self.stare = self.group['stares'] try:
if self.qualitycheck(): self.stare = self.group['stares']
obj = self.createObj(True) if self.qualitycheck():
calib, straight, dbreduced = self.reduce(obj) obj = self.createObj(True)
if straight: calib, straight, dbreduced = self.reduce(obj)
os.remove(obj) if straight:
os.remove(straight) os.remove(obj)
self.group.clear() os.remove(straight)
self.group.clear()
except:
pass
return 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