py-ewr 2.3.6__py3-none-any.whl → 2.3.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
py_ewr/data_inputs.py CHANGED
@@ -14,14 +14,14 @@ BASE_PATH = Path(__file__).resolve().parent
14
14
 
15
15
  @cached(cache=TTLCache(maxsize=1024, ttl=1800))
16
16
  def get_ewr_calc_config(file_path:str = None) -> dict:
17
- '''Loads the EWR calculation configuration file from repository or local file
17
+ '''Loads the ewr calculation configuration file from repository or local file
18
18
  system
19
19
 
20
20
  Args:
21
- file_path (str): Location of the EWR calculation configuration file
21
+ file_path (str): Location of the ewr calculation configuration file
22
22
 
23
23
  Returns:
24
- dict: Returns a dictionary of the EWR calculation configuration file
24
+ dict: Returns a dictionary of the ewr calculation configuration file
25
25
  '''
26
26
 
27
27
  if file_path:
@@ -35,6 +35,42 @@ def get_ewr_calc_config(file_path:str = None) -> dict:
35
35
 
36
36
  return ewr_calc_config
37
37
 
38
+ def modify_EWR_table(EWR_table:pd.DataFrame) -> pd.DataFrame:
39
+
40
+ ''' Does all miscellaneous changes to the ewr table to get in the right format for all the handling functions. i.e. datatype changing, splitting day/month data, handling %
41
+ '''
42
+
43
+ int_components = ['FlowThresholdMin', 'FlowThresholdMax', 'VolumeThreshold', 'Duration', 'WithinEventGapTolerance', 'EventsPerYear', 'MinSpell', 'AccumulationPeriod', 'MaxSpell', 'TriggerDay', 'TriggerMonth', 'AnnualBarrageFlow', 'ThreeYearsBarrageFlow', 'HighReleaseWindowStart', 'HighReleaseWindowEnd', 'LowReleaseWindowStart', 'LowReleaseWindowEnd', 'PeakLevelWindowStart', 'PeakLevelWindowEnd', 'LowLevelWindowStart', 'LowLevelWindowEnd', 'NonFlowSpell', 'EggsDaysSpell', 'LarvaeDaysSpell', 'StartDay', 'EndDay', 'StartMonth', 'EndMonth']
44
+ float_components = ['RateOfRiseMax1', 'RateOfRiseMax2', 'RateOfFallMin', 'RateOfRiseThreshold1', 'RateOfRiseThreshold2', 'RateOfRiseRiverLevel', 'RateOfFallRiverLevel', 'CtfThreshold', 'MaxLevelChange', 'LevelThresholdMin', 'LevelThresholdMax', 'DrawDownRateWeek', 'MaxInter-event']
45
+
46
+ # Modify startmonth/endmonth
47
+ col_names = ['StartMonth', 'EndMonth']
48
+ for col_name in col_names:
49
+ rows = EWR_table[col_name].copy().items()
50
+ day_col_name = col_name[:-5]+"Day"
51
+ for r_idx, val in rows:
52
+ if "." in val:
53
+ month, day = val.split('.')
54
+ else:
55
+ month = val
56
+ day = None
57
+ EWR_table.loc[r_idx, col_name] = month
58
+ EWR_table.loc[r_idx, day_col_name] = day # the datatype conversion all takes place in # Modify integers #
59
+
60
+ # I actually think the drawdown rate modifications were doing nothing and the handling of percentage / float values is done in all functions that use drawdown_rate.
61
+
62
+ # Modify floats
63
+ for col_name in float_components:
64
+ col = pd.to_numeric(EWR_table[col_name], errors='coerce')
65
+ EWR_table[col_name] = pd.Series(col, dtype='Float64')
66
+
67
+ # Modify integers
68
+ for col_name in int_components:
69
+ col = pd.to_numeric(EWR_table[col_name], errors='coerce')
70
+ EWR_table[col_name] = pd.Series(col, dtype='Int64')
71
+
72
+ return EWR_table
73
+
38
74
  @cached(cache=TTLCache(maxsize=1024, ttl=1800))
39
75
  def get_EWR_table(file_path:str = None) -> dict:
40
76
 
@@ -43,76 +79,138 @@ def get_EWR_table(file_path:str = None) -> dict:
43
79
  does some cleaning, including swapping out '?' in the frequency column with 0
44
80
 
45
81
  Args:
46
- file_path (str): Location of the EWR dataset
82
+ file_path (str): Location of the ewr dataset
47
83
  Returns:
48
84
  tuple(pd.DataFrame, pd.DataFrame): EWRs that meet the minimum requirements; EWRs that dont meet the minimum requirements
49
85
  '''
