Commit daa2623c authored by Monica Rainer's avatar Monica Rainer
Browse files

Merge branch 'master' into develop

parents d58855b8 8aa37a4f
No preview for this file type
GOFIO DRS
Language: Python 2.7, one subroutine in Fortran77
If you use this software, please reference the following paper:
Rainer M., et al., 2018, Proc.SPIE 10702, 1070266
"Introducing GOFIO: a DRS for the GIANO-B near-infrared spectrograph",
https://doi.org/10.1117/12.2312130
Python packages:
- AstroPy v1.3
- ccdproc v1.2 (a sub-package of AstroPy)
......
......@@ -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['KEY_WEXT'] = (' '.join((CONFIG['KEY_DRS'],'WEXT')),'Standard extraction window [pixel]')
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
......@@ -241,6 +245,7 @@ CONFIG['HWTM'] = 6. # hwtm limit for contamination between A and B
CONFIG['S1D'] = True # flag for creation of s1d output (True/False)
CONFIG['S1D_NORM'] = False # flag for normalization of s1d output (True/False)
CONFIG['S1D_STEP'] = 0.001 # constant step to use in s1d spectra
CONFIG['NCOSMIC'] = 20 # NCOSMIC+1 is maximum number of cosmic/outliers to be removed for each orders
#
# Wavelength calibration
......
......@@ -15,6 +15,7 @@ from astropy.utils.exceptions import AstropyWarning
from ccdproc import CCDData, Combiner
from drslib.config import CONFIG
from drslib import db
from drslib import metadata
import numpy as np
import os, shutil
......@@ -105,6 +106,10 @@ class GBDarks():
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)
mdark = fits.HDUList([hdu])
......
......@@ -112,6 +112,31 @@ def remove_dbfile(night,cal=False):
return
def remove_dbfile1(file1):
"""
Removes all instances of a specific calibration file from the database and
from the calibrations directory.
Requires as input the name of the file to be removed
How to call from gofio directory:
from drslib.db import remove_dbfile1
remove_dbfile('filename')
"""
filename = os.path.splitext(os.path.basename(file1))[0]
filename = ''.join(['%',filename,'%'])
dbcalib = sqlite3.connect(CONFIG['DB_CALIB_PATH'])
cursor = dbcalib.cursor()
#print CONFIG['DB_CALIB_COLS']
for colname in CONFIG['DB_CALIB_COLS'].values():
cursor.execute("UPDATE {table} SET {calib}=NULL WHERE {calib} LIKE ?"\
.format(table='calibrations',calib=colname),(filename,))
dbcalib.commit()
return
# ---------- OPERATIONS: calibration database -----------------
......
......@@ -21,6 +21,7 @@ from astropy.utils.exceptions import AstropyWarning
import ccdproc
from drslib.config import CONFIG
from drslib import db, varie
from drslib import metadata
import numpy as np
import math, os, subprocess, shutil
......@@ -159,6 +160,9 @@ class GBFlats():
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)
masterflat = fits.HDUList([hdu])
masterflat.writeto(nome,clobber=True)
......@@ -201,9 +205,41 @@ class GBFlats():
shiftY = varie.shiftY(mflat.data)
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
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):
"""
Straighten the masterflat, normalize it and create the masked array
......@@ -245,13 +281,22 @@ class GBFlats():
#print 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.')
db.insert_dbfile(self.dbconn,'flatstr',straight)
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
norflat = np.ones((CONFIG['YCCD'],CONFIG['XCCD']), dtype='float32')
......@@ -312,10 +357,20 @@ class GBFlats():
fnor = ccdproc.CCDData(norflat, unit=u.adu)
fnor.header = mflat.header
#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.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))
shutil.copyfile(nor,red_nor)
......
......@@ -9,7 +9,7 @@ from drslib import db, rawfiles, darkframes, flatframes, wlframes, nodding, star
def gofio_init(docopt_args):
if docopt_args['--cfg']:
if docopt_args['--cfg'] or docopt_args['-g']:
try:
USRCFG = read_usr_config(docopt_args['-g'])
except:
......
......@@ -5,6 +5,7 @@ Implemented in the GIANOB DRS by Monica Rainer
import logging
from drslib.config import CONFIG as CFG
from sys import stdout
class DrsLogger():
def __init__(self):
......@@ -29,7 +30,7 @@ class DrsLogger():
def addconsolelogger(self):
"""The logger to the terminal is defined"""
console_handler = logging.StreamHandler()
console_handler = logging.StreamHandler(stream=stdout)
formatter = logging.Formatter(fmt=self.conslogfmt)
console_handler.setFormatter(formatter)
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
......@@ -10,9 +10,7 @@ Reduction of the single AB nodding:
- use the optimal profiles with UNe lamp and do wavelength calibration of A-B and B-A
- save A, B and the average of A+B
Reduction of the nodding group:
- average the A noddings
- average the B noddings
- create average nodding A-B
- average the A-B noddings
- straigthen the average nodding
- divide by the masterflat (if required)
- perform optimal extraction of A-B and B-A
......@@ -23,6 +21,7 @@ Reduction of the nodding group:
from drslib.config import CONFIG
from drslib import db, varie
from drslib import metadata
from astropy import units as u
from astropy.io import ascii, fits
......@@ -84,14 +83,10 @@ class GBNodding():
return True
def createAB(self):
def create_nodcorr(self):
"""
Create nodding images A-B and save them in temporary directory if
the keyword SPEXTMODE is set to GRPAVG_EXT.
Create nodcorr
"""
hea = self.nodlist[0].header
badpix = ccdproc.CCDData.read(CONFIG['BADPIX_MASK'], unit=u.adu)
bad_mask=badpix.data
inverse_mask=np.logical_not(bad_mask)
......@@ -108,6 +103,46 @@ class GBNodding():
self.nodcorr[nod.header[CONFIG['KEYS']['SLIT']]] = nod_corr
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
nodA = self.nodcorr[CONFIG['A']]
......@@ -201,8 +236,13 @@ class GBNodding():
shift = varie.shiftY(mflat.data)
db.insert_dbfile(self.dbconn,'shiftY',shift)
except:
db.copy_dbfile(self.dbconn,'shiftY')
shift = db.extract_dbfile(self.dbconn,'shiftY')
try:
db.copy_dbfile(self.dbconn,'shiftY')
shift = db.extract_dbfile(self.dbconn,'shiftY')
except:
shift = CONFIG['SHIFT_Y']
self.messages.append('No flat-field or shift value present in the calibration database, no shift will be applied.')
if not shift:
shift = CONFIG['SHIFT_Y']
......@@ -212,17 +252,28 @@ class GBNodding():
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))
try: shutil.copyfile(straight,str_file)
except: pass
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
for key in CONFIG['STRAIGHT_PAR']:
hea_ima[CONFIG['STRAIGHT_PAR'][key]] = imstr.header[CONFIG['STRAIGHT_PAR'][key]]
imflat = imstr.data
imflat = imstr.data.copy()
# read the number of images averaged to obtain the current image
# in order to compute the SNR
......@@ -236,11 +287,19 @@ class GBNodding():
try:
masterflat = db.extract_dbfile(self.dbconn,'flatstr')
except:
masterflat = False
if not masterflat:
db.copy_dbfile(self.dbconn,'flatstr')
masterflat = db.extract_dbfile(self.dbconn,'flatstr')
self.messages.append('No masterflat found for this night, it will be taken from the calibration database: %s' % (os.path.basename(masterflat)))
# masterflat = False
# if not masterflat:
# db.copy_dbfile(self.dbconn,'flatstr')
# masterflat = db.extract_dbfile(self.dbconn,'flatstr')
# self.messages.append('No masterflat found for this night, it will be taken from the calibration database: %s' % (os.path.basename(masterflat)))
try:
db.copy_dbfile(self.dbconn,'flatstr')
masterflat = db.extract_dbfile(self.dbconn,'flatstr')
self.messages.append('No masterflat found for this night, it will be taken from the calibration database: %s' % (os.path.basename(masterflat)))
except:
self.messages.append('No masterflat found in the calibration database, it is not possible to identify the orders. The spectra will not be reduced.')
return
mflat = ccdproc.CCDData.read(masterflat, unit=u.adu)
varie.buildMaskC(mflat.data)
self.messages.append('The extraction mask was created.')
......@@ -310,13 +369,22 @@ class GBNodding():
try:
masterlamp = db.extract_dbfile(self.dbconn,'une_str')
except:
masterlamp = False
# masterlamp = False
#
# if not masterlamp:
# db.copy_dbfile(self.dbconn,'une_str')
# masterlamp = db.extract_dbfile(self.dbconn,'une_str')
# db.copy_dbfile(self.dbconn,'une_calib')
# self.messages.append('No calibration lamp found for this night, it will be taken from the calibration database: %s' % (os.path.basename(masterlamp)))
if not masterlamp:
db.copy_dbfile(self.dbconn,'une_str')
masterlamp = db.extract_dbfile(self.dbconn,'une_str')
db.copy_dbfile(self.dbconn,'une_calib')
self.messages.append('No calibration lamp found for this night, it will be taken from the calibration database: %s' % (os.path.basename(masterlamp)))
try:
db.copy_dbfile(self.dbconn,'une_str')
masterlamp = db.extract_dbfile(self.dbconn,'une_str')
db.copy_dbfile(self.dbconn,'une_calib')
self.messages.append('No calibration lamp found for this night, it will be taken from the calibration database: %s' % (os.path.basename(masterlamp)))
except:
self.messages.append('No calibration lamp found in the calibration database, the spectra will not be reduced.')
return
mlamp = ccdproc.CCDData.read(masterlamp, unit=u.adu)
......@@ -330,6 +398,7 @@ class GBNodding():
heacal = OrderedDict()
#stdSpectrum = np.zeros((CONFIG['N_ORD'],CONFIG['YCCD']))
optSpectrum = np.zeros((CONFIG['N_ORD'],CONFIG['YCCD']))
snrSpectrum = np.zeros((CONFIG['N_ORD'],CONFIG['YCCD']))
fsnr = np.zeros((CONFIG['N_ORD'],CONFIG['YCCD']))
snr = np.zeros((CONFIG['N_ORD'],CONFIG['YCCD']))
......@@ -372,6 +441,15 @@ class GBNodding():
extlamp = varie.extract(goodlamp, optSpectrum[x], x1, x2, profile, lgaineff, lroneff)
osnr = imstr.data[start:end]
if slit_pos == CONFIG['B_POS']:
osnr = -osnr
ordersnr = np.ma.MaskedArray(osnr,mask=omask)
goodsnr = np.ma.compress_rows(ordersnr)
snrSpectrum[x] = varie.extract(goodsnr, optSpectrum[x], x1, x2, profile, gaineff, roneff)
if any(CONFIG['USE_FLAT'].values()) is True:
extflat = varie.extract(norflat, optSpectrum[x], x1, x2, profile, fgaineff, froneff)
#print extflat
......@@ -382,13 +460,30 @@ class GBNodding():
fsnr[fsnr==-np.inf] = 0
fsnr = np.nan_to_num(fsnr)
#print fsnr
#osnr = imstr.data[start:end]
#if slit_pos == CONFIG['B_POS']:
# osnr = -osnr
#ordersnr = np.ma.MaskedArray(osnr,mask=omask)
#goodsnr = np.ma.compress_rows(ordersnr)
#snrSpectrum[x] = varie.extract(goodsnr, optSpectrum[x], x1, x2, profile, gaineff, roneff)
with np.errstate(divide='ignore', invalid='ignore'):
#ssnr = (np.sqrt(roneff**2 + (gaineff*nspec*optSpectrum[x])))/(gaineff*nspec*optSpectrum[x])
ssnr = np.true_divide(np.sqrt(roneff**2 + (gaineff*snrSpectrum[x])),gaineff*snrSpectrum[x])
#ssnr = np.true_divide(np.sqrt(np.abs(x2-x1)*roneff**2 + (gaineff*snrSpectrum[x])),gaineff*snrSpectrum[x])
snr[x] = 1.0/(np.sqrt(ssnr**2 + fsnr[x]**2))
else:
fsnr[x] = np.zeros(len(optSpectrum[x]))
with np.errstate(divide='ignore', invalid='ignore'):
#ssnr = (np.sqrt(roneff**2 + (gaineff*nspec*optSpectrum[x])))/(gaineff*nspec*optSpectrum[x])
ssnr = np.true_divide(np.sqrt(roneff**2 + (gaineff*nspec*optSpectrum[x])),gaineff*nspec*optSpectrum[x])
snr[x] = 1.0/(np.sqrt(ssnr**2 + fsnr[x]**2))
with np.errstate(divide='ignore', invalid='ignore'):
#ssnr = np.true_divide(np.sqrt(roneff**2 + (gaineff*nspec*optSpectrum[x])),gaineff*nspec*optSpectrum[x])
ssnr = np.true_divide(np.sqrt(roneff**2 + (gaineff*snrSpectrum[x])) , gaineff*snrSpectrum[x])
snr[x] = 1.0/(np.sqrt(ssnr**2 + fsnr[x]**2))
calib_failed, coeffs, comments = varie.UNe_calibrate(extlamp,x+32,select_lines[x+32],all_lines[x+32])
......@@ -529,6 +624,9 @@ class GBNodding():
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])
prihdu = fits.PrimaryHDU(data=None, header=heaspe)
......@@ -557,6 +655,9 @@ class GBNodding():
heaspe['CTYPE1'] = ('Nanometers','Units of coordinates')
heaspe['BUNIT'] = ('Relative Flux','Units of data values')
# Add metadata to header
heaspe = metadata.add_metadata(heaspe)
s1dfits = fits.PrimaryHDU(s1d,header=heaspe)
calname1d = os.path.join(CONFIG['RED_DIR'],calname1d)
s1dfits.writeto(calname1d,clobber=True)
......@@ -570,15 +671,15 @@ class GBNodding():
#print 's1d spectrum: %s s' % str(t2-t1)
if hea_ima[CONFIG['KEYS']['EXTMODE']] == CONFIG['EXTPAIR']:
return calname, fsnr, straight, dbreduced
return calname, fsnr, straight, dbreduced, snrSpectrum
elif 'grp' in fitsfile:
return calname, fsnr, straight, dbreduced
return calname, fsnr, straight, dbreduced, snrSpectrum
return calname, fsnr, False, dbreduced
return calname, fsnr, False, dbreduced, snrSpectrum
def combine(self,acalib,bcalib,fsnr):
def combine(self,acalib,bcalib,fsnr, asnrSpec, bsnrSpec):
dbreduced = {}
......@@ -631,10 +732,15 @@ class GBNodding():
#bshift = varie.rebin(awaves,bfluxes[o],bwaves,o)
bshift = varie.rebin(abhea,bfluxes[o],bwaves,o)
abcalib[o] = (afluxes[o]+bshift)/2.0
bsnr = varie.rebin(abhea,bsnrSpec[o],bwaves,o)
absnr = (asnrSpec[o]+bsnr)/2.0
#snr.append(max(np.mean(abcalib[o][1000:1050])/np.std(abcalib[o][1000:1050]),0))
with np.errstate(divide='ignore', invalid='ignore'):
#ssnr = (np.sqrt(roneff**2 + (gaineff*2*abcalib[o])))/(gaineff*2*abcalib[o])
ssnr = np.true_divide(np.sqrt(roneff**2 + (gaineff*2*abcalib[o])),gaineff*2*abcalib[o])
#ssnr = np.true_divide(np.sqrt(roneff**2 + (gaineff*2*abcalib[o])),gaineff*2*abcalib[o])
#ssnr = np.true_divide(np.sqrt(roneff**2 + (gaineff*abcalib[o])),gaineff*abcalib[o])
ssnr = np.true_divide(np.sqrt(roneff**2 + (gaineff*absnr)),gaineff*absnr)
snr[o] = 1.0/(np.sqrt(ssnr**2 + fsnr[o]**2))
abcalib = np.asarray(abcalib, dtype='float32')
......@@ -727,6 +833,9 @@ class GBNodding():
heaspe[CONFIG['DRS_VERSION'][0]] = (CONFIG['VERSION'], CONFIG['DRS_VERSION'][1])