Esempio n. 1
0
def run_population_size(model, SAT, population_size, tmax, nruns, hdfstore):
    if population_size == 1000:
        _copy_run(model, SAT, population_size, nruns, hdfstore)
    else:
        p = herd.Parameters(model=model, SAT=SAT)
        p.population_size = population_size
        logging_prefix = (', '.join(
            (f'model {model}', f'SAT {SAT}',
             f'population_size {population_size}')) + ', ')
        df = run.run_many(p, tmax, nruns, logging_prefix=logging_prefix)
        run._prepend_index_levels(df,
                                  model=model,
                                  SAT=SAT,
                                  population_size=population_size)
        hdfstore.put(df, min_itemsize=run._min_itemsize)
Esempio n. 2
0
def run_start_time(model, SAT, start_time, tmax, nruns, hdfstore):
    if start_time == 0.5:
        _copy_run(model, SAT, start_time, nruns, hdfstore)
    else:
        p = herd.Parameters(model=model, SAT=SAT)
        p.start_time = start_time
        logging_prefix = (', '.join(
            (f'model {model}', f'SAT {SAT}', f'start_time {start_time}')) +
                          ', ')
        df = run.run_many(p, tmax, nruns, logging_prefix=logging_prefix)
        run._prepend_index_levels(df,
                                  model=model,
                                  SAT=SAT,
                                  start_time=start_time)
        hdfstore.put(df, min_itemsize=run._min_itemsize)
Esempio n. 3
0
def run_initial_conditions(model, SAT, initial_conditions, tmax, nruns,
                           hdfstore):
    if initial_conditions == SAT:
        _copy_run(model, SAT, initial_conditions, nruns, hdfstore)
    else:
        p = herd.Parameters(model=model,
                            SAT=SAT,
                            _initial_conditions=initial_conditions)
        logging_prefix = (', '.join(
            (f'model {model}', f'SAT {SAT}',
             f'initial_conditions {initial_conditions}')) + ', ')
        df = run.run_many(p, tmax, nruns, logging_prefix=logging_prefix)
        run._prepend_index_levels(df,
                                  model=model,
                                  SAT=SAT,
                                  initial_conditions=initial_conditions)
        hdfstore.put(df, min_itemsize=run._min_itemsize)
Esempio n. 4
0
def run_birth_seasonality(model, SAT, birth_seasonality_scaling, tmax, nruns,
                          hdfstore):
    p = herd.Parameters(model=model, SAT=SAT)
    p.birth_seasonal_coefficient_of_variation *= birth_seasonality_scaling
    bscov = p.birth_seasonal_coefficient_of_variation
    if birth_seasonality_scaling == 1:
        _copy_run(model, SAT, bscov, nruns, hdfstore)
    else:
        logging_prefix = (', '.join(
            (f'model {model}', f'SAT {SAT}',
             f'birth_seasonality_scaling {birth_seasonality_scaling}')) + ', ')
        df = run.run_many(p, tmax, nruns, logging_prefix=logging_prefix)
        run._prepend_index_levels(
            df,
            model=model,
            SAT=SAT,
            birth_seasonal_coefficient_of_variation=bscov)
        hdfstore.put(df, min_itemsize=run._min_itemsize)
Esempio n. 5
0
    data_mean = get_mean(data)
    for (j, (k, x)) in enumerate(data_mean.items()):
        ax[j].step(365 * x.index, x, where='post', color='black', alpha=0.6)
        ax[j].set_ylabel(k.replace(' ', '\n'))

    ax[-1].set_xlabel(data.index.names[1])

    for ax_ in ax:
        yl = ax_.get_ylim()
        if yl[0] < 0:
            ax_.set_ylim(ymin=0)

    if show:
        pyplot.show()


if __name__ == '__main__':
    SAT = 1
    model = 'chronic'
    nruns = 100
    tmax = 10

    p = herd.Parameters(model=model, SAT=SAT)
    t0 = time.time()
    data = run.run_many(p, tmax, nruns)
    t1 = time.time()
    print('Run time: {} seconds.'.format(t1 - t0))

    make_plots(data)