50
86
 
51
87
  if file_path:
52
- df = pd.read_csv(file_path,
53
- usecols=['PlanningUnitID', 'PlanningUnitName', 'LTWPShortName', 'SWSDLName', 'State', 'CompliancePoint/Node', 'Gauge', 'Code', 'StartMonth',
54
- 'EndMonth', 'TargetFrequency', 'TargetFrequencyMin', 'TargetFrequencyMax', 'EventsPerYear', 'Duration', 'MinSpell',
55
- 'FlowThresholdMin', 'FlowThresholdMax', 'MaxInter-event', 'WithinEventGapTolerance', 'WeirpoolGauge', 'FlowLevelVolume',
56
- 'LevelThresholdMin', 'LevelThresholdMax', 'VolumeThreshold', 'DrawdownRate', 'MaxLevelRise','AccumulationPeriod',
57
- 'Multigauge', 'MaxSpell', 'TriggerDay', 'TriggerMonth', 'DrawDownRateWeek', 'AnnualFlowSum','AnnualBarrageFlow',
58
- 'ThreeYearsBarrageFlow', 'HighReleaseWindowStart', 'HighReleaseWindowEnd', 'LowReleaseWindowStart', 'LowReleaseWindowEnd',
59
- 'PeakLevelWindowStart', 'PeakLevelWindowEnd', 'LowLevelWindowStart', 'LowLevelWindowEnd', 'NonFlowSpell', 'EggsDaysSpell',
60
- 'LarvaeDaysSpell','MinLevelRise', 'RateOfRiseMax1','RateOfRiseMax2','RateOfFallMin','RateOfRiseThreshold1',
61
- 'RateOfRiseThreshold2','RateOfRiseRiverLevel','RateOfFallRiverLevel', 'CtfThreshold', 'GaugeType'],
62
- dtype='str', encoding='cp1252')
63
-
64
-
65
- if not file_path:
66
- my_url = os.path.join(BASE_PATH, "parameter_metadata/parameter_sheet.csv")
67
- proxies={} # Populate with your proxy settings
68
- df = pd.read_csv(my_url,
69
- usecols=['PlanningUnitID', 'PlanningUnitName', 'LTWPShortName', 'SWSDLName', 'State', 'CompliancePoint/Node', 'Gauge', 'Code', 'StartMonth',
70
- 'EndMonth', 'TargetFrequency', 'TargetFrequencyMin', 'TargetFrequencyMax', 'EventsPerYear', 'Duration', 'MinSpell',
71
- 'FlowThresholdMin', 'FlowThresholdMax', 'MaxInter-event', 'WithinEventGapTolerance', 'WeirpoolGauge', 'FlowLevelVolume',
72
- 'LevelThresholdMin', 'LevelThresholdMax', 'VolumeThreshold', 'DrawdownRate', 'MaxLevelRise', 'AccumulationPeriod',
73
- 'Multigauge', 'MaxSpell', 'TriggerDay', 'TriggerMonth', 'DrawDownRateWeek','AnnualFlowSum','AnnualBarrageFlow',
74
- 'ThreeYearsBarrageFlow', 'HighReleaseWindowStart', 'HighReleaseWindowEnd', 'LowReleaseWindowStart', 'LowReleaseWindowEnd',
75
- 'PeakLevelWindowStart', 'PeakLevelWindowEnd', 'LowLevelWindowStart', 'LowLevelWindowEnd', 'NonFlowSpell','EggsDaysSpell',
76
- 'LarvaeDaysSpell','MinLevelRise', 'RateOfRiseMax1','RateOfRiseMax2','RateOfFallMin','RateOfRiseThreshold1',
77
- 'RateOfRiseThreshold2','RateOfRiseRiverLevel','RateOfFallRiverLevel', 'CtfThreshold', 'GaugeType'],
78
- dtype='str', encoding='cp1252'
79
- )
88
+ my_url = file_path
89
+ else:
90
+ my_url = os.path.join(BASE_PATH, "parameter_metadata/parameter_sheet.csv")
91
+
92
+ df = pd.read_csv(my_url,
93
+ usecols=['PlanningUnitID', 'PlanningUnitName', 'Gauge', 'Code', 'StartMonth', 'TargetFrequency', 'State', 'SWSDLName',
94
+ 'EndMonth', 'EventsPerYear', 'Duration', 'MinSpell',
95
+ 'FlowThresholdMin', 'FlowThresholdMax', 'MaxInter-event', 'WithinEventGapTolerance', 'WeirpoolGauge', 'FlowLevelVolume',
96
+ 'LevelThresholdMin', 'LevelThresholdMax', 'VolumeThreshold', 'DrawdownRate', 'MaxLevelChange', 'AccumulationPeriod',
97
+ 'Multigauge', 'MaxSpell', 'TriggerDay', 'TriggerMonth', 'DrawDownRateWeek','AnnualBarrageFlow',
98
+ 'ThreeYearsBarrageFlow', 'HighReleaseWindowStart', 'HighReleaseWindowEnd', 'LowReleaseWindowStart', 'LowReleaseWindowEnd',
99
+ 'PeakLevelWindowStart', 'PeakLevelWindowEnd', 'LowLevelWindowStart', 'LowLevelWindowEnd', 'NonFlowSpell','EggsDaysSpell',
100
+ 'LarvaeDaysSpell', 'RateOfRiseMax1','RateOfRiseMax2','RateOfFallMin','RateOfRiseThreshold1',
101
+ 'RateOfRiseThreshold2','RateOfRiseRiverLevel','RateOfFallRiverLevel', 'CtfThreshold', 'GaugeType'],
102
+ dtype='str', encoding='cp1252'
103
+ )
80
104
 
