| Conditions | 1 |
| Total Lines | 121 |
| Code Lines | 48 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | """The central module containing all code dealing with scenario table. |
||
| 62 | def insert_scenarios(): |
||
| 63 | """Insert scenarios and their parameters to scenario table |
||
| 64 | |||
| 65 | Returns |
||
| 66 | ------- |
||
| 67 | None. |
||
| 68 | |||
| 69 | """ |
||
| 70 | |||
| 71 | db.execute_sql("DELETE FROM scenario.egon_scenario_parameters CASCADE;") |
||
| 72 | |||
| 73 | session = sessionmaker(bind=db.engine())() |
||
| 74 | |||
| 75 | # Scenario eGon2035 |
||
| 76 | egon2035 = EgonScenario(name="eGon2035") |
||
| 77 | |||
| 78 | egon2035.description = """ |
||
| 79 | The mid-term scenario eGon2035 is based on scenario C 2035 of the |
||
| 80 | Netzentwicklungsplan Strom 2035, Version 2021. |
||
| 81 | Scenario C 2035 is characretized by an ambitious expansion of |
||
| 82 | renewable energies and a higher share of sector coupling. |
||
| 83 | Analogous to the Netzentwicklungsplan, the countries bordering germany |
||
| 84 | are modeled based on Ten-Year Network Development Plan, Version 2020. |
||
| 85 | """ |
||
| 86 | egon2035.global_parameters = parameters.global_settings(egon2035.name) |
||
| 87 | |||
| 88 | egon2035.electricity_parameters = parameters.electricity(egon2035.name) |
||
| 89 | |||
| 90 | egon2035.gas_parameters = parameters.gas(egon2035.name) |
||
| 91 | |||
| 92 | egon2035.heat_parameters = parameters.heat(egon2035.name) |
||
| 93 | |||
| 94 | egon2035.mobility_parameters = parameters.mobility(egon2035.name) |
||
| 95 | |||
| 96 | session.add(egon2035) |
||
| 97 | |||
| 98 | session.commit() |
||
| 99 | |||
| 100 | # Scenario eGon100RE |
||
| 101 | egon100re = EgonScenario(name="eGon100RE") |
||
| 102 | |||
| 103 | egon100re.description = """ |
||
| 104 | The long-term scenario eGon100RE represents a 100% renewable |
||
| 105 | energy secor in Germany. |
||
| 106 | """ |
||
| 107 | egon100re.global_parameters = parameters.global_settings(egon100re.name) |
||
| 108 | |||
| 109 | egon100re.electricity_parameters = parameters.electricity(egon100re.name) |
||
| 110 | |||
| 111 | egon100re.gas_parameters = parameters.gas(egon100re.name) |
||
| 112 | |||
| 113 | egon100re.heat_parameters = parameters.heat(egon100re.name) |
||
| 114 | |||
| 115 | egon100re.mobility_parameters = parameters.mobility(egon100re.name) |
||
| 116 | |||
| 117 | session.add(egon100re) |
||
| 118 | |||
| 119 | session.commit() |
||
| 120 | |||
| 121 | # Scenario eGon2021 |
||
| 122 | eGon2021 = EgonScenario(name="eGon2021") |
||
| 123 | |||
| 124 | eGon2021.description = """ |
||
| 125 | Status quo scenario for 2021. Note: This is NOT A COMPLETE SCENARIO |
||
| 126 | and covers only some sector data required by ding0, such as demand |
||
| 127 | on NUTS 3 level and generation units . |
||
| 128 | """ |
||
| 129 | eGon2021.global_parameters = parameters.global_settings(eGon2021.name) |
||
| 130 | |||
| 131 | eGon2021.electricity_parameters = parameters.electricity(eGon2021.name) |
||
| 132 | |||
| 133 | eGon2021.gas_parameters = parameters.gas(eGon2021.name) |
||
| 134 | |||
| 135 | eGon2021.heat_parameters = parameters.heat(eGon2021.name) |
||
| 136 | |||
| 137 | eGon2021.mobility_parameters = parameters.mobility(eGon2021.name) |
||
| 138 | |||
| 139 | session.add(eGon2021) |
||
| 140 | |||
| 141 | session.commit() |
||
| 142 | |||
| 143 | # Scenario status2019 |
||
| 144 | status2019 = EgonScenario(name="status2019") |
||
| 145 | |||
| 146 | status2019.description = """ |
||
| 147 | Status quo ante scenario for 2019 for validation use within the project PoWerD. |
||
| 148 | """ |
||
| 149 | status2019.global_parameters = parameters.global_settings(status2019.name) |
||
| 150 | |||
| 151 | status2019.electricity_parameters = parameters.electricity(status2019.name) |
||
| 152 | |||
| 153 | status2019.gas_parameters = parameters.gas(status2019.name) |
||
| 154 | |||
| 155 | status2019.heat_parameters = parameters.heat(status2019.name) |
||
| 156 | |||
| 157 | status2019.mobility_parameters = parameters.mobility(status2019.name) |
||
| 158 | |||
| 159 | session.add(status2019) |
||
| 160 | |||
| 161 | session.commit() |
||
| 162 | |||
| 163 | # Scenario status2023 |
||
| 164 | status2023 = EgonScenario(name="status2023") |
||
| 165 | |||
| 166 | status2023.description = """ |
||
| 167 | Status quo ante scenario for 2023. |
||
| 168 | """ |
||
| 169 | # TODO status2023 all settings from 2019 are used |
||
| 170 | status2023.global_parameters = parameters.global_settings(status2023.name) |
||
| 171 | |||
| 172 | status2023.electricity_parameters = parameters.electricity(status2019.name) |
||
| 173 | |||
| 174 | status2023.gas_parameters = parameters.gas(status2019.name) |
||
| 175 | |||
| 176 | status2023.heat_parameters = parameters.heat(status2019.name) |
||
| 177 | |||
| 178 | status2023.mobility_parameters = parameters.mobility(status2023.name) |
||
| 179 | |||
| 180 | session.add(status2023) |
||
| 181 | |||
| 182 | session.commit() |
||
| 183 | |||
| 316 |