Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
thornoe committed Apr 16, 2024
1 parent 0a8ada1 commit 4b7d1f0
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion gis/CV_coastal.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def stepwise_selection(subset, dummies, data, dfDummies, years):
a.to_csv("output/coastal_" + b + ".csv") # save means by subset to CSV
f = {row: "{:0.0f}".format if row == "n" else "{:0.4f}".format for row in a.index}
with open("output/coastal_" + b + ".tex", "w") as tf:
tf.write(a.apply(f, axis=1).to_latex()) # apply formatter and save to LaTeX
tf.write(a.apply(f, axis=1).to_latex(column_format="lcc")) # column alignment


########################################################################################
Expand Down
2 changes: 1 addition & 1 deletion gis/CV_lakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def stepwise_selection(subset, dummies, data, dfDummies, years):
a.to_csv("output/lakes_" + b + ".csv") # save means by subset to CSV
f = {row: "{:0.0f}".format if row == "n" else "{:0.4f}".format for row in a.index}
with open("output/lakes_" + b + ".tex", "w") as tf:
tf.write(a.apply(f, axis=1).to_latex()) # apply formatter and save to LaTeX
tf.write(a.apply(f, axis=1).to_latex(column_format="lccc")) # column alignment


########################################################################################
Expand Down
2 changes: 1 addition & 1 deletion gis/CV_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def stepwise_selection(subset, dummies, data, dfDummies, years, select_all=False
a.to_csv("output/streams_" + b + ".csv") # save means by subset to CSV
f = {row: "{:0.0f}".format if row == "n" else "{:0.4f}".format for row in a.index}
with open("output/streams_" + b + ".tex", "w") as tf:
tf.write(a.apply(f, axis=1).to_latex()) # apply formatter and save to LaTeX
tf.write(a.apply(f, axis=1).to_latex(column_format="lccc")) # column alignment


########################################################################################
Expand Down
2 changes: 1 addition & 1 deletion gis/output/all_cost_decomposed_growth.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\begin{tabular}{llll}
\begin{tabular}{lrrr}
\toprule
& growth (million DKK) & growth (\%) & growth rate (\%) \\
driver & & & \\
Expand Down
2 changes: 1 addition & 1 deletion gis/output/all_cost_decomposed_growth_v.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\begin{tabular}{llllllll}
\begin{tabular}{lrrrrrrr}
\toprule
& mean & std & min & 25\% & 50\% & 75\% & max \\
driver & & & & & & & \\
Expand Down
4 changes: 2 additions & 2 deletions gis/output/all_investment_decomposed_v.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\begin{tabular}{llllllll}
\begin{tabular}{lrrrrrrr}
\toprule
& mean & std & min & 25\% & 50\% & 75\% & max \\
driver & & & & & & & \\
Expand All @@ -7,5 +7,5 @@
lakes & 2,533 & 1,619 & -2,161 & 1,577 & 2,367 & 3,390 & 7,059 \\
streams & 4,843 & 4,501 & -7,313 & 2,091 & 5,522 & 7,959 & 17,402 \\
all & 8,062 & 4,375 & -4,551 & 5,024 & 8,003 & 10,503 & 21,378 \\
\bottomrule
\bottomrules
\end{tabular}
3 changes: 1 addition & 2 deletions gis/output/coastal_VP_basis.csv
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ Stratified,1.605263157894737,1.7333333333333334
Sediment,1.6785714285714286,1.6774193548387097
Saline,1.6,1.7435897435897436
Tide,1.4285714285714286,1.4285714285714286
All,1.6458333333333333,1.712962962962963
n,96.0,108.0
All,96.0,108.0
5 changes: 2 additions & 3 deletions gis/output/coastal_VP_basis.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\begin{tabular}{lll}
\begin{tabular}{lcc}
\toprule
& Observed subset & All in basis analysis \\
\midrule
Expand All @@ -15,7 +15,6 @@
Sediment & 1.6786 & 1.6774 \\
Saline & 1.6000 & 1.7436 \\
Tide & 1.4286 & 1.4286 \\
All & 1.6458 & 1.7130 \\
n & 96 & 108 \\
All & 96.0000 & 108.0000 \\
\bottomrule
\end{tabular}
2 changes: 1 addition & 1 deletion gis/output/coastal_VP_stats.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\begin{tabular}{lll}
\begin{tabular}{lcc}
\toprule
& Observed subset & All in VP3 \\
\midrule
Expand Down
2 changes: 1 addition & 1 deletion gis/output/lakes_VP_basis.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\begin{tabular}{llll}
\begin{tabular}{lccc}
\toprule
& Sparse subset & Observed subset & All in basis analysis \\
\midrule
Expand Down
2 changes: 1 addition & 1 deletion gis/output/lakes_VP_stats.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\begin{tabular}{llll}
\begin{tabular}{lccc}
\toprule
& Sparse subset & Observed subset & All in VP3 \\
\midrule
Expand Down
2 changes: 1 addition & 1 deletion gis/output/streams_VP_basis.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\begin{tabular}{llll}
\begin{tabular}{lccc}
\toprule
& Sparse subset & Observed subset & All in basis analysis \\
\midrule
Expand Down
2 changes: 1 addition & 1 deletion gis/output/streams_VP_stats.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\begin{tabular}{llll}
\begin{tabular}{lccc}
\toprule
& Sparse subset & Observed subset & All in VP3 \\
\midrule
Expand Down
8 changes: 5 additions & 3 deletions gis/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@
col: "{:0,.0f}".format if col == growth.columns[0] else "{:0.2f}".format
for col in growth.columns
}
col_f = "lrrr" # right-aligned column format; match number of columns
print("Growth in total CWP due to driver (other things equal at 2018 level)")
print(d.tail(3), "\n")
else:
Expand All @@ -319,13 +320,14 @@
)
growth = d[d.index.get_level_values("t") == "g (%)"].describe().drop("count").T
growth.columns = ["mean", "std", "min", "25\%", "50\%", "75\%", "max"]
f = {col: "{:0.2f}".format for col in growth.columns}
f = {col: "{:0.2f}".format for col in growth.columns} # two decimals
col_f = "lrrrrrrr" # right-aligned column format; match number of columns
print("The 15 catchment areas with largest reduction in total CWP")
print(d.loc["g (%)", :].nsmallest(15, ("all")), "\n")
print("The 15 catchment areas with largest increase in total CWP")
print(d.loc["g (%)", :].nlargest(15, ("all")), "\n")
with open("output\\all_cost_decomposed_growth" + suffix + ".tex", "w") as tf:
tf.write(growth.apply(f).to_latex()) # apply formatter and save to LaTeX
tf.write(growth.apply(f).to_latex(column_format=col_f)) # column alignment
d.to_csv("output\\all_cost_decomposed" + suffix + ".csv") # save table as CSV

