forked from isichos/epa
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring a list of value type to edit the DB more easily
- Loading branch information
1 parent
7922d7d
commit 850b593
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.core.management.base import BaseCommand, CommandError | ||
import pandas as pd | ||
from projects.models import * | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Update the valuetype objects from /static/valuetypes_list.csv" | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
"--update", action="store_true", help="Update existing assets" | ||
) | ||
|
||
def handle(self, *args, **options): | ||
|
||
update_valuetypes = options["update"] | ||
|
||
df = pd.read_csv("static/valuetypes_list.csv") | ||
valuetypes = df.to_dict(orient="records") | ||
for vt_params in valuetypes: | ||
qs = ValueType.objects.filter(type=vt_params["type"]) | ||
|
||
if qs.exists() is False: | ||
new_valuetype = ValueType(**vt_params) | ||
new_valuetype.save() | ||
else: | ||
if update_valuetypes is True: | ||
qs.update(**vt_params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
type,unit | ||
duration,year | ||
annuity_factor,factor | ||
discount,factor | ||
tax,factor | ||
crf,factor | ||
crate,factor of total capacity (kWh) | ||
age_installed,year | ||
soc_max,factor | ||
soc_min,factor | ||
capex_fix,currency | ||
opex_var,currency/unit/year | ||
efficiency,factor | ||
installed_capacity,unit | ||
lifetime,year | ||
maximum_capacity,kW | ||
energy_price,currency/kWh | ||
feedin_tariff,currency/kWh | ||
optimize_cap,bool | ||
peak_demand_pricing,currency/kW | ||
peak_demand_pricing_period,"times per year (1,2,3,4,6,12)" | ||
renewable_share,factor | ||
capex_var,currency/unit | ||
opex_fix,currency/year | ||
specific_costs_om,currency/year | ||
input_timeseries,kWh | ||
evaluated_period,days | ||
renewable_asset,bool | ||
thermal_loss_rate,factor | ||
efficiency_multiple,factor | ||
beta,factor | ||
fixed_thermal_losses_relative,factor | ||
fixed_thermal_losses_absolute,kWh |