config.py 16.6 KB
Newer Older
Monica Rainer's avatar
Monica Rainer committed
1 2 3 4 5 6 7
"""
Written by Avet Harutyunyan for the old GIANO pipeline
Implemented in the GIANOB DRS by Monica Rainer
"""

import os, tempfile, datetime
from collections import OrderedDict
Monica Rainer's avatar
Monica Rainer committed
8
from __version__ import __version__
Monica Rainer's avatar
Monica Rainer committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44


def getdate(date_time=None):
    tlimit = datetime.time(9, 0, 0)
    oneday = datetime.timedelta(days=1)
    if date_time:
        if isinstance(date_time, datetime.datetime):
            pass
        elif isinstance(date_time, basestring): 
            date_time = datetime.datetime.strptime(date_time, '%Y-%m-%dT%H:%M:%S.%f')
    else:
        date_time = datetime.datetime.utcnow()
    date_, time_ = date_time.date(), date_time.time()
    if time_ < tlimit:
        date_ = date_ - oneday
    return date_.strftime('%Y-%m-%d')


def read_usr_config(path):
    f = open(path, 'r')
    cntnt = f.readlines()
    f.close()
    usrconfig = {}
    for aline in cntnt:
        aline = aline.strip()
        #print aline
        if aline:
            if aline[0] != '#':
                key, value = aline.split(':::')
                #print key
                #print value
                usrconfig[key.strip()] = eval(value.strip())
    return usrconfig

usr_cfg_path = os.path.join(os.getcwd(), 'gofio.cfg')
if os.path.isfile(usr_cfg_path):
Monica Rainer's avatar
Monica Rainer committed
45
    #print 'qui'
Monica Rainer's avatar
Monica Rainer committed
46 47 48 49 50
    try:
        USRCONFIG = read_usr_config(usr_cfg_path)
    except:
        USRCONFIG = {}
        USRCONFIG['OFFLINE'] = False
Monica Rainer's avatar
Monica Rainer committed
51
    #print USRCONFIG
Monica Rainer's avatar
Monica Rainer committed
52
else:
Monica Rainer's avatar
Monica Rainer committed
53
    #print 'qui2'
Monica Rainer's avatar
Monica Rainer committed
54 55
    USRCONFIG ={}
    USRCONFIG['OFFLINE'] = False
Monica Rainer's avatar
Monica Rainer committed
56
#print USRCONFIG
Monica Rainer's avatar
Monica Rainer committed
57 58 59 60 61 62 63 64


#
# pipeline configuration
#

CONFIG = {}
CONFIG['APPNAME'] = 'GOFIO'
Monica Rainer's avatar
Monica Rainer committed
65 66
#CONFIG['VERSION'] = 1.0
CONFIG['VERSION'] = __version__
Monica Rainer's avatar
Monica Rainer committed
67 68 69 70 71 72 73 74 75
CONFIG['DATE'] = getdate()
CONFIG['OFFLINE'] = False

#
# Directories 
#

CONFIG['TMP_DIR'] = tempfile.gettempdir()
CONFIG['APP_DIR'] = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
76

Monica Rainer's avatar
Monica Rainer committed
77
#CONFIG['BASE_RAW'] = '/mnt/nfs/RAW'
Monica Rainer's avatar
Monica Rainer committed
78
CONFIG['BASE_RAW'] = '/Users/monica/Documents/GOFIO/gofio/raw'
Monica Rainer's avatar
Monica Rainer committed
79 80
CONFIG['BASE_RED_DIR'] = os.path.join(CONFIG['APP_DIR'],'reduced')
#CONFIG['BASE_RED_DIR'] = '/mnt/nfs/REDUCED'
Monica Rainer's avatar
Monica Rainer committed
81

82 83 84
CONFIG['BASE_RAMP'] = '/home/avet/gianorp/databases'


