Skip to content

Commit 733af95

Browse files
committed
Move get_model_weights function
1 parent ace5ccf commit 733af95

File tree

1 file changed

+0
-74
lines changed

1 file changed

+0
-74
lines changed

src/dscim/utils/functions.py

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -22,80 +22,6 @@ def mean_func(consumption, dims):
2222
return consumption.mean(dims)
2323

2424

25-
def get_model_weights(rcp):
26-
# clean weights
27-
WEIGHT_FILE = (
28-
f"/shares/gcp/climate/SMME-weights/{rcp}_2090_SMME_edited_for_April_2016.tsv"
29-
)
30-
weights = pd.read_csv(
31-
WEIGHT_FILE, sep="\t", usecols=["quantile", "model", "weight"]
32-
)
33-
34-
name_dict = {
35-
"rcp45": {
36-
"pattern1_": "surrogate_MRI-CGCM3_01",
37-
"pattern2_": "surrogate_GFDL-ESM2G_01",
38-
"pattern3_": "surrogate_MRI-CGCM3_06",
39-
"pattern5_": "surrogate_MRI-CGCM3_11",
40-
"pattern6_": "surrogate_GFDL-ESM2G_11",
41-
"pattern27_": "surrogate_GFDL-CM3_89",
42-
"pattern28_": "surrogate_CanESM2_89",
43-
"pattern29_": "surrogate_GFDL-CM3_94",
44-
"pattern30_": "surrogate_CanESM2_94",
45-
"pattern31_": "surrogate_GFDL-CM3_99",
46-
"pattern32_": "surrogate_CanESM2_99",
47-
},
48-
"rcp85": {
49-
"pattern1_": "surrogate_MRI-CGCM3_01",
50-
"pattern2_": "surrogate_GFDL-ESM2G_01",
51-
"pattern3_": "surrogate_MRI-CGCM3_06",
52-
"pattern4_": "surrogate_GFDL-ESM2G_06",
53-
"pattern5_": "surrogate_MRI-CGCM3_11",
54-
"pattern6_": "surrogate_GFDL-ESM2G_11",
55-
"pattern28_": "surrogate_GFDL-CM3_89",
56-
"pattern29_": "surrogate_CanESM2_89",
57-
"pattern30_": "surrogate_GFDL-CM3_94",
58-
"pattern31_": "surrogate_CanESM2_94",
59-
"pattern32_": "surrogate_GFDL-CM3_99",
60-
"pattern33_": "surrogate_CanESM2_99",
61-
},
62-
}
63-
64-
common = {
65-
"access1-0": "ACCESS1-0",
66-
"bnu-esm": "BNU-ESM",
67-
"canesm2": "CanESM2",
68-
"ccsm4": "CCSM4",
69-
"cesm1-bgc": "CESM1-BGC",
70-
"cnrm-cm5": "CNRM-CM5",
71-
"csiro-mk3-6-0": "CSIRO-Mk3-6-0",
72-
"gfdl-cm3": "GFDL-CM3",
73-
"gfdl-esm2g": "GFDL-ESM2G",
74-
"gfdl-esm2m": "GFDL-ESM2M",
75-
"ipsl-cm5a-lr": "IPSL-CM5A-LR",
76-
"ipsl-cm5a-mr": "IPSL-CM5A-MR",
77-
"miroc-esm-chem": "MIROC-ESM-CHEM",
78-
"miroc-esm*": "MIROC-ESM",
79-
"miroc5": "MIROC5",
80-
"mpi-esm-lr": "MPI-ESM-LR",
81-
"mpi-esm-mr": "MPI-ESM-MR",
82-
"mri-cgcm3": "MRI-CGCM3",
83-
"noresm1-m": "NorESM1-M",
84-
}
85-
86-
[v.update(common) for k, v in name_dict.items()]
87-
88-
for old, new in name_dict[rcp].items():
89-
weights.loc[weights.model.str.contains(f"{old}"), "model"] = (
90-
weights.model.apply(lambda x: x.replace(x, new))
91-
)
92-
weights.model = weights.model.apply(lambda x: x.replace("*", ""))
93-
weights = weights.rename(columns={"model": "gcm"}).set_index("gcm").to_xarray()
94-
weights = weights.assign_coords({"rcp": rcp})
95-
96-
return weights.weight
97-
98-
9925
def gcms():
10026
return [
10127
"ACCESS1-0",

0 commit comments

Comments
 (0)