コード例 #1
0
ファイル: taskloader.py プロジェクト: tommibergman/ece2cmor3
def create_cmor_source(pardict, tag):
    src = pardict.get(json_source_key, None)
    expr = pardict.get(cmor_source.expression_key, None)
    if not src and not expr:
        log.error("Could not find a source or expression entry for parameter table block %s" % (str(pardict.__dict__)))
        return None
    if tag == "ifs":
        return cmor_source.ifs_source.read(expr if expr is not None else src)
    elif tag == "tm5":
        grid = "lonlat"
        return cmor_source.tm5_source(src, cmor_source.tm5_grid.index(grid))
    elif tag == "nemo":
        grid = pardict.get(json_grid_key, None)
        if not (grid in cmor_source.nemo_grid):
            log.error("Could not find a grid value in the nemo parameter table for %s" % src)
            return None
        print 'soruce',grid
        return cmor_source.nemo_source(src, cmor_source.nemo_grid.index(grid))
    return None
コード例 #2
0
ファイル: nemo2cmor_test.py プロジェクト: zklaus/ece2cmor3
 def test_cmor_single_task3d(self):
     tab_dir = get_table_path()
     conf_path = os.path.join(os.path.dirname(nemo2cmor.__file__),
                              "resources", "metadata-template.json")
     cmor.setup(tab_dir)
     cmor.dataset_json(conf_path)
     nemo2cmor.initialize(self.data_dir, "exp",
                          os.path.join(tab_dir, "CMIP6"),
                          datetime.datetime(1990, 3, 1),
                          datetime.timedelta(days=365))
     src = cmor_source.nemo_source("to", cmor_source.nemo_grid.grid_T, 3)
     tgt = cmor_target.cmor_target("thetao", "Omon")
     setattr(tgt, "frequency", "mon")
     setattr(tgt, "dimensions", "longitude latitude olevel time")
     tgt.dims = 3
     tsk = cmor_task.cmor_task(src, tgt)
     nemo2cmor.execute([tsk])
     nemo2cmor.finalize()
     cmor.close()
コード例 #3
0
ファイル: taskloader.py プロジェクト: zklaus/ece2cmor3
def create_cmor_source(pardict, tag):
    src = pardict.get(json_source_key, None)
    expr = pardict.get(cmor_source.expression_key, None)
    if (not src and not expr):
        log.error(
            "Could not find a source entry for parameter table entry %s...skipping variable %s for table %s."
            % (str(pardict.__dict__), target.variable, target.table))
        return None
    cmorsrc = None
    if (tag == "ifs"):
        return cmor_source.ifs_source.read(expr if expr != None else src)
    elif (tag == "nemo"):
        grid = pardict.get(json_grid_key, None)
        if (not (grid in cmor_source.nemo_grid)):
            log.error(
                "Could not find a grid value in the nemo parameter table for %s...skipping variable."
                % src)
            return None
        return cmor_source.nemo_source(src, cmor_source.nemo_grid.index(grid))
    return None
コード例 #4
0
 def test_create_nemo_source(self):
     src=nemo_source("tos",nemo_grid.grid_T)
     eq_(src.grid(),"grid_T")
     eq_(src.dims(),-1)