Commit 3ed7c0b0 authored by Monica Rainer's avatar Monica Rainer
Browse files

Merge branch 'develop'

parents 903acfe2 c7b9dec3
......@@ -18,6 +18,7 @@ webuidatabases
*~
.~*
gofio/calibrations
gofio/drslib/berv
gofio/raw
gofio/reduced
gofio/resources/straight_giano_2D
......
No preview for this file type
......@@ -8,6 +8,8 @@ Python packages:
- SciPy v0.19
- watchdog v0.8.2
- docopt v0.6.1
- barycorrpy
Other requirements:
- fortran77 compiler
......@@ -34,10 +36,6 @@ Installation:
stare.py
varie.py
wlframes.py
berv/
__init__.py
astroTimeLegacy.py
baryvel.py
resources/
GIANOB_MASKC.fits
UNe_lines_GIANO_selected.txt
......
__version__ = '1.4.0'
__version__ = '1.5.0'
......@@ -113,7 +113,11 @@ 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 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' ,'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:
......@@ -125,8 +129,10 @@ CONFIG['WCAL_FP'] = 'WCAL_FP'
#CONFIG['WCAL_FP'] = 'WCAL_LFC'
CONFIG['SCIENCE'] = 'SCIENCE'
# CONFIG['NODSTARE'] keyword values to determine if stare or nodding
CONFIG['NODVALUE'] = 'GIANO_sci_nodding'
CONFIG['STAREVALUE'] = 'GIANO_sci_stare'
#CONFIG['NODVALUE'] = 'GIANO_sci_nodding'
CONFIG['NODVALUE'] = 'GIANO_obs_nod' # keyword value contains this string
#CONFIG['STAREVALUE'] = 'GIANO_sci_stare'
CONFIG['STAREVALUE'] = 'GIANO_obs_stare' # keyword value contains this string
# CONFIG['SLIT'] keyword values to determine the slit position
CONFIG['A'] = 'A' # value of CONFIG['SLIT'] for A position
CONFIG['B'] = 'B' # value of CONFIG['SLIT'] for B position
......@@ -134,10 +140,11 @@ 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['UNKNOWN'] = 'UNKNOWN'
# CONFIG['EXTMODE'] keyword values to determine to extraction mode
CONFIG['EXTPAIR'] = 'PAIR_EXT'
CONFIG['EXTAVG'] = 'GRPAVG_EXT'
CONFIG['EXTDEFAULT'] = CONFIG['EXTAVG']
CONFIG['EXTDEFAULT'] = CONFIG['EXTPAIR']
# CONFIG['TARG_TYPE'] keyword values to determine type of object (science, telluric, ...)
CONFIG['TELLURIC'] = 'TELLURIC'
CONFIG['FASTROT'] = 'FASTROT'
......@@ -154,10 +161,10 @@ CONFIG['SPEC_USED'] = (' '.join((CONFIG['KEY_DRS'],'SPEC')),'Images combined')
CONFIG['SPEC_MJD'] = (' '.join((CONFIG['KEY_DRS'],'MJD')),'MJD of the relative image')
CONFIG['SNR'] = (' '.join((CONFIG['KEY_DRS'],'SNR')),'SNR in the middle of the order',)
CONFIG['STRAIGHT_PAR'] = OrderedDict([ ('P1',' '.join((CONFIG['KEY_DRS'],'STR2DP1'))), ('P2',' '.join((CONFIG['KEY_DRS'],'STR2DP2'))), ('P3',' '.join((CONFIG['KEY_DRS'],'STR2DP3'))), ('P4',' '.join((CONFIG['KEY_DRS'],'STR2DP4'))), ('P5',' '.join((CONFIG['KEY_DRS'],'STR2DP5'))), ('P6',' '.join((CONFIG['KEY_DRS'],'STR2DP6'))) ])
CONFIG['DRS_MJD'] = (' '.join((CONFIG['KEY_DRS'],'MJD')),'MJD of the (combined) image')
CONFIG['DRS_MJD'] = (' '.join((CONFIG['KEY_DRS'],'MJD')),'Mid-exposure MJD of the (combined) image')
CONFIG['BERV'] = (' '.join((CONFIG['KEY_DRS'],'BERV')),'Barycentric correction [km/s]')
CONFIG['HJD'] = (' '.join((CONFIG['KEY_DRS'],'HJD')),'HJD_UTC of the (combined) image')
CONFIG['BJD'] = (' '.join((CONFIG['KEY_DRS'],'BJD')),'BJD_TDB of the (combined) image')
CONFIG['HJD'] = (' '.join((CONFIG['KEY_DRS'],'HJD')),'Mid-exposure HJD (MJD, UTC) of the (combined) image')
CONFIG['BJD'] = (' '.join((CONFIG['KEY_DRS'],'BJD')),'Mid-exposure BJD (MJD, TDB) of the (combined) image')
CONFIG['AIRMASS'] = (' '.join((CONFIG['KEY_DRS'],'AIRMASS')),'Airmass of the combined image')
CONFIG['MASTERFLAT'] = (' '.join((CONFIG['KEY_DRS'],'FLAT')),'Flat-field used for the reduction')
CONFIG['MASTERLAMP'] = (' '.join((CONFIG['KEY_DRS'],'LAMP')),'Calibration lamp used for the reduction')
......
......@@ -83,7 +83,8 @@ def gofio_init(docopt_args):
CONFIG['S1D'] = True
CONFIG['S1D_NORM'] = False
if docopt_args['--group']:
CONFIG['EXTDEFAULT'] = CONFIG['EXTAVG']
maskc = ''.join(('GIANOB_MASKC_',CONFIG['DATE'],'.fits'))
CONFIG['MASK_C'] = os.path.join(CONFIG['RES_DIR'], maskc)
......@@ -216,13 +217,18 @@ def GianoBreduce(rawfits,rawlists,dbcalib,working,group,do_calib,stop,drslogger,
# check raw file and insert in the correct list
else:
drslogger.log('Checking the FITS file ' + str(os.path.basename(rawfits)))
raw = rawfiles.GBCheckRawFiles(rawfits,rawlists,working,group,do_calib)
raw.check_raw_file()
working = raw.working
group = raw.group
go = raw.go
if rawfits:
drslogger.log('Checking the FITS file ' + str(os.path.basename(rawfits)))
raw = rawfiles.GBCheckRawFiles(rawfits,rawlists,working,group,do_calib)
raw.check_raw_file()
working = raw.working
group = raw.group
go = raw.go
#do_calib = raw.do_calib
else:
raw = rawfiles.GBCheckRawFiles(rawfits,rawlists,working,group,do_calib)
raw.command[CONFIG['STAREVALUE']] = 'incomplete_group'
go = raw.go
for message in raw.messages:
drslogger.log(message)
......
......@@ -203,8 +203,8 @@ class GBNodding():
except:
db.copy_dbfile(self.dbconn,'shiftY')
shift = db.extract_dbfile(self.dbconn,'shiftY')
if not shift:
shift = CONFIG['SHIFT_Y']
if not shift:
shift = CONFIG['SHIFT_Y']
shiftY = [''.join(('DY=',str(shift - CONFIG['SHIFT_Y'])))]
#print shiftY
......
......@@ -278,7 +278,13 @@ class GBCheckRawFiles():
return
try:
nod_stare = hdr[CONFIG['KEYS']['NODSTARE']]
#nod_stare = hdr[CONFIG['KEYS']['NODSTARE']]
if CONFIG['NODVALUE'] in hdr[CONFIG['KEYS']['NODSTARE']]:
nod_stare = CONFIG['NODVALUE']
elif CONFIG['STAREVALUE'] in hdr[CONFIG['KEYS']['NODSTARE']]:
nod_stare = CONFIG['STAREVALUE']
else:
nod_stare = hdr[CONFIG['KEYS']['NODSTARE']]
except:
if slitpos == CONFIG['C']:
nod_stare = CONFIG['STAREVALUE']
......
......@@ -85,7 +85,7 @@ class GBStare():
continue
# check the signal in a well-defined zone
if nod.header[CONFIG['KEYS']['STARE']] == CONFIG['OBJ']:
if nod.header[CONFIG['KEYS']['STARE']] == CONFIG['OBJ'] or nod.header[CONFIG['KEYS']['STARE']] == CONFIG['UNKNOWN']:
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)
......@@ -316,7 +316,7 @@ class GBStare():
return Cnome
def reduce(self,fitsfile,slit_pos):
def reduce(self,fitsfile):
"""
Straighten, divide by the masterflat, optimal extraction
"""
......@@ -351,8 +351,8 @@ class GBStare():
except:
db.copy_dbfile(self.dbconn,'shiftY')
shift = db.extract_dbfile(self.dbconn,'shiftY')
if not shift:
shift = CONFIG['SHIFT_Y']
if not shift:
shift = CONFIG['SHIFT_Y']
shiftY = [''.join(('DY=',str(shift - CONFIG['SHIFT_Y'])))]
#print shiftY
......@@ -370,6 +370,18 @@ class GBStare():
try: nspec = imstr.header[CONFIG['KEYS']['NCOMBINE']]
except: nspec = 1
# search for slit position
try:
slit_value = imstr.header[CONFIG['KEYS']['SLIT']]
if slit_value == CONFIG['A']:
slit_pos = CONFIG['A_POS']
elif slit_value == CONFIG['B']:
slit_pos = CONFIG['B_POS']
else:
slit_pos = CONFIG['C_POS']
except: slit_pos = CONFIG['C_POS']
# use only the regions of the orders
try:
goodmask = ccdproc.CCDData.read(CONFIG['MASK_C'], unit=u.adu)
......@@ -679,7 +691,7 @@ class GBStare():
warnings.simplefilter('ignore', category=AstropyWarning)
if self.qualitycheck():
obj = self.createObj(False)
calib, straight, dbreduced = self.reduce(obj,CONFIG['C_POS'])
calib, straight, dbreduced = self.reduce(obj)
try:
db.insert_dbreduced(self.dbnight, dbreduced['s1d'], stamp)
......@@ -705,7 +717,7 @@ class GBStare():
#print self.stare
if self.qualitycheck():
obj = self.createObj(True)
calib, straight, dbreduced = self.reduce(obj,CONFIG['C_POS'])
calib, straight, dbreduced = self.reduce(obj)
if straight:
os.remove(obj)
os.remove(straight)
......@@ -719,7 +731,7 @@ class GBStare():
self.stare = self.group['stares']
if self.qualitycheck():
obj = self.createObj(True)
calib, straight, dbreduced = self.reduce(obj,CONFIG['C_POS'])
calib, straight, dbreduced = self.reduce(obj)
if straight:
os.remove(obj)
os.remove(straight)
......
......@@ -16,12 +16,15 @@
"""
from drslib.config import CONFIG
from drslib.berv import baryvel
#from drslib.berv import baryvel
from astropy import constants as const
from astropy import units as u
from astropy import coordinates as coord
from astropy.io import fits
from astropy.time import Time
import barycorrpy as bc
import numpy as np
import numpy.polynomial.polynomial as poly
......@@ -1095,7 +1098,7 @@ def check_keywords(header,filename):
#--------------------- Compute barycentric correction -------------------
def berv_corr(hdr):
def berv_corr_old(hdr):
# CORREZIONE BARICENTRICA + BJD
# TNG coordinates
latitude = 28.754
......@@ -1129,24 +1132,96 @@ def berv_corr(hdr):
pmd = 0.0
# JD (if MJD then convert to JD) + half exposure time
try:
expt = float(hdr[CONFIG['KEYS']['EXPTIME']])/2.0
except:
expt = 0.0
try:
mjd = float(hdr[CONFIG['DRS_MJD'][0]])
except:
mjd = float(hdr[CONFIG['KEYS']['MJD']])
mjd = mjd + (expt/(86400.0))
if mjd < 100000:
mjd = mjd + 2400000.5
barycorr, hjd, bjd, vbar, vdiurnal = baryvel.helcorr(longitude,latitude,elevation,ra,dec,mjd,equinox,pma,pmd)
return barycorr, hjd, bjd
#--------------------- Compute barycentric correction NEW -------------------
def berv_corr(hdr):
# CORREZIONE BARICENTRICA + BJD
# TNG coordinates
latitude = 28.754
longitude = -17.889056
elevation = 2387.2
tng = coord.EarthLocation.from_geodetic(latitude,-longitude,elevation)
try:
ra = hdr[CONFIG['KEYS']['RA']]
dec = hdr[CONFIG['KEYS']['DEC']]
except:
barycorr = 0.0
hjd = hdr[CONFIG['DRS_MJD'][0]]
return barycorr, hjd
# proper motions
try:
pma = float(hdr[CONFIG['KEYS']['PMA']])
pmd = float(hdr[CONFIG['KEYS']['PMD']])
except:
pma = 0.0
pmd = 0.0
if abs(pma) > 100:
pma = 0.0
if abs(pmd) > 100:
pmd = 0.0
# target coordinates
radec = coord.SkyCoord(ra,dec, unit=(u.hourangle, u.deg))
ra = radec.ra.value
dec = radec.dec.value
equinox = float(hdr[CONFIG['KEYS']['EQUINOX']])
t = Time(equinox,format='jyear')
epoch = t.jd
# JD (if MJD then convert to JD) + half exposure time
try:
expt = float(hdr[CONFIG['KEYS']['EXPTIME']])/2.0
except:
expt = 0.0
mjd = mjd + (expt/(86400.0))
try:
mjd = float(hdr[CONFIG['DRS_MJD'][0]])
except:
mjd = float(hdr[CONFIG['KEYS']['MJD']])
mjd = mjd + (expt/(86400.0))
if mjd < 100000:
mjd = mjd + 2400000.5
times = Time(mjd, format='jd', scale='utc', location=tng)
barycorr, hjd, bjd, vbar, vdiurnal = baryvel.helcorr(longitude,latitude,elevation,ra,dec,mjd,equinox,pma,pmd)
#ltt_bary = times.light_travel_time(radec)
#bjd = times.tdb + ltt_bary
#bjd = bjd.value
ltt_helio = times.light_travel_time(radec, 'heliocentric')
hjd = times.utc + ltt_helio
hjd = hjd.value - 2400000.5
return barycorr, hjd, bjd
#berv = bc.get_BC_vel(JDUTC=mjd, ra=ra, dec=dec, lat = latitude, longi = longitude, alt = elevation, pmra = pma, pmdec = pmd, epoch=epoch, ephemeris = 'de430', leap_update=True)
berv = bc.get_BC_vel(JDUTC=mjd, ra=ra, dec=dec, lat = latitude, longi = longitude, alt = elevation, pmra = pma, pmdec = pmd, epoch=epoch, leap_update=True)
berv = berv[0][0]/1000.0
corr_time = bc.utc_tdb.JDUTC_to_BJDTDB(mjd, ra=ra, dec=dec, lat = latitude, longi = longitude, alt = elevation, pmra = pma, pmdec = pmd, epoch=epoch, leap_update=True)
corr_time = corr_time[0][0] - 2400000.5
return berv, hjd, corr_time
#--------------------- Create s1d output -------------------
......
......@@ -35,11 +35,14 @@ class GBWls():
self.messages = []
self.wllist = []
self.wlcorr = []
self.mlamp = ''
def qualitycheck(self,unefp):
"""
Quality check for UNe and FP lamps still to be defined.
--> It will be done after the default wavelength calibration,
here everything is defined as ok.
"""
for frame in self.wls:
......@@ -128,7 +131,7 @@ class GBWls():
#wlname = hea[CONFIG['KEYS']['IMANAME']].replace('.fts','_LFC.fits')
#wlname = wlname.replace(' ', '').replace('-', '_')
nome = os.path.join(CONFIG['CALIB_DIR'],wlname)
self.mlamp = os.path.join(CONFIG['CALIB_DIR'],wlname)
mwl.header = hea
mwl.header[CONFIG['KEYS']['FILENAME']] = wlname
......@@ -140,18 +143,20 @@ class GBWls():
hdu = fits.PrimaryHDU(data=mwl.data,header=mwl.header)
masterwl = fits.HDUList([hdu])
masterwl.writeto(nome,clobber=True)
masterwl.writeto(self.mlamp,clobber=True)
mwl = None
db.insert_dbfile(self.dbconn,unefp,nome)
self.messages.append('%s masterlamp %s was created and inserted in the calibration database.' % (unefp,str(os.path.basename(nome))))
#db.insert_dbfile(self.dbconn,unefp,self.mlamp)
#self.messages.append('%s masterlamp %s was created and inserted in the calibration database.' % (unefp,str(os.path.basename(self.mlamp))))
else:
self.messages.append('There are no available %s lamps. The reference lamp will be taken from the calibration database.' % (unefp))
self.messages.append('There are no useful %s lamps. The reference lamp will be taken from the calibration database.' % (unefp))
if db.check_dbfile(self.dbconn,unefp):
try:
db.copy_dbfile(self.dbconn,unefp)
self.mlamp = db.extract_dbfile(self.dbconn,unefp)
except:
self.messages.append('There are no %s lamps in the calibration database.' %(unefp))
return False
......@@ -160,7 +165,8 @@ class GBWls():
def extract(self,unefp):
# straighten the lamp's orders
lamp = db.extract_dbfile(self.dbconn,unefp)
# lamp = db.extract_dbfile(self.dbconn,unefp)
lamp = self.mlamp
#print lamp
straight = lamp.replace('.fits','_str.fits')
......@@ -180,18 +186,19 @@ class GBWls():
pass
if dy:
shift = db.extract_dbfile(self.dbconn,'shiftY')
if not shift:
cal_flat = db.extract_dbfile(self.dbconn,'flat')
if cal_flat:
try:
shift = db.extract_dbfile(self.dbconn,'shiftY')
except:
try:
cal_flat = db.extract_dbfile(self.dbconn,'flat')
mflat = ccdproc.CCDData.read(cal_flat, unit=u.adu)
shift = varie.shiftY(mflat.data)
db.insert_dbfile(self.dbconn,'shiftY',shift)
else:
except:
db.copy_dbfile(self.dbconn,'shiftY')
shift = db.extract_dbfile(self.dbconn,'shiftY')
if not shift:
shift = CONFIG['SHIFT_Y']
if not shift:
shift = CONFIG['SHIFT_Y']
shiftY = [''.join(('DY=',str(shift - CONFIG['SHIFT_Y'])))]
#print shiftY
......@@ -204,9 +211,9 @@ class GBWls():
#self.messages.append('%s: orders straightened.' % (str(os.path.basename(lamp))))
strname = '_'.join((unefp,'str'))
db.insert_dbfile(self.dbconn,strname,straight)
self.messages.append('Straightened %s masterlamp %s was created and inserted in the calibration database.' % (unefp,str(os.path.basename(straight))))
#strname = '_'.join((unefp,'str'))
#db.insert_dbfile(self.dbconn,strname,straight)
#self.messages.append('Straightened %s masterlamp %s was created and inserted in the calibration database.' % (unefp,str(os.path.basename(straight))))
wl = ccdproc.CCDData.read(straight, unit=u.adu)
......@@ -233,6 +240,12 @@ class GBWls():
keyfail = ''.join((CONFIG['CAL_FAILED'][0],str(x+32)))
if calib_failed:
if self.quality[0] == 'OK':
self.quality = ['FAILED' for q in self.quality]
#db.remove_dbfile(CONFIG['DATE'],'UNE')
#return
wl.header[keyfail] = (False,CONFIG['CAL_FAILED'][1])
self.messages.append(' *** WARNING ***')
self.messages.append('The default wavelength calibration for the order %s will be taken from the database and as such it will not be optimal for the night.' % str(x+32))
......@@ -299,9 +312,24 @@ class GBWls():
red_extr = os.path.join(CONFIG['RED_CALIB'],os.path.basename(extracted))
shutil.copyfile(extracted,red_extr)
calname = '_'.join((unefp,'calib'))
db.insert_dbfile(self.dbconn,calname,extracted)
self.messages.append('%s wavelength calibration %s was created and inserted in the calibration database.' % (unefp,str(os.path.basename(extracted))))
if self.quality[0] == 'OK':
db.insert_dbfile(self.dbconn,unefp,self.mlamp)
self.messages.append('%s masterlamp %s was created and inserted in the calibration database.' % (unefp,str(os.path.basename(self.mlamp))))
strname = '_'.join((unefp,'str'))
db.insert_dbfile(self.dbconn,strname,straight)
self.messages.append('Straightened %s masterlamp %s was created and inserted in the calibration database.' % (unefp,str(os.path.basename(straight))))
calname = '_'.join((unefp,'calib'))
db.insert_dbfile(self.dbconn,calname,extracted)
self.messages.append('%s wavelength calibration %s was created and inserted in the calibration database.' % (unefp,str(os.path.basename(extracted))))
else:
os.remove(self.mlamp)
os.remove(straight)
os.remove(extracted)
wlextract = None
ordini = None
......
......@@ -7,8 +7,8 @@ Usage:
gofioDRS.py [-g=<config>]
gofioDRS.py <date> [-g=<config>]
gofioDRS.py <date> <calib_date> [-g=<config>]
gofioDRS.py <date> [--dark --flat --une --fp --all_calib --only_calib --use_flat=<flag> --s1d=<s1d>]
gofioDRS.py <date> <calib_date> [--dark --flat --une --fp --all_calib --only_calib --use_flat=<flag> --s1d=<s1d>]
gofioDRS.py <date> [--dark --flat --une --fp --all_calib --only_calib --use_flat=<flag> --s1d=<s1d> --group]
gofioDRS.py <date> <calib_date> [--dark --flat --une --fp --all_calib --only_calib --use_flat=<flag> --s1d=<s1d> --group]
Options:
-h,--help : show this screen
......@@ -27,6 +27,8 @@ Options:
options are global/order/nor/none [Default: order]
--s1d=<s1d> : s1d outputs are created, either normalized or not
options are yes/no/norm [Default: yes]
--group : group reduction of all the images of the same
observing block
"""
......@@ -85,6 +87,7 @@ def run_gofio(CONFIG, rawlists, dbcalib, working, group, stop, drslogger, dbnigh
while raws:
if CONFIG['OFFLINE']:
working, group, go, do_calib, rawlists = gofio.GianoBreduce(raws[0], rawlists, dbcalib, working, group, do_calib, stop, drslogger, dbnight)
#print rawlists
if go:
raws.pop(0)
#raws.pop(0)
......@@ -105,6 +108,9 @@ def run_gofio(CONFIG, rawlists, dbcalib, working, group, stop, drslogger, dbnigh
time.sleep(1)
if CONFIG['OFFLINE']:
if rawlists[CONFIG['SCIENCE']] and group['nodstare'] == CONFIG['STAREVALUE']:
gofio.GianoBreduce(None, rawlists, dbcalib, working, group, do_calib, stop, drslogger, dbnight)
drslogger.log('No more files to reduce.')
dbcalib.close()
try: os.remove(CONFIG['MASK_C'])
......@@ -124,6 +130,11 @@ def run_gofio(CONFIG, rawlists, dbcalib, working, group, stop, drslogger, dbnigh
if db.check_raw(dbramps,raws[n]):
gofio.GianoBreduce(raws[n], rawlists, dbcalib, working, group, do_calib, stop, drslogger, dbnight)
break
if not raws:
if rawlists[CONFIG['SCIENCE']] and group['nodstare'] == CONFIG['STAREVALUE']:
gofio.GianoBreduce(None, rawlists, dbcalib, working, group, do_calib, stop, drslogger, dbnight)
try: os.remove(CONFIG['MASK_C'])
except: pass
drslogger.log('Pipeline stopped.')
......
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