81
105
  df = df.replace('?','')
82
106
  df = df.fillna('')
107
+
83
108
  # removing the 'See notes'
84
- okay_EWRs = df.loc[(df["StartMonth"] != 'See note') & (df["EndMonth"] != 'See note')]
85
- see_notes = df.loc[(df["StartMonth"] == 'See note') & (df["EndMonth"] == 'See note')]
109
+ see_notes_idx = (df["StartMonth"] == 'See note') & (df["EndMonth"] == 'See note')
86
110
 
87
111
  # Filtering those with no flow/level/volume thresholds
88
- noThresh_df = okay_EWRs.loc[(okay_EWRs["FlowThresholdMin"] == '') & (okay_EWRs["FlowThresholdMax"] == '') &\
89
- (okay_EWRs["VolumeThreshold"] == '') &\
90
- (okay_EWRs["LevelThresholdMin"] == '') & (okay_EWRs["LevelThresholdMax"] == '')]
91
- okay_EWRs = okay_EWRs.loc[(okay_EWRs["FlowThresholdMin"] != '') | (okay_EWRs["FlowThresholdMax"] != '') |\
92
- (okay_EWRs["VolumeThreshold"] != '') |\
93
- (okay_EWRs["LevelThresholdMin"] != '') | (okay_EWRs["LevelThresholdMax"] != '')]
112
+ no_thresh_idx = (df["FlowThresholdMin"] == '') & \
113
+ (df["FlowThresholdMax"] == '') &\
114
+ (df["VolumeThreshold"] == '') &\
115
+ (df["LevelThresholdMin"] == '') &\
116
+ (df["LevelThresholdMax"] == '')
94
117
 
95
118
  # Filtering those with no durations
