metadata.py 2.81 KB
Newer Older
Andrea Bignamini's avatar
Andrea Bignamini 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
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