1 def set_time_params(dict, h2
, hours
=None):
2 # Given FMDA dictionary and time params,
3 # You CAN use this function just to change h2 (training period hours)
4 # NOTE: this only performs a shallow copy and once you filter you can't filter original data to make larger dataset
6 # dict: fmda dictionary
7 # h2: (int) length of training period
8 # hours: (int) total number of hours (train + test)
10 return_dict
= dict.copy()
12 if not(hours
is None):
13 for case
in return_dict
:
14 if len(return_dict
[case
]['fm']) < hours
:
15 raise ValueError(f
"Number of hours ({hours}) is greater than length of fm data ({len(return_dict[case]['fm'])})")
16 return_dict
[case
]['hours']=hours
17 # Filter relevant fields (compatible with synthetic data)
18 return_dict
[case
]['rain']=return_dict
[case
]['rain'][0:hours
]
19 return_dict
[case
]['Ed']=return_dict
[case
]['Ed'][0:hours
]
20 return_dict
[case
]['Ew']=return_dict
[case
]['Ew'][0:hours
]
21 return_dict
[case
]['fm']=return_dict
[case
]['fm'][0:hours
]
23 # Filter fields not in synthetic data
24 if not('synthetic' not in return_dict
[case
]['title'].lower() or 'synthetic' not in return_dict
[case
]['descr'].lower()):
25 return_dict
[case
]['solar']=return_dict
[case
]['solar'][0:hours
]
26 return_dict
[case
]['temp']=return_dict
[case
]['temp'][0:hours
]
27 return_dict
[case
]['rh']=return_dict
[case
]['rh'][0:hours
]
28 return_dict
[case
]['wind_speed']=return_dict
[case
]['wind_speed'][0:hours
]
32 # Loop through cases and change training period
33 for case
in return_dict
:
34 return_dict
[case
]['h2']=h2