Monica Rainer's avatar
Monica Rainer committed
85 86
CONFIG['RAW_DIR'] = os.path.join(CONFIG['BASE_RAW'],CONFIG['DATE'])
CONFIG['RED_DIR'] = os.path.join(CONFIG['BASE_RED_DIR'],CONFIG['DATE'])
Monica Rainer's avatar
Monica Rainer committed
87
CONFIG['OFFLINE_DIR'] = False
Monica Rainer's avatar
Monica Rainer committed
88 89 90 91 92 93 94
CONFIG['RED_CALIB'] = os.path.join(CONFIG['RED_DIR'],'CALIB')
CONFIG['RED_STR'] = os.path.join(CONFIG['RED_DIR'],'STR')

# Resources

CONFIG['RES_DIR']      = os.path.join(CONFIG['APP_DIR'], 'resources')
CONFIG['BADPIX_MASK']  = os.path.join(CONFIG['RES_DIR'], 'badpix_mask.fits')
95
CONFIG['LOGGER'] = {'TERM':True,'FILE':True} # logger writes to terminal and/or to file
Monica Rainer's avatar
Monica Rainer committed
96 97
CONFIG['LOG_FILE'] = os.path.join(CONFIG['RED_DIR'], 'drs.log')
CONFIG['STRAIGHT'] = os.path.join(CONFIG['RES_DIR'],'straight_giano_2D')
98 99
CONFIG['STRAIGHT_OPT'] = ['I=1'] # the option DY is computed automatically
#CONFIG['STRAIGHT_OPT'] = ['I=1','DY=-5'] # define DY only if you want to override the automatic procedure
Monica Rainer's avatar
Monica Rainer committed
100 101 102
CONFIG['BASE_CALIB_DIR']    = os.path.join(CONFIG['APP_DIR'], 'calibrations')
CONFIG['CALIB_DIR']    = os.path.join(CONFIG['BASE_CALIB_DIR'], 'calfiles')
CONFIG['CALIB_DB_DIR']    = os.path.join(CONFIG['BASE_CALIB_DIR'], 'database')
Monica Rainer's avatar
Monica Rainer committed
103
CONFIG['WEBUI_DB_DIR'] = os.path.join(CONFIG['APP_DIR'], 'webuidatabases')
Monica Rainer's avatar
Monica Rainer committed
104

105 106 107 108 109
# Output name

CONFIG['MERGED'] = 's1d' # suffix for merged spectra
CONFIG['UNMERGED'] = 'ms1d' # suffix for unmerged spectra

Monica Rainer's avatar
Monica Rainer committed
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
#
# Header configuration 
#

# 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' }


# Values of the keyword:
# CONFIG['OBSTYPE'] keyword values to determine the nature of the files
CONFIG['DARK'] = 'DARK'
CONFIG['FLAT'] = 'FLAT'
CONFIG['WCAL_UNE'] = 'WCAL_UNE'
CONFIG['WCAL_FP'] = 'WCAL_FP'
Monica Rainer's avatar
Monica Rainer committed
125
#CONFIG['WCAL_FP'] = 'WCAL_LFC'
Monica Rainer's avatar
Monica Rainer committed
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
CONFIG['SCIENCE'] = 'SCIENCE'
# CONFIG['NODSTARE'] keyword values to determine if stare or nodding
CONFIG['NODVALUE'] = 'GIANO_sci_nodding'
CONFIG['STAREVALUE'] = 'GIANO_sci_stare'
# 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
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['EXTMODE'] keyword values to determine to extraction mode
CONFIG['EXTPAIR'] = 'PAIR_EXT'
CONFIG['EXTAVG'] = 'GRPAVG_EXT'
CONFIG['EXTDEFAULT'] = CONFIG['EXTAVG']
# CONFIG['TARG_TYPE'] keyword values to determine type of object (science, telluric, ...) 
CONFIG['TELLURIC'] = 'TELLURIC'
CONFIG['FASTROT'] = 'FASTROT'
CONFIG['TYPE_SCIENCE'] = 'SCIENCE'

