config.py 15.7 KB
Newer Older
Monica Rainer's avatar
Monica Rainer committed
1 2 3 4 5 6 7 8 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
"""
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


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):
    try:
        USRCONFIG = read_usr_config(usr_cfg_path)
    except:
        USRCONFIG = {}
        USRCONFIG['OFFLINE'] = False
else:
    USRCONFIG ={}
    USRCONFIG['OFFLINE'] = False


#
# pipeline configuration
#

CONFIG = {}
CONFIG['APPNAME'] = 'GOFIO'
CONFIG['VERSION'] = 1.0
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__)))
70

Monica Rainer's avatar
Monica Rainer committed
71 72 73 74
#CONFIG['BASE_RAW'] = '/mnt/nfs/RAW'
CONFIG['BASE_RAW'] = '/home/monica/Documenti/gianob/gianobdrs/varie/commissioning_marzo/raw'
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
75

76 77 78
CONFIG['BASE_RAMP'] = '/home/avet/gianorp/databases'


Monica Rainer's avatar
Monica Rainer committed
79 80
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
81
CONFIG['OFFLINE_DIR'] = False
Monica Rainer's avatar
Monica Rainer committed
82 83 84 85 86 87 88
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')
89
CONFIG['LOGGER'] = {'TERM':True,'FILE':True} # logger writes to terminal and/or to file
Monica Rainer's avatar
Monica Rainer committed
90 91
CONFIG['LOG_FILE'] = os.path.join(CONFIG['RED_DIR'], 'drs.log')
CONFIG['STRAIGHT'] = os.path.join(CONFIG['RES_DIR'],'straight_giano_2D')
Monica Rainer's avatar
Monica Rainer committed
92 93
#CONFIG['STRAIGHT_OPT'] = ['I=1']
CONFIG['STRAIGHT_OPT'] = ['I=1','DY=-5']
Monica Rainer's avatar
Monica Rainer committed
94 95 96
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
97
CONFIG['WEBUI_DB_DIR'] = os.path.join(CONFIG['APP_DIR'], 'webuidatabases')
Monica Rainer's avatar
Monica Rainer committed
98

99 100 101 102 103
# Output name

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

Monica Rainer's avatar
Monica Rainer committed
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
#
# 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
119
#CONFIG['WCAL_FP'] = 'WCAL_LFC'
Monica Rainer's avatar
Monica Rainer committed
120 121 122 123 124 125 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
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'))) ])
CONFIG['DRS_MJD'] = (' '.join((CONFIG['KEY_DRS'],'MJD')),'MJD of the combined image')
CONFIG['BERV'] = (' '.join((CONFIG['KEY_DRS'],'BERV')),'Barycentric correction [km/s]')
CONFIG['HJD'] = (' '.join((CONFIG['KEY_DRS'],'HJD')),'HJD of the combined image')
CONFIG['AIRMASS'] = (' '.join((CONFIG['KEY_DRS'],'AIRMASS')),'Airmass of the combined image')
155 156
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')
157
CONFIG['KEY_WEXT'] = (' '.join((CONFIG['KEY_DRS'],'WEXT')),'Standard extraction window [pixel]')
Monica Rainer's avatar
Monica Rainer committed
158

159
# Wavelength calibration
Monica Rainer's avatar
Monica Rainer committed
160 161
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}
162 163 164 165
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
166

167 168 169 170 171
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
172 173 174 175 176 177 178 179 180 181 182 183 184
#
# 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
185 186 187

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'), ('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
188 189 190 191 192 193
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'

# Night reduction database
Monica Rainer's avatar
Monica Rainer committed
194 195 196 197 198 199 200 201

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'
202
CONFIG['DB_CAL_TBL'] = 'calib'
Monica Rainer's avatar
Monica Rainer committed
203 204 205

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')])
206
CONFIG['DB_CAL_COLS'] = OrderedDict([('type', 'calib_type'), ('names', 'calib_names'), ('status', 'calib_status'), ('stamp', 'process_timestamp')])
Monica Rainer's avatar
Monica Rainer committed
207 208 209

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'}
210
CONFIG['DB_CAL_DATATYPE'] = {'type': 'TEXT', 'names': 'TEXT unique', 'status': 'TEXT', 'stamp': 'REAL'}
Monica Rainer's avatar
Monica Rainer committed
211 212 213

CONFIG['DB_NIGHT'] = CONFIG['DB_ONLINE']
CONFIG['DB_NIGHT_PATH'] = CONFIG['DB_ONLINE_PATH']
Monica Rainer's avatar
Monica Rainer committed
214 215 216 217 218 219 220 221 222

#
# 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
Monica Rainer's avatar
Monica Rainer committed
223
CONFIG['Y_POS'] = 2 # max. pixel difference between expected and real pixel position
Monica Rainer's avatar
Monica Rainer committed
224
CONFIG['HWTM'] = 6. # hwtm limit for contamination between A and B
Monica Rainer's avatar
Monica Rainer committed
225
CONFIG['S1D'] = True # flag for creation of s1d output (True/False)
226
CONFIG['S1D_NORM'] = False # flag for normalization of s1d output (True/False)
227
CONFIG['S1D_STEP'] = 0.001 # constant step to use in s1d spectra
Monica Rainer's avatar
Monica Rainer committed
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244

#
# 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}
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
245 246 247

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
248 249 250
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
251
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
252 253 254 255 256

#
# CCD info
#

Monica Rainer's avatar
Monica Rainer committed
257 258 259 260
CONFIG['RON'] = 5.0 # electrons
CONFIG['GAIN'] = 2.2 # e/ADU
CONFIG['XCCD'] = 2048
CONFIG['YCCD'] = 2048
Monica Rainer's avatar
Monica Rainer committed
261 262 263 264 265 266 267
CONFIG['N_ORD'] = 50 # number of echelle orders
CONFIG['W_ORD'] = 41 # width of straighten order in pixel

#
# Quality checks
#

Monica Rainer's avatar
Monica Rainer committed
268
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
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
CONFIG['FLATSIGNAL'] = 300 # lowest flat signal expected to pass quality check
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



if USRCONFIG['OFFLINE']:
    for key in USRCONFIG.keys():
        CONFIG[key] = USRCONFIG[key]

    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'])

289 290
    CONFIG['DB_OFFLINE'] = ''.join(('db_',CONFIG['DATE'],'_offline.db'))
    CONFIG['DB_OFFLINE_PATH'] = os.path.join(CONFIG['WEBUI_DB_DIR'], CONFIG['DB_OFFLINE'])
Monica Rainer's avatar
Monica Rainer committed
291 292 293
    CONFIG['DB_NIGHT'] = CONFIG['DB_OFFLINE']
    CONFIG['DB_NIGHT_PATH'] = CONFIG['DB_OFFLINE_PATH']

Monica Rainer's avatar
Monica Rainer committed
294 295 296
    maskc = ''.join(('GIANOB_MASKC_',CONFIG['DATE'],'.fits'))
    CONFIG['MASK_C'] = os.path.join(CONFIG['RES_DIR'], maskc)

Monica Rainer's avatar
Monica Rainer committed
297