model.customadoption
Custom PDS/REF Adoption module
Returns DataFrame to be populated by adoption data
Take csv data that may have missing columns or rows, and pad it out to the full array.
Equivalent to Custom PDS and REF Adoption sheets in xls. Allows user to input custom adoption scenarios. The data can be raw or generated from a script within the solution directory.
Arguments
data_sources: a list of group names which contain dicts of data source names. For example: [ {'name': 'Study Name A', 'filename': 'filename A', 'include': boolean}, {'name': 'Study Name B', 'filename': 'filename B', 'include': boolean}, {'name': 'Study Name C', 'include': boolean, 'datapoints': pd.DataFrame([ [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [2060, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0], ], columns=ca_pds_columns).set_index('Year') }, {'name': 'Study Name D', 'include': boolean, 'growth_rate': 0.0132, 'growth_initial': pd.DataFrame([ [2014, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0], ], columns=ca_pds_columns).set_index('Year') }
... ] where ca_pds_columns = ['Year'] + dd.REGIONS
soln_adoption_custom_name: from advanced_controls. Can be avg, high, low or a specific custom PDS scenario name. For example: 'Average of All Custom PDS Scenarios' low_sd_mult: std deviation multiplier for 'low' values high_sd_mult: std deviation multiplier for 'high' values total_adoption_limit: the total adoption possible, adoption can be no greater than this. For RRS solutions this is typically tam.py:{pds,ref}_tam_per_region. For Land solutions this is typically tla.py:tla_per_region. The columns in total_adoption_limit must match the columns in generate_df_template.
Generates average/high/low of chosen scenarios to be used as adoption data for the solution.
Return a dataframe of adoption trends, one column per region.
For custom adoption data, no trend curve fitting is done. We return the custom data.
Provides information on two potential issues with the scenarios
1) Checks if any of the regions exceed their adoption limits 2) Checks if the sum of the main regions matches the corresponding World value
Args
- adoption_limits: optionally input adoption limits for check #1
Returns
A DataFrame summary of the checks for each scenario and a data dict. The data dict has the scenarios as keys and dicts of the following format as values: {'amount exceeded': DataFrame (rows = years, cols = regions) containing the amount each datapoint exceeds that region's limit (NaN if it is under the limit). 'adoption ratio': Series (index = years) containing the sum of the main regional values divided by the corresponding World value for each year (should be 1). }