#
# Keywords added by the DRS, with relative comments
#
CONFIG['KEY_DRS'] = 'HIERARCH TNG DRS'
CONFIG['RON_EFF'] = (' '.join((CONFIG['KEY_DRS'],'RON')),'Effective RON after image reduction')
CONFIG['GAIN_EFF'] = (' '.join((CONFIG['KEY_DRS'],'GAIN')),'Effective gain after image reduction')
CONFIG['TEXP_EFF'] = (' '.join((CONFIG['KEY_DRS'],'EXPTIME')),'Effective exposure time after image reduction')
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'))) ])
Monica Rainer's avatar
Monica Rainer committed
157
CONFIG['DRS_MJD'] = (' '.join((CONFIG['KEY_DRS'],'MJD')),'MJD of the (combined) image')
Monica Rainer's avatar
Monica Rainer committed
158
CONFIG['BERV'] = (' '.join((CONFIG['KEY_DRS'],'BERV')),'Barycentric correction [km/s]')
Monica Rainer's avatar
Monica Rainer committed
159 160
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')
Monica Rainer's avatar
Monica Rainer committed
161
CONFIG['AIRMASS'] = (' '.join((CONFIG['KEY_DRS'],'AIRMASS')),'Airmass of the combined image')
162 163
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')
164
CONFIG['KEY_WEXT'] = (' '.join((CONFIG['KEY_DRS'],'WEXT')),'Standard extraction window [pixel]')
Monica Rainer's avatar
Monica Rainer committed
165 166
CONFIG['DRS_VERSION'] = (' '.join((CONFIG['KEY_DRS'],'VERSION')),'GOFIO version')

Monica Rainer's avatar
Monica Rainer committed
167

168
# Wavelength calibration
Monica Rainer's avatar
Monica Rainer committed
169 170
CONFIG['CAL_FUNC'] = {'Oliva':True, 'Poly3':False} # function used for wavelength calibration (Tino Oliva Polynomial or 3-degree polynomial)
#CONFIG['CAL_FUNC'] = {'Oliva':False, 'Poly3':True}
Monica Rainer's avatar
Monica Rainer committed
171 172
CONFIG['CAL_FAILED'] = (' '.join((CONFIG['KEY_DRS'],'CAL ORDER')),'Calibration successful')

173 174 175 176
CONFIG['WLFIT'] = (' '.join((CONFIG['KEY_DRS'],'CAL WLFUNC')),'Function used for wavelength calibration')

if CONFIG['CAL_FUNC']['Oliva']:
    CONFIG['WLFIT_FUNC'] = 'l0 + k1*(x-xc) + k2*(x-xc)**2 + k3*(x-xc)**3'
Monica Rainer's avatar
Monica Rainer committed
177

178 179 180 181 182
else:
    CONFIG['WLFIT_FUNC'] = 'c0 + c1*x + c2*x**2 + c3*x**3'

CONFIG['WLCOEFFS'] = {'k1':(' '.join((CONFIG['KEY_DRS'],'CAL K1')),'k1 coefficient of the calibration function'),'k2':(' '.join((CONFIG['KEY_DRS'],'CAL K2')),'k2 coefficient of the calibration function'),'k3':(' '.join((CONFIG['KEY_DRS'],'CAL K3')),'k3 coefficient of the calibration function'),'l0':(' '.join((CONFIG['KEY_DRS'],'CAL L0')),'l0 coefficient of the calibration function'),'xc':(' '.join((CONFIG['KEY_DRS'],'CAL XC')),'xc coefficient of the calibration function'),'rms':(' '.join((CONFIG['KEY_DRS'],'CAL RMSE')),'[m/s] RMS error of the calibration'), 'c0':(' '.join((CONFIG['KEY_DRS'],'CAL C0')),'c0 coefficient of the calibration function'),'c1':(' '.join((CONFIG['KEY_DRS'],'CAL C1')),'c1 coefficient of the calibration function'),'c2':(' '.join((CONFIG['KEY_DRS'],'CAL C2')),'c2 coefficient of the calibration function'),'c3':(' '.join((CONFIG['KEY_DRS'],'CAL C3')),'c3 coefficient of the calibration function'),'rms_poly':(' '.join((CONFIG['KEY_DRS'],'CAL RMSE')),'[m/s] RMS error of the calibration')}