96
- okay_EWRs = okay_EWRs.loc[(okay_EWRs["Duration"] != '')]
97
- no_duration = df.loc[(df["Duration"] == '')]
98
-
99
- # FIltering DSF EWRs
100
- condDSF = df['Code'].str.startswith('DSF')
101
- DSF_ewrs = df[condDSF]
102
- condDSF_inv = ~(okay_EWRs['Code'].str.startswith('DSF'))
103
- okay_EWRs = okay_EWRs[condDSF_inv]
104
-
105
- # Combine the unuseable EWRs into a dataframe and drop dups:
106
- bad_EWRs = pd.concat([see_notes, noThresh_df, no_duration, DSF_ewrs], axis=0)
107
- bad_EWRs = bad_EWRs.drop_duplicates()
108
-
109
- # Changing the flow and level max threshold to a high value when there is none available:
110
- okay_EWRs['FlowThresholdMax'].replace({'':'1000000'}, inplace = True)
111
- okay_EWRs['LevelThresholdMax'].replace({'':'1000000'}, inplace = True)
119
+ no_duration_idx = (df["Duration"] == '')
120
+
121
+ # Filtering DSF EWRs
122
+ DSF_idx = df['Code'].str.startswith('DSF')
123
+
124
+ # Combine the filters and get the okay and bad EWRs
125
+ bad_EWRs_idx = see_notes_idx | no_thresh_idx | no_duration_idx | DSF_idx
126
+
127
+ okay_EWRs = df[~bad_EWRs_idx].copy(deep=True)
128
+ bad_EWRs = df[bad_EWRs_idx].copy(deep=True)
129
+
130
+ # Here are all the prior assumptions of what to fill in to the parameter sheet if the value is missing.
131
+ # The aim is to remove all of these and have the parameter sheet be correct, the tool should not run
132
+ # the calculation of an ewr with missing (or extra?) values.
133
+ okay_EWRs.loc[:, 'FlowThresholdMax'] = (okay_EWRs['FlowThresholdMax'].replace('', '1000000'))
134
+ okay_EWRs.loc[:, 'LevelThresholdMax'] = (okay_EWRs['LevelThresholdMax'].replace('', '1000000'))
135
+ okay_EWRs.loc[:, 'FlowThresholdMin'] = (okay_EWRs['FlowThresholdMin'].replace('', '0'))
136
+ okay_EWRs.loc[:, 'LevelThresholdMin'] = (okay_EWRs['LevelThresholdMin'].replace('', '0'))
137
+ okay_EWRs.loc[:, 'MaxInter-event'] = (okay_EWRs['MaxInter-event'].replace('', '0'))
138
+ okay_EWRs.loc[:, 'WithinEventGapTolerance'] = (okay_EWRs['WithinEventGapTolerance'].replace('', '0'))
139
+
140
+ okay_EWRs.loc[:, 'CtfThreshold'] = (okay_EWRs['CtfThreshold'].replace('', '5'))
141
+ okay_EWRs.loc[:, 'NonFlowSpell'] = (okay_EWRs['NonFlowSpell'].replace('', '0'))
142
+ okay_EWRs.loc[:, 'DrawDownRateWeek'] = (okay_EWRs['DrawDownRateWeek'].replace('30', '0.03'))
143
+ okay_EWRs.loc[:, 'DrawDownRateWeek'] = (okay_EWRs['DrawDownRateWeek'].replace('30%', '0.03'))#just for test, change the PS in that test to reflect this
144
+ okay_EWRs.loc[:, 'DrawdownRate'] = (okay_EWRs['DrawdownRate'].replace('', '1000000'))
145
+ okay_EWRs.loc[:, 'MaxSpell'] = (okay_EWRs['MaxSpell'].replace('', '1000000'))
146
+ okay_EWRs.loc[:, 'MaxLevelChange'] = (okay_EWRs['MaxLevelChange'].replace('', '1000000'))
147
+
148
+ okay_EWRs = modify_EWR_table(okay_EWRs)
112
149
 
113
150
  return okay_EWRs, bad_EWRs
114
151
 
