input_damages
Calculate damages from the projection system using VSL
Functions:
Name | Description |
---|---|
calculate_energy_impacts |
Calculate impacts for labor results for individual modeling unit. |
calculate_labor_impacts |
Calculate impacts for labor results. |
compute_ag_damages |
Reshapes ag estimate runs for use in integration system, |
concatenate_damage_output |
Concatenate labor/energy damage output across batches. |
concatenate_energy_damages |
Concatenate damages across batches and create a lazy array for future |
concatenate_labor_damages |
Concatenate damages across batches. |
read_energy_files |
Read energy CSV files and trasnform them to Xarray objects |
read_energy_files_parallel |
Concatenate energy results from CSV to NetCDF by batches using |
dscim.preprocessing.input_damages.calculate_energy_impacts
calculate_energy_impacts(input_path, file_prefix, variable)
Calculate impacts for labor results for individual modeling unit.
Read in individual damages files from the labor projection system output and re-index to add region dimension. This is needed to adjust the projection file outcomes that do not have a region dimension
Paramemters
input_path str
Path to model/gcm/iam/rcp/ folder, usually from the
_parse_projection_filesys
function.
file_prefix str
Prefix of the MC output filenames
variable str
Variable to use within xr.Dataset
Returns:
Type | Description |
---|---|
xr.Dataset object with per-capita monetary damages
|
|
Source code in src/dscim/preprocessing/input_damages.py
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 |
|
dscim.preprocessing.input_damages.calculate_labor_impacts
calculate_labor_impacts(input_path, file_prefix, variable, val_type)
Calculate impacts for labor results.
Paramemters
input_path str
Path to model/gcm/iam/rcp/ folder, usually from the
_parse_projection_filesys
function.
file_prefix str
Prefix of the MC output filenames
variable str
Variable to use within xr.Dataset
val_type str
Valuation type.
Returns:
Type | Description |
---|---|
xr.Dataset object with per-capita monetary damages
|
|
Source code in src/dscim/preprocessing/input_damages.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
dscim.preprocessing.input_damages.compute_ag_damages
compute_ag_damages(input_path, save_path, pop, varname, query='exists==True', topcode=None, scalar=None, integration=False, batches=range(0, 15), num_cpus=15, file='/disaggregated_damages.nc4', vars=None, min_year=2010, max_year=2099)
Reshapes ag estimate runs for use in integration system, then converts to negative per capita damages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_path
|
Path to NetCDF4 files to be reshaped. |
required | |
file
|
Name of files to be globbed. |
'/disaggregated_damages.nc4'
|
|
integration
|
If True, will format files to be integrated with other sectors. |
False
|
|
pop
|
Population data to convert ag damages into per capita terms. |
required | |
save_path
|
Path where files should be saved |
required |
Source code in src/dscim/preprocessing/input_damages.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
|
dscim.preprocessing.input_damages.concatenate_damage_output
concatenate_damage_output(damage_dir, basename, save_path)
Concatenate labor/energy damage output across batches.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
damage_dir
|
Directory containing separate labor/energy damage output files by batches. |
required | |
basename
|
Prefix of the damage output filenames (ex. {basename}_batch0.zarr) |
required | |
save_path
|
Path to save concatenated file in .zarr format |
required |
Source code in src/dscim/preprocessing/input_damages.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
dscim.preprocessing.input_damages.concatenate_energy_damages
concatenate_energy_damages(input_path, save_path, ec_cls, file_prefix='TINV_clim_integration_total_energy', variable='rebased', format_file='netcdf', **kwargs)
Concatenate damages across batches and create a lazy array for future calculations.
Using the value_mortality_damages
function this function lazily loads all
damages for SCC calculations and scale damage to per-capital damages and
also scale labor inpacts to indicate increasing damages as positive, and
gains from warming as negative.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_path
|
Directory containing all raw projection output. |
required | |
ec_cls
|
EconVars class with population and GDP data to rescale damages |
required | |
save_path
|
Path to save concatenated file in .zarr or .nc4 format |
required | |
file_prefix
|
Prefix of the MC output filenames |
'TINV_clim_integration_total_energy'
|
|
variables
|
Variable names to extract from calculated damages |
required | |
format_file
|
Format to save file. Options are 'netcdf' or 'zarr' |
'netcdf'
|
|
**kwargs
|
Other options passed to the |
{}
|
Source code in src/dscim/preprocessing/input_damages.py
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
|
dscim.preprocessing.input_damages.concatenate_labor_damages
concatenate_labor_damages(input_path, save_path, ec_cls, file_prefix='uninteracted_main_model', variable='rebased', val_type='wage-levels', format_file='netcdf', **kwargs)
Concatenate damages across batches.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_path
|
Directory containing all raw projection output. |
required | |
ec_cls
|
EconVars class with population and GDP data to rescale damages |
required | |
save_path
|
Path to save concatenated file in .zarr or .nc4 format |
required | |
file_prefix
|
Prefix of the MC output filenames |
'uninteracted_main_model'
|
|
variables
|
Variable names to extract from calculated damages |
required | |
format_file
|
Format to save file. Options are 'netcdf' or 'zarr' |
'netcdf'
|
|
**kwargs
|
Other options passed to the |
{}
|
Source code in src/dscim/preprocessing/input_damages.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
dscim.preprocessing.input_damages.read_energy_files
read_energy_files(df, seed='TINV_clim_price014_total_energy_fulladapt-histclim')
Read energy CSV files and trasnform them to Xarray objects
This function reads a dataframe with the filesystem metadata (from
_parse_projection_filesys
) to read all CSV files in it with the desired
seed
and transform to xarray object adding the directory metadata as
new dimensions, this will be helpful for data concatenation.
This function is parallelized by read_energy_files_parallel
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame with projection system metadata by batch/RCP/IAM/GCM |
required |
Returns:
Type | Description |
---|---|
None
|
Saved data array with expanded damages from original CSV |
Source code in src/dscim/preprocessing/input_damages.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 |
|
dscim.preprocessing.input_damages.read_energy_files_parallel
read_energy_files_parallel(input_path, **kwargs)
Concatenate energy results from CSV to NetCDF by batches using multiprocessing
This function takes all CSV files per batch and maps the
read_energy_files
function to all the files within a batch. The files
will be saved in the same path as the CSV files but in NetCDF format.
Once saved, the files will be read again, using a Dask Client
and
chunked to be finally saved as files per batch. Before saving, the function
will calculate damages per capita using SSP populations for each scenario
with a EconVars
class and then calculate 2019 USD damages
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_path
|
str
|
Path to root folder organized by batch containing all projection system files |
required |
**kwargs
|
Other elements too the |
{}
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/dscim/preprocessing/input_damages.py
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 |
|