Monica Rainer's avatar
Monica Rainer committed
183 184 185 186 187 188 189 190 191 192 193 194 195
#
# DB configuration 
#
# Ramp processor database
CONFIG['RAMP_NAME'] = 'ramps' + CONFIG['DATE'] + '.db'
CONFIG['DB_RAMP'] = os.path.join(CONFIG['BASE_RAMP'],CONFIG['RAMP_NAME'])
CONFIG['DB_RAMP_TBL'] = 'reducedramps'
CONFIG['DB_RAMP_COLS'] = {'fpath':'FPATH' , 'obstype':'OBSTYPE' , 'dateobs':'DATEOBS' , 'object' : 'OBJECT' , 'exptime':'EXPTIME' , 'nodstare':'NODSTARE' , 'slitpos':'SLITPOS' , 'groupi':'GROUPI' , 'groupn':'GROUPN'}

# Calibration database
CONFIG['DB_CALIB'] = 'drs_calib.db'
CONFIG['DB_CALIB_PATH'] = os.path.join(CONFIG['CALIB_DB_DIR'], CONFIG['DB_CALIB'])
CONFIG['DB_CALIB_TBL'] = 'calibrations'
Monica Rainer's avatar
Monica Rainer committed
196

197
CONFIG['DB_CALIB_COLS'] = OrderedDict([('01_data', 'date_calib'), ('dark10', 'masterdark10'), ('dark30', 'masterdark30'), ('dark60', 'masterdark60'), ('dark100', 'masterdark100'),  ('dark200', 'masterdark200'), ('dark300', 'masterdark300'), ('dark600', 'masterdark600'),('flat', 'masterflat'), ('flatstr', 'masterflat_str'), ('flatnor', 'masterflat_nor'), ('shiftY', 'shift_Y') ,('une', 'wl_une'), ('une_str', 'wl_une_str'), ('une_calib', 'wl_une_calib'), ('fp', 'wl_fp'), ('fp_str', 'wl_fp_str'), ('fp_calib','wl_fp_calib')])
Monica Rainer's avatar
Monica Rainer committed
198

Monica Rainer's avatar
Monica Rainer committed
199 200 201 202
CONFIG['DB_CALIB_DATATYPE'] = OrderedDict()
for colname in CONFIG['DB_CALIB_COLS']:
    CONFIG['DB_CALIB_DATATYPE'][colname] = 'TEXT' 
CONFIG['DB_CALIB_DATATYPE']['01_data'] = 'TEXT unique'
203
CONFIG['DB_CALIB_DATATYPE']['shiftY'] = 'INTEGER'
Monica Rainer's avatar
Monica Rainer committed
204 205

# Night reduction database
Monica Rainer's avatar
Monica Rainer committed
206 207 208 209 210 211 212 213

CONFIG['DB_ONLINE'] = ''.join(('db_',CONFIG['DATE'],'_online.db'))
CONFIG['DB_OFFLINE'] = ''.join(('db_',CONFIG['DATE'],'_offline.db'))
CONFIG['DB_ONLINE_PATH'] = os.path.join(CONFIG['WEBUI_DB_DIR'], CONFIG['DB_ONLINE'])
CONFIG['DB_OFFLINE_PATH'] = os.path.join(CONFIG['WEBUI_DB_DIR'], CONFIG['DB_OFFLINE'])

