Example #1
0
def recalc_financial_objective(df, scenarios, obj_col):
    f_cols = [col for col in df.columns if col.endswith('_financial_model')]

    data = dict()
    for idx, row in df.iterrows():
        for i, scenario in enumerate(scenarios):

            for j, col in enumerate(f_cols):
                new_col = col.split('_')[0] + '_' + scenario['name']
                if new_col not in data:
                    data[new_col] = []

                d = expand_financial_model(row[col])
                model = Singleowner.new()  #.default(defaults[tech_prefix[j]])
                model.assign(d)

                for key, val in scenario['values'].items():
                    if key == 'cp_capacity_credit_percent':
                        model.value(key, calc_capacity_credit_perc(d, val))
                    else:
                        model.value(key, val)

                model.execute()
                data[new_col].append(model.value(obj_col))

    for key, val in data.items():
        df[key] = val

    return df
Example #2
0
def recalc_financials(result, assumptions):
    cols = [col for col in result.keys() if col.endswith('_financial_model')]
    
    models = []
    for col in cols:
        model_dict = expand_financial_model(result[col])
        model = Singleowner.new() #.default(defaults[tech_prefix[j]])
        model.assign(model_dict)
        
        for key, val in assumptions.items():
            if key == 'cp_capacity_credit_percent':
                val = calc_capacity_credit_percent(model_dict, N=val)
            model.value(key, val)
        model.execute()
                
        models.append(model)
        
    return models