Skip to content

Commit 9bdadc2

Browse files
committed
Format and remove debug
1 parent 266e2a8 commit 9bdadc2

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

src/dscim/preprocessing/input_damages.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -771,12 +771,18 @@ def prep(
771771

772772
d_ls = []
773773
for eta in etas:
774-
paths_ls = [paths.format(i,eta) for i in range(15)]
775-
data = xr.open_mfdataset(paths_ls, preprocess=prep, parallel=True, engine="zarr").assign_coords({'eta': eta}).expand_dims('eta')
774+
paths_ls = [paths.format(i, eta) for i in range(15)]
775+
data = (
776+
xr.open_mfdataset(
777+
paths_ls, preprocess=prep, parallel=True, engine="zarr"
778+
)
779+
.assign_coords({"eta": eta})
780+
.expand_dims("eta")
781+
)
776782
d_ls.append(data)
777-
783+
778784
data = xr.merge(d_ls)
779-
785+
780786
damages = xr.Dataset(
781787
{
782788
"delta": (
@@ -804,7 +810,6 @@ def prep(
804810
"gcm": 1,
805811
"year": 10,
806812
"region": -1,
807-
"eta": 1,
808813
}
809814
)
810815
damages.coords.update({"batch": [f"batch{i}" for i in damages.batch.values]})
@@ -821,7 +826,7 @@ def prep(
821826
if damages[v].dtype == object:
822827
damages[v] = damages[v].astype("unicode")
823828

824-
damages.coords['gcm'] = damages.coords['gcm'].astype('object')
829+
damages.coords["gcm"] = damages.coords["gcm"].astype("object")
825830

826831
if i == 0:
827832
damages.to_zarr(

src/dscim/preprocessing/preprocessing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ def ce_from_chunk(
4343
else:
4444
raise NotImplementedError("Pass 'cc' or 'no_cc' to reduction.")
4545

46-
calculation = xr.where(calculation > 1e8, np.nan, calculation)
47-
4846
if recipe == "adding_up":
4947
result = mean_func(
5048
np.maximum(
@@ -110,7 +108,9 @@ def reduce_damages(
110108
}
111109

112110
ce_batch_dims = [i for i in gdppc.dims] + [
113-
i for i in ds.dims if i not in gdppc.dims and i != "batch" and i != "eta"
111+
i
112+
for i in ds.dims
113+
if i not in gdppc.dims and i != "batch" and i != "eta"
114114
]
115115
ce_batch_coords = {c: ds[c].values for c in ce_batch_dims}
116116
ce_batch_coords["region"] = [
@@ -126,8 +126,8 @@ def reduce_damages(
126126

127127
other = xr.open_zarr(damages).chunk(chunkies)
128128
if "eta" in other.coords:
129-
other = other.sel(eta = eta, drop=True)
130-
129+
other = other.sel(eta=eta, drop=True)
130+
131131
out = other.map_blocks(
132132
ce_from_chunk,
133133
kwargs=dict(

src/dscim/utils/menu_runs.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ def run_ssps(
104104
"damage_function_path": f"{conf['paths']['ssp_damage_function_library']}/{sector}/2020/unmasked",
105105
"save_files": [
106106
"damage_function_points",
107-
#"uncollapsed_marginal_damages",
108-
#"uncollapsed_discount_factors",
109107
"marginal_damages",
110108
"discount_factors",
111109
"uncollapsed_sccs",

0 commit comments

Comments
 (0)