CONFIG['DB_2D_TBL'] = 'spec2dfiles'
CONFIG['DB_1D_TBL'] = 'spec1dfiles'
214
CONFIG['DB_CAL_TBL'] = 'calib'
Monica Rainer's avatar
Monica Rainer committed
215 216 217

CONFIG['DB_2D_COLS'] = OrderedDict([('names', 'spec_2d_names'), ('stamp', 'process_timestamp')])
CONFIG['DB_1D_COLS'] = OrderedDict([('path', 'spec_1d_path'), ('stamp', 'process_timestamp'), ('id', 'spec_1d_id'), ('type', 'spec_1d_type'), ('stat', 'arch_stat'), ('name', 'objname'), ('slit', 'slitpos'), ('snry', 'snr1'), ('snrj', 'snr2'), ('snrh', 'snr3'), ('snrk', 'snr4')])
218
CONFIG['DB_CAL_COLS'] = OrderedDict([('type', 'calib_type'), ('names', 'calib_names'), ('status', 'calib_status'), ('stamp', 'process_timestamp')])
Monica Rainer's avatar
Monica Rainer committed
219 220 221

CONFIG['DB_2D_DATATYPE'] = {'names': 'TEXT unique', 'stamp': 'REAL'}
CONFIG['DB_1D_DATATYPE'] = {'path': 'TEXT unique', 'stamp': 'REAL', 'id': 'TEXT', 'type': 'TEXT', 'stat': 'INTEGER', 'name': 'TEXT', 'slit': 'TEXT', 'snry': 'REAL', 'snrj': 'REAL', 'snrh': 'REAL', 'snrk': 'REAL'}
222
CONFIG['DB_CAL_DATATYPE'] = {'type': 'TEXT', 'names': 'TEXT unique', 'status': 'TEXT', 'stamp': 'REAL'}
Monica Rainer's avatar
Monica Rainer committed
223 224 225

CONFIG['DB_NIGHT'] = CONFIG['DB_ONLINE']
CONFIG['DB_NIGHT_PATH'] = CONFIG['DB_ONLINE_PATH']
Monica Rainer's avatar
Monica Rainer committed
226 227 228 229 230 231 232 233 234

#
# Extraction info
#

CONFIG['MASK_C'] = os.path.join(CONFIG['RES_DIR'], 'GIANOB_MASKC.fits')
CONFIG['A_POS'] = 8. # guess pixel position for A
CONFIG['B_POS'] = 23. # guess pixel position for B
CONFIG['C_POS'] = 15. # guess pixel position for C
235
CONFIG['Y_POS'] = 4 # max. pixel difference between expected and real pixel position
Monica Rainer's avatar
Monica Rainer committed
236
CONFIG['HWTM'] = 6. # hwtm limit for contamination between A and B
Monica Rainer's avatar
Monica Rainer committed
237
CONFIG['S1D'] = True # flag for creation of s1d output (True/False)
238
CONFIG['S1D_NORM'] = False # flag for normalization of s1d output (True/False)
239
CONFIG['S1D_STEP'] = 0.001 # constant step to use in s1d spectra
Monica Rainer's avatar
Monica Rainer committed
240 241 242 243 244 245 246 247

#
# Wavelength calibration
#

