outsource function to get idl for append mode

This commit is contained in:
Justus Kuhlmann 2025-10-30 10:00:46 +00:00
commit de4f741985

View file

@ -580,10 +580,12 @@ def _read_compact_rep(path, rep, sub_ls, intern, needed_keys, im):
return_vals[key][t][cfg] = cfg_data[key][t] return_vals[key][t][cfg] = cfg_data[key][t]
return return_vals return return_vals
def _default_idl_func(gauge_line_string, cfg_sep):
return int(gauge_line_string.split(cfg_sep)[-1])
def _read_chunk(chunk, gauge_line, cfg_sep, start_read, T, corr_line, b2b, pattern, im, single): def _read_chunk(chunk, gauge_line, cfg_sep, start_read, T, corr_line, b2b, pattern, im, single, idl_func = _default_idl_func):
try: try:
idl = int(chunk[gauge_line].split(cfg_sep)[-1]) idl = idl_func(chunk[gauge_line], cfg_sep)
except Exception: except Exception:
raise Exception("Couldn't parse idl from directory, problem with chunk around line ", gauge_line) raise Exception("Couldn't parse idl from directory, problem with chunk around line ", gauge_line)
@ -634,6 +636,7 @@ def _read_append_rep(filename, pattern, b2b, cfg_separator, im, single):
start = data_starts[cnfg] start = data_starts[cnfg]
stop = start + data_starts[1] stop = start + data_starts[1]
chunk = content[start:stop] chunk = content[start:stop]
print(start)
idl, data = _read_chunk(chunk, gauge_line, cfg_separator, start_read, T, corr_line, b2b, pattern, im, single) idl, data = _read_chunk(chunk, gauge_line, cfg_separator, start_read, T, corr_line, b2b, pattern, im, single)
rep_idl.append(idl) rep_idl.append(idl)
rep_data.append(data) rep_data.append(data)