Ejemplo n.º 1
0
def impl_text(setup):
    parameter_text = '\n'.join(
        f':{p.name}: [{p.minbound:0.4g}..{p.maxbound:0.4g}] {p.description}'
        for p in setup.parameters
    )

    cmf_text = cmf.describe(setup.project)

    return dedent(f'''
Implementierung des Konzepts
-------------------------------

Modell-Parameter
.................

{parameter_text}

Die Modell-Klasse
.................

.. autoclass:: {setup.__module__}.{setup.__class__.__name__}
    :members:

Das CMF-Projekt
...................

{cmf_text}

    ''')
Ejemplo n.º 2
0
    def __init__(self, days=None):

        self.driver_data = _load_data('cmf_data/driver_data_site24.csv')
        self.evaluation_data = np.loadtxt('cmf_data/soilmoisture_site24.csv',
                                          delimiter=',',
                                          comments='#',
                                          usecols=[1, 2, 3])

        self.datastart = self.driver_data.time[0]

        # Set the end point for the model runtime, either by parameter days or
        # run to the end of available driver data
        if days is None:
            self.dataend = self.driver_data.time[-1]
        else:
            self.dataend = self.datastart + timedelta(days=days)

        # The depth below ground in m where the evaluation data belongs to
        self.eval_depth = [0.1, 0.25, 0.4]

        # Make the model
        self.model = _CmfProject(self.make_parameters())
        # Load meteo data
        self.model.load_meteo(driver_data=self.driver_data)
        self.__doc__ += '\n\n' + cmf.describe(self.model.project)
Ejemplo n.º 3
0
 def test_describe(self):
     p = cmf.project()
     c = p.NewCell(0, 0, 0, 1000, True)
     p.meteo_stations.add_station('Giessen', (0, 0, 0))
     c.add_layer(1.0)
     text = cmf.describe(p).split('\n')
     self.assertGreaterEqual(len(text), 25)
Ejemplo n.º 4
0
 def test_describe(self):
     p = cmf.project()
     c = p.NewCell(0, 0, 0, 1000, True)
     p.meteo_stations.add_station('Giessen', (0, 0, 0))
     c.add_layer(1.0)
     text = cmf.describe(p).split('\n')
     print('cmf.describe(project) returns {} lines'.format(len(text)))
     self.assertGreaterEqual(len(text), 5)
Ejemplo n.º 5
0
def descr(model):
    """
    Prints out a description of your model
    Usage: cmflumped descr <model.py>
           <model.py>: The Python file containing the model
    """
    import cmf
    m = _get_model_class(model)()
    print(cmf.describe(m.project))
Ejemplo n.º 6
0
def test_inlet():

    folder_path = r'C:\Users\Christian\Dropbox\Arbejde\DTU BYG\Livestock\livestock\livestock\test\test_data\cmf_boundary_conditions\outlet'
    helper.unpack(folder_path)

    model = hy.CMFModel(folder_path)
    p = model.run_model()

    print(cmf.describe(p))

    plot_outlet(folder_path)
Ejemplo n.º 7
0
    def make_boundaries(self):
        """
        Creates the boundary conditions like outlet and rain
        :return:
        """
        p = self.project
        c = p[0]
        outlet = p.NewOutlet('GW', c.x, c.y, c.z - c.soildepth)
        cmf.FreeDrainagePercolation(c.layers[-1], outlet)
        rainfall = cmf.timeseries.from_sequence(self.starttime, cmf.day,
                                                [25, 0, 0, 0, 0, 0, 0] * 200)
        p.rainfall_stations.add('Heavy rain once a week', rainfall, (0, 0, 0))
        print(cmf.describe(p.rainfall_stations))
        p.use_nearest_rainfall()

        return outlet
Ejemplo n.º 8
0
    runs = 2

    # File names of the forcing data
    fnQ = "Q_Kammerzell_1979_1999.txt"
    fnT = "T_kammerzell_1979_1999_max_min_avg.txt"
    fnP = "P_Krigavg_kammerzell_1979_1999.txt"

    # import algorithm
    from spotpy.algorithms import mc as Sampler

    # Find out if the model should run parallel (for supercomputer)
    parallel = 'mpi' if 'OMPI_COMM_WORLD_SIZE' in os.environ else 'seq'

    # Create the model
    model = ComplexLumped(datetime.datetime(begin, 1, 1),
                          datetime.datetime(end, 12, 31))
    print(cmf.describe(model.project))
    # If there is an command line argument, take its value for the amount of
    #  runs
    if len(sys.argv) > 1:
        runs = int(sys.argv[1])

    # run the model
    if runs:
        sampler = Sampler(model,
                          parallel=parallel,
                          dbname="complex_lumped",
                          dbformat="csv",
                          save_sim=True)
        sampler.sample(runs)  #, subsets = 30)
Ejemplo n.º 9
0
 def summerize(self):
     for ts_name in 'P ETpot T Q'.split():
         ts = getattr(self, ts_name)
         print(ts_name, cmf.describe(ts).replace('\n', ''))
Ejemplo n.º 10
0
 def describe(self):
     return cmf.describe(self.project)