CONFIG['WAVE_SELECT'] = os.path.join(CONFIG['RES_DIR'], 'UNe_lines_GIANO_selected.txt')
CONFIG['WAVE_ALL'] = os.path.join(CONFIG['RES_DIR'], 'UNe_observed_lines_GIANOB_18nov2016.txt')
CONFIG['WAVE_FIT'] = {'drift':0.0, 'low_fwhm':1.7, 'high_fwhm':4.0, 'wrange1':10, 'confidence1':3, 'wrange2':5, 'confidence2':1.5, 'xc_range':10}
Monica Rainer's avatar
Monica Rainer committed
248
#CONFIG['WAVE_FIT'] = {'drift':0.0, 'low_fwhm':0.5, 'high_fwhm':4.0, 'wrange1':10, 'confidence1':3, 'wrange2':5, 'confidence2':2.5, 'xc_range':10}
Monica Rainer's avatar
Monica Rainer committed
249 250 251 252 253 254 255 256 257
CONFIG['XC_GUESS'] = {32:987, 33:984, 34:982, 35:980, 36:978, 37:976, 38:974, 39:972, 40:970, 41:968, 42:965, 43:963, 44:960, 45:957, 46:955, 47:952, 48:949, 49:946, 50:943, 51:940, 52:937, 53:933, 54:930, 55:927, 56:924, 57:921, 58:918, 59:914, 60:910, 61:907, 62:904, 63:901, 64:898, 65:895, 66:892, 67:889, 68:886, 69:883, 70:880, 71:877, 72:874, 73:871, 74:868, 75:865, 76:862, 77:859, 78:857, 79:855, 80:853, 81:851}
CONFIG['L0_GUESS'] = {32:2398.32, 33:2325.63, 34:2257.24, 35:2192.68, 36:2131.75, 37:2074.09, 38:2019.53, 39:1967.73, 40:1918.56, 41:1871.75, 42:1827.18, 43:1784.70, 44:1744.14, 45:1705.38, 46:1668.31, 47:1632.82, 48:1598.81, 49:1566.20, 50:1534.86, 51:1504.78, 52:1475.85, 53:1448.03, 54:1421.20, 55:1395.38, 56:1370.45, 57:1346.41, 58:1323.22, 59:1300.78, 60:1279.12, 61:1258.15, 62:1237.85, 63:1218.21, 64:1199.17, 65:1180.72, 66:1162.83, 67:1145.47, 68:1128.62, 69:1112.26, 70:1096.36, 71:1080.91, 72:1065.89, 73:1051.28, 74:1037.06, 75:1023.22, 76:1003.74, 77:996.61, 78:983.81, 79:971.34, 80:959.17, 81:947.30}

#
# Misc Calibrations
#

CONFIG['DO_CALIB'] = {'dark':True, 'flat':True, 'une':True, 'fp':True, 'only_calib':False}
#CONFIG['DO_CALIB'] = {'dark':False, 'flat':False, 'une':False, 'fp':False, 'only_calib':False}
Monica Rainer's avatar
Monica Rainer committed
258 259 260

CONFIG['USE_FLAT'] = {'global':False, 'order':True, 'nor':False} # global: flat normalized by global mean value - order: flat normalized order by order by mean value - nor: flat normalized row by row by continuum fitting, removing the blaze function - No True value: no flat division

Monica Rainer's avatar
Monica Rainer committed
261 262 263
CONFIG['DARKLIST'] = {10:[],30:[],60:[],100:[],200:[],300:[],600:[]} # exptime dei dark
CONFIG['NDARK'] = len(CONFIG['DARKLIST']) # quanti tipi di dark (esempio: 10,30,60,100 sec = 4) meglio sovrastimare

Monica Rainer's avatar
Monica Rainer committed
264
CONFIG['WEXT'] = 10 # extraction half-window for wavelength calibration, it will extract 2*wext around the center of the order
Monica Rainer's avatar
Monica Rainer committed
265 266

#
267
# Detector info
Monica Rainer's avatar
Monica Rainer committed
268 269
#

Monica Rainer's avatar
Monica Rainer committed
270 271 272 273
CONFIG['RON'] = 5.0 # electrons
CONFIG['GAIN'] = 2.2 # e/ADU
CONFIG['XCCD'] = 2048
CONFIG['YCCD'] = 2048
Monica Rainer's avatar
Monica Rainer committed
274 275
CONFIG['N_ORD'] = 50 # number of echelle orders
CONFIG['W_ORD'] = 41 # width of straighten order in pixel
276
CONFIG['SHIFT_Y'] = 20 # expected bottom position of flat signal on the lowest order and the left side of the detector. DO NOT CHANGE.
Monica Rainer's avatar
Monica Rainer committed
277 278 279 280 281