115
- def get_MDBA_codes() -> pd.DataFrame:
152
+ def get_components_map() -> dict:
153
+ components_map = {
154
+ 'PlanningUnitID': 'PlanningUnit',
155
+ 'Gauge': 'Gauge',
156
+ 'Code': 'Code',
157
+ 'FlowThresholdMin': 'min_flow',
158
+ 'FlowThresholdMax': 'max_flow',
159
+ 'VolumeThreshold': 'min_volume',
160
+ 'Duration': 'duration',
161
+ 'WithinEventGapTolerance': 'gap_tolerance',
162
+ 'EventsPerYear': 'events_per_year',
163
+ 'MinSpell': 'min_event',
164
+ 'AccumulationPeriod': 'accumulation_period',
165
+ 'MaxSpell': 'max_duration',
166
+ 'TriggerDay': 'trigger_day',
167
+ 'TriggerMonth': 'trigger_month',
168
+ 'AnnualBarrageFlow': 'annual_barrage_flow',
169
+ 'ThreeYearsBarrageFlow': 'three_years_barrage_flow',
170
+ 'HighReleaseWindowStart': 'high_release_window_start',
171
+ 'HighReleaseWindowEnd': 'high_release_window_end',
172
+ 'LowReleaseWindowStart': 'low_release_window_start',
173
+ 'LowReleaseWindowEnd': 'low_release_window_end',
174
+ 'PeakLevelWindowStart': 'peak_level_window_start',
175
+ 'PeakLevelWindowEnd': 'peak_level_window_end',
176
+ 'LowLevelWindowStart': 'low_level_window_start',
177
+ 'LowLevelWindowEnd': 'low_level_window_end',
178
+ 'NonFlowSpell': 'non_flow_spell',
179
+ 'EggsDaysSpell': 'eggs_days_spell',
180
+ 'LarvaeDaysSpell': 'larvae_days_spell',
181
+ 'RateOfRiseMax1': 'rate_of_rise_max1',
182
+ 'RateOfRiseMax2': 'rate_of_rise_max2',
183
+ 'RateOfFallMin': 'rate_of_fall_min',
184
+ 'RateOfRiseThreshold1': 'rate_of_rise_threshold1',
185
+ 'RateOfRiseThreshold2': 'rate_of_rise_threshold2',
186
+ 'RateOfRiseRiverLevel': 'rate_of_rise_river_level',
187
+ 'RateOfFallRiverLevel': 'rate_of_fall_river_level',
188
+ 'CtfThreshold': 'ctf_threshold',
189
+ 'MaxLevelChange': 'max_level_change',
190
+ 'LevelThresholdMin': 'min_level',
191
+ 'LevelThresholdMax': 'max_level',
192
+ 'StartMonth': 'start_month',
193
+ 'EndMonth': 'end_month',
194
+ 'StartDay': 'start_day',
195
+ 'EndDay': 'end_day',
196
+ 'DrawDownRateWeek': 'drawdown_rate_week',
197
+ 'MaxInter-event': 'max_inter-event',
198
+ 'Multigauge': 'second_gauge',
199
+ 'DrawdownRate': 'drawdown_rate',
200
+ 'FlowLevelVolume': 'flow_level_volume',
201
+ 'WeirpoolGauge': 'weirpool_gauge',
202
+
203
+ # these are required at the end after scenarios are processed
204
+ # TODO: Clarify/check if we require more here for interevents, etc. other 4 outputs of the tool
205
+ 'TargetFrequency': 'TargetFrequency',
206
+ 'PlanningUnitName': 'PlanningUnitName',
207
+ 'State': 'State',
208
+ 'SWSDLName': 'SWSDLName',
209
+ 'GaugeType': 'GaugeType',
210
+ }
211
+ return components_map
212
+
213
+ def get_MDBA_codes(model_type: str) -> pd.DataFrame:
116
214
  '''
117
215
  Load MDBA model metadata file containing model nodes
118
216
  and gauges they correspond to
@@ -121,7 +219,10 @@ def get_MDBA_codes() -> pd.DataFrame:
121
219
  pd.DataFrame: dataframe for linking MDBA model nodes to gauges
122
220
 
123
221
  '''
124
- metadata = pd.read_csv( BASE_PATH / 'model_metadata/SiteID_MDBA.csv', engine = 'python', dtype=str)#, encoding='windows-1252')
222
+ if model_type == 'Bigmod - MDBA':
223
+ metadata = pd.read_csv( BASE_PATH / 'model_metadata/SiteID_MDBA.csv', engine = 'python', dtype=str)#, encoding='windows-1252')
224
+ if model_type == 'FIRM - MDBA':
225
+ metadata = pd.read_csv( BASE_PATH / 'model_metadata/EWR_Sitelist_FIRM_20250718.csv', engine = 'python', dtype=str)
125
226
 
126
227
  return metadata
127
228
 
@@ -201,8 +302,8 @@ def get_multi_gauges(dataType: str) -> dict:
201
302
 
202
303
  def get_EWR_components(category):
203
304
  '''
204
- Ingests EWR category, returns the components required to analyse this type of EWR.
205
- Each code represents a unique component in the EWR dataset.
305
+ Ingests ewr category, returns the components required to analyse this type of ewr.
306
+ Each code represents a unique component in the ewr dataset.
206
307
 
207
308
  Args:
208
309
  category (str): options = 'flow', 'low flow', 'cease to flow', 'cumulative', 'level', 'weirpool-raising', 'weirpool-falling', 'nest-level', 'nest-percent',
@@ -210,51 +311,51 @@ def get_EWR_components(category):
210
311
  'simul-gauge-flow', 'simul-gauge-low flow', 'simul-gauge-cease to flow', 'complex'
211
312
 
212
313
  Returns:
213
- list: Components needing to be pulled from the EWR dataset
314
+ list: Components needing to be pulled from the ewr dataset
214
315
  '''
215
316
 
216
317
  if category == 'flow':
217
- pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'GP', 'EPY', 'MIE', 'FLV']
318
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'FlowThresholdMin', 'FlowThresholdMax', 'Duration', 'MinSpell', 'WithinEventGapTolerance', 'EventsPerYear', 'MaxInter-event', 'FlowLevelVolume']
218
319
  elif category == 'low flow':
219
- pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'EPY', 'MIE', 'FLV']
320
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'FlowThresholdMin', 'FlowThresholdMax', 'Duration', 'MinSpell', 'EventsPerYear', 'MaxInter-event', 'FlowLevelVolume']
220
321
  elif category == 'cease to flow':
