Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/iiasa/rime into setuptest
Browse files Browse the repository at this point in the history
  • Loading branch information
byersiiasa committed Feb 25, 2024
2 parents be9de08 + 93fb40e commit f1e4674
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
6 changes: 6 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: rime
channels:
- defaults
- conda-forge
dependencies:
- python
4 changes: 2 additions & 2 deletions rime/process_tabledata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
@author: byers
"""
if __name__ == "__main__":
from process_config import *
from rime_functions import *
from rime.process_config import *
from rime.rime_functions import *

# from alive_progress import alive_bar
import dask.dataframe as dd
Expand Down
22 changes: 19 additions & 3 deletions rime/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
import pandas as pd
import pyam
import yaml


def fix_duplicate_temps(df, years):
Expand Down Expand Up @@ -89,10 +90,11 @@ def ssp_helper(dft, ssp_meta_col="Ssp_family", default_ssp="SSP2", keep_meta=Tru
dft = np.round(dft.as_pandas()[pyam.IAMC_IDX + ["year", "value"] + meta_cols], 3)
# Check if SSP denoted by numbers only already?
sspdic = {1.0: "SSP1", 2.0: "SSP2", 3.0: "SSP3", 4.0: "SSP4", 5.0: "SSP5"}
dft[ssp_meta_col].replace(
sspdic, inplace=True
) # metadata must have Ssp_family column. If not SSP2 automatically chosen
dft[ssp_meta_col] = dft[ssp_meta_col].replace(
sspdic) # metadata must have Ssp_family column. If not SSP2 automatically chosen
dft.loc[dft[ssp_meta_col].isnull(), ssp_meta_col] = default_ssp
dft.loc[dft[ssp_meta_col]=='', ssp_meta_col] = default_ssp

metadata = (
dft[["model", "scenario"] + meta_cols]
.drop_duplicates()
Expand Down Expand Up @@ -153,3 +155,17 @@ def check_ds_dims(ds):
raise ValueError(
"The dataset does not contain 'lat' and 'lon' or 'x' and 'y' dimensions."
)

def load_indicator_params():
"""
Function to load the indicator parameters to facilitate reading in climate impacts data from Climate Solutions Explorer (Werning et al. 2023 - DOI: https://zenodo.org/doi/10.5281/zenodo.7971429 )
Returns
-------
params : dict
"""
with open("rime.indicator_params.yml", "r") as f:
params = yaml.full_load(f)

return params

0 comments on commit f1e4674

Please sign in to comment.