-
Notifications
You must be signed in to change notification settings - Fork 1
/
load_lakeheat_albm.py
executable file
·60 lines (41 loc) · 2.01 KB
/
load_lakeheat_albm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
Author : Inne Vanderkelen (inne.vanderkelen@vub.be)
Institution : Vrije Universiteit Brussel (VUB)
Date : November 2019
Function to load lake heat of ALBM and fill nan on years with issues
"""
import numpy as np
def load_lakeheat_albm(outdir,flag_scenario,years_analysis):
# load lakeheat from file
lakeheat_albm = np.load(outdir+'lakeheat_'+flag_scenario+'_ALBM.npy',allow_pickle='TRUE').item()
forcings = ['gfdl-esm2m','hadgem2-es','ipsl-cm5a-lr','miroc5']
# issues are only present for 'climate' and 'both' as they are in the lake temperature profiles
if not flag_scenario == 'reservoirs':
# change the data in these periods to nan
for forcing in forcings:
lakeheat_forcing = lakeheat_albm['ALBM'][forcing]
# 3. miroc5: bad value for year 1997. replace with nan
ind_start = years_analysis.index(2006)
ind_end = years_analysis.index(2013)
lakeheat_forcing[ind_start:ind_end,:,:] = np.nan
if forcing == 'miroc5':
# 3. miroc5: bad value for year 1997. replace with nan
ind_1996 = years_analysis.index(1996)
ind_1997 = years_analysis.index(1998)
lakeheat_forcing[ind_1996:ind_1997,:,:] = np.nan
lakeheat_albm['ALBM'][forcing] = lakeheat_forcing
return lakeheat_albm
def cor_for_albm(dict_forcing,model,forcing):
# function to correct for missing values of albm
years_analysis = range(1896,2025,1)
if model == 'ALBM':
ind_start = years_analysis.index(2006)
ind_end = years_analysis.index(2013)
dict_forcing[forcing][ind_start:-1] = np.nan
#ind_1996 = years_analysis.index(2013)
#dict_forcing[forcing][ind_1996:-1] = np.nan
if forcing == 'miroc5':
ind_1996 = years_analysis.index(1996)
ind_1997 = years_analysis.index(1998)
dict_forcing[forcing][ind_1996:ind_1997] = np.nan
return dict_forcing