221
- pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'EPY', 'MIE', 'FLV']
322
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'FlowThresholdMin', 'FlowThresholdMax', 'Duration', 'MinSpell', 'EventsPerYear', 'MaxInter-event', 'FlowLevelVolume']
222
323
  elif category == 'cumulative':
223
- pull = ['SM', 'EM', 'MINV', 'DUR', 'ME', 'EPY', 'MINF', 'MAXF', 'MIE','AP','GP', 'FLV']
324
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'VolumeThreshold', 'Duration', 'MinSpell', 'EventsPerYear', 'FlowThresholdMin', 'FlowThresholdMax', 'MaxInter-event','AccumulationPeriod','WithinEventGapTolerance', 'FlowLevelVolume']
224
325
  elif category == 'cumulative_bbr':
225
- pull = ['SM', 'EM', 'MINV', 'DUR', 'ME', 'EPY', 'MINF', 'MAXF', 'MIE','AP','GP', 'FLV','MAXL','WPG']
326
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'VolumeThreshold', 'Duration', 'MinSpell', 'EventsPerYear', 'FlowThresholdMin', 'FlowThresholdMax', 'MaxInter-event','AccumulationPeriod','WithinEventGapTolerance', 'FlowLevelVolume','LevelThresholdMax','WeirpoolGauge']
226
327
  elif category == 'water_stability':
227
- pull = ['SM', 'EM', 'DUR', 'ME', 'EPY', 'MINF', 'MAXF', 'MIE','AP','GP', 'FLV','MAXL','WPG', 'EDS', 'LDS', 'ML', 'MD']
328
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'Duration', 'MinSpell', 'EventsPerYear', 'FlowThresholdMin', 'FlowThresholdMax', 'MaxInter-event','AccumulationPeriod','WithinEventGapTolerance', 'FlowLevelVolume','LevelThresholdMax','WeirpoolGauge', 'EggsDaysSpell', 'LarvaeDaysSpell', 'MaxLevelChange', 'DrawdownRate']
228
329
  elif category == 'water_stability_level':
229
- pull = ['SM', 'EM', 'DUR', 'ME', 'EPY', 'MINF', 'MIE','AP','GP', 'FLV','MAXL', 'MINL', 'WPG', 'EDS', 'LDS', 'ML', 'MD']
330
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'Duration', 'MinSpell', 'EventsPerYear', 'FlowThresholdMin', 'MaxInter-event','AccumulationPeriod','WithinEventGapTolerance', 'FlowLevelVolume','LevelThresholdMax', 'LevelThresholdMin', 'WeirpoolGauge', 'EggsDaysSpell', 'LarvaeDaysSpell', 'MaxLevelChange', 'DrawdownRate']
230
331
  elif category == 'level':
231
- pull = ['SM', 'EM', 'MINL', 'MAXL', 'DUR', 'ME', 'EPY', 'MD', 'MIE', 'FLV', 'MAXD','GP','MLR']
332
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'LevelThresholdMin', 'LevelThresholdMax', 'Duration', 'MinSpell', 'EventsPerYear', 'DrawdownRate', 'MaxInter-event', 'FlowLevelVolume', 'MaxSpell','WithinEventGapTolerance']
232
333
  elif category == 'weirpool-raising':
233
- pull=['SM', 'EM', 'MINF', 'MAXF', 'MINL', 'DUR', 'ME', 'MD', 'EPY','WPG', 'MIE', 'FLV', 'GP']
334
+ pull=['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'FlowThresholdMin', 'FlowThresholdMax', 'LevelThresholdMin', 'Duration', 'MinSpell', 'DrawdownRate', 'EventsPerYear','WeirpoolGauge', 'MaxInter-event', 'FlowLevelVolume', 'WithinEventGapTolerance']
234
335
  elif category == 'weirpool-falling':
235
- pull=['SM', 'EM', 'MINF', 'MAXF', 'MAXL', 'DUR', 'ME', 'MD', 'EPY','WPG', 'MIE', 'FLV', 'GP']
336
+ pull=['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'FlowThresholdMin', 'FlowThresholdMax', 'LevelThresholdMax', 'Duration', 'MinSpell', 'DrawdownRate', 'EventsPerYear','WeirpoolGauge', 'MaxInter-event', 'FlowLevelVolume', 'WithinEventGapTolerance']
236
337
  elif category == 'nest-level':
237
- pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'MD', 'EPY', 'WPG', 'MIE', 'FLV','WDD','GP']
338
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'FlowThresholdMin', 'FlowThresholdMax', 'Duration', 'MinSpell', 'EventsPerYear', 'WeirpoolGauge', 'MaxInter-event', 'FlowLevelVolume','DrawDownRateWeek','WithinEventGapTolerance']
238
339
  elif category == 'nest-percent':
