Skip to main content

Prototype framework for projected socio-economic climate damages

Project description

pythonpackage codecov

dlong

Prototype framework for projected socio-economic climate damages

This is a prototype. It is likely to change in breaking ways. It might delete all your data so don't use it in production.

Examples

import dlong
from dlong.types import ClimateData
import xarray as xr

# First, let's make some demo data.
# Say 3 years of annual temperature data across 3 regions:
region = [1, 2, 3]
year = [2019, 2020, 2021]
input_temperature = xr.DataArray(
    [[1.0, 2.0, 3.0], [2.0, 3.0, 4.0], [3.0, 4.0, 5.0]],
    coords=[region, year],
    dims=["region", "year"],
)
# And here are coefficients for a quadratic damage function. Different for 
# each region.
damage_coefficients = xr.Dataset(
    data_vars={
        "beta0": (["region"], [1, 1, 1]),
        "beta1": (["region"], [1, 2, 3]),
        "beta2": (["region"], [4, 5, 6]),
    },
    coords={"region": (["region"], region)},
)

# Put it all together to describe climate data, a damage function, and
# a strategy for discounting damages.
climate = dlong.types.ClimateData(temperature=input_temperature)
damage_model = dlong.QuadraticDamageModel(coefs=damage_coefficients)
discount_strategy = dlong.FractionalDiscount(rate=0.02, reference_year=2020)
# We could use these individually, or combine them into a "recipe" to output 
# discounted damages. The idea is that these components are compositable
# so components can be customized and run in large batches.
recipe = dlong.ExampleRecipe(
    climate=climate, damage_function=damage_model, discount=discount_strategy
)
damages = recipe.discounted_damages()
#<xarray.DataArray (region: 3, year: 3)>
#array([[  6.12      ,  19.        ,  39.21568627],
#       [ 25.5       ,  52.        ,  87.25490196],
#       [ 65.28      , 109.        , 162.74509804]])
#Coordinates:
#* region   (region) int64 1 2 3
#* year     (year) int64 2019 2020 2021

Installation

pip install dlong

dlong currently requires Python > 3.8 and the xarray package.

Install the unreleased bleeding-edge version of the package with:

pip install git+https://github.com/brews/dlong

Support

Source code is available online at https://github.com/brews/dlong/. This software is Open Source and available under the Apache License, Version 2.0.

Development

Please file bugs in the bug tracker.

Want to contribute? Great! Fork the main branch and file a pull request when you're ready. Please be sure to write unit tests and follow pep8. Fork away!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dlong-0.2.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

dlong-0.2.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file dlong-0.2.0.tar.gz.

File metadata

  • Download URL: dlong-0.2.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for dlong-0.2.0.tar.gz
Algorithm Hash digest
SHA256 db3bc8b07d441ea13d6722ea1931b2e63fa8f1a4300330dade9627ccb1cf77b6
MD5 e340c0b092493e52de5ad99c68241562
BLAKE2b-256 696a794beece4927aa762f5992227c81308fd464da544b94a8a5047ab6a30dcb

See more details on using hashes here.

File details

Details for the file dlong-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dlong-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for dlong-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7803b9fbc35694d53b5b41fd751ad7be0833d5ff900eb4c671982794414a514a
MD5 c07ec9f5ef4780e43fce9fb8295f3fcc
BLAKE2b-256 853d483bb90797c187170cc4f21bf0198d4dc79fe2b4f131c93fa4b0dbaf02de

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page