config.py 18.9 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
"""
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
from __version__ import __version__


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


#
# pipeline configuration
#

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

#CONFIG['BASE_RAW'] = '/mnt/nfs/RAW'
CONFIG['BASE_RAW'] = '/Users/monica/Documents/gofio/gofio3/raw'
CONFIG['BASE_RED_DIR'] = os.path.join(CONFIG['APP_DIR'],'reduced')
#CONFIG['BASE_RED_DIR'] = '/mnt/nfs/REDUCED'

CONFIG['BASE_RAMP'] = '/home/avet/gianorp/databases'


CONFIG['RAW_DIR'] = os.path.join(CONFIG['BASE_RAW'],CONFIG['DATE'])
CONFIG['RED_DIR'] = os.path.join(CONFIG['BASE_RED_DIR'],CONFIG['DATE'])
CONFIG['OFFLINE_DIR'] = False
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')
CONFIG['LOGGER'] = {'TERM':True,'FILE':True} # logger writes to terminal and/or to file
CONFIG['LOG_FILE'] = os.path.join(CONFIG['RED_DIR'], 'drs.log')
CONFIG['STRAIGHT'] = os.path.join(CONFIG['RES_DIR'],'straight_giano_2D')
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
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')
CONFIG['WEBUI_DB_DIR'] = os.path.join(CONFIG['APP_DIR'], 'webuidatabases')

# Output name

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

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



# 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'
#CONFIG['WCAL_FP'] = 'WCAL_LFC'
CONFIG['SCIENCE'] = 'SCIENCE'
# CONFIG['NODSTARE'] keyword values to determine if stare or nodding
#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
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['EXTPAIR']
# 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')),'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')),'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')
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')
CONFIG['YPOS'] = (' '.join((CONFIG['KEY_DRS'],'SIGNAL_POS')),'Pixel position of the signal maximum on the slit') # stare images
CONFIG['YPOS_LOW'] = (' '.join((CONFIG['KEY_DRS'],'SIGNAL_LOW')),'Lower pixel position of the signal on the slit') # stare images
CONFIG['YPOS_UP'] = (' '.join((CONFIG['KEY_DRS'],'SIGNAL_UP')),'Upper pixel position of the signal on the slit') # stare images
CONFIG['AYPOS'] = (' '.join((CONFIG['KEY_DRS'],'ASIGNAL_POS')),'Pixel position of the A signal maximum on the slit') # nodding images
CONFIG['AYPOS_LOW'] = (' '.join((CONFIG['KEY_DRS'],'ASIGNAL_LOW')),'Lower pixel position of the A signal on the slit') # nodding images
CONFIG['AYPOS_UP'] = (' '.join((CONFIG['KEY_DRS'],'ASIGNAL_UP')),'Upper pixel position of the A signal on the slit') # nodding images
CONFIG['BYPOS'] = (' '.join((CONFIG['KEY_DRS'],'BSIGNAL_POS')),'Pixel position of the B signal maximum on the slit') # nodding images
CONFIG['BYPOS_LOW'] = (' '.join((CONFIG['KEY_DRS'],'BSIGNAL_LOW')),'Lower pixel position of the B signal on the slit') # nodding images
CONFIG['BYPOS_UP'] = (' '.join((CONFIG['KEY_DRS'],'BSIGNAL_UP')),'Upper pixel position of the B signal on the slit') # nodding images


# Wavelength calibration
CONFIG['CAL_FUNC'] = {'Oliva':True, 'Poly3':False, 'Poly4':False} # function used for wavelength calibration (Tino Oliva Polynomial or 3-degree polynomial)
#CONFIG['CAL_FUNC'] = {'Oliva':False, 'Poly3':False, 'Poly4':True}
CONFIG['CAL_FAILED'] = (' '.join((CONFIG['KEY_DRS'],'CAL ORDER')),'Calibration successful')

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'

if CONFIG['CAL_FUNC']['Poly3']:
    CONFIG['WLFIT_FUNC'] = 'c0 + c1*x + c2*x**2 + c3*x**3'

else:
    CONFIG['WLFIT_FUNC'] = 'c0 + c1*x + c2*x**2 + c3*x**3 + c4*x**4'

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'),'c4':(' '.join((CONFIG['KEY_DRS'],'CAL C4')),'c4 coefficient of the calibration function'),'rms_poly':(' '.join((CONFIG['KEY_DRS'],'CAL RMSE')),'[m/s] RMS error of the calibration')}

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

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

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'
CONFIG['DB_CALIB_DATATYPE']['shiftY'] = 'INTEGER'

# Night reduction database

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'
CONFIG['DB_CAL_TBL'] = 'calib'

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')])
CONFIG['DB_CAL_COLS'] = OrderedDict([('type', 'calib_type'), ('names', 'calib_names'), ('status', 'calib_status'), ('stamp', 'process_timestamp')])

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'}
CONFIG['DB_CAL_DATATYPE'] = {'type': 'TEXT', 'names': 'TEXT unique', 'status': 'TEXT', 'stamp': 'REAL'}

CONFIG['DB_NIGHT'] = CONFIG['DB_ONLINE']
CONFIG['DB_NIGHT_PATH'] = CONFIG['DB_ONLINE_PATH']

#
# 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
CONFIG['Y_POS'] = 7 # max. pixel difference between expected and real pixel position
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
#

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

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

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

CONFIG['WEXT'] = 10 # extraction half-window for wavelength calibration, it will extract 2*wext around the center of the order

#
# Detector info
#

CONFIG['RON'] = 5.0 # electrons
CONFIG['GAIN'] = 2.2 # e/ADU
CONFIG['XCCD'] = 2048
CONFIG['YCCD'] = 2048
CONFIG['N_ORD'] = 50 # number of echelle orders
CONFIG['W_ORD'] = 41 # width of straighten order in pixel
CONFIG['SHIFT_Y'] = 20 # expected bottom position of flat signal on the lowest order and the left side of the detector. DO NOT CHANGE.

#
# Quality checks
#

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)
CONFIG['FLATSIGNAL'] = 2000 # 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


#
# Miscellaneous
#

CONFIG['LEAP_UPDATE'] = True # Used by baycorrpy to update the leapsecond. Set to False if the online table are not available



# radial velocity computation configuration
# TO DO


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

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

#    maskc = ''.join(('GIANOB_MASKC_',CONFIG['DATE'],'.fits'))
#    CONFIG['MASK_C'] = os.path.join(CONFIG['RES_DIR'], maskc)