239
- pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'MD', 'EPY', 'MIE', 'FLV','TD','TM','GP']
340
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'FlowThresholdMin', 'FlowThresholdMax', 'Duration', 'MinSpell', 'DrawdownRate', 'EventsPerYear', 'MaxInter-event', 'FlowLevelVolume','TriggerDay','TriggerMonth','WithinEventGapTolerance']
240
341
  elif category == 'multi-gauge-flow':
241
- pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'GP', 'EPY', 'MG', 'MIE', 'FLV']
342
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'FlowThresholdMin', 'FlowThresholdMax', 'Duration', 'MinSpell', 'WithinEventGapTolerance', 'EventsPerYear', 'Multigauge', 'MaxInter-event', 'FlowLevelVolume']
242
343
  elif category == 'multi-gauge-low flow':
243
- pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'EPY', 'MG', 'MIE', 'FLV']
344
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'FlowThresholdMin', 'FlowThresholdMax', 'Duration', 'MinSpell', 'EventsPerYear', 'Multigauge', 'MaxInter-event', 'FlowLevelVolume']
244
345
  elif category == 'multi-gauge-cease to flow':
245
- pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'EPY', 'MG', 'MIE', 'FLV']
346
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'FlowThresholdMin', 'FlowThresholdMax', 'Duration', 'MinSpell', 'EventsPerYear', 'Multigauge', 'MaxInter-event', 'FlowLevelVolume']
246
347
  elif category == 'multi-gauge-cumulative':
247
- pull = ['SM', 'EM', 'MINV', 'DUR', 'ME', 'EPY', 'MINF', 'MAXF','MG', 'MIE','AP','GP', 'FLV']
348
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'VolumeThreshold', 'Duration', 'MinSpell', 'EventsPerYear', 'FlowThresholdMin', 'FlowThresholdMax','Multigauge', 'MaxInter-event','AccumulationPeriod','WithinEventGapTolerance', 'FlowLevelVolume']
248
349
  elif category == 'flood-plains':
249
- pull=['SM', 'EM', 'MINF', 'MAXF', 'MAXL', 'DUR', 'ME', 'MD', 'ML','EPY','WPG', 'MIE', 'FLV', 'GP']
350
+ pull=['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'FlowThresholdMin', 'FlowThresholdMax', 'LevelThresholdMax', 'Duration', 'MinSpell', 'DrawdownRate', 'MaxLevelChange','EventsPerYear','WeirpoolGauge', 'MaxInter-event', 'FlowLevelVolume', 'WithinEventGapTolerance']
250
351
  elif category == 'barrage-flow':
251
- pull=['SM', 'EM','DUR', 'ME','EPY','MIE','FLV','ABF','TYBF','HRWS', 'HRWE', 'LRWS', 'LRWE']
352
+ pull=['StartMonth', 'EndMonth', 'StartDay', 'EndDay','Duration', 'MinSpell','EventsPerYear','MaxInter-event','FlowLevelVolume','AnnualBarrageFlow','ThreeYearsBarrageFlow','HighReleaseWindowStart', 'HighReleaseWindowEnd', 'LowReleaseWindowStart', 'LowReleaseWindowEnd']
252
353
  elif category == 'barrage-level':
253
- pull=['SM', 'EM','DUR', 'ME','EPY','MIE','FLV','HRWS', 'HRWE', 'LRWS', 'LRWE','PLWS', 'PLWE', 'LLWS', 'LLWE','MINL','MAXL']
354
+ pull=['StartMonth', 'EndMonth', 'StartDay', 'EndDay','Duration', 'MinSpell','EventsPerYear','MaxInter-event','FlowLevelVolume','HighReleaseWindowStart', 'HighReleaseWindowEnd', 'LowReleaseWindowStart', 'LowReleaseWindowEnd','PeakLevelWindowStart', 'PeakLevelWindowEnd', 'LowLevelWindowStart', 'LowLevelWindowEnd','LevelThresholdMin','LevelThresholdMax']
254
355
  elif category == 'flow-ctf':
255
- pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'GP', 'EPY', 'MIE', 'FLV', 'NFS', 'CTFT']
356
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'FlowThresholdMin', 'FlowThresholdMax', 'Duration', 'MinSpell', 'WithinEventGapTolerance', 'EventsPerYear', 'MaxInter-event', 'FlowLevelVolume', 'NonFlowSpell', 'CtfThreshold']
256
357
  elif category == 'rise_fall':
