@@ -71,26 +71,26 @@ def _extract_timeseries(result):
7171 """Return (data_id, domain, df_with_timeindex) or None for non-timeseries."""
7272 if isinstance (result , RHEEDVideoResult ):
7373 domain = "rheed"
74- df = result .timeseries_data
74+ timeseries = result .timeseries_data
7575 elif isinstance (result , OpticalResult ):
7676 domain = "optical"
77- df = result .timeseries_data
77+ timeseries = result .timeseries_data
7878 elif isinstance (result , MetrologyResult ):
7979 domain = "metrology"
80- df = result .timeseries_data
80+ timeseries = result .timeseries_data
8181 else :
8282 return None
8383
84- if df is None or df .empty :
84+ if timeseries is None or timeseries .empty :
8585 return None
8686
8787 # Build time index: prefer absolute epochs; fall back to upload_datetime + relative offsets.
8888 upload_dt = getattr (result , "upload_datetime" , None )
8989
90- time_index = _infer_absolute_time (df )
90+ time_index = _infer_absolute_time (timeseries )
9191 if time_index is None and upload_dt is not None :
9292 base = pd .to_datetime (upload_dt , utc = True , errors = "coerce" )
93- rel = _infer_relative_time (df )
93+ rel = _infer_relative_time (timeseries )
9494 if base is not pd .NaT and rel is not None :
9595 time_index = base + rel
9696
@@ -101,7 +101,7 @@ def _extract_timeseries(result):
101101 if not valid_mask .any ():
102102 return None
103103
104- indexed = df .loc [valid_mask ].copy (deep = False )
104+ indexed = timeseries .loc [valid_mask ].copy (deep = False )
105105 indexed .index = pd .Index (time_index [valid_mask ], name = "time" )
106106 indexed = indexed .sort_index ()
107107
@@ -173,11 +173,11 @@ def align_timeseries(
173173 if not extracted :
174174 continue
175175
176- data_id , domain , df = extracted
177- df = df .copy (deep = False )
178- df .columns = pd .MultiIndex .from_product ([[data_id ], [domain ], df .columns ])
179- frames .append (df )
180- indices .append (df .index )
176+ data_id , domain , frame = extracted
177+ frame = frame .copy (deep = False )
178+ frame .columns = pd .MultiIndex .from_product ([[data_id ], [domain ], frame .columns ])
179+ frames .append (frame )
180+ indices .append (frame .index )
181181
182182 if not frames :
183183 return pd .DataFrame ()
@@ -211,28 +211,28 @@ def align_timeseries(
211211
212212 # Merge compatible metrics across items: if multiple columns share (domain, metric)
213213 # and never conflict where they overlap, collapse into (shared, domain, metric).
214- def _merge_compatible_metrics (df : pd .DataFrame ) -> pd .DataFrame :
215- if not isinstance (df .columns , pd .MultiIndex ):
216- return df
217- domains = df .columns .get_level_values (1 )
218- metrics = df .columns .get_level_values (2 )
214+ def _merge_compatible_metrics (data : pd .DataFrame ) -> pd .DataFrame :
215+ if not isinstance (data .columns , pd .MultiIndex ):
216+ return data
217+ domains = data .columns .get_level_values (1 )
218+ metrics = data .columns .get_level_values (2 )
219219 new_cols : dict = {}
220220 drop_cols : list = []
221221
222222 for domain in domains .unique ():
223223 for metric in metrics .unique ():
224224 cols = [
225225 c
226- for c in df .columns
226+ for c in data .columns
227227 if c [1 ] == domain and c [2 ] == metric and c [0 ] != "shared"
228228 ]
229229 if len (cols ) <= 1 :
230230 continue
231231
232- merged = df [cols [0 ]]
232+ merged = data [cols [0 ]]
233233 conflict = False
234234 for c in cols [1 :]:
235- other = df [c ]
235+ other = data [c ]
236236 overlap_mask = merged .notna () & other .notna ()
237237 if (merged [overlap_mask ] != other [overlap_mask ]).any ():
238238 conflict = True
@@ -247,10 +247,10 @@ def _merge_compatible_metrics(df: pd.DataFrame) -> pd.DataFrame:
247247 drop_cols .extend (cols )
248248
249249 if new_cols :
250- df = df .drop (columns = drop_cols )
250+ data = data .drop (columns = drop_cols )
251251 for col , series in new_cols .items ():
252- df [col ] = series
253- df = df .sort_index (axis = 1 )
254- return df
252+ data [col ] = series
253+ data = data .sort_index (axis = 1 )
254+ return data
255255
256256 return _merge_compatible_metrics (aligned )
0 commit comments