# Colors and line styles by category j - matching those used for total CWP decomposition
Expand Down Expand Up @@ -382,7 +384,7 @@
mean.columns = ["mean", "std", "min", "25\%", "50\%", "75\%", "max"]
f = {col: "{:0,.0f}".format for col in mean.columns}
with open("output\\all_investment_decomposed_v.tex", "w") as tf:
tf.write(mean.apply(f).to_latex()) # apply formatter and save to LaTeX
tf.write(mean.apply(f).to_latex(column_format="lrrrrrrr")) # col alignment
print("The 15 catchment areas with lowest total IV per household")
print(d.loc["mean IV", :].nsmallest(15, ("all")), "\n")
print("The 15 catchment areas with highest total IV per household")
Expand Down
8 changes: 5 additions & 3 deletions gis/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@
col: "{:0,.0f}".format if col == growth.columns[0] else "{:0.2f}".format
for col in growth.columns
}
col_f = "lrrr" # right-aligned column format; match number of columns
print("Growth in total CWP due to driver (other things equal at 2018 level)")
print(d.tail(3), "\n")
else:
Expand All @@ -283,13 +284,14 @@
)
growth = d[d.index.get_level_values("t") == "g (%)"].describe().drop("count").T
growth.columns = ["mean", "std", "min", "25\%", "50\%", "75\%", "max"]
f = {col: "{:0.2f}".format for col in growth.columns}
f = {col: "{:0.2f}".format for col in growth.columns} # two decimals
col_f = "lrrrrrrr" # right-aligned column format; match number of columns
print("The 15 catchment areas with largest reduction in total CWP")
print(d.loc["g (%)", :].nsmallest(15, ("all")), "\n")
print("The 15 catchment areas with largest increase in total CWP")
print(d.loc["g (%)", :].nlargest(15, ("all")), "\n")
with open("output\\all_cost_decomposed_growth" + suffix + ".tex", "w") as tf:
tf.write(growth.apply(f).to_latex()) # apply formatter and save to LaTeX
tf.write(growth.apply(f).to_latex(column_format=col_f)) # column alignment
d.to_csv("output\\all_cost_decomposed" + suffix + ".csv") # save table as CSV

# Colors and line styles by category j - matching those used for total CWP decomposition
Expand Down Expand Up @@ -346,7 +348,7 @@
mean.columns = ["mean", "std", "min", "25\%", "50\%", "75\%", "max"]
f = {col: "{:0,.0f}".format for col in mean.columns}
with open("output\\all_investment_decomposed_v.tex", "w") as tf:
tf.write(mean.apply(f).to_latex()) # apply formatter and save to LaTeX
tf.write(mean.apply(f).to_latex(column_format="lrrrrrrr")) # col alignment
print("The 15 catchment areas with lowest total IV per household")
print(d.loc["mean IV", :].nsmallest(15, ("all")), "\n")
print("The 15 catchment areas with highest total IV per household")
Expand Down

0 comments on commit 4b7d1f0

Please sign in to comment.