257
- pull = ['SM', 'EM', 'MINF', 'MAXF', 'DUR', 'ME', 'GP', 'EPY', 'MIE', 'FLV', 'NFS', 'MLR', 'RRM1', 'RRM2', 'RFM', 'RRT1', 'RRT2', 'RRL', 'RFL' ]
358
+ pull = ['StartMonth', 'EndMonth', 'StartDay', 'EndDay', 'FlowThresholdMin', 'FlowThresholdMax', 'Duration', 'MinSpell', 'WithinEventGapTolerance', 'EventsPerYear', 'MaxInter-event', 'FlowLevelVolume', 'NonFlowSpell', 'RateOfRiseMax1', 'RateOfRiseMax2', 'RateOfFallMin', 'RateOfRiseThreshold1', 'RateOfRiseThreshold2', 'RateOfRiseRiverLevel', 'RateOfFallRiverLevel' ]
258
359
  return pull
259
360
 
260
361
  def get_bad_QA_codes() -> list:
@@ -266,18 +367,18 @@ def get_bad_QA_codes() -> list:
266
367
  '''
267
368
  return [151, 152, 153, 155, 180, 201, 202, 204, 205, 207, 223, 255]
268
369
 
269
- def weirpool_type(EWR: str) -> str:
270
- '''Returns the type of Weirpool EWR. Currently only WP2 EWRs are classified as weirpool raisings
370
+ def weirpool_type(ewr: str) -> str:
371
+ '''Returns the type of Weirpool ewr. Currently only WP2 EWRs are classified as weirpool raisings
271
372
 
272
373
  Args:
273
- EWR (str): WP2 is considered raising, the remaining WP EWRs are considered falling
374
+ ewr (str): WP2 is considered raising, the remaining WP EWRs are considered falling
274
375
 
275
376
  Returns:
276
377
  str: either 'raising' or 'falling'
277
378
 
278
379
  '''
279
380
 
280
- return 'raising' if EWR == 'WP2' else 'falling'
381
+ return 'raising' if ewr == 'WP2' else 'falling'
281
382
 
282
383
  @cached(cache=TTLCache(maxsize=1024, ttl=1800))
283
384
  def get_planning_unit_info() -> pd.DataFrame:
@@ -295,24 +396,24 @@ def get_planning_unit_info() -> pd.DataFrame:
295
396
 
296
397
 
297
398
 
298
- # Function to pull out the EWR parameter information
299
- def ewr_parameter_grabber(EWR_TABLE: pd.DataFrame, GAUGE: str, PU: str, EWR: str, PARAMETER: str) -> str:
399
+ # Function to pull out the ewr parameter information
400
+ def ewr_parameter_grabber(EWR_TABLE: pd.DataFrame, gauge: str, pu: str, ewr: str, PARAMETER: str) -> str:
300
401
  '''
301
- Input an EWR table to pull data from, a gauge, planning unit, and EWR for the unique value, and a requested parameter
402
+ Input an ewr table to pull data from, a gauge, planning unit, and ewr for the unique value, and a requested parameter
302
403
 
303
404
  Args:
304
405
  EWR_TABLE (pd.DataFrame): dataset of EWRs
305
- GAUGE (str): Gauge string
306
- PU (str): Planning unit name
307
- EWR (str): EWR string
308
- PARAMETER (str): which parameter of the EWR to access
406
+ gauge (str): Gauge string
407
+ pu (str): Planning unit name
408
+ ewr (str): ewr string
409
+ PARAMETER (str): which parameter of the ewr to access
309
410
  Results:
310
- str: requested EWR component
411
+ str: requested ewr component
311
412
 
312
413
  '''
313
- component = (EWR_TABLE[((EWR_TABLE['Gauge'] == GAUGE) &
314
- (EWR_TABLE['Code'] == EWR) &
315
- (EWR_TABLE['PlanningUnitName'] == PU)
414
+ component = (EWR_TABLE[((EWR_TABLE['Gauge'] == gauge) &
415
+ (EWR_TABLE['Code'] == ewr) &
416
+ (EWR_TABLE['PlanningUnitName'] == pu)
316
417
  )][PARAMETER]).to_list()[0]
317
418
  return component if component else 0
318
419
 
@@ -453,4 +554,4 @@ def get_causal_ewr() -> dict:
453
554
  "obj2yrtarget":pd.read_csv(obj2yrtarget_path)
454
555
  }
455
556
 
456
- return causal_ewr
557
+ return causal_ewr