@@ -264,31 +264,6 @@ def load_ag_rev_data() -> Tuple[List[Dict], List[Dict]]:
264264 return location_results , tier_results
265265
266266
267- def _discover_env_flows_files () -> List [Tuple [Path , str ]]:
268- """
269- Find ENV_FLOWS CSV files in staging. Returns (path, label) pairs.
270- Ordered so historical is processed first, then cc50, then cc95
271- (later files overwrite earlier ones for overlapping scenarios).
272- """
273- priority = {'historical' : 0 , 'cc50' : 1 , 'cc95' : 2 }
274-
275- def sort_key (p : Path ) -> int :
276- name_lower = p .stem .lower ()
277- for tag , order in priority .items ():
278- if tag in name_lower :
279- return order
280- return 99
281-
282- files = []
283- legacy = STAGING_DIR / 'ENV_FLOWS.csv'
284- if legacy .exists ():
285- files .append ((legacy , 'ENV_FLOWS.csv' ))
286- split = sorted (STAGING_DIR .glob ('ENV_FLOWS_*.csv' ), key = sort_key )
287- for p in split :
288- files .append ((p , p .name ))
289- return files
290-
291-
292267def _ensure_unique_axes (df : pd .DataFrame , csv_path : Path ) -> pd .DataFrame :
293268 """Detect duplicate row or column labels in a tier staging frame.
294269
@@ -339,31 +314,6 @@ def _conflicts(frame: pd.DataFrame) -> bool:
339314 return df
340315
341316
342- def _load_one_env_flows_file (csv_path : Path ) -> pd .DataFrame :
343- """
344- Load a single ENV_FLOWS CSV and return a DataFrame with
345- index=station IDs, columns=scenario IDs (canonical orientation).
346-
347- Auto-detects whether rows are scenarios or stations by inspecting
348- the first-column values.
349- """
350- df = pd .read_csv (csv_path , index_col = 0 )
351- df = _ensure_unique_axes (df , csv_path )
352- first_vals = [str (v ) for v in df .index [:5 ]]
353- rows_are_scenarios = all (v .startswith ('s0' ) for v in first_vals )
354- if rows_are_scenarios :
355- df = df .T
356- else :
357- scenario_mapping = {}
358- for col in df .columns :
359- base = col .split ('(' )[0 ].strip ()
360- if base not in scenario_mapping :
361- scenario_mapping [base ] = col
362- if scenario_mapping :
363- df = df .rename (columns = {v : k for k , v in scenario_mapping .items ()})
364- return df
365-
366-
367317def load_env_flows_data () -> Tuple [List [Dict ], List [Dict ]]:
368318 """
369319 ENV_FLOWS — Environmental Flows.
0 commit comments