grat.loaders.get_ccc
¶
Loads crop compatibility calendars from csvs.
get_crop_calendar
¶
Constructs the crop calendar data dictionary.
The crop compatibility calendar (CCC) is an agronomic model that determines quantity and timing of water applied based on the weekly capacity of crops to receive water for or in excess of crop demand (evapotranspiration, ETc) for in lieu or direct on-farm recharge (OFR), respectively, while maintaining crop health. The CCC is applicable only to these two types of recharge and does not apply to canal seepage or basin recharge. For both in-lieu and on-farm recharge types, the output of the CCC is the maximum volume (ft) of water a field can receive for OFR that is spatially and temporally compatible with the season, cultural practices, SAGBI soil type, and crop type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ccc_file
|
path to the crop compatibility calendar csv file |
required |
Returns:
| Type | Description |
|---|---|
|
Crop calendar dictionary, recording each crop's retention depth (feet) per SAGBI type:: {"Alfalfa": {"Very Poor": [0, 0, 0.1, 0], "Poor": [0, 0, 0, 0]}, "Corn": {"Very Poor": [0, 0, 0, 0], "Poor": [0, 0, 5, 0]}} |
Source code in src/grat/loaders/get_ccc.py
ccc_valid_crops
¶
Return the crops present in the crop compatibility calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ccc_dictionary
|
input crop compatibility dictionary (output from get_crop_calendar()) |
required |
Returns:
| Type | Description |
|---|---|
|
list of crop types |
Source code in src/grat/loaders/get_ccc.py
ccc_valid_soil_types
¶
Return a list of the soil types (SAGBI classification) found in the crop compatibility calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ccc_dictionary
|
input crop compatibility dictionary (output from get_crop_calendar()) |
required |
Returns:
| Type | Description |
|---|---|
|
list of soil types |
Source code in src/grat/loaders/get_ccc.py
get_il_crop_calendar
¶
Constructs the in-lieu crop calendar data dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ccc_file
|
path to the in-lieu crop compatibility calendar csv file |
required |
Returns:
| Type | Description |
|---|---|
|
Crop calendar dictionary, each crop's retention depth (feet) per climate region:: {"Alfalfa": {"8": [0, 0, 0.1, 0], "12": [0, 0, 0, 0]}, "Corn": {"8": [0, 0, 0, 0], "10": [0, 0, 5, 0]}} |
Source code in src/grat/loaders/get_ccc.py
load_in_lieu_climate_multiplier
¶
Load the in-lieu climate multiplier file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_to_ratio_file
|
str
|
path to the csv file |
required |
scenario
|
str
|
name of the scenario to load |
'T0'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
dataframe with columns: Crop, Region, MonthlyMultiplier (12 values, January first) |
Raises:
| Type | Description |
|---|---|
ValueError
|
the scenario is not a column in the multiplier file. |
Source code in src/grat/loaders/get_ccc.py
ccc_dict_to_df
¶
Convert the IL crop compatibility calendar dictionary to a dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ccc_dictionary
|
dict
|
input IL crop compatibility dictionary (output from get_il_crop_calendar()) |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
dataframe with columns: Crop, Region, depth |
Source code in src/grat/loaders/get_ccc.py
multiply_by_monthly_factor
¶
Multiply daily values by monthly factors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
daily_values
|
array of daily values for the water year |
required | |
monthly_factors
|
array of 12 monthly factors, January first |
required |
Returns:
| Type | Description |
|---|---|
|
array of daily values multiplied by monthly factors |
Raises:
| Type | Description |
|---|---|
ValueError
|
there are not 365 or 366 daily values, or not 12 monthly factors. |
Source code in src/grat/loaders/get_ccc.py
ccc_multiplier
¶
Multiplies the depth by the monthly multiplier for the chosen scenario.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ccc_df
|
in-lieu crop compatibility calendar dataframe |
required | |
multiplier_df
|
multiplier dataframe |
required |
Returns:
| Type | Description |
|---|---|
|
the joined dataframe, with the multiplied daily values in a |
Source code in src/grat/loaders/get_ccc.py
in_lieu_crop_calendar_multiplier_dict
¶
Converts the dataframe into a nested dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ccc_df_multi
|
dataframe with columns: Crop, Region, depth_factor |
required |
Returns:
| Type | Description |
|---|---|
dict
|
nested dictionary with keys: Crop, Region |
Source code in src/grat/loaders/get_ccc.py
multiply_crop_calendar
¶
Multiply the crop calendar by the monthly factor for the chosen scenario.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
il_ccc
|
crop calendar dictionary |
required | |
multiplier_df
|
multiplier dataframe |
required |
Returns:
| Type | Description |
|---|---|
|
crop calendar dictionary with the depth values multiplied by the monthly multipliers |
Source code in src/grat/loaders/get_ccc.py
add_mlrp_to_ccc
¶
Add the MLRP crop type to the crop calendar dictionary by cloning the Fallow crop type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ccc_dict
|
crop calendar dictionary |
required | |
mlrp_crop_name
|
name of the MLRP crop |
'MLRP'
|
Returns:
| Type | Description |
|---|---|
|
crop calendar dictionary with the MLRP crop added |
Raises:
| Type | Description |
|---|---|
KeyError
|
the crop calendar has no Fallow crop type. |