Exemplo n.º 1
0
 def test_plot_model_key_dependencies_scatter_plot(self):
     ml = self.ml  #only veg
     target_key = "scalar_func_phot"
     sublist = ModelList([el for el in ml if el.has_key(target_key)])
     fig = plt.figure()
     ax = fig.add_subplot(1, 1, 1)
     sublist.plot_model_key_dependencies_scatter_plot(target_key, ax)
     fig.savefig("plot.pdf")
     ax = fig.add_subplot(1, 1, 1)
Exemplo n.º 2
0
    def test_create_old_overview_report(self):
        # fixme:
        # The tested method is deprecated and should be replaced by templates as soon as possible.
        # we create a target directory populated with only a few files and create a overview html from it
        d = defaults()
        #sp=d['paths']['tested_records']
        sp = d['paths']['tested_records'].parent.joinpath('VerosTestModels')
        src_dir_name = 'localDataBase'
        src_dir_path = Path(src_dir_name)
        src_dir_path.mkdir()
        rec_list = [rec for rec in sp.glob('*.yaml')]  #[0:2]

        for rec in rec_list:
            src = str(sp.joinpath(rec))
            target = (src_dir_name)

            shutil.copy(src, src_dir_name)

        ml = ModelList.from_dir_path(src_dir_path)

        target_dir_path = Path('.').joinpath('html')
        targetFileName = 'overview.html'
        create_overview_report(ml, target_dir_path, targetFileName)
        targetPath = target_dir_path.joinpath(targetFileName)
        self.assertTrue(targetPath.exists())
Exemplo n.º 3
0
    def setUp(self):
        yaml_str = """\
        model:
            - environmental_paramters: 
                - T:
                    key: Temperature
                - f:
                    key: foliage

            - components:
                - b:
                    exprs: b = Matrix(3,1, [1, 0, 1])
                    key: input_vector
                - u:
                    exprs: u=T*f
                    key: scalar_func_phot
                - f_s:
                    exprs: "f_s = u*b"
                    key: state_vector_derivative
        """
        model_0 = IncompleteModel(yaml_str, "mod0")
        model_0.sections, model_0.section_titles, model_0.complete_dict = load_sections_and_titles(
            model_0.complete_dict)
        model_0.df = load_df(model_0.complete_dict, model_0.sections)
        model_0.syms_dict, model_0.exprs_dict, model_0.symbols_by_type = load_expressions_and_symbols(
            model_0.df)
        model_0.set_component_keys()

        yaml_str = """\
        model:
            - environmental_paramters: 
                - a:
                - T:
                    key: Temperature
                - f:
                    key: roots
                    exprs: f=5*a 

            - components:
                - b:
                    exprs: b = Matrix(3,1, [1, 0, 1])
                    key: input_vector
                - u:
                    exprs: u=T*f
                    key: scalar_func_phot
                - f_s:
                    exprs: "f_s = u*b"
                    key: state_vector_derivative
        """
        model_1 = IncompleteModel(yaml_str, "mod1")
        model_1.sections, model_1.section_titles, model_1.complete_dict = load_sections_and_titles(
            model_1.complete_dict)
        model_1.df = load_df(model_1.complete_dict, model_1.sections)
        model_1.syms_dict, model_1.exprs_dict, model_1.symbols_by_type = load_expressions_and_symbols(
            model_1.df)
        model_1.set_component_keys()

        self.ml = ModelList([model_0, model_1])
Exemplo n.º 4
0
def table(request):
    from bgc_md.ModelList import ModelList
    from bgc_md.reports import  defaults
    d=defaults() 
    source_dir_path=d['paths']['tested_records']    
    ml=ModelList.from_dir_path(src_dir_path)
    target_dir_path=Path('.').joinpath('html')
    targetFileName='table.html'
    rel=ml.create_overview_table(target_dir_path,targetFileName)
    
    return HttpResponse('Test') 
Exemplo n.º 5
0
    def test_website_from_template(self):
        d = defaults()
        sp = d['paths']['tested_records'].parent.joinpath('TestModels_1')
        model_list = ModelList.from_dir_path(sp)

        list_tp = d['paths']['report_templates'].joinpath(
            'multiple_model', 'Website.py')
        #rel=render(list_tp,model_list=model_list)
        rel = render(list_tp, model_list)

        target_dir_path = Path('.')
        target_dir_path.mkdir(parents=True, exist_ok=True)
        targetFileName = 'overview.html'
        rel.write_pandoc_html(target_dir_path.joinpath(targetFileName))
Exemplo n.º 6
0
    def test_create_overview_table(self):
        # we create a target directory populated with only a few files and create a overview html from it
        d = defaults()
        sp = d['paths']['tested_records']
        src_dir_name = 'localDataBase'
        src_dir_path = Path(src_dir_name)
        src_dir_path.mkdir()
        rec_list = [rec for rec in sp.glob('*.yaml')][0:1]

        for rec in rec_list:
            print(rec)
            src = (sp.joinpath(rec)).as_posix()
            target = (src_dir_name)
            shutil.copy(src, src_dir_name)

        ml = ModelList.from_dir_path(src_dir_path)
        target_dir_path = Path('.').joinpath('html')
        rel = ml.create_overview_table(target_dir_path)
        targetFileName = 'table.html'
        targetPath = target_dir_path.joinpath(targetFileName)
        rel.write_pandoc_html(targetPath)
        print(targetPath)
        self.assertTrue(targetPath.exists())
Exemplo n.º 7
0
 def setUp(self):
     this = Path(__file__).parents[1]  #the package dir
     vegModelPath = defaults()['paths'][
         'veg']  ### Fix me!!! Temporarily changed Vegetation for Test
     self.ml = ModelList.from_dir_path(vegModelPath)