Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f3d04c1
Add pytests for processing labor input damages
davidrzhdu Feb 1, 2023
51de339
Code modification
davidrzhdu Feb 1, 2023
7d39ee4
Fix some errors
davidrzhdu Feb 1, 2023
c26cef3
Fix some errors
davidrzhdu Feb 1, 2023
736f096
“black”
davidrzhdu Feb 7, 2023
5f92462
Add pytest fixtures and clean some functions
davidrzhdu Feb 9, 2023
bcb8360
Merge branch 'dscim-v0.4.0' into input_damages_pytests
JMGilbert Feb 9, 2023
4a69ee6
Add pytests for processing energy input damages
davidrzhdu Feb 13, 2023
ca0b63d
Add pytests for processing Ag and coastal input damages
davidrzhdu Mar 2, 2023
02d7bfc
Remove unused variables
davidrzhdu Mar 2, 2023
b2ac7a9
Add pytesy for processing coastal input damages
davidrzhdu Mar 7, 2023
4c012db
test errors in coastal inputs
davidrzhdu Apr 13, 2023
5b7b71c
Rewrite test_error_coastal_inputs
davidrzhdu Apr 13, 2023
e17ee3d
Add pytest for 'prep_mortality_damages()'
davidrzhdu Apr 21, 2023
00e93db
Clean work flow
davidrzhdu Apr 21, 2023
7312c34
Convert ag ds_out_expected to float32
davidrzhdu Apr 21, 2023
c2798a4
Merge branch 'dscim-v0.4.0' into input_damages_pytests
davidrzhdu Apr 21, 2023
4097883
change filepath and make the format of mortality v0 output consistent…
davidrzhdu Apr 21, 2023
65f7195
Remove NoneType batches before concatenation
davidrzhdu Apr 24, 2023
9cd2ebe
Add pytests for some untested lines
davidrzhdu Apr 24, 2023
f5776c8
Force chunk_size to be 1 when it is zero
davidrzhdu Apr 24, 2023
d7a65cb
Add pytest for calculate_energy_damages()
davidrzhdu Apr 24, 2023
6709621
Fix wrong file path
davidrzhdu Apr 24, 2023
d0a7e83
Add docstring to each function
davidrzhdu Apr 26, 2023
83beb43
Remove unnecessary update
davidrzhdu Apr 26, 2023
d35a971
'flake8'
davidrzhdu Apr 26, 2023
db55896
Rename econvars correctly
davidrzhdu Apr 26, 2023
d66fb0e
Update CHANGELOG.md
davidrzhdu Apr 26, 2023
1aaa8e2
Merge branch 'dscim-v0.4.0' into input_damages_pytests
davidrzhdu Apr 26, 2023
9f4a35e
Remove testing return statement in concatenate_labor_damages
davidrzhdu May 3, 2023
7cf92eb
Remove testing return statement in concatenate_energy_damages and upd…
davidrzhdu May 3, 2023
15fac41
'black'
davidrzhdu May 3, 2023
9dee1f3
Update CHANGELOG.md
davidrzhdu May 3, 2023
d744c98
Fix tiny issue
davidrzhdu May 3, 2023
5d33021
Merge branch 'input_damages_pytests' of https://github.com/ClimateImp…
davidrzhdu May 3, 2023
8bdc1ee
Set file path correctly
davidrzhdu May 3, 2023
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
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.4.0] - Unreleased
### Added
- New unit tests for [dscim/utils/input_damages.py](https://github.com/ClimateImpactLab/dscim/blob/main/src/dscim/preprocessing/input_damages.py). ([PR #68](https://github.com/ClimateImpactLab/dscim/pull/68), [@davidrzhdu](https://github.com/davidrzhdu))
- New unit tests for [dscim/utils/rff.py](https://github.com/ClimateImpactLab/dscim/blob/main/src/dscim/utils/rff.py). ([PR #73](https://github.com/ClimateImpactLab/dscim/pull/73), [@JMGilbert](https://github.com/JMGilbert))
- New unit tests for [dscim/dscim/preprocessing.py](https://github.com/ClimateImpactLab/dscim/blob/main/src/dscim/preprocessing/preprocessing.py). ([PR #67](https://github.com/ClimateImpactLab/dscim/pull/67), [@JMGilbert](https://github.com/JMGilbert))
- Add functions used for producing RFF weights. ([PR #66](https://github.com/ClimateImpactLab/dscim/pull/66), [@davidrzhdu](https://github.com/davidrzhdu))
- Functions used for producing RFF weights. ([PR #66](https://github.com/ClimateImpactLab/dscim/pull/66), [@davidrzhdu](https://github.com/davidrzhdu))
### Changed
- Changed `prep_mortality_damages` function to work with new format mortality outputs. ([PR #74](https://github.com/ClimateImpactLab/dscim/pull/65), [@JMGilbert](https://github.com/JMGilbert))
- Changed `coastal_inputs` function to work with new version of coastal outputs. ([PR #75](https://github.com/ClimateImpactLab/dscim/pull/75), [@davidrzhdu](https://github.com/davidrzhdu))
- Changed `prep_mortality_damages` function to work with new format mortality outputs. ([PR #74](https://github.com/ClimateImpactLab/dscim/pull/74) and [PR #68](https://github.com/ClimateImpactLab/dscim/pull/68), [@JMGilbert](https://github.com/JMGilbert))
- Included US territories in damages and economic variable subsetting. ([PR #78](https://github.com/ClimateImpactLab/dscim/pull/78), [@JMGilbert](https://github.com/JMGilbert))
- Changed format of `eta_rhos` to allow for multiple values of `rho` for the same `eta`. ([PR #65](https://github.com/ClimateImpactLab/dscim/pull/65), [@JMGilbert](https://github.com/JMGilbert))
### Removed
Expand All @@ -20,6 +22,8 @@ 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
- Add `.load()` to every loading of population data from EconVars. ([PR #82](https://github.com/ClimateImpactLab/dscim/pull/82), [@davidrzhdu](https://github.com/davidrzhdu))
- Make `compute_ag_damages` function correctly save outputs in float32. ([PR #72](https://github.com/ClimateImpactLab/dscim/pull/72) and [PR #82](https://github.com/ClimateImpactLab/dscim/pull/82), [@davidrzhdu](https://github.com/davidrzhdu))
- 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
24 changes: 15 additions & 9 deletions src/dscim/preprocessing/input_damages.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ def process_batch(g):
batches = p_map(
process_batch, [g for i, g in paths.groupby("batch")], num_cpus=num_cpus
)
batches = [ds for ds in batches if ds is not None]
chunkies = {
"rcp": 1,
"region": 24378,
Expand Down Expand Up @@ -704,11 +705,18 @@ def prep(
scaling_costs=scaling_costs,
valuation=valuation,
):
return ds.sel(
gcm=gcm,
scaling=[scaling_deaths, scaling_costs],
valuation=valuation,
).drop(["gcm", "valuation"])
if scaling_deaths == scaling_costs:
return ds.sel(
gcm=gcm,
scaling=[scaling_deaths],
valuation=valuation,
).drop(["gcm", "valuation"])
else:
return ds.sel(
gcm=gcm,
scaling=[scaling_deaths, scaling_costs],
valuation=valuation,
).drop(["gcm", "valuation"])

data = xr.open_mfdataset(paths, preprocess=prep, parallel=True, engine="zarr")

Expand Down Expand Up @@ -747,15 +755,13 @@ def prep(

if i == 0:
damages.to_zarr(
outpath
/ f"impacts-darwin-montecarlo-damages-v{mortality_version}.zarr",
f"{outpath}/impacts-darwin-montecarlo-damages-v{mortality_version}.zarr",
consolidated=True,
mode="w",
)
else:
damages.to_zarr(
outpath
/ f"impacts-darwin-montecarlo-damages-v{mortality_version}.zarr",
f"{outpath}/impacts-darwin-montecarlo-damages-v{mortality_version}.zarr",
consolidated=True,
append_dim="gcm",
)
Expand Down
Loading