Ejemplo n.º 1
0
def run_frequent_harvest(freq, trig, targ):
    params, matrix_weather, days_harvest, doy_irr = establish_org_input(
        'lincoln')

    strs = [
        '{}-{:03d}'.format(e, f)
        for e, f in matrix_weather[['year', 'doy']].itertuples(False, None)
    ]
    days_harvest = pd.DataFrame({
        'year': matrix_weather.loc[:, 'year'],
        'doy': matrix_weather.loc[:, 'doy'],
        'frac_harv': np.ones(len(matrix_weather)),  # set filler values
        'harv_trig':
        np.zeros(len(matrix_weather)) - 1,  # set flag to not harvest
        'harv_targ': np.zeros(len(matrix_weather)),  # set filler values
        'weed_dm_frac': np.zeros(len(matrix_weather)),  # set filler values
    })

    # start harvesting at the same point
    harv_days = pd.date_range(start='2011-09-03',
                              end='2017-04-30',
                              freq='{}D'.format(freq))
    idx = np.in1d(pd.to_datetime(strs, format='%Y-%j'), harv_days)
    days_harvest.loc[idx, 'harv_trig'] = trig
    days_harvest.loc[idx, 'harv_targ'] = targ

    out = run_basgra_nz(params,
                        matrix_weather,
                        days_harvest,
                        doy_irr,
                        verbose=False)
    return out
Ejemplo n.º 2
0
def run_nonirr_lincoln_low_basil(IBASAL):
    params, matrix_weather, days_harvest, doy_irr = establish_org_input(
        'lincoln')

    matrix_weather = get_lincoln_broadfield()
    matrix_weather.loc[:, 'max_irr'] = 10
    matrix_weather.loc[:, 'irr_trig'] = 0
    matrix_weather.loc[:, 'irr_targ'] = 1

    matrix_weather = matrix_weather.loc[:, matrix_weather_keys_pet]

    params['IRRIGF'] = 0  # no irrigation
    params['BASALI'] = IBASAL  # start at 20% basal

    days_harvest = _clean_harvest(days_harvest, matrix_weather)

    out = run_basgra_nz(params,
                        matrix_weather,
                        days_harvest,
                        doy_irr,
                        verbose=False)
    out.loc[:, 'per_fc'] = out.loc[:, 'WAL'] / out.loc[:, 'WAFC']
    out.loc[:, 'per_paw'] = out.loc[:, 'PAW'] / out.loc[:, 'MXPAW']

    return out
Ejemplo n.º 3
0
def run_example_basgra():
    params, matrix_weather, days_harvest, doy_irr = establish_org_input()
    days_harvest = _clean_harvest(days_harvest, matrix_weather)
    out = run_basgra_nz(params,
                        matrix_weather,
                        days_harvest,
                        doy_irr,
                        verbose=False)
Ejemplo n.º 4
0
def run_old_basgra():
    params, matrix_weather, days_harvest, doy_irr = establish_org_input(
        'lincoln')

    days_harvest = _clean_harvest(days_harvest, matrix_weather)

    out = run_basgra_nz(params,
                        matrix_weather,
                        days_harvest,
                        doy_irr,
                        verbose=False)
    return out
Ejemplo n.º 5
0
def support_for_memory_usage():
    params, matrix_weather, days_harvest, doy_irr = establish_org_input()
    start_year = matrix_weather['year'].min()
    start_day = matrix_weather.loc[matrix_weather.year == start_year,
                                   'doy'].min()

    # set up a maximum run time
    idxs = np.random.random_integers(0, len(matrix_weather) - 1, 36600)
    matrix_weather = matrix_weather.iloc[idxs]
    expected_days = pd.Series(
        pd.date_range(start=pd.to_datetime('{}-{}'.format(
            start_year, start_day),
                                           format='%Y-%j'),
                      periods=36600))
    matrix_weather.loc[:, 'year'] = expected_days.dt.year.values
    matrix_weather.loc[:, 'doy'] = expected_days.dt.dayofyear.values

    days_harvest = _clean_harvest(days_harvest, matrix_weather)
    out = run_basgra_nz(params,
                        matrix_weather,
                        days_harvest,
                        doy_irr,
                        verbose=False)