dasystem.py 2.4 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
"""CarbonTracker Data Assimilation Shell (CTDAS) Copyright (C) 2017 Wouter Peters. 
Users are recommended to contact the developers (wouter.peters@wur.nl) to receive
updates of the code. See also: http://www.carbontracker.eu. 

This program is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software Foundation, 
version 3. This program is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 

You should have received a copy of the GNU General Public License along with this 
program. If not, see <http://www.gnu.org/licenses/>."""
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
# control.py

"""
Author : peters 

Revision History:
File created on 26 Aug 2010.

"""

import logging
25

26
27
28
29
30

################### Begin Class CtDaSystem ###################

from da.baseclasses.dasystem import DaSystem

31
class CO2GriddedDaSystem(DaSystem):
32
33
34
    """ Information on the data assimilation system used. This is normally an rc-file with settings.
    """

karolina's avatar
karolina committed
35
    def __init__(self, rcfilename):
36
37
38
39
40
        """
        Initialization occurs from passed rc-file name, items in the rc-file will be added
        to the dictionary
        """

karolina's avatar
karolina committed
41
        self.ID = 'CarbonTracker Gridded CO2'    # the identifier gives the platform name
42
        self.load_rc(rcfilename)
43

karolina's avatar
karolina committed
44
        logging.debug('Data Assimilation System initialized: %s' % self.ID)
45

46
    def validate(self):
47
        """ 
48
        validate the contents of the rc-file given a dictionary of required keys
49
50
51
52
53
54
55
56
57
58
        """

        needed_rc_items = ['obs.input.dir',
                           'obs.input.fname',
                           'ocn.covariance',
                           'nparameters',
                           'deltaco2.prefix',
                           'regtype']


59
        for k, v in self.items():
60
61
62
63
            if v == 'True' : self[k] = True
            if v == 'False': self[k] = False

        for key in needed_rc_items:
brunner's avatar
brunner committed
64
            if key not in self:
65
                msg = 'Missing a required value in rc-file : %s' % key
66
                logging.error(msg)
brunner's avatar
brunner committed
67
                raise IOError(msg)
68

69
        logging.debug('DA System Info settings have been validated succesfully')
70
71
72
73
74
75

################### End Class CtDaSystem ###################


if __name__ == "__main__":
    pass