forked from respec/HSPsquared
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCOPY.py
50 lines (42 loc) · 2.01 KB
/
COPY.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
from HSP2.utilities import get_timeseries
import pandas as pd
from typing import List, Dict
from HSP2IO.protocols import SupportsReadTS
class Copy():
"""
Partial implementation of the COPY module.
In HSPF, COPY module supports ability able to 'copy' in this case output timeseries to
locations specified in NETWORK block or to EXTERNAL SOURCES.
This functionality is not currently implemented, presently only loading from EXT SOURCES
"""
def __init__(self, io:SupportsReadTS, sim_info: Dict, ext_sources: List) -> None:
self._ts = {}
self._ts['MEAN'] = {}
self._ts['POINT'] = {}
ts = get_timeseries(io, ext_sources, sim_info)
for source in ext_sources:
themn = source.TMEMN
themsb = source.TMEMSB
self.set_ts(ts[f'{themn}{themsb}'], themn, themsb)
def set_ts(self, ts: pd.Series, themn: str, themsb: str) -> None:
"""Set the provided timeseries to ts dictionary
ts: pd.Series
pandas Series class instance corresponding to a timeseries
tmemn: str, {'MEAN', 'POINT'}
Target member name, specifies if target timeseries is in mean-valued
or point-valued dictionaries
tmemsb: str,
Target member name subscripts, acts as key for mean-valued and point-valued dictionaries
Original HSPF restricts this to 0-20 but no limit enforced in HSP2
"""
self._ts[themn][themsb] = ts
def get_ts(self, tmemn: str, tmemsb: str) -> pd.Series:
"""Gets the specified timeseries from copy class instance based
tmemn: str, {'MEAN', 'POINT'}
Target member name, specifies if target timeseries is in mean-valued
or point-valued dictionaries
tmemsb: str,
Target member name subscripts, acts as key for mean-valued and point-valued dictionaries
Original HSPF restricts this to 0-20 but no limit enforced in HSP2
"""
return self._ts[tmemn][tmemsb]