This notebook demonstrates the query to get all necessary data to calculate runoff coefficients

[1]:
templates = {
'template_runoff_coefficient': {
    'target_concept': 'https://dbpedia.org/resource/Runoff_curve_number', # concept for
    'target_unit': '[%]',
    'target_method': 'df["runoff_coefficient"] = round(df.Q_OF_mean_selected/ df.P_mean_selected * 100, 1)',
    'requires':
    [
        {'concept': 'https://dbpedia.org/resource/Runoff',
         'alternative_concept': 'http://aims.fao.org/aos/agrovoc/c_35388',
         'name': 'runoff_volume',
         'unit': '[mm]',
         'method': 'template_runoff_volume'
        },
        {'concept': 'https://dbpedia.org/resource/Rain',
         'alternative_concept': 'http://aims.fao.org/aos/agrovoc/c_25202',
         'name': 'rainfall_volume',
         'unit': '[mm]',
         'method': 'template_rainfall_volume'
        }
    ]
},

'template_runoff_volume_Ries': {
    'target_concept': 'https://dbpedia.org/resource/Runoff',
    'target_unit': '[mm]',
    'target_method': 'df_target = df.pivot_table(values=["P_mean_selected","Q_OF_mean_selected"], columns=["Site_number","Experiment_numbe"], aggfunc="sum", dropna=True)',
    'requires':
    [
        {'concept': 'https://dbpedia.org/resource/Runoff',
         'alternative_concept': 'http://aims.fao.org/aos/agrovoc/c_35388',
         'name': 'runoff_rate',
         'unit': '[mm]',
        },
        {'concept': 'http://aims.fao.org/aos/agrovoc/c_7778',
         'name': 'duration',
         'unit': '[mm]'
        }
    ]
},

'template_runoff_volume_TUBAF': {
    'target_concept': 'https://dbpedia.org/resource/Runoff',
    'target_unit': '[l]',
    'target_method': 'runoff_volume = [sum_timesteps("ruoff_rate * duration") for row in data.rows "]', # we need to aggregate timesteps here
    'requires':
    [
        {'concept': 'https://dbpedia.org/resource/Runoff',
         'alternative_concept': 'http://aims.fao.org/aos/agrovoc/c_35388',
         'name': 'runoff_rate',
         'unit': '[l/s]',
        },
        {'concept': 'http://aims.fao.org/aos/agrovoc/c_7778',
         'name': 'duration',
         'unit': '[s]'
        }
    ]
},

'template_rainfall_volume': {
    'target_concept': 'https://dbpedia.org/resource/Rain',
    'target_unit': '[l]',
    'target_method': 'ruoff_volume = [sum_timesteps("rainfall_rate * duration", id) for id in data.ids "]', # we need to aggregate timesteps here
    'requires':
    [
        {'concept': 'https://dbpedia.org/resource/Rain',
         'alternative_concept': 'http://aims.fao.org/aos/agrovoc/c_25202',
         'name': 'rainfall_rate',
         'unit': '[l/s]'
        },
        {'concept': 'http://aims.fao.org/aos/agrovoc/c_7778',
         'name': 'duration',
         'unit': '[s]'
        }
    ]
}
}
#def sum_timesteps(operation, data):
#    ... see Jonas dissertation functions...{
# rainfall https://github.com/jonaslenz/diss/blob/gitbook/database/hydraulic_func.R#L45-L59
# runoff https://github.com/jonaslenz/diss/blob/gitbook/database/hydraulic_func.R#L29-L43
[2]:
templates['template_rainfall_volume']
[2]:
{'target_concept': 'https://dbpedia.org/resource/Rain',
 'target_unit': '[l]',
 'target_method': 'ruoff_volume = [sum_timesteps("rainfall_rate * duration", id) for id in data.ids "]',
 'requires': [{'concept': 'https://dbpedia.org/resource/Rain',
   'alternative_concept': 'http://aims.fao.org/aos/agrovoc/c_25202',
   'name': 'rainfall_rate',
   'unit': '[l/s]'},
  {'concept': 'http://aims.fao.org/aos/agrovoc/c_7778',
   'name': 'duration',
   'unit': '[s]'}]}