Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Remove old/unnecessary files. ([PR #57](https://github.com/ClimateImpactLab/dscim/pull/57), [@JMGilbert](https://github.com/JMGilbert))
- Remove unused “save_path” and “ec_cls” from `read_energy_files_parallel()`. ([PR #56](https://github.com/ClimateImpactLab/dscim/pull/56), [@davidrzhdu](https://github.com/davidrzhdu))
### Fixed
- Make rff damage functions read in and save out in the proper filepath structure. ([PR #79](https://github.com/ClimateImpactLab/dscim/pull/79), [@JMGilbert](https://github.com/JMGilbert))
- Enter the proper functional form of isoelastic utility when `eta = 1`. ([PR #65](https://github.com/ClimateImpactLab/dscim/pull/65), [@JMGilbert](https://github.com/JMGilbert))
- Pin numpy version to stop tests failing. ([PR #60](https://github.com/ClimateImpactLab/dscim/pull/60), [@JMGilbert](https://github.com/JMGilbert))

Expand Down
9 changes: 6 additions & 3 deletions src/dscim/utils/rff.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def weight_df(
factors,
pulse_year,
fractional=False,
mask="unmasked",
):
"""Weight, fractionalize, and combine SSP damage functions,
then multiply by RFF GDP to return RFF damage functions.
Expand All @@ -328,7 +329,7 @@ def weight_df(
# get damage function as share of global GDP
df = (
xr.open_dataset(
f"{in_library}/{sector}/{pulse_year}/{recipe}_{disc}_eta{eta_rho[0]}_rho{eta_rho[1]}_{file}.nc4"
f"{in_library}/{sector}/{pulse_year}/{mask}/{recipe}_{disc}_eta{eta_rho[0]}_rho{eta_rho[1]}_{file}.nc4"
)
/ ssp_gdp
)
Expand All @@ -339,7 +340,7 @@ def weight_df(
# save fractional damage function
if fractional:
rff.sel(year=slice(2020, 2099)).to_netcdf(
f"{out_library}/{sector}/{pulse_year}/{recipe}_{disc}_eta{eta_rho[0]}_rho{eta_rho[1]}_fractional_{file}.nc4"
f"{out_library}/{sector}/{pulse_year}/{mask}/{recipe}_{disc}_eta{eta_rho[0]}_rho{eta_rho[1]}_fractional_{file}.nc4"
)

# recover damage function as dollars instead of fraction
Expand All @@ -352,7 +353,7 @@ def weight_df(

os.makedirs(f"{out_library}/{sector}/{pulse_year}/", exist_ok=True)
dfs.to_netcdf(
f"{out_library}/{sector}/{pulse_year}/{recipe}_{disc}_eta{eta_rho[0]}_rho{eta_rho[1]}_{file}.nc4"
f"{out_library}/{sector}/{pulse_year}/{mask}/{recipe}_{disc}_eta{eta_rho[0]}_rho{eta_rho[1]}_{file}.nc4"
)


Expand All @@ -368,6 +369,7 @@ def rff_damage_functions(
runid_path,
weights_path,
pulse_year,
mask,
):
"""Wrapper function for `weight_df()`."""

Expand Down Expand Up @@ -405,6 +407,7 @@ def rff_damage_functions(
weights=weights,
factors=factors,
pulse_year=pulse_year,
mask=mask,
)


Expand Down