Spaces:
Sleeping
Sleeping
Durand D'souza
commited on
Loan tenor bug fix
Browse files
model.py
CHANGED
|
@@ -173,7 +173,7 @@ def calculate_cashflow_for_renewable_project(
|
|
| 173 |
model = model.to_pandas()
|
| 174 |
|
| 175 |
for period in model["Period"]:
|
| 176 |
-
if period > 1:
|
| 177 |
model.loc[period, "Interest_Expense_mn"] = (
|
| 178 |
model.loc[period, "Debt_Outstanding_BoP_mn"] * assumptions.cost_of_debt
|
| 179 |
)
|
|
|
|
| 173 |
model = model.to_pandas()
|
| 174 |
|
| 175 |
for period in model["Period"]:
|
| 176 |
+
if period > 1 and period <= assumptions.loan_tenor_years:
|
| 177 |
model.loc[period, "Interest_Expense_mn"] = (
|
| 178 |
model.loc[period, "Debt_Outstanding_BoP_mn"] * assumptions.cost_of_debt
|
| 179 |
)
|
ui.py
CHANGED
|
@@ -229,7 +229,11 @@ def update_equity_from_debt(debt_pct):
|
|
| 229 |
|
| 230 |
def get_params(request: gr.Request) -> Dict:
|
| 231 |
params = SolarPVAssumptions.model_validate(dict(request.query_params))
|
| 232 |
-
location_params = dict(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
for key in location_params:
|
| 234 |
if location_params[key] == "None":
|
| 235 |
location_params[key] = None
|
|
@@ -245,7 +249,11 @@ def get_params(request: gr.Request) -> Dict:
|
|
| 245 |
cost_of_equity: params.cost_of_equity,
|
| 246 |
tax_rate: params.tax_rate,
|
| 247 |
project_lifetime_years: params.project_lifetime_years,
|
| 248 |
-
loan_tenor_years:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
degradation_rate: params.degradation_rate,
|
| 250 |
debt_pct_of_capital_cost: params.debt_pct_of_capital_cost,
|
| 251 |
dscr: params.dscr,
|
|
@@ -613,11 +621,13 @@ with gr.Blocks(theme="citrus", title="Renewable LCOE API") as interface:
|
|
| 613 |
# If user changes the project lifetime, set the maximum loan tenor to the project lifetime
|
| 614 |
def update_loan_tenor(project_lifetime_years, loan_tenor_years):
|
| 615 |
if project_lifetime_years < loan_tenor_years:
|
| 616 |
-
return gr.Slider(
|
|
|
|
|
|
|
| 617 |
return gr.Slider(maximum=project_lifetime_years)
|
| 618 |
|
| 619 |
project_lifetime_years.change(
|
| 620 |
fn=update_loan_tenor,
|
| 621 |
inputs=[project_lifetime_years, loan_tenor_years],
|
| 622 |
outputs=[loan_tenor_years],
|
| 623 |
-
)
|
|
|
|
| 229 |
|
| 230 |
def get_params(request: gr.Request) -> Dict:
|
| 231 |
params = SolarPVAssumptions.model_validate(dict(request.query_params))
|
| 232 |
+
location_params = dict(
|
| 233 |
+
longitude=request.query_params.get("longitude"),
|
| 234 |
+
latitude=request.query_params.get("latitude"),
|
| 235 |
+
address=request.query_params.get("address"),
|
| 236 |
+
)
|
| 237 |
for key in location_params:
|
| 238 |
if location_params[key] == "None":
|
| 239 |
location_params[key] = None
|
|
|
|
| 249 |
cost_of_equity: params.cost_of_equity,
|
| 250 |
tax_rate: params.tax_rate,
|
| 251 |
project_lifetime_years: params.project_lifetime_years,
|
| 252 |
+
loan_tenor_years: (
|
| 253 |
+
params.loan_tenor_years
|
| 254 |
+
if params.loan_tenor_years
|
| 255 |
+
else params.project_lifetime_years
|
| 256 |
+
),
|
| 257 |
degradation_rate: params.degradation_rate,
|
| 258 |
debt_pct_of_capital_cost: params.debt_pct_of_capital_cost,
|
| 259 |
dscr: params.dscr,
|
|
|
|
| 621 |
# If user changes the project lifetime, set the maximum loan tenor to the project lifetime
|
| 622 |
def update_loan_tenor(project_lifetime_years, loan_tenor_years):
|
| 623 |
if project_lifetime_years < loan_tenor_years:
|
| 624 |
+
return gr.Slider(
|
| 625 |
+
value=project_lifetime_years, maximum=project_lifetime_years
|
| 626 |
+
)
|
| 627 |
return gr.Slider(maximum=project_lifetime_years)
|
| 628 |
|
| 629 |
project_lifetime_years.change(
|
| 630 |
fn=update_loan_tenor,
|
| 631 |
inputs=[project_lifetime_years, loan_tenor_years],
|
| 632 |
outputs=[loan_tenor_years],
|
| 633 |
+
)
|