Skip to content

Commit

Permalink
Fix pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davide-f committed Jun 30, 2023
1 parent 6340398 commit 7986630
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 63 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ notebooks/old_notebooks/*.tif
doc/_build

# VS code related
.vscode
doc/.vscode/settings.json
.vscode/settings.json
*.vscode
doc/*.vscode/settings.json
*.vscode/settings.json
*.code-workspace

# Additional debugging folders
Expand Down
16 changes: 14 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Copied from https://github.com/PyPSA/pypsa-eur/pull/302/files

exclude: ^(LICENSES|README.md)
exclude: ^(LICENSES)


repos:
Expand All @@ -26,7 +26,7 @@ repos:
- id: isort
args: ["--profile", "black", "--filter-files"]

# Find common spelling mistakes in comments and docstrings
# Find common spelling mistakes in comments and docstrings
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
Expand All @@ -35,6 +35,18 @@ repos:
types_or: [python, rst, markdown]
files: ^(scripts|doc)/

# # Make docstrings PEP 257 compliant
# - repo: https://github.com/PyCQA/docformatter
# rev: v1.7.3
# hooks:
# - id: docformatter
# args: ["--in-place", "--make-summary-multi-line", "--pre-summary-newline"]

# - repo: https://github.com/keewis/blackdoc
# rev: v0.3.8
# hooks:
# - id: blackdoc

# Formatting with "black" coding style
- repo: https://github.com/psf/black
rev: 23.3.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later

# PyPSA-Earth

<p align="left">
<p align="left">
by
<a href="https://pypsa-meets-earth.github.io">
<img src="https://github.com/pypsa-meets-earth/pypsa-meets-earth.github.io/raw/main/assets/img/logo.png" width="150">
Expand Down
4 changes: 2 additions & 2 deletions config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ monte_carlo:
# Key: add below the pypsa object for the monte_carlo sampling, "network" is only allowed for filtering!
# Value: currently supported format [l_bound, u_bound] or empty [], represent multiplication factors for the object
loads_t.p_set: [0.9, 1.1]
generators_t.p_max_pu.loc[:, n.generators.carrier == "wind"]: [0.9, 1.1]
generators_t.p_max_pu.loc[:, n.generators.carrier == "solar"]: [0.9, 1.1]
# generators_t.p_max_pu.loc[:, n.generators.carrier == "wind"]: [0.9, 1.1]
# generators_t.p_max_pu.loc[:, n.generators.carrier == "solar"]: [0.9, 1.1]


solving:
Expand Down
4 changes: 2 additions & 2 deletions config.tutorial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ monte_carlo:
# Key: add below the pypsa object for the monte_carlo sampling, "network" is only allowed for filtering!
# Value: currently supported format [l_bound, u_bound] or empty [], represent multiplication factors for the object
loads_t.p_set: [0.9, 1.1]
generators_t.p_max_pu.loc[:, n.generators.carrier == "wind"]: [0.9, 1.1]
generators_t.p_max_pu.loc[:, n.generators.carrier == "solar"]: [0.9, 1.1]
# generators_t.p_max_pu.loc[:, n.generators.carrier == "wind"]: [0.9, 1.1]
# generators_t.p_max_pu.loc[:, n.generators.carrier == "solar"]: [0.9, 1.1]


solving:
Expand Down
8 changes: 4 additions & 4 deletions data/costs.csv
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ fuel cell,2030,investment,339,EUR/kWel,NREL http://www.nrel.gov/docs/fy09osti/45
fuel cell,2030,FOM,3,%/year,NREL http://www.nrel.gov/docs/fy09osti/45873.pdf; budischak2013
fuel cell,2030,lifetime,20,years,NREL http://www.nrel.gov/docs/fy09osti/45873.pdf; budischak2013
fuel cell,2030,efficiency,0.58,per unit,NREL http://www.nrel.gov/docs/fy09osti/45873.pdf; budischak2013 conservative 2020
hydrogen storage tank,2030,investment,11.2,USD/kWh,budischak2013
hydrogen storage tank,2030,lifetime,20,years,budischak2013
hydrogen storage underground,2030,investment,0.5,EUR/kWh,maximum from https://www.nrel.gov/docs/fy10osti/46719.pdf
hydrogen storage underground,2030,lifetime,40,years,http://www.acatech.de/fileadmin/user_upload/Baumstruktur_nach_Website/Acatech/root/de/Publikationen/Materialien/ESYS_Technologiesteckbrief_Energiespeicher.pdf
hydrogen storage,2030,investment,11.2,USD/kWh,budischak2013
hydrogen storage,2030,lifetime,20,years,budischak2013
hydrogen underground storage,2030,investment,0.5,EUR/kWh,maximum from https://www.nrel.gov/docs/fy10osti/46719.pdf
hydrogen underground storage,2030,lifetime,40,years,http://www.acatech.de/fileadmin/user_upload/Baumstruktur_nach_Website/Acatech/root/de/Publikationen/Materialien/ESYS_Technologiesteckbrief_Energiespeicher.pdf
H2 pipeline,2030,investment,267,EUR/MW/km,Welder et al https://doi.org/10.1016/j.ijhydene.2018.12.156
H2 pipeline,2030,lifetime,40,years,Krieg2012 http://juser.fz-juelich.de/record/136392/files/Energie%26Umwelt_144.pdf
H2 pipeline,2030,FOM,5,%/year,Krieg2012 http://juser.fz-juelich.de/record/136392/files/Energie%26Umwelt_144.pdf
Expand Down
2 changes: 1 addition & 1 deletion data/custom_powerplants.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Name,Fueltype,Technology,Set,Country,Capacity,Efficiency,Duration,Volume_Mm3,DamHeight_m,StorageCapacity_MWh,DateIn,DateRetrofit,DateMothball,DateOut,lat,lon,EIC,projectID,bus
Name,Fueltype,Technology,Set,Country,Capacity,Efficiency,Duration,Volume_Mm3,DamHeight_m,StorageCapacity_MWh,DateIn,DateRetrofit,DateMothball,DateOut,lat,lon,EIC,projectID,bus
79 changes: 40 additions & 39 deletions data/hydro_capacities.csv
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
country_name,Country,p_nom_discharge[GW],p_nom_store[GW],E_store[TWh],InflowHourlyAvg[GWh]
Algeria,DZ,237.9,0.0,0.27106283954730553,0.030927
Angola,AO,2414.8,0.0,3.87187109487045,0.72444
Benin,BJ,32.8,0.0,0.241497582235,0.01476
Algeria,DZ,237.900,0.000,0.267,3.65331931
Angola,AO,2414.800,0.000,3.892,53.32168268
Benin,BJ,32.800,0.000,0.243,3.325925824
Botswana,BW,-,-,-,-
Burkina Faso,BF,32.0,0.0,1.0897537659895833,0.011519999999999999
Burundi,BI,56.0,0.0,0.00031164920784374997,0.011760000000000001
Cameroon,CM,987.0,0.0,1.068834825538675,0.68103
Central African Republic,CF,18.0,0.0,0.012662870863368054,0.017099999999999997
Burkina Faso,BF,32.000,0.000,1.096,15.00818418
Burundi,BI,56.000,0.000,0.000,0
Cameroon,CM,987.000,0.000,0.950,13.01468008
Central African Republic,CF,18.000,0.000,0.013,0.174394165
Chad,TD,-,-,-,-
Congo,CG,236.0,0.0,0.051629206458472215,0.12272000000000001
Democratic Republic of Congo,CD,2593.0,0.0,0.011146392607743458,0.98534
Côte d'Ivoire,CI,880.0,0.0,4.44632844420207,0.2992
Congo,CG,236.000,0.000,0.052,0.711041947
Cote d'Ivoire,CI,880.000,0.000,4.470,61.23522422
Democratic Republic of Congo,CD,2593.000,0.000,-,-
Djibouti,DJ,-,-,-,-
Egypt,EG,2842.0,0.0,49.556976867319435,1.5346799999999998
Equatorial Guinea,GQ,128.0,0.0,0.004692744516331666,0.01408
Egypt,EG,2842.000,0.000,49.823,682.5030197
Equatorial Guinea,GQ,128.000,0.000,0.005,0.064628888
Eritrea,ER,-,-,-,-
Eswatini,SZ,88.49,0.0,0.11857778434386985,0.0433601
Ethiopia,ET,4073.5,0.0,14.502793875917417,1.018375
Gabon,GA,330.59,0.0,0.0839275254774211,0.1752127
Eswatini,SZ,-,-,-,-
Ethiopia,ET,4073.500,0.000,-,-
Gabon,GA,330.590,0.000,0.084,1.155464484
Gambia,GM,-,-,-,-
Ghana,GH,1605.8,0.0,56.12238684589444,1.0277120000000002
Guinea,GN,367.15,0.0,0.3594381356103611,0.154203
Ghana,GH,1605.800,0.000,56.423,772.9224202
Guinea,GN,367.150,0.000,0.361,4.950213441
Guinea-Bissau,GW,-,-,-,-
Kenya,KE,836.48,0.0,1.192706097288018,0.334592
Lesotho,LS,72.0,0.0,0.9797599279270833,0.05616
Liberia,LR,93.0,0.0,0.01231224853018611,0.0558
Kenya,KE,836.480,0.000,-,-
Lesotho,LS,72.000,0.000,0.985,13.49333942
Liberia,LR,93.000,0.000,0.012,0.169565364
Libya,LY,-,-,-,-
Madagascar,MG,-,-,-,-
Malawi,MW,348.75,0.0,0.0,0.202275
Mali,ML,356.478,0.0,2.3049819842874997,0.20319246
Mauritania,MR,49.0,0.0,0.0019948265199236114,0.027440000000000003
Morocco,MA,1922.972,466.0,2.9832338646504724,0.46151327999999997
Mozambique,MZ,2207.11,0.0,24.62189631717892,1.5670480999999998
Malawi,MW,348.750,0.000,0.000,0
Mali,ML,356.478,0.000,2.317,31.74441348
Mauritania,MR,49.000,0.000,0.002,0.027472925
Morocco,MA,1922.972,466.000,2.999,41.08339401
Mozambique,MZ,2207.110,0.000,24.754,339.0949095
Namibia,NA,353.000,0.000,0.951,13.03140528
Niger,NE,-,-,-,-
Nigeria,NG,2058.34,0.0,5.9879368969524025,0.823336
Rwanda,RW,140.35,0.0,0.0016034657281999995,0.05614
Senegal,SN,150.0,0.0,0.0019948265199236114,0.069
Sierra Leone,SL,61.2,0.0,0.1063545357661111,0.016524
Niger,NE0
Nigeria,NG,2058.340,0.000,6.020,82.46639066
Rwanda,RW,140.350,0.000,-,-
Senegal,SN,150.000,0.000,0.002,0.027472925
Sierra Leone,SL,61.200,0.000,0.107,1.464723968
Somalia,SO,-,-,-,-
South Africa,ZA,3624.754,2922.4,2.298976201229809,0.65245572
South Sudan,SS,5.0,0.0,0.0,0.00455
Sudan,SD,1903.8,0.0,4.624738449539444,0.76152
Tanzania,TZ,572.0,0.0,0.5043584121292499,0.2574
Togo,TG,32.8,0.0,0.241497582235,0.014431999999999999
Tunisia,TN,62.324999999999996,0.0,0.11927120722619375,0.0074789999999999995
Uganda,UG,741.2,0.0,6.518163551281302,0.378012
South Africa,ZA,3624.754,2922.400,2.311,31.66170131
South Sudan,SS,5.000,0.000,0.000,0
Sudan,SD,1903.800,0.000,4.650,63.69230241
Swaziland,SZ,88.490,0.000,0.119,1.633063617
Tanzania,TZ,572.000,0.000,0.507,6.946068164
Togo,TG,32.800,0.000,0.243,3.325925824
Tunisia,TN,62.325,0.000,0.106,1.45312886
Uganda,UG,741.200,0.000,6.553,89.76871852
Western Sahara,EH,-,-,-,-
Zambia,ZM,2325.55,0.0,33.95387782885528,1.5116075
Zimbabwe,ZW,1001.79,0.0,32.67810226666262,0.7012529999999999
Zambia,ZM,2325.550,0.000,34.136,467.6157751
Zimbabwe,ZW,1001.790,0.000,32.853,450.0456825
9 changes: 6 additions & 3 deletions scripts/add_electricity.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def calculate_annuity(n, r):
discount rate of r, e.g. annuity(20, 0.05) * 20 = 1.6
"""
if isinstance(r, pd.Series):
return pd.Series(1 / n, index=r.index).where(
return pd.Series(1 / n, index=r.index, dtype=float).where(
r == 0, r / (1.0 - 1.0 / (1.0 + r) ** n)
)
elif r > 0:
Expand Down Expand Up @@ -187,7 +187,8 @@ def costs_for_storage(store, link1, link2=None, max_hours=1.0):
if link2 is not None:
capital_cost += link2["capital_cost"]
return pd.Series(
dict(capital_cost=capital_cost, marginal_cost=0.0, co2_emissions=0.0)
dict(capital_cost=capital_cost, marginal_cost=0.0, co2_emissions=0.0),
dtype=float,
)

max_hours = elec_config["max_hours"]
Expand Down Expand Up @@ -374,7 +375,9 @@ def attach_conventional_generators(
conventional_config,
conventional_inputs,
):
carriers = set(conventional_carriers) | (set(extendable_carriers["Generator"]) - set(renewable_carriers))
carriers = set(conventional_carriers) | (
set(extendable_carriers["Generator"]) - set(renewable_carriers)
)
_add_missing_carriers_from_costs(n, costs, carriers)

ppl = (
Expand Down
12 changes: 6 additions & 6 deletions scripts/monte_carlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def monte_carlo_sampling_pydoe2(
correlation_matrix=correlation_matrix,
)
discrepancy = qmc.discrepancy(lh)
logger.info("Hypercube discrepancy is:", discrepancy)
logger.info(f"Hypercube discrepancy is: {discrepancy}")

return lh

Expand All @@ -121,9 +121,9 @@ def monte_carlo_sampling_chaospy(N_FEATURES, SAMPLES, rule="latin_hypercube", se
uniform_cube = eval(
f"chaospy.J({N_FEATURES})"
) # writes Nfeatures times the chaospy.uniform... command)
lh = uniform_cube.sample(SAMPLES, rule=rule, seed=seed).T
lh = np.atleast_2d(uniform_cube.sample(SAMPLES, rule=rule, seed=seed)).T
discrepancy = qmc.discrepancy(lh)
logger.info("Hypercube discrepancy is:", discrepancy)
logger.info(f"Hypercube discrepancy is: {discrepancy}")

return lh

Expand Down Expand Up @@ -154,7 +154,7 @@ def monte_carlo_sampling_scipy(
)
lh = sampler.random(n=SAMPLES)
discrepancy = qmc.discrepancy(lh)
logger.info("Hypercube discrepancy is:", discrepancy)
logger.info(f"Hypercube discrepancy is: {discrepancy}")

return lh

Expand All @@ -167,9 +167,9 @@ def monte_carlo_sampling_scipy(
snakemake = mock_snakemake(
"monte_carlo",
simpl="",
clusters="10",
clusters="6",
ll="copt",
opts="Co2L-24H",
opts="Co2L-4H",
unc="m0",
)
configure_logging(snakemake)
Expand Down

0 comments on commit 7986630

Please sign in to comment.