示例#1
0
        'date', 'precipitation', 'temperature', 'evapotranspiration', 'flow',
        'flow_mm'
    ]
    df.index = df['date']

    # One month aggregation using period as index :
    precipitation = df['precipitation'].resample('M', kind='period').sum()
    temperature = df['temperature'].resample('M', kind='period').mean()
    evapotranspiration = df['evapotranspiration'].resample(
        'm', kind='period').sum()
    flow_mm = df['flow_mm'].resample('M', kind='period').sum()
    df = pd.concat([precipitation, temperature, evapotranspiration, flow_mm],
                   axis=1)
    df['date'] = df.index

    input_handler = InputDataHandler(ModelGr2m, df)

    warm_up_start_date = datetime.datetime(1989, 1, 1, 0, 0)
    start_date = datetime.datetime(1990, 1, 1, 0, 0)
    end_date = datetime.datetime(1999, 1, 1, 0, 0)
    sub_input = input_handler.get_sub_period(warm_up_start_date, end_date)

    air_gr_parameters = [265.072, 1.040]
    model = ModelGr2m(sub_input, air_gr_parameters)
    outputs = model.run()

    filtered_input = model.input_data[model.input_data.index >= start_date]
    filtered_output = outputs[outputs.index >= start_date]

    plot_hydrograph(filtered_output, sub_input.data['flow_mm'])
示例#2
0
from pathlib import Path
import pandas as pd
import datetime
from hydrogr import InputDataHandler, ModelGr6j
from hydrogr.plot_tools import plot_hydrograph

if __name__ == '__main__':

    data_path = Path.cwd().parent / 'data'
    df = pd.read_pickle(data_path / 'L0123001.pkl')
    df.columns = [
        'date', 'precipitation', 'temperature', 'evapotranspiration', 'flow',
        'flow_mm'
    ]
    df.index = df['date']

    air_gr_parameters = [242.257, 0.637, 53.517, 2.218, 0.424, 4.759]

    input_handler = InputDataHandler(ModelGr6j, df)

    start_date = datetime.datetime(1989, 1, 1, 0, 0)
    end_date = datetime.datetime(1999, 12, 31, 0, 0)
    sub_input = input_handler.get_sub_period(start_date, end_date)

    model = ModelGr6j(sub_input, air_gr_parameters)
    model.set_initial_conditions(production_store_filling=0.3,
                                 routing_store_filling=0.5)
    outputs = model.run()

    plot_hydrograph(outputs, sub_input.data['flow_mm'])
示例#3
0
import pandas as pd
import datetime
from hydrogr import InputDataHandler, ModelGr4h
from hydrogr.plot_tools import plot_hydrograph

if __name__ == '__main__':

    data_path = Path.cwd().parent / 'data'
    # df = pd.read_csv(data_path / 'L0123003.csv')
    # df['date'] = pd.to_datetime(df['date'], format='%d/%m/%Y %H:%M')
    # df.to_pickle(data_path / 'L0123003.pkl')
    df = pd.read_pickle(data_path / 'L0123003.pkl')
    df.columns = [
        'date', 'precipitation', 'temperature', 'evapotranspiration', 'flow',
        'flow_mm'
    ]
    df.index = df['date']

    my_inputs_handler = InputDataHandler(ModelGr4h, df)
    filtered_input = my_inputs_handler.get_sub_period(
        datetime.datetime(2004, 1, 1, 0, 0),
        datetime.datetime(2008, 1, 1, 0, 0))

    model = ModelGr4h(filtered_input, [521.113, -2.918, 218.009, 4.124])
    model.set_initial_conditions(production_store_filling=0.9,
                                 routing_store_filling=0.9)
    outputs = model.run()
    print(outputs.head())

    plot_hydrograph(outputs, my_inputs_handler.data['flow_mm'])