예제 #1
0
def _get_document(info):
    """Returns output document deleting JSON content if it already exists.

    """
    doc = ModelTopicOutput.create(info.cmip6_i, info.cmip6_s, info.cmip6_t)
    if os.path.exists(doc.fpath):
        os.remove(doc.fpath)
        doc = ModelTopicOutput.create(info.cmip6_i, info.cmip6_s, info.cmip6_t)

    return doc
예제 #2
0
def _get_document(institution, domain, model, topics):
    """Generates one CIM document per institute | domain | model.

    """
    # Set JSON data file accessors.
    accessors = [
        ModelTopicOutput.create(institution, domain, model, t) for t in topics
    ]

    # Map JSON -> CIM.
    doc = _map_model(institution, domain, model, accessors)
    if doc is None:
        return

    # Destructure injected properties.
    _destructure(doc)

    # Emit validation report.
    errors = pyesdoc.validate(doc)
    errors = [
        e for e in errors if e.endswith('values --> is an empty list') == False
    ]
    if errors:
        print("INVALID CIM DOCUMENT: {}".format(s))
        for err in errors:
            print(err)

    return doc
def _yield_documentation():
    """Yields documentation for map/reduce job.
    
    """
    for i, m, t in vocabs.yield_topics(None):
        output = ModelTopicOutput.create(i, m, t)
        if output.content:
            yield i, m, t, output.content
예제 #4
0
def _get_data_accessors(i, s, settings):
    """Returns a collection of model spreadsheet output accessors - one per spreadsheet.

    """
    topics = vocabs.get_model_topics(s)
    topics = [t for t in topics if t.canonical_name in settings]
    accessors = [ModelTopicOutput.create(i, s, t) for t in topics]

    return [a for a in accessors if a.content]
예제 #5
0
    def __init__(self, i, s, t):
        """Instance constructor.

        """
        self.doc = ModelTopicOutput.create(i, s, t)
        self.institution_id = i.canonical_name
        self.t = self.doc.specialization
        self.topic_label = t.label
        self.topic_id = t.canonical_name
        self.p = None
        self.ps = None
        self.p_values = []
        self.source_id = s.canonical_name
        self.st = None
        self.wb = None
        self.ws = None
        self.ws_row = 0
        self.CMIP6_MIP_ERA = _CMIP6_MIP_ERA
        self.VERSION = _VERSION
예제 #6
0
파일: __main__.py 프로젝트: ES-DOC/cordex
    def __init__(self, i, s, t, d):
        """Instance constructor.

        """
        self.doc = ModelTopicOutput.create(i, d, s, t)
        self.domain_id = d.canonical_name
        self.fpath = io_mgr.get_model_topic_xls(i, s, t, d)
        self.institution_id = i.canonical_name
        self.t = self.doc.specialization
        self.topic_label = t.label
        self.topic_id = t.canonical_name
        self.p = None
        self.ps = None
        self.p_values = []
        self.source_id = s.canonical_name
        self.st = None
        self.wb = None
        self.ws = None
        self.ws_row = 0
        self.MIP_ERA = _MIP_ERA
        self.VERSION = _VERSION