#
# Quality checks
#

Monica Rainer's avatar
Monica Rainer committed
282
CONFIG['DARK_MEAN'] = {10:[10.0,10.0,10.0,10.0], 30:[25.0,25.0,25.0,25.0], 60:[50.0,50.0,50.0,50.0], 100:[80.0,80.0,80.0,80.0], 200:[800.0,800.0,800.0,800.0], 300:[800.0,800.0,800.0,800.0], 600:[800.0,800.0,800.0,800.0]} # Dark quality check: mean signal below this number (4 quadrant for 7 exposure time)
Monica Rainer's avatar
Monica Rainer committed
283
CONFIG['FLATSIGNAL'] = 2000 # lowest flat signal expected to pass quality check
Monica Rainer's avatar
Monica Rainer committed
284 285 286 287 288
CONFIG['SCIENCECHECK'] = [500,540,140,160] # region x1:x2,y1:y2 for images' quality check
#CONFIG['NODSIGNAL'] = 2*CONFIG['DARK_MEAN']['quadrant'][0] # lowest image signal expected to pass quality check
CONFIG['NODSIGNAL'] = 0.0 # lowest image signal expected to pass quality check


Monica Rainer's avatar
Monica Rainer committed
289
# radial velocity computation configuration
Unknown's avatar
Unknown committed
290
# TO DO
Monica Rainer's avatar
Monica Rainer committed
291

Monica Rainer's avatar
Monica Rainer committed
292

Monica Rainer's avatar
Monica Rainer committed
293 294 295
#if USRCONFIG['OFFLINE']:
#    for key in USRCONFIG.keys():
#        CONFIG[key] = USRCONFIG[key]
Monica Rainer's avatar
Monica Rainer committed
296

Monica Rainer's avatar
Monica Rainer committed
297 298 299 300 301 302 303 304
#    CONFIG['RAW_DIR'] = os.path.join(CONFIG['BASE_RAW'],CONFIG['DATE'])
#    CONFIG['OFFLINE_DIR'] = os.path.join(CONFIG['BASE_RED_DIR'],CONFIG['DATE'])
#    CONFIG['RED_DIR'] = os.path.join(CONFIG['OFFLINE_DIR'],'offline')
#    CONFIG['RED_CALIB'] = os.path.join(CONFIG['RED_DIR'],'CALIB')
#    CONFIG['RED_STR'] = os.path.join(CONFIG['RED_DIR'],'STR')
#    CONFIG['LOG_FILE'] = os.path.join(CONFIG['RED_DIR'], 'drs.log')
#    CONFIG['RAMP_NAME'] = 'ramps' + CONFIG['DATE'] + '.db'
#    CONFIG['DB_RAMP'] = os.path.join(CONFIG['BASE_RAMP'],CONFIG['RAMP_NAME'])
Monica Rainer's avatar
Monica Rainer committed
305

Monica Rainer's avatar
Monica Rainer committed
306 307 308 309
#    CONFIG['DB_OFFLINE'] = ''.join(('db_',CONFIG['DATE'],'_offline.db'))
#    CONFIG['DB_OFFLINE_PATH'] = os.path.join(CONFIG['WEBUI_DB_DIR'], CONFIG['DB_OFFLINE'])
#    CONFIG['DB_NIGHT'] = CONFIG['DB_OFFLINE']
#    CONFIG['DB_NIGHT_PATH'] = CONFIG['DB_OFFLINE_PATH']
Monica Rainer's avatar
Monica Rainer committed
310

Monica Rainer's avatar
Monica Rainer committed
311 312
#    maskc = ''.join(('GIANOB_MASKC_',CONFIG['DATE'],'.fits'))
#    CONFIG['MASK_C'] = os.path.join(CONFIG['RES_DIR'], maskc)
Monica Rainer's avatar
Monica Rainer committed
313

Monica Rainer's avatar
Monica Rainer committed
314