Example #1
0
def run_model(name, switches):
    # Create a coupled model instance
    modelo = Conectado()

    # Establish SDM and Biofisical model paths. The Biofisical model path must point to the Python wrapper for the model
    modelo.estab_bf(os.path.join(os.path.split(__file__)[0], 'SAHYSMOD.py'))

    modelo.estab_mds(
        os.path.join(os.path.split(__file__)[0], 'Tinamit_sub_v2.vpm'))

    # Set appropriate switches for policy analysis
    modelo.mds.inic_vals_vars(switches)

    # Couple models(Change variable names as needed)
    modelo.conectar(
        var_mds='Soil salinity Tinamit CropA',
        mds_fuente=False,
        var_bf="Cr4 - Fully rotated land irrigated root zone salinity")
    modelo.conectar(
        var_mds='Soil salinity Tinamit CropB',
        mds_fuente=False,
        var_bf="Cr4 - Fully rotated land irrigated root zone salinity")
    modelo.conectar(var_mds='Watertable depth Tinamit',
                    mds_fuente=False,
                    var_bf="Dw - Groundwater depth")
    modelo.conectar(var_mds='ECdw Tinamit',
                    mds_fuente=False,
                    var_bf='Cqf - Aquifer salinity')
    modelo.conectar(var_mds='Lc',
                    mds_fuente=True,
                    var_bf='Lc - Canal percolation')
    modelo.conectar(var_mds='IaAS1',
                    mds_fuente=True,
                    var_bf='IaA - Crop A field irrigation')
    modelo.conectar(var_mds='IaBS1',
                    mds_fuente=True,
                    var_bf='IaB - Crop B field irrigation')
    modelo.conectar(var_mds='Gw',
                    mds_fuente=True,
                    var_bf='Gw - Groundwater extraction')
    modelo.conectar(var_mds='Irrigation efficiency',
                    mds_fuente=True,
                    var_bf='FsA - Water storage efficiency crop A')
    modelo.conectar(var_mds='Fw',
                    mds_fuente=True,
                    var_bf='Fw - Fraction well water to irrigation')

    # Simulate the coupled model
    modelo.simular(
        paso=1, t_final=240,
        nombre_corrida=name)  # time step and final time are in months
Example #2
0
 def test_unidades_tiempo_mes_y_día(símismo):
     bf = ModeloPrueba(unid_tiempo='días')
     cnctd = Conectado(bf, símismo.mds)
     cnctd.conectar(var_mds='Aleatorio', var_bf='Escala', mds_fuente=False)
     res = cnctd.simular(10, vars_interés=['bf_Escala', 'mds_Aleatorio'])
     npt.assert_array_equal(res['mds_Aleatorio'], np.arange(11 * 30,
                                                            step=30))
Example #3
0
 def test_unidades_tiempo_definidas(símismo):
     bf = ModeloPrueba(unid_tiempo='દિવસ')
     cnctd = Conectado(bf, símismo.mds)
     cnctd.conectar(var_mds='Aleatorio', var_bf='Escala', mds_fuente=False)
     cnctd.estab_conv_tiempo(mod_base='mds', conv=30)
     res = cnctd.simular(10, vars_interés=['bf_Escala', 'mds_Aleatorio'])
     npt.assert_array_equal(res['mds_Aleatorio'], np.arange(11 * 30,
                                                            step=30))
    modelo.conectar(var_mds='Irrigation efficiency', mds_fuente=True, var_bf='FsA - Water storage efficiency crop A')
    modelo.conectar(var_mds='Fw', mds_fuente=True, var_bf='Fw - Fraction well water to irrigation')

    # 4. Finally, run the model
    if use_simple:
        runs = runs_simple
    else:
        runs = runs_complex

    if not climate_change:
        # Run the model for all desired runs
        for name, run in runs.items():
            print('Runing model {}.\n-----------------'.format(name))

            # Simulate the coupled model
            modelo.simular(paso=1, t_final=40, vals_inic=run,
                           nombre_corrida=name)  # time step and final time are in months

            # Draw maps
            modelo.dibujar_mapa(geog=Rechna_Doab, corrida=name, var='Watertable depth Tinamit', directorio='Maps')
            modelo.dibujar_mapa(geog=Rechna_Doab, corrida=name, var='Soil salinity Tinamit CropA', directorio='Maps')
    else:
        # Climate change runs
        location = Lugar(lat=32.178207, long=73.217391, elev=217)
        location.observar_mensuales((os.path.join(base_dir, 'مشاہدہ بارش.csv')), meses='مہینہ', años='سال',
                                    cols_datos={'Precipitación': 'بارش (ملیمیٹر)',
                                                'Temperatura mínima': 'درجہ_حرارت_کم',
                                                'Temperatura máxima': 'درجہ_حرارت_زیادہ'
                                                },
                                    conv={'Precipitación': 1,
                                          'Temperatura mínima': 1,
                                          'Temperatura máxima': 1})
Example #5
0
import os

from tinamit.Conectado import Conectado

modelo = Conectado()

directorio = os.path.dirname(__file__)

modelo.estab_mds(os.path.join(directorio, "Prueba dll.mdl"))
modelo.estab_bf(os.path.join(directorio, 'Prueba bf.py'))

modelo.conectar(var_mds='Lluvia', var_bf='Lluvia', mds_fuente=False)
modelo.conectar(var_mds='Bosques', var_bf='Bosques', mds_fuente=True)

res = modelo.simular(paso=1, t_final=100, nombre_corrida='Corrida_Tinamit')
print(res)